forwarder19 0.2.0rc5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -147,28 +147,44 @@ we do not always use whitespaces, than we can leave the second paramter to be pr
147
147
  of the defined forwarder proxy.
148
148
 
149
149
  ```ruby
150
- forward :add_whitespace_to_punctuation,
150
+ forward :add_something_to_punctuation,
151
151
  to: :name,
152
152
  as: :gsub!,
153
- with: /[,.]\b/
153
+ with: /([,.])\b/
154
154
  ```
155
155
 
156
156
  We can achieve the same as above with the following invocation
157
157
 
158
158
  ```ruby
159
- o = Name.new( "the,quick, fox." )
160
- o.add_whitespace_to_punctuation( '\1 ' )
159
+ o = Name.new( "the,quick, fox." )
160
+ o.add_something_to_punctuation( '\1 ' )
161
161
  # name: "the, quick, fox." )
162
162
  ```
163
163
 
164
164
  but we can also add a hyphen after interpunctations with this invocation
165
165
 
166
166
  ```ruby
167
- o = Name.new( "the,quick, fox." )
168
- o.add_whitespace_to_punctuation( '\1- ' )
167
+ o = Name.new( "the,quick, fox." )
168
+ o.add_something_to_punctuation( '\1- ' )
169
169
  # name: "the,- quick,- fox." )
170
170
  ```
171
171
 
172
+ But more importantely we can forward to the partial application, thus using the
173
+ partial application as a mean of composition
174
+
175
+ ```ruby
176
+ forward :add_ws_to_punctuation,
177
+ to_object: :self,
178
+ as: :add_something_to_punctuation,
179
+ with: '\1 '
180
+
181
+ forward :add_hypen_to_punctuation,
182
+ to_object: self,
183
+ as: :add_something_to_punctuation,
184
+ with_block: ->(*grps){ "#{grps.first}- " }
185
+
186
+ ```
187
+
172
188
  ### Passing One Array
173
189
 
174
190
  If a real array shall be passed in as one parameter it can be wrapped into an array of one element,
data/lib/forwarder.rb CHANGED
@@ -3,6 +3,11 @@ require 'forwarder/params'
3
3
 
4
4
  module Forwarder
5
5
 
6
+ # How forward works:
7
+ # The parameters are analyzied by the Params object by means of the `prepare_forward`
8
+ # method. The `prepare_forward` method makes have use of the Argument object which
9
+ # implements a query API for what the given arguments allow the forwarder to do.
10
+ # And eventually the `forward!` method realises the delegation
6
11
  def forward *args, &blk
7
12
  params = Forwarder::Params.new self
8
13
  params.prepare_forward( *args, &blk )
@@ -1,5 +1,8 @@
1
1
  require 'forwarder/evaller'
2
2
  module Forwarder
3
+ # The compiler's responsability is to create a string representation of
4
+ # the delegation method, or to nil if no such string representation exists
5
+ # and delegation has to be done dynamically.
3
6
  class Compiler
4
7
  attr_reader :arguments
5
8
 
@@ -11,10 +14,8 @@ module Forwarder
11
14
  # To Hash can always compile
12
15
  return compile_to_hash if arguments.to_hash?
13
16
 
14
- # Cannot compile because arguments cannot be compiled
15
- @compiled_args = Evaller.serialize arguments.args
16
-
17
17
  # Cannot compile only because the arguments.args cannot be compiled
18
+ @compiled_args = Evaller.serialize arguments.args
18
19
  return unless @compiled_args
19
20
 
20
21
  # Can compile :)))
@@ -1,6 +1,7 @@
1
1
  require 'forwarder/arguments'
2
2
  require 'forwarder/compiler'
3
3
  require 'forwarder/meta'
4
+
4
5
  module Forwarder
5
6
  class Params
6
7
  attr_reader :forwardee, :arguments
@@ -1,3 +1,3 @@
1
1
  module Forwarder
2
- VERSION = '0.2.0rc5'
2
+ VERSION = '0.2.0'
3
3
  end # module Forwarder
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forwarder19
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0rc5
5
- prerelease: 5
4
+ version: 0.2.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert Dober
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-28 00:00:00.000000000Z
12
+ date: 2013-01-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lab419_core
16
- requirement: &13783720 !ruby/object:Gem::Requirement
16
+ requirement: &79251030 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13783720
24
+ version_requirements: *79251030
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby-debug19
27
- requirement: &13782800 !ruby/object:Gem::Requirement
27
+ requirement: &79250720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.11'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *13782800
35
+ version_requirements: *79250720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &13781560 !ruby/object:Gem::Requirement
38
+ requirement: &79250430 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.2.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *13781560
46
+ version_requirements: *79250430
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &13780620 !ruby/object:Gem::Requirement
49
+ requirement: &79250140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.9.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *13780620
57
+ version_requirements: *79250140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: maruku
60
- requirement: &13779720 !ruby/object:Gem::Requirement
60
+ requirement: &79249860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *13779720
68
+ version_requirements: *79249860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: wirble
71
- requirement: &13778460 !ruby/object:Gem::Requirement
71
+ requirement: &79249630 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.1.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *13778460
79
+ version_requirements: *79249630
80
80
  description: ! "Ruby's core Forwardable gets the job done(barely) and produces most
81
81
  unreadable code. \n\n Forwarder19 not only is more readable, much more feature
82
82
  rich, but also slightly faster, meaning you can use it without performance penalty.\n\n
@@ -87,13 +87,13 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - lib/forwarder.rb
91
- - lib/forwarder/evaller.rb
92
90
  - lib/forwarder/arguments.rb
93
- - lib/forwarder/version.rb
94
- - lib/forwarder/params.rb
95
- - lib/forwarder/meta.rb
96
91
  - lib/forwarder/compiler.rb
92
+ - lib/forwarder/meta.rb
93
+ - lib/forwarder/params.rb
94
+ - lib/forwarder/evaller.rb
95
+ - lib/forwarder/version.rb
96
+ - lib/forwarder.rb
97
97
  - LICENSE
98
98
  - README.md
99
99
  homepage: https://github.com/RobertDober/Forwarder19
@@ -112,12 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
- - - ! '>'
115
+ - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3.1
117
+ version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 1.8.10
120
+ rubygems_version: 1.8.11
121
121
  signing_key:
122
122
  specification_version: 3
123
123
  summary: Delegation And AOP Filters For It