crafterm-comma 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/comma/extractors.rb +14 -3
- metadata +2 -3
data/lib/comma/extractors.rb
CHANGED
@@ -43,18 +43,29 @@ module Comma
|
|
43
43
|
class DataExtractor < Extractor
|
44
44
|
|
45
45
|
def method_missing(sym, *args, &block)
|
46
|
-
|
46
|
+
if args.blank?
|
47
|
+
result = block ? yield(@instance.send(sym)) : @instance.send(sym)
|
48
|
+
@results << result.to_s
|
49
|
+
end
|
47
50
|
|
48
51
|
args.each do |arg|
|
49
52
|
case arg
|
50
53
|
when Hash
|
51
54
|
arg.each do |k, v|
|
52
|
-
|
55
|
+
if block
|
56
|
+
@results << (@instance.send(sym).nil? ? '' : yield(@instance.send(sym).send(k)).to_s )
|
57
|
+
else
|
58
|
+
@results << (@instance.send(sym).nil? ? '' : @instance.send(sym).send(k).to_s )
|
59
|
+
end
|
53
60
|
end
|
54
61
|
when Symbol
|
62
|
+
if block
|
63
|
+
@results << (@instance.send(sym).nil? ? '' : yield(@instance.send(sym).send(arg)).to_s)
|
64
|
+
else
|
55
65
|
@results << ( @instance.send(sym).nil? ? '' : @instance.send(sym).send(arg).to_s )
|
66
|
+
end
|
56
67
|
when String
|
57
|
-
@results << @instance.send(sym).to_s
|
68
|
+
@results << (block ? yield(@instance.send(sym)) : @instance.send(sym)).to_s
|
58
69
|
else
|
59
70
|
raise "Unknown data symbol #{arg.inspect}"
|
60
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crafterm-comma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcus Crafter
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- lib/comma/extractors.rb
|
38
38
|
has_rdoc: false
|
39
39
|
homepage: http://github.com/crafterm/comma
|
40
|
-
licenses:
|
41
40
|
post_install_message:
|
42
41
|
rdoc_options: []
|
43
42
|
|
@@ -58,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements: []
|
59
58
|
|
60
59
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.2.0
|
62
61
|
signing_key:
|
63
62
|
specification_version: 2
|
64
63
|
summary: Ruby Comma Seperated Values generation library
|