diggr 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/README.txt +4 -3
- data/lib/diggr.rb +1 -1
- data/lib/diggr/request.rb +9 -5
- data/lib/diggr/response_classes/story.rb +4 -10
- data/test/test_request.rb +11 -0
- metadata +3 -3
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
* Documentation - http://diggr.rubyforge.org
|
4
4
|
* Source - http://github.com/dfg59/diggr/tree/master
|
5
|
+
* Issue Tracking - http://drewolson.lighthouseapp.com/projects/16743/home
|
5
6
|
|
6
7
|
== DESCRIPTION:
|
7
8
|
|
@@ -35,8 +36,8 @@ Options such as count or offset can be set using the options method and providin
|
|
35
36
|
arguments. See synopsis for more information.
|
36
37
|
|
37
38
|
Note: In an effort to remain consistent with the Digg API, some method names do not follow
|
38
|
-
the ruby idiom of underscores. Although somewhat ugly, this allows a user read the Digg
|
39
|
-
and understand the exact methods to call in Diggr to achieve their desired results.
|
39
|
+
the ruby idiom of underscores. Although somewhat ugly, this allows a user to read the Digg
|
40
|
+
API and understand the exact methods to call in Diggr to achieve their desired results.
|
40
41
|
|
41
42
|
== FEATURES/PROBLEMS:
|
42
43
|
|
@@ -78,7 +79,7 @@ and understand the exact methods to call in Diggr to achieve their desired resul
|
|
78
79
|
|
79
80
|
* need 1.0.2 or greater
|
80
81
|
* json 1.1.3 or greater
|
81
|
-
* activesupport 2.1.
|
82
|
+
* activesupport 2.1.1 or greater
|
82
83
|
|
83
84
|
== INSTALL:
|
84
85
|
|
data/lib/diggr.rb
CHANGED
data/lib/diggr/request.rb
CHANGED
@@ -12,7 +12,7 @@ module Diggr
|
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@end_point = ''
|
15
|
-
@options =
|
15
|
+
@options = ''
|
16
16
|
end
|
17
17
|
|
18
18
|
def options(params)
|
@@ -31,7 +31,13 @@ module Diggr
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def each(&block)
|
34
|
-
fetch
|
34
|
+
result = fetch
|
35
|
+
|
36
|
+
if result.kind_of? Array
|
37
|
+
fetch.each(&block)
|
38
|
+
else
|
39
|
+
yield result
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
def fetch
|
@@ -59,9 +65,7 @@ module Diggr
|
|
59
65
|
end
|
60
66
|
|
61
67
|
def path
|
62
|
-
|
63
|
-
path += @options if @options
|
64
|
-
path
|
68
|
+
@end_point + "?appkey=#{cleanse(Diggr::Constants::APP_KEY)}" + @options
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
@@ -12,21 +12,15 @@ module Diggr
|
|
12
12
|
|
13
13
|
def self.new_from_parsed_json(data)
|
14
14
|
story = Story.new
|
15
|
+
|
16
|
+
%w(id link submit_date diggs comments title description status media href).each do |attribute|
|
17
|
+
story.send("#{attribute}=",data[attribute]) if data[attribute]
|
18
|
+
end
|
15
19
|
|
16
|
-
story.id = data['id'] if data['id']
|
17
|
-
story.link = data['link'] if data['link']
|
18
|
-
story.submit_date = data['submit_date'] if data['submit_date']
|
19
|
-
story.diggs = data['diggs'] if data['diggs']
|
20
|
-
story.comments = data['comments'] if data['comments']
|
21
|
-
story.title = data['title'] if data['title']
|
22
|
-
story.description = data['description'] if data['description']
|
23
|
-
story.status = data['status'] if data['status']
|
24
|
-
story.media = data['media'] if data['media']
|
25
20
|
story.user = Diggr::User.new_from_parsed_json(data['user']) if data['user']
|
26
21
|
story.topic = Diggr::Topic.new_from_parsed_json(data['topic']) if data['topic']
|
27
22
|
story.container = Diggr::Container.new_from_parsed_json(data['container']) if data['container']
|
28
23
|
story.thumbnail = Diggr::Photo.new_from_parsed_json(data['thumbnail']) if data['thumbnail']
|
29
|
-
story.href = data['href'] if data['href']
|
30
24
|
|
31
25
|
story
|
32
26
|
end
|
data/test/test_request.rb
CHANGED
@@ -108,4 +108,15 @@ class TestRequest < Test::Unit::TestCase
|
|
108
108
|
assert_instance_of Diggr::Story, item
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
def test_each_with_singular_response
|
113
|
+
story = Diggr::Story.new
|
114
|
+
Diggr::JSONParser.any_instance.stubs(:parse).with(story).returns(story)
|
115
|
+
request = Diggr::Request.new
|
116
|
+
request.stubs(:make_request).returns(story)
|
117
|
+
|
118
|
+
request.each do |item|
|
119
|
+
assert_instance_of Diggr::Story, item
|
120
|
+
end
|
121
|
+
end
|
111
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diggr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Olson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-14 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 1.7.0
|
54
54
|
version:
|
55
|
-
description: "Diggr is a ruby wrapper for the Digg API. Diggr strives to remain consistent with the Digg API endpoints listed here: http://apidoc.digg.com/CompleteList. Endpoints are created in Diggr with method calls. Each node in an endpoint becomes a method call and each node which is an argument becomes an argument to the previous method. As an example, the following endpoint /user/{user name} in which the user name is \"johndoe\" would be created with this Diggr call: diggr.user(\"johndoe\") To send the request to the Digg API and retrieve the results of the call, Diggr requests are terminated in one of two ways. 1. Using the fetch method. By ending your request with the fetch method, your result will be returned to you. If the request is singular, you will receive a single object as a response. If the request is plural, you will receive a collection of objects stored in an array. 2. Using any Enumerable method. This works only on plural requests. In this case, it is unnecessary to use the fetch method. See the synopsis for examples of each of these types of calls. Options such as count or offset can be set using the options method and providing a hash of arguments. See synopsis for more information. Note: In an effort to remain consistent with the Digg API, some method names do not follow the ruby idiom of underscores. Although somewhat ugly, this allows a user read the Digg API and understand the exact methods to call in Diggr to achieve their desired results."
|
55
|
+
description: "Diggr is a ruby wrapper for the Digg API. Diggr strives to remain consistent with the Digg API endpoints listed here: http://apidoc.digg.com/CompleteList. Endpoints are created in Diggr with method calls. Each node in an endpoint becomes a method call and each node which is an argument becomes an argument to the previous method. As an example, the following endpoint /user/{user name} in which the user name is \"johndoe\" would be created with this Diggr call: diggr.user(\"johndoe\") To send the request to the Digg API and retrieve the results of the call, Diggr requests are terminated in one of two ways. 1. Using the fetch method. By ending your request with the fetch method, your result will be returned to you. If the request is singular, you will receive a single object as a response. If the request is plural, you will receive a collection of objects stored in an array. 2. Using any Enumerable method. This works only on plural requests. In this case, it is unnecessary to use the fetch method. See the synopsis for examples of each of these types of calls. Options such as count or offset can be set using the options method and providing a hash of arguments. See synopsis for more information. Note: In an effort to remain consistent with the Digg API, some method names do not follow the ruby idiom of underscores. Although somewhat ugly, this allows a user to read the Digg API and understand the exact methods to call in Diggr to achieve their desired results."
|
56
56
|
email:
|
57
57
|
- drew@drewolson.org
|
58
58
|
executables: []
|