kiita 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.simplecov +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/LICENSE.md +22 -0
- data/README.md +129 -0
- data/Rakefile +1 -0
- data/kiita.gemspec +27 -0
- data/lib/kiita.rb +26 -0
- data/lib/kiita/api.rb +118 -0
- data/lib/kiita/errors.rb +43 -0
- data/lib/kiita/model.rb +33 -0
- data/lib/kiita/post.rb +41 -0
- data/lib/kiita/tag.rb +30 -0
- data/lib/kiita/user.rb +57 -0
- data/lib/kiita/version.rb +3 -0
- data/spec/kiita/api_spec.rb +301 -0
- data/spec/kiita/errors_spec.rb +5 -0
- data/spec/kiita/post_spec.rb +64 -0
- data/spec/kiita/tag_spec.rb +26 -0
- data/spec/kiita/user_spec.rb +63 -0
- data/spec/kiita_spec.rb +13 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/api_responses/auth.json +4 -0
- data/spec/support/api_responses/search.json +37 -0
- data/spec/support/api_responses/user.json +17 -0
- data/spec/support/api_responses/user_stocks.json +38 -0
- data/spec/support/vcr.rb +22 -0
- metadata +183 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kiita::Tag do
|
4
|
+
describe "initialization" do
|
5
|
+
context "with attributes" do
|
6
|
+
let(:valid_attr) do
|
7
|
+
{
|
8
|
+
"name" => "c#",
|
9
|
+
"url_name" => "C%23",
|
10
|
+
"icon_url" => "http://qiita.com/system/tags/icons/000/000/187/medium/C_Sharp.png",
|
11
|
+
"item_count" => 94,
|
12
|
+
"follower_count" => 183,
|
13
|
+
"following" => false
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
subject { Kiita::Tag.new(valid_attr) }
|
18
|
+
its(:name) { should == "c#" }
|
19
|
+
its(:url_name) { should == "C%23" }
|
20
|
+
its(:icon_url) { should == "http://qiita.com/system/tags/icons/000/000/187/medium/C_Sharp.png" }
|
21
|
+
its(:item_count) { should == 94 }
|
22
|
+
its(:follower_count){ should == 183 }
|
23
|
+
its(:following) { should == false }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Kiita::User do
|
5
|
+
use_vcr_cassette "qiita/user_api", record: :new_episodes
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
context "with valid attrs" do
|
9
|
+
let(:valid_attrs) do
|
10
|
+
{
|
11
|
+
"url_name" => "yaotti",
|
12
|
+
"profile_image_url" => "https://si0.twimg.com/profile_images/1476972552/face_normal.jpeg",
|
13
|
+
"url" => "http://qiita.com/users/yaotti",
|
14
|
+
"description" => "Qiita(Ruby on Rails)やKobito(Macアプリ)の開発をしています.\r\n",
|
15
|
+
"website_url" => "http://yaotti.hatenablog.com",
|
16
|
+
"organization" => "Increments Inc",
|
17
|
+
"location" => "Tokyo, Japan",
|
18
|
+
"facebook" => "yaotti",
|
19
|
+
"linkedin" => "yaotti",
|
20
|
+
"twitter" => "yaotti",
|
21
|
+
"github" => "yaotti",
|
22
|
+
"followers" => 187,
|
23
|
+
"following_users" => 129,
|
24
|
+
"items" => 102
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
subject { Kiita::User.new(valid_attrs) }
|
29
|
+
its(:url_name) { should == "yaotti" }
|
30
|
+
its(:profile_image_url){ should == "https://si0.twimg.com/profile_images/1476972552/face_normal.jpeg" }
|
31
|
+
its(:url) { should == "http://qiita.com/users/yaotti" }
|
32
|
+
its(:description) { should == "Qiita(Ruby on Rails)やKobito(Macアプリ)の開発をしています.\r\n" }
|
33
|
+
its(:website_url) { should == "http://yaotti.hatenablog.com" }
|
34
|
+
its(:organization) { should == "Increments Inc" }
|
35
|
+
its(:location) { should == "Tokyo, Japan" }
|
36
|
+
its(:facebook) { should == "yaotti" }
|
37
|
+
its(:linkedin) { should == "yaotti" }
|
38
|
+
its(:twitter) { should == "yaotti" }
|
39
|
+
its(:github) { should == "yaotti" }
|
40
|
+
its(:followers) { should == 187 }
|
41
|
+
its(:following_users) { should == 129 }
|
42
|
+
its(:items) { should == 102 }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#find" do
|
47
|
+
subject { Kiita::User.find("yaotti") }
|
48
|
+
its(:url_name) { should == "yaotti" }
|
49
|
+
its(:profile_image_url){ should == "https://si0.twimg.com/profile_images/1476972552/face_normal.jpeg" }
|
50
|
+
its(:url) { should == "http://qiita.com/users/yaotti" }
|
51
|
+
its(:description) { should == "Qiita(Ruby on Rails)やKobito(Macアプリ)の開発をしています.\r\n" }
|
52
|
+
its(:website_url) { should == "http://yaotti.hatenablog.com" }
|
53
|
+
its(:organization) { should == "Increments Inc" }
|
54
|
+
its(:location) { should == "Tokyo, Japan" }
|
55
|
+
its(:facebook) { should == "yaotti" }
|
56
|
+
its(:linkedin) { should == "yaotti" }
|
57
|
+
its(:twitter) { should == "yaotti" }
|
58
|
+
its(:github) { should == "yaotti" }
|
59
|
+
its(:followers) { should be_a Fixnum }
|
60
|
+
its(:following_users) { should be_a Fixnum }
|
61
|
+
its(:items) { should be_a Fixnum }
|
62
|
+
end
|
63
|
+
end
|
data/spec/kiita_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kiita do
|
4
|
+
its(:timeout) { should == 30 }
|
5
|
+
its(:keep_alive) { should == 0 }
|
6
|
+
|
7
|
+
describe "#connection" do
|
8
|
+
subject { Kiita.connection }
|
9
|
+
it { should be_a HTTPClient }
|
10
|
+
#its(:connect_timeout) { should == 60 }
|
11
|
+
#its(:keep_alive_timeout){ should == 15 }
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
Bundler.require
|
8
|
+
|
9
|
+
# Requires supporting files with custom matchers and macros, etc,
|
10
|
+
# in ./support/ and its subdirectories.
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
require 'webmock/rspec'
|
15
|
+
|
16
|
+
config.mock_with :rspec
|
17
|
+
config.extend VCR::RSpec::Macros
|
18
|
+
config.extend VCR::RSpec::MacrosExtention
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id":6260,
|
4
|
+
"uuid":"1fb6b57eea034e6fdaa9",
|
5
|
+
"user": {
|
6
|
+
"name":"\u306a\u304a\u3066\u3043\u30fc",
|
7
|
+
"url_name":"naoty_k",
|
8
|
+
"profile_image_url":"https://si0.twimg.com/profile_images/2348083286/69pb9bhzdziawoadnfs5_normal.jpeg",
|
9
|
+
"following":false
|
10
|
+
},
|
11
|
+
"title":"I'm a title.",
|
12
|
+
"body":"I'm a content.",
|
13
|
+
"created_at":"2012-06-17 11:55:50 +0900",
|
14
|
+
"updated_at":"2012-06-17 11:55:50 +0900",
|
15
|
+
"created_at_in_words":"4\u30f6\u6708\u524d",
|
16
|
+
"updated_at_in_words":"4\u30f6\u6708\u524d",
|
17
|
+
"tags": [
|
18
|
+
{
|
19
|
+
"name":"Ruby",
|
20
|
+
"url_name":"Ruby",
|
21
|
+
"icon_url":"http://qiita.com/system/tags/icons/000/000/003/thumb/ruby.jpeg?1316130908",
|
22
|
+
"item_count":780,
|
23
|
+
"follower_count":2712,
|
24
|
+
"following":true,
|
25
|
+
"versions":[]
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"stock_count":6,
|
29
|
+
"stock_users": ["Takutakku", "houryu", "sys_cat", "T_Hash", "yaotti", "yuki24"],
|
30
|
+
"comment_count":0,
|
31
|
+
"url":"http://qiita.com/items/1fb6b57eea034e6fdaa9",
|
32
|
+
"gist_url":null,
|
33
|
+
"private":false,
|
34
|
+
"created_at_as_seconds":1339901750,
|
35
|
+
"stocked":true
|
36
|
+
}
|
37
|
+
]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name":"Test User",
|
3
|
+
"url_name":"testuser",
|
4
|
+
"profile_image_url":"https://secure.gravatar.com/avatar/bcd6fc0618a420ba3d59fe5bfaf2b323?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
|
5
|
+
"url":"http://qiita.com/users/testuser",
|
6
|
+
"description":"",
|
7
|
+
"website_url":null,
|
8
|
+
"organization":null,
|
9
|
+
"location":null,
|
10
|
+
"facebook":null,
|
11
|
+
"linkedin":null,
|
12
|
+
"twitter":"testuser",
|
13
|
+
"github":"testuser",
|
14
|
+
"followers":256,
|
15
|
+
"following_users":64,
|
16
|
+
"items":16
|
17
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id":8922,
|
4
|
+
"uuid":"41af818b76145b255ea7",
|
5
|
+
"user": {
|
6
|
+
"name":"quwa",
|
7
|
+
"url_name":"quwa",
|
8
|
+
"profile_image_url":"https://si0.twimg.com/profile_images/1234132944/me_left_normal.png",
|
9
|
+
"following":false
|
10
|
+
},
|
11
|
+
"title":"I'm a title.",
|
12
|
+
"body":"I'm a content.",
|
13
|
+
"created_at":"2012-09-07 15:25:51 +0900",
|
14
|
+
"updated_at":"2012-09-07 15:25:51 +0900",
|
15
|
+
"created_at_in_words":"1\u30f6\u6708\u524d",
|
16
|
+
"updated_at_in_words":"1\u30f6\u6708\u524d",
|
17
|
+
"tags": [
|
18
|
+
{
|
19
|
+
"name":"Emacs",
|
20
|
+
"url_name":"Emacs",
|
21
|
+
"icon_url":"http://qiita.com/system/tags/icons/000/000/007/thumb/emacs.jpeg?1316130821",
|
22
|
+
"item_count":182,
|
23
|
+
"follower_count":1169,
|
24
|
+
"following":true,
|
25
|
+
"versions": [
|
26
|
+
]
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"stock_count":1,
|
30
|
+
"stock_users":["yuki24"],
|
31
|
+
"comment_count":0,
|
32
|
+
"url":"http://qiita.com/items/41af818b76145b255ea7",
|
33
|
+
"gist_url":null,
|
34
|
+
"private":false,
|
35
|
+
"created_at_as_seconds":1346999151,
|
36
|
+
"stocked":true
|
37
|
+
}
|
38
|
+
]
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'webmock'
|
3
|
+
|
4
|
+
VCR.configure do |c|
|
5
|
+
c.cassette_library_dir = 'tmp/cassettes'
|
6
|
+
c.hook_into :webmock
|
7
|
+
end
|
8
|
+
|
9
|
+
module VCR::RSpec::MacrosExtention
|
10
|
+
# automatically record all remote calls with RSpec
|
11
|
+
def cache_http_calls
|
12
|
+
around(:each) do |example|
|
13
|
+
options = example.metadata[:vcr] || {}
|
14
|
+
if options[:record] == :skip
|
15
|
+
VCR.turned_off(&example)
|
16
|
+
else
|
17
|
+
name = example.metadata[:full_description].split(/\s+/, 2).join("/").underscore.gsub(/[^\w\/]+/, "_")
|
18
|
+
VCR.use_cassette(name, options, &example)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kiita
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yuki Nishijima
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httpclient
|
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: oj
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activesupport
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.0.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: vcr
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: webmock
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Kiita is yet another Qiita API wrapper.
|
111
|
+
email:
|
112
|
+
- mail@yukinishijima.net
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- .rvmrc
|
120
|
+
- .simplecov
|
121
|
+
- .travis.yml
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.md
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- kiita.gemspec
|
127
|
+
- lib/kiita.rb
|
128
|
+
- lib/kiita/api.rb
|
129
|
+
- lib/kiita/errors.rb
|
130
|
+
- lib/kiita/model.rb
|
131
|
+
- lib/kiita/post.rb
|
132
|
+
- lib/kiita/tag.rb
|
133
|
+
- lib/kiita/user.rb
|
134
|
+
- lib/kiita/version.rb
|
135
|
+
- spec/kiita/api_spec.rb
|
136
|
+
- spec/kiita/errors_spec.rb
|
137
|
+
- spec/kiita/post_spec.rb
|
138
|
+
- spec/kiita/tag_spec.rb
|
139
|
+
- spec/kiita/user_spec.rb
|
140
|
+
- spec/kiita_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/support/api_responses/auth.json
|
143
|
+
- spec/support/api_responses/search.json
|
144
|
+
- spec/support/api_responses/user.json
|
145
|
+
- spec/support/api_responses/user_stocks.json
|
146
|
+
- spec/support/vcr.rb
|
147
|
+
homepage: https://github.com/yuki24/kiita
|
148
|
+
licenses: []
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 1.8.24
|
168
|
+
signing_key:
|
169
|
+
specification_version: 3
|
170
|
+
summary: Yet Another Qiita API Wrapper
|
171
|
+
test_files:
|
172
|
+
- spec/kiita/api_spec.rb
|
173
|
+
- spec/kiita/errors_spec.rb
|
174
|
+
- spec/kiita/post_spec.rb
|
175
|
+
- spec/kiita/tag_spec.rb
|
176
|
+
- spec/kiita/user_spec.rb
|
177
|
+
- spec/kiita_spec.rb
|
178
|
+
- spec/spec_helper.rb
|
179
|
+
- spec/support/api_responses/auth.json
|
180
|
+
- spec/support/api_responses/search.json
|
181
|
+
- spec/support/api_responses/user.json
|
182
|
+
- spec/support/api_responses/user_stocks.json
|
183
|
+
- spec/support/vcr.rb
|