rolando-comma 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/comma/extractors.rb +14 -10
  2. metadata +7 -5
@@ -1,5 +1,5 @@
1
1
  module Comma
2
-
2
+
3
3
  class Extractor
4
4
 
5
5
  def initialize(instance, &block)
@@ -7,18 +7,22 @@ module Comma
7
7
  @block = block
8
8
  @results = []
9
9
  end
10
-
10
+
11
11
  def results
12
12
  instance_eval &@block
13
13
  @results
14
14
  end
15
+
16
+ def id
17
+ method_missing(:id)
18
+ end
15
19
  end
16
-
20
+
17
21
  class HeaderExtractor < Extractor
18
-
22
+
19
23
  def method_missing(sym, *args, &block)
20
24
  @results << sym.to_s.humanize if args.blank?
21
-
25
+
22
26
  args.each do |arg|
23
27
  case arg
24
28
  when Hash
@@ -35,20 +39,20 @@ module Comma
35
39
  end
36
40
  end
37
41
  end
38
-
42
+
39
43
  class DataExtractor < Extractor
40
-
44
+
41
45
  def method_missing(sym, *args, &block)
42
46
  @results << @instance.send(sym).to_s if args.blank?
43
-
47
+
44
48
  args.each do |arg|
45
49
  case arg
46
50
  when Hash
47
51
  arg.each do |k, v|
48
- @results << @instance.send(sym).send(k).to_s
52
+ @results << (@instance.send(sym).nil? ? '' : @instance.send(sym).send(k).to_s )
49
53
  end
50
54
  when Symbol
51
- @results << @instance.send(sym).send(arg).to_s
55
+ @results << ( @instance.send(sym).nil? ? '' : @instance.send(sym).send(arg).to_s )
52
56
  when String
53
57
  @results << @instance.send(sym).to_s
54
58
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rolando-comma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-04-08 00:00:00 -07:00
13
+ date: 2010-01-02 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -46,8 +46,10 @@ files:
46
46
  - MIT-LICENSE
47
47
  - lib/comma.rb
48
48
  - lib/comma/extractors.rb
49
- has_rdoc: false
49
+ has_rdoc: true
50
50
  homepage: http://github.com/rolando/comma
51
+ licenses: []
52
+
51
53
  post_install_message:
52
54
  rdoc_options: []
53
55
 
@@ -68,9 +70,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
70
  requirements: []
69
71
 
70
72
  rubyforge_project:
71
- rubygems_version: 1.2.0
73
+ rubygems_version: 1.3.5
72
74
  signing_key:
73
- specification_version: 2
75
+ specification_version: 3
74
76
  summary: Germanified version with ; instead of , as field seperator
75
77
  test_files: []
76
78