kiita 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,3 +3,5 @@ script: "bundle exec rspec spec/"
3
3
  rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - ruby-2.0.0-preview2
7
+ - ruby-head
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in kiita.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'oj'
6
7
  gem 'pry'
7
8
  gem 'simplecov'
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency 'httpclient'
21
- gem.add_dependency 'oj'
21
+ gem.add_dependency 'multi_json'
22
22
  gem.add_dependency 'activesupport', '>= 3.0.0'
23
23
 
24
24
  gem.add_development_dependency 'rspec'
@@ -112,7 +112,7 @@ module Kiita
112
112
 
113
113
  def self.handle_response(response)
114
114
  on_complete(response)
115
- Oj.load(response.body.empty? ? "null" : response.body)
115
+ MultiJson.load(response.body.empty? ? "null" : response.body)
116
116
  end
117
117
  end
118
118
  end
@@ -1,10 +1,12 @@
1
1
  module Kiita
2
- class Error < StandardError; end
3
- class BadRequest < Error; end # 400
4
- class Unauthorized < Error; end # 401
5
- class Forbidden < Error; end # 403
6
- class NotFound < Error; end # 404
7
- class InternalServerError < Error; end # 500
2
+ class Exception < StandardError; end
3
+ class InternalServerError < Exception; end # 500
4
+
5
+ class Error < Exception; end
6
+ class BadRequest < Error; end # 400
7
+ class Unauthorized < Error; end # 401
8
+ class Forbidden < Error; end # 403
9
+ class NotFound < Error; end # 404
8
10
 
9
11
  module Errors
10
12
  module HandlerMethods
@@ -34,7 +36,7 @@ module Kiita
34
36
  if response.body.empty?
35
37
  "#{response.http_header.request_method} #{response.http_header.request_uri.to_s}: #{response.status}"
36
38
  else
37
- Oj.load(response.body)["error"]
39
+ MultiJson.load(response.body)["error"]
38
40
  end
39
41
  end
40
42
  private :error_message
@@ -1,3 +1,3 @@
1
1
  module Kiita
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -2,7 +2,9 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Kiita::Post do
5
- use_vcr_cassette "qiita/item_api", record: :new_episodes
5
+ def qiita_api_response(path)
6
+ File.new("#{File.dirname(__FILE__)}/../support/api_responses/#{path}")
7
+ end
6
8
 
7
9
  describe "initialization" do
8
10
  context "with valid attrs" do
@@ -44,6 +46,8 @@ describe Kiita::Post do
44
46
  end
45
47
 
46
48
  describe "#find" do
49
+ before { stub_request(:get, /^https:\/\/qiita.com/).to_return(body: qiita_api_response("get_item.json")) }
50
+
47
51
  subject { Kiita::Post.find("2e6258b7c6a5b13b7d16") }
48
52
 
49
53
  its(:id) { should == 1408 }
@@ -2,7 +2,9 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Kiita::User do
5
- use_vcr_cassette "qiita/user_api", record: :new_episodes
5
+ def qiita_api_response(path)
6
+ File.new("#{File.dirname(__FILE__)}/../support/api_responses/#{path}")
7
+ end
6
8
 
7
9
  describe "initialization" do
8
10
  context "with valid attrs" do
@@ -44,7 +46,10 @@ describe Kiita::User do
44
46
  end
45
47
 
46
48
  describe "#find" do
49
+ before { stub_request(:get, /^https:\/\/qiita.com/).to_return(body: qiita_api_response("get_user.json")) }
50
+
47
51
  subject { Kiita::User.find("yaotti") }
52
+
48
53
  its(:url_name) { should == "yaotti" }
49
54
  its(:profile_image_url){ should == "https://si0.twimg.com/profile_images/1476972552/face_normal.jpeg" }
50
55
  its(:url) { should == "http://qiita.com/users/yaotti" }
@@ -0,0 +1,85 @@
1
+ {
2
+ "id":1408,
3
+ "uuid":"2e6258b7c6a5b13b7d16",
4
+ "user": {
5
+ "name":"Yuki Nishijima",
6
+ "url_name":"yuki24",
7
+ "profile_image_url":"https://secure.gravatar.com/avatar/bcd6fc0618a420ba3d59fe5bfaf2b323?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"
8
+ },
9
+ "title":"\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b gem \u3092\u5168\u3066\u524a\u9664\u3059\u308b\u3002",
10
+ "body":"<ol>\n<li><code>gemlist</code> \u3067\u30ea\u30b9\u30c8\u3092\u8868\u793a\u3057\u3001</li>\n<li><code>cut-d&quot; &quot; -f1</code> \u3067\u540d\u524d\u3092\u62bd\u51fa\u3057\u3001</li>\n<li>\u305d\u308c\u3092<code>gem uninstall</code> \u306b\u6295\u3052\u308b\u3002</li>\n</ol>\n\n<p>\u3092\u4e0b\u8a18\u3067\u5b9f\u884c\u3067\u304d\u308b\u3002</p>\n<divclass=\"code-frame\"><div class=\"highlight\"><pre><span class=\"n\">gem</span><span class=\"n\">list</span> <span class=\"o\">|</span> <span class=\"n\">cut</span><span class=\"o\">-</span><span class=\"n\">d</span>&quot; &quot; <span class=\"o\">-</span><spanclass=\"n\">f1</span> <span class=\"o\">|</span> <span class=\"n\">xargs</span><span class=\"n\">gem</span> <span class=\"n\">uninstall</span> <span class=\"o\">-</span><spanclass=\"n\">aIx</span>\n</pre>\n</div>\n</div>",
11
+ "created_at":"2011-12-19 00:04:14 +0900",
12
+ "updated_at":"2012-03-16 11:30:26 +0900",
13
+ "created_at_in_words":"10\u30f6\u6708\u524d",
14
+ "updated_at_in_words":"7\u30f6\u6708\u524d",
15
+ "tags": [
16
+ {
17
+ "name":"Ruby",
18
+ "url_name":"Ruby",
19
+ "icon_url":"http://qiita.com/system/tags/icons/000/000/003/thumb/ruby.jpeg?1316130908",
20
+ "item_count":782,
21
+ "follower_count":2714,
22
+ "versions":[]
23
+ },
24
+ {
25
+ "name":"Gems",
26
+ "url_name":"Gems",
27
+ "icon_url":"http://qiita.com/icons/thumb/missing.png",
28
+ "item_count":6,
29
+ "follower_count":0,
30
+ "versions":[]
31
+ },
32
+ {
33
+ "name":"Rails",
34
+ "url_name":"Rails",
35
+ "icon_url":"http://qiita.com/system/tags/icons/000/000/034/thumb/Ruby_on_Rails_logo.jpeg?1320170723",
36
+ "item_count":453,
37
+ "follower_count":432,
38
+ "versions":[]
39
+ }
40
+ ],
41
+ "stock_count":13,
42
+ "stock_users": [
43
+ "amazedkoumei@github",
44
+ "pisolino_jp",
45
+ "inouetakuya",
46
+ "naoty_k",
47
+ "arexsam",
48
+ "tkg24",
49
+ "kysnm",
50
+ "bris@github",
51
+ "cou_z",
52
+ "yusuke_1031",
53
+ "yang8",
54
+ "mdaisuke",
55
+ "yaotti"
56
+ ],
57
+ "comment_count":2,
58
+ "url":"http://qiita.com/items/2e6258b7c6a5b13b7d16",
59
+ "gist_url":null,
60
+ "private":false,
61
+ "created_at_as_seconds":1324220654,
62
+ "raw_body":"1.`gem list` \u3067\u30ea\u30b9\u30c8\u3092\u8868\u793a\u3057\u3001\n2. `cut-d\" \" -f1` \u3067\u540d\u524d\u3092\u62bd\u51fa\u3057\u3001\n3. \u305d\u308c\u3092`gem uninstall` \u306b\u6295\u3052\u308b\u3002\n\n\u3092\u4e0b\u8a18\u3067\u5b9f\u884c\u3067\u304d\u308b\u3002\n\n```\ngemlist | cut -d\" \" -f1 | xargs gem uninstall -aIx\n```",
63
+ "comments": [
64
+ {
65
+ "id":471,
66
+ "uuid":"31c6572311d6304346b8",
67
+ "user": {
68
+ "name":"\u4f50\u5009\u674f\u5b50",
69
+ "url_name":"aereal",
70
+ "profile_image_url":"https://si0.twimg.com/profile_images/1796360201/a8b842d3448ded45259dd74d452c5972_normal.png"
71
+ },
72
+ "body":"<p>gemuni $(gem li --no-versions)</p>\n\n<p>\u3067\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306d\u3002<br>\ngemlist\u306f\u51fa\u529b\u5148\u304cSTDOUT\u3060\u3068 &quot;*** LOCAL GEMS***&quot; \u3068\u304b\u51fa\u529b\u3055\u308c\u307e\u3059\u304c\u3001\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u3066\u3044\u308b\u3068\u51fa\u529b\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u3061\u3083\u3093\u3068gem\u306e\u540d\u524d\u3060\u3051\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002</p>\n"
73
+ },
74
+ {
75
+ "id":504,
76
+ "uuid":"934de2ca98f9601065cd",
77
+ "user": {
78
+ "name":"YukiNishijima",
79
+ "url_name":"yuki24",
80
+ "profile_image_url":"https://secure.gravatar.com/avatar/bcd6fc0618a420ba3d59fe5bfaf2b323?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"
81
+ },
82
+ "body":"<p>\u304a\u3049\u3001\u3053\u308c\u306f\u30b7\u30f3\u30d7\u30eb\uff01\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01</p>\n"
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "Name": "\u3084\u304a\u3063\u3061/Hiroshige Umino",
3
+ "url_name": "yaotti",
4
+ "profile_image_url": "https://si0.twimg.com/profile_images/1476972552/face_normal.jpeg",
5
+ "url": "http://qiita.com/users/yaotti",
6
+ "description": "Qiita(Ruby on Rails)\u3084Kobito(Mac\u30a2\u30d7\u30ea)\u306e\u958b\u767a\u3092\u3057\u3066\u3044\u307e\u3059\uff0e\r\n",
7
+ "website_url": "http://yaotti.hatenablog.com",
8
+ "organization": "Increments Inc",
9
+ "location": "Tokyo, Japan",
10
+ "facebook": "yaotti",
11
+ "linkedin": "yaotti",
12
+ "twitter": "yaotti",
13
+ "github": "yaotti",
14
+ "followers": 187,
15
+ "following_users": 129,
16
+ "items": 102
17
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiita
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: oj
31
+ name: multi_json
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -140,6 +140,8 @@ files:
140
140
  - spec/kiita_spec.rb
141
141
  - spec/spec_helper.rb
142
142
  - spec/support/api_responses/auth.json
143
+ - spec/support/api_responses/get_item.json
144
+ - spec/support/api_responses/get_user.json
143
145
  - spec/support/api_responses/search.json
144
146
  - spec/support/api_responses/user.json
145
147
  - spec/support/api_responses/user_stocks.json
@@ -177,6 +179,8 @@ test_files:
177
179
  - spec/kiita_spec.rb
178
180
  - spec/spec_helper.rb
179
181
  - spec/support/api_responses/auth.json
182
+ - spec/support/api_responses/get_item.json
183
+ - spec/support/api_responses/get_user.json
180
184
  - spec/support/api_responses/search.json
181
185
  - spec/support/api_responses/user.json
182
186
  - spec/support/api_responses/user_stocks.json