quotefm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/lib/quotefm/article.rb +28 -0
- data/lib/quotefm/category.rb +7 -0
- data/lib/quotefm/page.rb +15 -0
- data/lib/quotefm/recommendation.rb +20 -0
- data/lib/quotefm/user.rb +21 -0
- data/lib/quotefm/version.rb +3 -0
- data/lib/quotefm.rb +95 -0
- data/quotefm.gemspec +21 -0
- data/spec/fixtures/quotefm/article/get.json +1 -0
- data/spec/fixtures/quotefm/article/listByCategories.json +1 -0
- data/spec/fixtures/quotefm/article/listByPage.json +1 -0
- data/spec/fixtures/quotefm/category/list.json +1 -0
- data/spec/fixtures/quotefm/page/get.json +1 -0
- data/spec/fixtures/quotefm/page/list.json +1 -0
- data/spec/fixtures/quotefm/recommendation/get.json +1 -0
- data/spec/fixtures/quotefm/recommendation/listByArticle.json +1 -0
- data/spec/fixtures/quotefm/recommendation/listByUser.json +1 -0
- data/spec/fixtures/quotefm/user/get.json +1 -0
- data/spec/fixtures/quotefm/user/listFollowers.json +1 -0
- data/spec/fixtures/quotefm/user/listFollowings.json +1 -0
- data/spec/quotefm/article_spec.rb +37 -0
- data/spec/quotefm/category_spec.rb +11 -0
- data/spec/quotefm/page_spec.rb +30 -0
- data/spec/quotefm/recommendation_spec.rb +31 -0
- data/spec/quotefm/user_spec.rb +32 -0
- data/spec/quotefm.spec +6 -0
- data/spec/spec_helper.rb +11 -0
- metadata +146 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "rspec"
|
3
|
+
require "quotefm"
|
4
|
+
require 'fakeweb'
|
5
|
+
|
6
|
+
FakeWeb.allow_net_connect = false
|
7
|
+
|
8
|
+
describe Quotefm::Recommendation do
|
9
|
+
|
10
|
+
it "should get a recommendation" do
|
11
|
+
stub_uri(:get, "/recommendation/get/?id=900", "quotefm/recommendation/get.json")
|
12
|
+
response = Quotefm::Recommendation.get 900
|
13
|
+
response['id'].should == 900
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should get recommendations by Article" do
|
17
|
+
stub_uri(:get, "/recommendation/listByArticle/?id=123", "quotefm/recommendation/listByArticle.json")
|
18
|
+
response = Quotefm::Recommendation.listByArticle 123
|
19
|
+
|
20
|
+
response['totalCount'].should == "1"
|
21
|
+
response['entities'].count.should == 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get recommendations by User" do
|
25
|
+
stub_uri(:get, "/recommendation/listByUser/?username=uarrr", "quotefm/recommendation/listByUser.json")
|
26
|
+
response = Quotefm::Recommendation.listByUser "uarrr"
|
27
|
+
|
28
|
+
response['totalCount'].should == "100"
|
29
|
+
response['entities'].count.should == 100
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "rspec"
|
2
|
+
|
3
|
+
FakeWeb.allow_net_connect = false
|
4
|
+
|
5
|
+
describe Quotefm::User do
|
6
|
+
|
7
|
+
it "should get a user by ID" do
|
8
|
+
stub_uri(:get, "/user/get/?id=1", "quotefm/user/get.json")
|
9
|
+
response = Quotefm::User.getByID 1
|
10
|
+
response['id'].should == 1
|
11
|
+
response['username'].should == "pwaldhauer"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should get a user by username" do
|
15
|
+
stub_uri(:get, "/user/get/?username=pwaldhauer", "quotefm/user/get.json")
|
16
|
+
response = Quotefm::User.getByUsername "pwaldhauer"
|
17
|
+
response['id'].should == 1
|
18
|
+
response['username'].should == "pwaldhauer"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should get a users followers" do
|
22
|
+
stub_uri(:get, "/user/listFollowers/?username=pwaldhauer", "quotefm/user/listFollowers.json")
|
23
|
+
response = Quotefm::User.listFollowers "pwaldhauer"
|
24
|
+
response['totalCount'].should == "464"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should get a users followings" do
|
28
|
+
stub_uri(:get, "/user/listFollowings/?username=pwaldhauer", "quotefm/user/listFollowings.json")
|
29
|
+
response = Quotefm::User.listFollowings "pwaldhauer"
|
30
|
+
response['totalCount'].should == "141"
|
31
|
+
end
|
32
|
+
end
|
data/spec/quotefm.spec
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
def fixture_file(filename)
|
2
|
+
return '' if filename == ''
|
3
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
4
|
+
File.read(file_path)
|
5
|
+
end
|
6
|
+
|
7
|
+
def stub_uri(method, url, filename)
|
8
|
+
options = { :body => fixture_file(filename), :content_type => 'application/json' }
|
9
|
+
url = "https://quote.fm/api"+url.to_s
|
10
|
+
FakeWeb.register_uri(method.to_sym, url, options)
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quotefm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Moritz Kröger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fakeweb
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.9'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.9'
|
62
|
+
description: Unofficial Wrapper for the Quote.fm REST API
|
63
|
+
email:
|
64
|
+
- moritz.kroeger@googlemail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rvmrc
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/quotefm.rb
|
76
|
+
- lib/quotefm/article.rb
|
77
|
+
- lib/quotefm/category.rb
|
78
|
+
- lib/quotefm/page.rb
|
79
|
+
- lib/quotefm/recommendation.rb
|
80
|
+
- lib/quotefm/user.rb
|
81
|
+
- lib/quotefm/version.rb
|
82
|
+
- quotefm.gemspec
|
83
|
+
- spec/fixtures/quotefm/article/get.json
|
84
|
+
- spec/fixtures/quotefm/article/listByCategories.json
|
85
|
+
- spec/fixtures/quotefm/article/listByPage.json
|
86
|
+
- spec/fixtures/quotefm/category/list.json
|
87
|
+
- spec/fixtures/quotefm/page/get.json
|
88
|
+
- spec/fixtures/quotefm/page/list.json
|
89
|
+
- spec/fixtures/quotefm/recommendation/get.json
|
90
|
+
- spec/fixtures/quotefm/recommendation/listByArticle.json
|
91
|
+
- spec/fixtures/quotefm/recommendation/listByUser.json
|
92
|
+
- spec/fixtures/quotefm/user/get.json
|
93
|
+
- spec/fixtures/quotefm/user/listFollowers.json
|
94
|
+
- spec/fixtures/quotefm/user/listFollowings.json
|
95
|
+
- spec/quotefm.spec
|
96
|
+
- spec/quotefm/article_spec.rb
|
97
|
+
- spec/quotefm/category_spec.rb
|
98
|
+
- spec/quotefm/page_spec.rb
|
99
|
+
- spec/quotefm/recommendation_spec.rb
|
100
|
+
- spec/quotefm/user_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: http://github.com/mcrip/quotefm
|
103
|
+
licenses: []
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.8.21
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Wraps all functions of the Quote.fm REST API into Ruby Objects and returns
|
126
|
+
its responses
|
127
|
+
test_files:
|
128
|
+
- spec/fixtures/quotefm/article/get.json
|
129
|
+
- spec/fixtures/quotefm/article/listByCategories.json
|
130
|
+
- spec/fixtures/quotefm/article/listByPage.json
|
131
|
+
- spec/fixtures/quotefm/category/list.json
|
132
|
+
- spec/fixtures/quotefm/page/get.json
|
133
|
+
- spec/fixtures/quotefm/page/list.json
|
134
|
+
- spec/fixtures/quotefm/recommendation/get.json
|
135
|
+
- spec/fixtures/quotefm/recommendation/listByArticle.json
|
136
|
+
- spec/fixtures/quotefm/recommendation/listByUser.json
|
137
|
+
- spec/fixtures/quotefm/user/get.json
|
138
|
+
- spec/fixtures/quotefm/user/listFollowers.json
|
139
|
+
- spec/fixtures/quotefm/user/listFollowings.json
|
140
|
+
- spec/quotefm.spec
|
141
|
+
- spec/quotefm/article_spec.rb
|
142
|
+
- spec/quotefm/category_spec.rb
|
143
|
+
- spec/quotefm/page_spec.rb
|
144
|
+
- spec/quotefm/recommendation_spec.rb
|
145
|
+
- spec/quotefm/user_spec.rb
|
146
|
+
- spec/spec_helper.rb
|