hentry_consumer 0.3.1 → 0.3.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/README.md +1 -1
 - data/lib/hentry_consumer/h_card.rb +1 -1
 - data/lib/hentry_consumer/h_entry.rb +2 -2
 - data/lib/hentry_consumer/h_feed.rb +7 -7
 - data/lib/hentry_consumer/version.rb +1 -1
 - data/spec/lib/hentry_consumer/format_rules_spec.rb +2 -2
 - data/spec/lib/hentry_consumer/h_entry_spec.rb +10 -10
 - data/spec/lib/hentry_consumer/h_feed_spec.rb +9 -9
 - data/spec/lib/hentry_consumer_spec.rb +5 -5
 - metadata +2 -2
 
    
        data/README.md
    CHANGED
    
    
| 
         @@ -21,14 +21,14 @@ module HentryConsumer 
     | 
|
| 
       21 
21 
     | 
    
         
             
                      :properties => {
         
     | 
| 
       22 
22 
     | 
    
         
             
                        :name       => self.name,
         
     | 
| 
       23 
23 
     | 
    
         
             
                        :categories => self.categories,
         
     | 
| 
       24 
     | 
    
         
            -
                        :author => self.author 
     | 
| 
      
 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 
     | 
| 
      
 25 
     | 
    
         
            +
                      :properties => {:entries => self.entries}
         
     | 
| 
       26 
26 
     | 
    
         
             
                    }]
         
     | 
| 
       27 
     | 
    
         
            -
                  }
         
     | 
| 
      
 27 
     | 
    
         
            +
                  }.to_json(a)
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
31 
     | 
    
         
             
            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[ 
     | 
| 
       65 
     | 
    
         
            -
                it { json[ 
     | 
| 
       66 
     | 
    
         
            -
                it { json[ 
     | 
| 
       67 
     | 
    
         
            -
                it { json[ 
     | 
| 
       68 
     | 
    
         
            -
                it { json[ 
     | 
| 
       69 
     | 
    
         
            -
                it { json[ 
     | 
| 
       70 
     | 
    
         
            -
                it { json[ 
     | 
| 
       71 
     | 
    
         
            -
                it { json[ 
     | 
| 
       72 
     | 
    
         
            -
                it { json[ 
     | 
| 
      
 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[ 
     | 
| 
       10 
     | 
    
         
            -
                it { json[ 
     | 
| 
       11 
     | 
    
         
            -
                it { json[ 
     | 
| 
       12 
     | 
    
         
            -
                it { json[ 
     | 
| 
       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. 
     | 
| 
      
 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- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-10-19 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: nokogiri
         
     |