fetcher-microdata 0.0.11 → 0.0.12

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.
@@ -1,5 +1,5 @@
1
1
  module Fetcher
2
2
  class Microdata
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -10,7 +10,8 @@ module Writer
10
10
 
11
11
  def hash
12
12
  @attributes = @source.attributes
13
- {
13
+
14
+ resp = {
14
15
  "type" => [
15
16
  @source._type
16
17
  ],
@@ -35,6 +36,13 @@ module Writer
35
36
  ]
36
37
  }
37
38
  }
39
+
40
+ resp["properties"].keys.each do |att|
41
+ if resp["properties"]["#{att}"] == [nil]
42
+ resp["properties"].delete "#{att}"
43
+ end
44
+ end
45
+ resp
38
46
  end
39
47
  end
40
48
  end
@@ -89,5 +89,65 @@ describe Writer::Fetcher::Microdata::PersonUser do
89
89
  writer.hash["properties"].should include @properties_hash
90
90
  end
91
91
  end
92
+ end
93
+
94
+ describe "#hash innecesary data" do
95
+
96
+ it 'should not put dateRegistered on the data if data registered is nil' do
97
+ @properties_hash = {
98
+ "User#dateRegistered" => [nil]
99
+ }
100
+ aux_stub = stub "aux stub"
101
+ aux_stub.stub(:[]) do |symbol|
102
+ if symbol == :dateRegistered
103
+ nil
104
+ else
105
+ symbol.to_s
106
+ end
107
+ end
108
+ @nil_user_stub.should_receive(:_type).and_return "some type"
109
+ @nil_user_stub.should_receive(:attributes).and_return aux_stub
110
+
111
+ writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub
112
+ writer.hash["properties"].should_not include @properties_hash
113
+ end
114
+
115
+ it 'should not put description on the data if data registered is nil' do
116
+ @properties_hash = {
117
+ "description" => [nil]
118
+ }
119
+ aux_stub = stub "aux stub"
120
+ aux_stub.stub(:[]) do |symbol|
121
+ if symbol == :description
122
+ nil
123
+ else
124
+ symbol.to_s
125
+ end
126
+ end
127
+ @nil_user_stub.should_receive(:_type).and_return "some type"
128
+ @nil_user_stub.should_receive(:attributes).and_return aux_stub
129
+
130
+ writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub
131
+ writer.hash["properties"].should_not include @properties_hash
132
+ end
133
+
134
+ it 'should not put url on the data if data registered is nil' do
135
+ @properties_hash = {
136
+ "url" => [nil]
137
+ }
138
+ aux_stub = stub "aux stub"
139
+ aux_stub.stub(:[]) do |symbol|
140
+ if symbol == :url
141
+ nil
142
+ else
143
+ symbol.to_s
144
+ end
145
+ end
146
+ @nil_user_stub.should_receive(:_type).and_return "some type"
147
+ @nil_user_stub.should_receive(:attributes).and_return aux_stub
148
+
149
+ writer = Writer::Fetcher::Microdata::PersonUser.new @nil_user_stub
150
+ writer.hash["properties"].should_not include @properties_hash
151
+ end
92
152
  end
93
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fetcher-microdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: