hentry_consumer 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,7 +22,7 @@ serialized h-entry objects. The returned Object structure looks something like t
22
22
 
23
23
  ## Current Version
24
24
 
25
- 0.3.0
25
+ 0.3.2
26
26
 
27
27
 
28
28
  ## Requirements
@@ -15,7 +15,7 @@ module HentryConsumer
15
15
  :url => self.url
16
16
  }
17
17
  }]
18
- }
18
+ }.to_json(a)
19
19
  end
20
20
 
21
21
  end
@@ -21,14 +21,14 @@ module HentryConsumer
21
21
  :properties => {
22
22
  :name => self.name,
23
23
  :categories => self.categories,
24
- :author => self.author.map(&:to_json),
24
+ :author => self.author,
25
25
  :content => self.content,
26
26
  :bookmark => self.bookmark,
27
27
  :published_at => self.published_at,
28
28
  :summary => self.summary
29
29
  }
30
30
  }]
31
- }
31
+ }.to_json(a)
32
32
  end
33
33
 
34
34
  private
@@ -5,7 +5,7 @@ module HentryConsumer
5
5
  @entries = []
6
6
  parse_html(html)
7
7
  end
8
-
8
+
9
9
  def parse_html(html)
10
10
  doc = Nokogiri::HTML(open(html).read)
11
11
  doc.css(".h-entry").each do |mf_entry|
@@ -13,19 +13,19 @@ module HentryConsumer
13
13
  self.entries << entry
14
14
  end
15
15
  end
16
-
16
+
17
17
  def to_html
18
18
  self.entries.collect(&:to_html).join
19
19
  end
20
-
20
+
21
21
  def to_json(*a)
22
- json = {:items =>
22
+ json = {:items =>
23
23
  [{
24
24
  :type => ["h-feed"],
25
- :properties => {:entries => self.entries.map(&:to_json)}
25
+ :properties => {:entries => self.entries}
26
26
  }]
27
- }
27
+ }.to_json(a)
28
28
  end
29
-
29
+
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module HentryConsumer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -17,11 +17,11 @@ describe HentryConsumer::FormatRules do
17
17
  it "can have many" do
18
18
  HentryConsumer::FormatRules.can_have_many?(:url).should be_true
19
19
  end
20
-
20
+
21
21
  it "can't have many" do
22
22
  HentryConsumer::FormatRules.can_have_many?(:uid).should be_false
23
23
  end
24
-
24
+
25
25
  it "is unique" do
26
26
  HentryConsumer::FormatRules.unique?(:uid).should be_true
27
27
  end
@@ -59,17 +59,17 @@ describe HentryConsumer::HEntry do
59
59
  end
60
60
 
61
61
  describe "json" do
62
- let(:json) { entry.to_json }
62
+ let(:json) { JSON.parse(entry.to_json) }
63
63
 
64
- it { json[:items].should be_an_instance_of Array }
65
- it { json[:items].first[:type].should include 'h-entry'}
66
- it { json[:items].first[:properties][:name].should eq ['Senior Cat Living']}
67
- it { json[:items].first[:properties][:content].first.should match /Locations/ }
68
- it { json[:items].first[:properties][:author].should be_an_instance_of Array }
69
- it { json[:items].first[:properties][:author].first[:items].first[:type].should include "h-card" }
70
- it { json[:items].first[:properties][:bookmark].should eq "http://g5.com/feed/entries/2012-08-26-20-09-0700" }
71
- it { json[:items].first[:properties][:published_at].should eq ["2012-08-26 20:09-0700"] }
72
- it { json[:items].first[:properties][:summary].should be_an_instance_of Array }
64
+ it { json["items"].should be_an_instance_of Array }
65
+ it { json["items"].first["type"].should include 'h-entry'}
66
+ it { json["items"].first["properties"]["name"].should eq ['Senior Cat Living']}
67
+ it { json["items"].first["properties"]["content"].first.should match /Locations/ }
68
+ it { json["items"].first["properties"]["author"].should be_an_instance_of Array }
69
+ it { json["items"].first["properties"]["author"].first["items"].first["type"].should include "h-card" }
70
+ it { json["items"].first["properties"]["bookmark"].should eq "http://g5.com/feed/entries/2012-08-26-20-09-0700" }
71
+ it { json["items"].first["properties"]["published_at"].should eq ["2012-08-26 20:09-0700"] }
72
+ it { json["items"].first["properties"]["summary"].should be_an_instance_of Array }
73
73
  end
74
74
 
75
75
  end
@@ -2,15 +2,15 @@ require 'hentry_consumer'
2
2
 
3
3
  describe HentryConsumer::HFeed do
4
4
  let(:feed) { HentryConsumer.parse(File.open("spec/support/example.html")) }
5
-
5
+
6
6
  describe "to json" do
7
- let(:json) { feed.to_json }
8
-
9
- it { json[:items].first[:type].should include 'h-feed'}
10
- it { json[:items].first[:properties][:entries].should be_an_instance_of Array }
11
- it { json[:items].first[:properties][:entries].first[:items].should be_an_instance_of Array }
12
- it { json[:items].first[:properties][:entries].first[:items].first[:type].should include "h-entry" }
13
-
7
+ let(:json) { JSON.parse(feed.to_json) }
8
+
9
+ it { json["items"].first["type"].should include 'h-feed'}
10
+ it { json["items"].first["properties"]["entries"].should be_an_instance_of Array }
11
+ it { json["items"].first["properties"]["entries"].first["items"].should be_an_instance_of Array }
12
+ it { json["items"].first["properties"]["entries"].first["items"].first["type"].should include "h-entry" }
13
+
14
14
  end
15
15
  # <article class=\"h-entry\"><h1 class=\"p-name\">Senior Cat Living</h1>
16
16
  # <article class=\"h-entry\">\n <h1 class=\"p-name\">Senior Cat Living</h1>\n
@@ -23,5 +23,5 @@ describe HentryConsumer::HFeed do
23
23
  end
24
24
  end
25
25
  end
26
-
26
+
27
27
  end
@@ -1,19 +1,19 @@
1
1
  require 'hentry_consumer'
2
2
 
3
3
  describe HentryConsumer do
4
-
4
+
5
5
  it { should respond_to :parse }
6
-
6
+
7
7
  describe "parsing a file" do
8
8
  let(:result) { HentryConsumer.parse(File.open("spec/support/example.html")) }
9
-
9
+
10
10
  it "should be a HentryConsumer object" do
11
11
  result.should be_an_instance_of HentryConsumer::HFeed
12
12
  end
13
-
13
+
14
14
  it "should have 2 enties" do
15
15
  result.entries.size.should eq 2
16
16
  end
17
-
17
+
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hentry_consumer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri