├── var ├── title ├── created ├── license ├── version ├── organization ├── summary ├── authors ├── requirements ├── copyrights ├── repositories ├── resources └── description ├── Gemfile ├── .gitignore ├── lib ├── opendsl │ └── version.rb └── opendsl.rb ├── .yardopts ├── .travis.yml ├── MANIFEST ├── work ├── deprecated │ └── openmodule.rb └── conf │ └── webme │ └── advert.html ├── DEMO.rdoc ├── demo └── example.rdoc ├── HISTORY.rdoc ├── Assembly ├── .ruby ├── COPYING.rdoc ├── README.rdoc └── .gemspec /var/title: -------------------------------------------------------------------------------- 1 | OpenDSL -------------------------------------------------------------------------------- /var/created: -------------------------------------------------------------------------------- 1 | 2009-07-18 -------------------------------------------------------------------------------- /var/license: -------------------------------------------------------------------------------- 1 | Apache 2.0 -------------------------------------------------------------------------------- /var/version: -------------------------------------------------------------------------------- 1 | 1.1.1 2 | -------------------------------------------------------------------------------- /var/organization: -------------------------------------------------------------------------------- 1 | rubyworks -------------------------------------------------------------------------------- /var/summary: -------------------------------------------------------------------------------- 1 | The ultimate DSL! 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | gemspec 3 | -------------------------------------------------------------------------------- /var/authors: -------------------------------------------------------------------------------- 1 | --- 2 | - 7rans 3 | 4 | -------------------------------------------------------------------------------- /var/requirements: -------------------------------------------------------------------------------- 1 | --- 2 | - detroit (build) 3 | - qed (test) 4 | -------------------------------------------------------------------------------- /var/copyrights: -------------------------------------------------------------------------------- 1 | --- 2 | - Copyright (c) 2009 Rubyworks (BSD-2-Clause) 3 | 4 | -------------------------------------------------------------------------------- /var/repositories: -------------------------------------------------------------------------------- 1 | --- 2 | upstream: git://github.com/rubyworks/opendsl.git 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .reap/digest 2 | .yardoc 3 | log 4 | pkg 5 | tmp 6 | web 7 | work 8 | -------------------------------------------------------------------------------- /lib/opendsl/version.rb: -------------------------------------------------------------------------------- 1 | class OpenDSL 2 | VERSION = "1.1.1" #:erb: VERSION = "<%= version %>" 3 | end 4 | 5 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --title "OpenDSL" 2 | --readme README.rdoc 3 | --protected 4 | --private 5 | lib/**/*.rb 6 | - 7 | [A-Z]*.* 8 | 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | rvm: 3 | - 1.8.7 4 | - 1.9.2 5 | - 1.9.3 6 | - rbx-2.0 7 | - jruby 8 | - ree 9 | script: "bundle exec qed -v" 10 | 11 | -------------------------------------------------------------------------------- /var/resources: -------------------------------------------------------------------------------- 1 | --- 2 | home: http://rubyworks.github.com/opendsl 3 | code: http://github.com/rubyworks/opendsl 4 | mail: http://groups.google.com/group/rubyworks-mailinglist 5 | 6 | -------------------------------------------------------------------------------- /var/description: -------------------------------------------------------------------------------- 1 | OpenDSL is the ultimate Domain Specific Langauge. It marries Ruby's metaprogramming chops 2 | with it's versitle mixin system to create a remarkably simple but incredibly 3 | powerful DSL framework. 4 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | #!mast .ruby .yardopts bin lib man qed spec test [A-Z]*.* 2 | .ruby 3 | .yardopts 4 | lib/opendsl/version.rb 5 | lib/opendsl.rb 6 | qed/example.rdoc 7 | HISTORY.rdoc 8 | README.rdoc 9 | QED.rdoc 10 | COPYING.rdoc 11 | -------------------------------------------------------------------------------- /work/deprecated/openmodule.rb: -------------------------------------------------------------------------------- 1 | # 2 | class OpenModule < Module 3 | 4 | def initialize(&block) 5 | instance_eval(&block) if block_given? 6 | end 7 | 8 | def method_missing(s, *a, &b) 9 | if block_given? 10 | define_method(s, &b) 11 | else 12 | super 13 | end 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /work/conf/webme/advert.html: -------------------------------------------------------------------------------- 1 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /DEMO.rdoc: -------------------------------------------------------------------------------- 1 | = README Example 2 | 3 | Require the OpenDSL library. 4 | 5 | require 'opendsl' 6 | 7 | Create an OpenDSL module. 8 | 9 | Foo = OpenDSL.new do 10 | foo do 11 | 'foo' 12 | end 13 | end 14 | 15 | Apply it to a class. 16 | 17 | class Something 18 | include Foo 19 | 20 | def foobar 21 | foo + 'bar' 22 | end 23 | end 24 | 25 | Verify it worked as expected. 26 | 27 | s = Something.new 28 | s.foobar.assert == 'foobar' 29 | 30 | 31 | -------------------------------------------------------------------------------- /demo/example.rdoc: -------------------------------------------------------------------------------- 1 | = README Example 2 | 3 | Require the OpenDSL library. 4 | 5 | require 'opendsl' 6 | 7 | Create an OpenDSL module. 8 | 9 | Foo = OpenDSL.new do 10 | foo do 11 | 'foo' 12 | end 13 | end 14 | 15 | Apply it to a class. 16 | 17 | class Something 18 | include Foo 19 | 20 | def foobar 21 | foo + 'bar' 22 | end 23 | end 24 | 25 | Verify it worked as expected. 26 | 27 | s = Something.new 28 | s.foobar.assert == 'foobar' 29 | 30 | -------------------------------------------------------------------------------- /HISTORY.rdoc: -------------------------------------------------------------------------------- 1 | = HISTORY 2 | 3 | == 1.1.1 / 2011-10-28 4 | 5 | Quick fix release to get misisng QED.rdoc into the gem so 6 | it show up on {rubydoc.info}[http://rubydoc.info]. 7 | 8 | Changes: 9 | 10 | * Add QED.rdoc to gem. 11 | 12 | 13 | == 1.1.0 / 2011-10-27 14 | 15 | This is simplay a maintenace release, to bring the project up to date 16 | with modern build tools. 17 | 18 | Changes: 19 | 20 | * Modernize build configuration. 21 | 22 | 23 | == 1.0.0 / 2010-03-02 24 | 25 | This is the initial release of OpenDSL. 26 | 27 | * 1 Major Enhancment 28 | 29 | * Happy Birthday! 30 | 31 | -------------------------------------------------------------------------------- /lib/opendsl.rb: -------------------------------------------------------------------------------- 1 | # OpenDSL is a clever way to create a plugable 2 | # free-form domain specific language. 3 | # 4 | # Example = OpenDSL.new do 5 | # size do 6 | # 100 7 | # end 8 | # end 9 | # 10 | # class Foo 11 | # include Example 12 | # end 13 | # 14 | # Foo.new.size #=> 100 15 | # 16 | class OpenDSL < Module 17 | 18 | require 'opendsl/version' 19 | 20 | # 21 | def initialize(&block) 22 | instance_eval(&block) if block_given? 23 | end 24 | 25 | # 26 | def method_missing(s, *a, &b) 27 | if block_given? 28 | define_method(s, &b) 29 | else 30 | super(s, *a, &b) 31 | end 32 | end 33 | 34 | end 35 | 36 | -------------------------------------------------------------------------------- /Assembly: -------------------------------------------------------------------------------- 1 | --- 2 | erbside: 3 | path: lib/opendsl/version.rb 4 | 5 | email: 6 | mailto: 7 | - ruby-talk@ruby-lang.org 8 | - rubyworks-mailinglist@googlegroups.com 9 | 10 | qed: 11 | files: demo/ 12 | 13 | qedoc: 14 | files: demo/ 15 | title: "OpenDSL Demonstration" 16 | output: DEMO.rdoc 17 | 18 | gem: 19 | active: true 20 | 21 | github: 22 | gh_pages: web 23 | 24 | dnote: 25 | title: Developer's Notes 26 | output: log/NOTES.rdoc 27 | 28 | vclog: 29 | output: 30 | - log/History.rdoc 31 | - log/Changes.rdoc 32 | 33 | tag: 34 | service: custom 35 | release: | 36 | puts %[pom news | git tag -a -F - #{project.version}] 37 | 38 | -------------------------------------------------------------------------------- /.ruby: -------------------------------------------------------------------------------- 1 | --- 2 | source: 3 | - meta 4 | authors: 5 | - name: 7rans 6 | email: transfire@gmail.com 7 | copyrights: 8 | - holder: Rubyworks 9 | year: '2009' 10 | license: BSD-2-Clause 11 | replacements: [] 12 | alternatives: [] 13 | requirements: 14 | - name: detroit 15 | groups: 16 | - build 17 | development: true 18 | - name: qed 19 | groups: 20 | - test 21 | development: true 22 | dependencies: [] 23 | conflicts: [] 24 | repositories: 25 | - uri: git://github.com/rubyworks/opendsl.git 26 | scm: git 27 | name: upstream 28 | resources: 29 | home: http://rubyworks.github.com/opendsl 30 | code: http://github.com/rubyworks/opendsl 31 | mail: http://groups.google.com/group/rubyworks-mailinglist 32 | extra: {} 33 | load_path: 34 | - lib 35 | revision: 0 36 | created: '2009-07-18' 37 | summary: The ultimate DSL! 38 | title: OpenDSL 39 | version: 1.1.1 40 | description: ! 'OpenDSL is the ultimate DSL system. It marries Ruby''s metaprogramming 41 | chops 42 | 43 | with it''s versitle mixin system to create a remarkably simple but incredibly 44 | 45 | powerful DSL framework.' 46 | organization: rubyworks 47 | date: '2011-10-27' 48 | -------------------------------------------------------------------------------- /COPYING.rdoc: -------------------------------------------------------------------------------- 1 | = COPYRIGHT NOTICES 2 | 3 | == OpenDSL 4 | 5 | Copyright:: (c) 2009 Rubyworks 6 | License:: BSD-2-Clause 7 | Website:: http://rubyworks.github.com/opendsl 8 | 9 | Copyright 2009 Rubyworks. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 23 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 28 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = OpenDSL 2 | 3 | {Homepage}[http://rubyworks.github.com/opendsl] | 4 | {Source Code}[http://github.com/rubyworks/opendsl] | 5 | {Mailing List}[http://groups.google.com/group/rubyworks-mailinglist] | 6 | {Issue Tracker}[http://github.com/rubyworks/opendsl/issues] 7 | 8 | {}[http://travis-ci.org/rubyworks/opendsl] 9 | 10 | 11 | == DESCRIPTION 12 | 13 | OpenDSL provides an open nomenclature for writing 14 | domain specific instructions. The idea is inline 15 | with the idea of duck-typing. You can allow domain 16 | instructions to be given up front free of restriction, 17 | then applying them later their correctness plays out 18 | as they are utilized. 19 | 20 | The library is especailly useful for plugins systems. 21 | 22 | 23 | == RELEASE NOTES 24 | 25 | Please see HISTORY.rdoc file. 26 | 27 | 28 | == SYNOPSIS 29 | 30 | There are a few different ways in which this library can be 31 | put to use, but the basic idea for all of them can be 32 | demonstrated simply enough. 33 | 34 | Foo = OpenDSL.new do 35 | foo do 36 | 'foo' 37 | end 38 | end 39 | 40 | class Something 41 | include Foo 42 | 43 | def foobar 44 | foo + 'bar' 45 | end 46 | end 47 | 48 | OpenDSL.new creates a subclass of Module. Indeed, this library was 49 | orginally called OpenModule, but the name was changed to focus 50 | on it's utility, rather than it's implementation. Since an OpenDSL 51 | object is a module you can use it just like any other module. 52 | 53 | 54 | == HOW TO INSTALL 55 | 56 | To install with RubyGems simply open a console and type: 57 | 58 | gem install opendsl 59 | 60 | Site installation requires Setup.rb (gem install setup), 61 | then download the tarball package and type: 62 | 63 | tar -xvzf openmodule-1.0.0.tgz 64 | cd opendsl-1.0.0.tgz 65 | sudo setup.rb all 66 | 67 | Windows users use 'ruby setup.rb all'. 68 | 69 | 70 | == COPYRIGHTS 71 | 72 | Copyright (c) 2009 Thomas Sawyer 73 | 74 | This program is ditributed unser the terms of the *FreeBSD* license. 75 | 76 | See COPYING.rdoc file for details. 77 | 78 | -------------------------------------------------------------------------------- /.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'yaml' 4 | 5 | module DotRuby 6 | 7 | # 8 | class GemSpec 9 | 10 | # For which revision of .ruby is this gemspec intended? 11 | REVISION = 0 12 | 13 | # 14 | PATTERNS = { 15 | :bin_files => 'bin/*', 16 | :lib_files => 'lib/{**/}*.rb', 17 | :ext_files => 'ext/{**/}extconf.rb', 18 | :doc_files => '*.{txt,rdoc,md,markdown,tt,textile}', 19 | :test_files => '{test/{**/}*_test.rb,spec/{**/}*_spec.rb}' 20 | } 21 | 22 | # 23 | def self.instance 24 | new.to_gemspec 25 | end 26 | 27 | attr :metadata 28 | 29 | attr :manifest 30 | 31 | # 32 | def initialize 33 | @metadata = YAML.load_file('.ruby') 34 | @manifest = Dir.glob('manifest{,.txt}', File::FNM_CASEFOLD).first 35 | 36 | if @metadata['revision'].to_i != REVISION 37 | warn "You have the wrong revision. Trying anyway..." 38 | end 39 | end 40 | 41 | # 42 | def scm 43 | @scm ||= \ 44 | case 45 | when File.directory?('.git') 46 | :git 47 | end 48 | end 49 | 50 | # 51 | def files 52 | @files ||= \ 53 | #glob_files[patterns[:files]] 54 | case 55 | when manifest 56 | File.readlines(manifest). 57 | map{ |line| line.strip }. 58 | reject{ |line| line.empty? || line[0,1] == '#' } 59 | when scm == :git 60 | `git ls-files -z`.split("\0") 61 | else 62 | Dir.glob('{**/}{.*,*}') # TODO: be more specific using standard locations ? 63 | end.select{ |path| File.file?(path) } 64 | end 65 | 66 | # 67 | def glob_files(pattern) 68 | Dir.glob(pattern).select { |path| 69 | File.file?(path) && files.include?(path) 70 | } 71 | end 72 | 73 | # 74 | def patterns 75 | PATTERNS 76 | end 77 | 78 | # 79 | def executables 80 | @executables ||= \ 81 | glob_files(patterns[:bin_files]).map do |path| 82 | File.basename(path) 83 | end 84 | end 85 | 86 | def extensions 87 | @extensions ||= \ 88 | glob_files(patterns[:ext_files]).map do |path| 89 | File.basename(path) 90 | end 91 | end 92 | 93 | # 94 | def name 95 | metadata['name'] || metadata['title'].downcase.gsub(/\W+/,'_') 96 | end 97 | 98 | # 99 | def to_gemspec 100 | Gem::Specification.new do |gemspec| 101 | gemspec.name = name 102 | gemspec.version = metadata['version'] 103 | gemspec.summary = metadata['summary'] 104 | gemspec.description = metadata['description'] 105 | 106 | metadata['authors'].each do |author| 107 | gemspec.authors << author['name'] 108 | 109 | if author.has_key?('email') 110 | if gemspec.email 111 | gemspec.email << author['email'] 112 | else 113 | gemspec.email = [author['email']] 114 | end 115 | end 116 | end 117 | 118 | gemspec.licenses = metadata['copyrights'].map{ |c| c['license'] }.compact 119 | 120 | metadata['requirements'].each do |req| 121 | name = req['name'] 122 | version = req['version'] 123 | groups = req['groups'] || [] 124 | 125 | case version 126 | when /^(.*?)\+$/ 127 | version = ">= #{$1}" 128 | when /^(.*?)\-$/ 129 | version = "< #{$1}" 130 | when /^(.*?)\~$/ 131 | version = "~> #{$1}" 132 | end 133 | 134 | if groups.empty? or groups.include?('runtime') 135 | # populate runtime dependencies 136 | if gemspec.respond_to?(:add_runtime_dependency) 137 | gemspec.add_runtime_dependency(name,*version) 138 | else 139 | gemspec.add_dependency(name,*version) 140 | end 141 | else 142 | # populate development dependencies 143 | if gemspec.respond_to?(:add_development_dependency) 144 | gemspec.add_development_dependency(name,*version) 145 | else 146 | gemspec.add_dependency(name,*version) 147 | end 148 | end 149 | end 150 | 151 | # convert external dependencies into a requirements 152 | if metadata['external_dependencies'] 153 | ##gemspec.requirements = [] unless metadata['external_dependencies'].empty? 154 | metadata['external_dependencies'].each do |req| 155 | gemspec.requirements << req.to_s 156 | end 157 | end 158 | 159 | # determine homepage from resources 160 | homepage = metadata['resources'].find{ |key, url| key =~ /^home/ } 161 | gemspec.homepage = homepage.last if homepage 162 | 163 | gemspec.require_paths = metadata['load_path'] || ['lib'] 164 | gemspec.post_install_message = metadata['install_message'] 165 | 166 | # RubyGems specific metadata 167 | gemspec.files = files 168 | gemspec.extensions = extensions 169 | gemspec.executables = executables 170 | 171 | if Gem::VERSION < '1.7.' 172 | gemspec.default_executable = gemspec.executables.first 173 | end 174 | 175 | gemspec.test_files = glob_files(patterns[:test_files]) 176 | 177 | unless gemspec.files.include?('.document') 178 | gemspec.extra_rdoc_files = glob_files(patterns[:doc_files]) 179 | end 180 | end 181 | end 182 | 183 | end #class GemSpec 184 | 185 | end 186 | 187 | DotRuby::GemSpec.instance 188 | --------------------------------------------------------------------------------