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 +22 -6
- data/lib/forwarder.rb +5 -0
- data/lib/forwarder/compiler.rb +4 -3
- data/lib/forwarder/params.rb +1 -0
- data/lib/forwarder/version.rb +1 -1
- metadata +23 -23
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 :
|
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
|
-
|
160
|
-
|
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
|
-
|
168
|
-
|
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 )
|
data/lib/forwarder/compiler.rb
CHANGED
@@ -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 :)))
|
data/lib/forwarder/params.rb
CHANGED
data/lib/forwarder/version.rb
CHANGED
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.
|
5
|
-
prerelease:
|
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:
|
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: &
|
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: *
|
24
|
+
version_requirements: *79251030
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ruby-debug19
|
27
|
-
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: *
|
35
|
+
version_requirements: *79250720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
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: *
|
46
|
+
version_requirements: *79250430
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
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: *
|
57
|
+
version_requirements: *79250140
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: maruku
|
60
|
-
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: *
|
68
|
+
version_requirements: *79249860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: wirble
|
71
|
-
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: *
|
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:
|
117
|
+
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.8.
|
120
|
+
rubygems_version: 1.8.11
|
121
121
|
signing_key:
|
122
122
|
specification_version: 3
|
123
123
|
summary: Delegation And AOP Filters For It
|