instant_dsl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README +35 -0
  5. data/Rakefile +19 -0
  6. data/VERSION +1 -0
  7. data/lib/instant_dsl.rb +20 -0
  8. metadata +71 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 jbe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,35 @@
1
+
2
+ ^ ^ ^
3
+ ....... ...
4
+ «~ INSTANT DSL ~»
5
+ ''''''' '''
6
+
7
+
8
+ Installation:
9
+
10
+ $ gem install instant_dsl
11
+
12
+ Usage:
13
+
14
+ require 'instant_dsl'
15
+
16
+ # Let's say we want DSL methods like in this lambda:
17
+
18
+ front_page = lambda do
19
+ title 'hey'
20
+ items 'box', 'bib'
21
+ items 'bob'
22
+ end
23
+
24
+ # One way to implement this is to define a new class
25
+ # with the appropriate instance methods, and run any
26
+ # DSL code in its instance scope.
27
+ # InstantDSL simplifies that:
28
+
29
+ PageDSL = InstantDSL[:title, :items] # instantiates new class
30
+
31
+ scope = PageDSL.new
32
+
33
+ scope.instance_eval( front_page )
34
+
35
+ scope.dsl_values # => {:title => ['hey'], :items => ['box', 'bib', 'bob']}
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "instant_dsl"
8
+ gem.summary = %Q{Define new DSL's with ease.}
9
+ gem.description = %Q{Helps you define new DSL's by manufacturing classes.}
10
+ gem.email = "post@jostein.be"
11
+ gem.homepage = "http://github.com/jbe/instant_dsl"
12
+ gem.authors = ["jbe"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,20 @@
1
+
2
+ module InstantDSL
3
+ def self.[](*actions)
4
+ kls = Class.new
5
+
6
+ kls.send :attr_accessor, :dsl_values
7
+
8
+ actions.each do |act|
9
+ kls.send :define_method, act do |*args|
10
+ @dsl_values ||= {}
11
+ @dsl_values[act] ||= []
12
+ @dsl_values[act] += args
13
+ self
14
+ end
15
+ end
16
+ kls
17
+ end
18
+ end
19
+
20
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: instant_dsl
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - jbe
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-08 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Helps you define new DSL's by manufacturing classes.
22
+ email: post@jostein.be
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README
30
+ files:
31
+ - .document
32
+ - .gitignore
33
+ - LICENSE
34
+ - README
35
+ - Rakefile
36
+ - VERSION
37
+ - lib/instant_dsl.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/jbe/instant_dsl
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.7
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Define new DSL's with ease.
70
+ test_files: []
71
+