drewolson-diggr 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/diggr/constants.rb +3 -0
- data/lib/diggr/response_classes/container.rb +1 -1
- data/lib/diggr/response_classes/story.rb +3 -1
- data/test/test_story.rb +5 -1
- metadata +1 -1
data/History.txt
CHANGED
data/lib/diggr/constants.rb
CHANGED
@@ -4,11 +4,12 @@ need { 'user' }
|
|
4
4
|
need { 'topic' }
|
5
5
|
need { 'container' }
|
6
6
|
need { 'photo' }
|
7
|
+
need { 'short_url' }
|
7
8
|
|
8
9
|
module Diggr
|
9
10
|
class Story
|
10
11
|
attr_accessor :id, :link, :submit_date, :diggs, :comments, :title, :description,
|
11
|
-
:status, :media, :user, :topic, :container, :thumbnail, :href
|
12
|
+
:status, :media, :user, :topic, :container, :thumbnail, :href, :shorturl
|
12
13
|
|
13
14
|
def self.new_from_parsed_json(data)
|
14
15
|
story = Story.new
|
@@ -21,6 +22,7 @@ module Diggr
|
|
21
22
|
story.topic = Diggr::Topic.new_from_parsed_json(data['topic']) if data['topic']
|
22
23
|
story.container = Diggr::Container.new_from_parsed_json(data['container']) if data['container']
|
23
24
|
story.thumbnail = Diggr::Photo.new_from_parsed_json(data['thumbnail']) if data['thumbnail']
|
25
|
+
story.shorturl = Diggr::ShortUrl.new_from_parsed_json(data['shorturl'][0]) if data['shorturl']
|
24
26
|
|
25
27
|
story
|
26
28
|
end
|
data/test/test_story.rb
CHANGED
@@ -43,13 +43,17 @@ class TestStory < Test::Unit::TestCase
|
|
43
43
|
"width" => 80,
|
44
44
|
"height" => 80
|
45
45
|
},
|
46
|
+
"shorturl" => [{
|
47
|
+
"short_url" => "http://digg.com/D123JKL",
|
48
|
+
"views" => 1
|
49
|
+
}],
|
46
50
|
"href" => "http://digg.com/linux_unix/Jukebox_con_Linux"
|
47
51
|
}
|
48
52
|
|
49
53
|
photo = Diggr::Story.new_from_parsed_json(parsed_json_data)
|
50
54
|
|
51
55
|
parsed_json_data.each do |key,val|
|
52
|
-
unless val.kind_of? Hash
|
56
|
+
unless val.kind_of? Hash or val.kind_of? Array
|
53
57
|
assert_equal val, photo.send(key)
|
54
58
|
end
|
55
59
|
end
|