greedy 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/greedy.gemspec +1 -1
- data/lib/greedy/entry.rb +7 -2
- data/test/test_entry.rb +6 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/greedy.gemspec
CHANGED
data/lib/greedy/entry.rb
CHANGED
@@ -26,14 +26,14 @@ module Greedy
|
|
26
26
|
@stream = stream
|
27
27
|
@feed = Greedy::Feed.new(item['origin'])
|
28
28
|
|
29
|
-
@author = normalize item['author']
|
30
|
-
@href = item['alternate'].first['href']
|
29
|
+
@author = normalize item['author']
|
31
30
|
@google_item_id = item['id']
|
32
31
|
@published = item['published']
|
33
32
|
@updated = item['updated']
|
34
33
|
|
35
34
|
set_body!(item)
|
36
35
|
set_title!(item)
|
36
|
+
set_href!(item)
|
37
37
|
end
|
38
38
|
|
39
39
|
# Provide the entry time by which the entry should be sorted amongst other entries
|
@@ -60,6 +60,11 @@ module Greedy
|
|
60
60
|
end
|
61
61
|
|
62
62
|
protected
|
63
|
+
def set_href!(hash)
|
64
|
+
links = hash['alternate']
|
65
|
+
@href = (links.first['href'] unless (links.nil? || links.empty?)) || @feed.href
|
66
|
+
end
|
67
|
+
|
63
68
|
def set_title!(hash)
|
64
69
|
raw_title = hash['title'] || "#{@feed.title} - #{published_at.strftime "%B %d"}"
|
65
70
|
@title = normalize raw_title
|
data/test/test_entry.rb
CHANGED
@@ -5,7 +5,7 @@ class TestEntry < Test::Unit::TestCase
|
|
5
5
|
setup do
|
6
6
|
@stream = stub("Greedy::Stream")
|
7
7
|
@raw_entry = a_typical_raw_entry_hash
|
8
|
-
@feed = stub("Greedy::Feed", :title => "The Feed Title")
|
8
|
+
@feed = stub("Greedy::Feed", :title => "The Feed Title", :href => "feed path")
|
9
9
|
Greedy::Feed.stubs(:new).returns(@feed)
|
10
10
|
end
|
11
11
|
|
@@ -44,6 +44,11 @@ class TestEntry < Test::Unit::TestCase
|
|
44
44
|
Greedy::Entry.new(@raw_entry, @stream).title.should == "The Feed Title - July 22"
|
45
45
|
end
|
46
46
|
|
47
|
+
should "set the href to the feed href if the entry href is missing" do
|
48
|
+
@raw_entry['alternate'] = nil
|
49
|
+
Greedy::Entry.new(@raw_entry, @stream).href.should == "feed path"
|
50
|
+
end
|
51
|
+
|
47
52
|
should_eventually "be able to share itself" do
|
48
53
|
@stream.expects(:change_state_for).with(@entry, "broadcast").returns(true)
|
49
54
|
@entry.share!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greedy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Weiland
|