dsl 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/.gitignore +2 -2
  2. data/README.md +17 -47
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/spec/spec_helper.rb +1 -0
  6. metadata +3 -3
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
1
  *.gemspec
2
- package\*
3
- .DS_Store
2
+ pkg/
3
+ .DS_Store
data/README.md CHANGED
@@ -21,62 +21,32 @@ Helpers for the creation of Domain Specific Languages within your libraries and
21
21
 
22
22
  ```ruby
23
23
  class Character
24
- class AttributeDSL < DSL
25
- def_dsl :name, :age, :gender
24
+
25
+ class AttrDSL < DSL
26
+ def_dsl_delegator :name, :age
26
27
  end
27
-
28
- attr_reader :name, :age, :gender
29
-
28
+
30
29
  def initialize(&blk)
31
- dsl = AttributeDSL.call(&blk)
32
-
33
- @name, @age, @gender = dsl.name, dsl.age, dsl.gender
34
-
35
- # OR:
36
- # @name, @age, @gender = dsl.to_h.values_at(:name, :age, :gender)
37
- end
38
- end
39
-
40
- Character.new do
41
- name 'John Doe'
42
- age 21
43
- gender :male
44
- end
45
- ```
46
-
47
- ### Advanced
48
-
49
- ```ruby
50
- class Character
51
- class AttributeDSL < DSL
52
- def_dsl :name do
53
- get do |value|
54
- value.split(' ').first.capitalize # Only return the first name, even if the person has a last name as well
55
- end
56
-
57
- set do |value| # The instance variable will be set to the result of this block
58
- raise 'name must be a String' unless value.respond_to?(:to_s)
59
-
60
- value.to_s
61
- end
62
- end
30
+ @dsl = AttrDSL.call(self, &blk)
63
31
  end
64
32
 
65
- attr_reader :name
33
+ def name=(value)
34
+ @name = value.to_s.split(/\s+/).first.upcase
35
+ end
66
36
 
67
- def initialize(&blk)
68
- dsl = AttributeDSL.call(&blk)
69
-
70
- @name = dsl.name
71
-
72
- # OR:
73
- # @name, @age, @gender = dsl.to_h.values_at(:name, :age, :gender)
37
+ def age=(value)
38
+ @age = value.to_i
74
39
  end
40
+
75
41
  end
76
42
 
77
- Character.new do
78
- name 1234 # Error: name must be a String
43
+ char = Character.new do
44
+ name 'john doe'
45
+ age '21'
79
46
  end
47
+
48
+ char.name # => "JOHN"
49
+ char.age # => 21
80
50
  ```
81
51
 
82
52
  ## License
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ spec = Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.lines.to_a.collect { |s| s.strip }
16
16
  s.executables = `git ls-files -- bin/*`.lines.to_a.collect { |s| File.basename(s.strip) }
17
17
 
18
- s.post_install_message = "NOTICE!\n\n DSL 2.x.x is INCOMPATIBLE with DSL 1.x.x!\n\n"
18
+ s.post_install_message = "NOTICE!\n\n DSL 0.2.x is INCOMPATIBLE with DSL 0.2.x!\n\n"
19
19
 
20
20
  s.add_dependency 'version', '~> 1.0.0'
21
21
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,5 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'dsl'
3
+ require 'bundler/setup'
3
4
 
4
5
  Bundler.require(:development)
5
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -51,7 +51,7 @@ files:
51
51
  - spec/support/character_without_attributes.rb
52
52
  homepage: http://github.com/c00lryguy/dsl
53
53
  licenses: []
54
- post_install_message: ! "NOTICE!\n\n DSL 2.x.x is INCOMPATIBLE with DSL 1.x.x!\n\n"
54
+ post_install_message: ! "NOTICE!\n\n DSL 0.2.x is INCOMPATIBLE with DSL 0.2.x!\n\n"
55
55
  rdoc_options: []
56
56
  require_paths:
57
57
  - lib
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: 3439450735216533917
66
+ hash: 1550716331272689819
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements: