kippt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/README.md +3 -1
- data/lib/core_ext/open_struct.rb +5 -0
- data/lib/kippt.rb +1 -0
- data/lib/kippt/collection_resource.rb +3 -3
- data/lib/kippt/connection.rb +12 -1
- data/lib/kippt/version.rb +1 -1
- data/spec/kippt/client_spec.rb +2 -2
- data/spec/kippt/clip_collection_spec.rb +1 -2
- data/spec/kippt/clip_spec.rb +1 -2
- data/spec/kippt/clips_spec.rb +1 -1
- data/spec/kippt/list_collection_spec.rb +1 -2
- data/spec/kippt/list_spec.rb +1 -2
- data/spec/spec_helper.rb +4 -4
- metadata +102 -78
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Kippt
|
2
2
|
|
3
|
-
Kippt is a gem that provides a client library for using Kippt.com API.
|
3
|
+
Kippt is a gem that provides a client library for using [Kippt.com API](https://kippt.com/developers/).
|
4
|
+
|
5
|
+
[![Build Status](https://secure.travis-ci.org/vesan/kippt.png)](http://travis-ci.org/vesan/kippt)
|
4
6
|
|
5
7
|
|
6
8
|
## Installation
|
data/lib/kippt.rb
CHANGED
@@ -19,12 +19,12 @@ module Kippt::CollectionResource
|
|
19
19
|
|
20
20
|
def save_resource(object)
|
21
21
|
if object.id
|
22
|
-
response = @client.put("#{base_uri}/#{object.id}", data
|
22
|
+
response = @client.put("#{base_uri}/#{object.id}", :data => writable_parameters_from(object))
|
23
23
|
else
|
24
|
-
response = @client.post("#{base_uri}", data
|
24
|
+
response = @client.post("#{base_uri}", :data => writable_parameters_from(object))
|
25
25
|
end
|
26
26
|
|
27
|
-
save_response = {success
|
27
|
+
save_response = {:success => response.success?}
|
28
28
|
if response.body["message"]
|
29
29
|
save_response[:error_message] = response.body["message"]
|
30
30
|
end
|
data/lib/kippt/connection.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require "multi_json"
|
2
|
+
require "faraday_middleware/response_middleware"
|
2
3
|
|
3
4
|
module Kippt::Connection
|
5
|
+
class ParseMultiJson < FaradayMiddleware::ResponseMiddleware
|
6
|
+
define_parser do |body|
|
7
|
+
begin
|
8
|
+
MultiJson.load(body) unless body.strip.empty?
|
9
|
+
rescue MultiJson::DecodeError
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
def get(url, options = {})
|
5
16
|
request(:get, url, options)
|
6
17
|
end
|
@@ -21,7 +32,7 @@ module Kippt::Connection
|
|
21
32
|
|
22
33
|
def connection
|
23
34
|
@connection ||= Faraday.new("https://kippt.com/api") do |builder|
|
24
|
-
builder.use
|
35
|
+
builder.use Kippt::Connection::ParseMultiJson
|
25
36
|
# builder.use Faraday::Response::Logger
|
26
37
|
builder.adapter Faraday.default_adapter
|
27
38
|
end
|
data/lib/kippt/version.rb
CHANGED
data/spec/kippt/client_spec.rb
CHANGED
@@ -13,12 +13,12 @@ describe Kippt::Client do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "connection" do
|
16
|
-
subject { Kippt::Client.new(username
|
16
|
+
subject { Kippt::Client.new(:username => "bob", :password => "secret") }
|
17
17
|
|
18
18
|
describe "default headers" do
|
19
19
|
it "includes correct mime-type and user-agent" do
|
20
20
|
stub_request(:get, "https://bob:secret@kippt.com/foobar").
|
21
|
-
with(:headers => {'Accept'=>'*/*', '
|
21
|
+
with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/vnd.kippt.20120429+json', 'User-Agent'=>"KipptRubyGem #{Kippt::VERSION},vesa@vesavanska.com,https://github.com/vesan/kippt", 'X-Kippt-Client'=>"KipptRubyGem #{Kippt::VERSION},vesa@vesavanska.com,https://github.com/vesan/kippt"})
|
22
22
|
subject.get("/foobar")
|
23
23
|
end
|
24
24
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "crack/json"
|
3
2
|
require "kippt/clip_collection"
|
4
3
|
|
5
4
|
describe Kippt::ClipCollection do
|
6
|
-
let(:data) {
|
5
|
+
let(:data) { MultiJson.load(fixture("clips.json").read) }
|
7
6
|
subject { Kippt::ClipCollection.new(data) }
|
8
7
|
|
9
8
|
it_behaves_like "collection"
|
data/spec/kippt/clip_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "crack/json"
|
3
2
|
require "kippt/clip"
|
4
3
|
|
5
4
|
describe Kippt::Clip do
|
6
5
|
subject { Kippt::Clip.new(data, collection_resource) }
|
7
6
|
let(:collection_resource) { Kippt::Client.new(valid_user_credentials).clips }
|
8
7
|
|
9
|
-
let(:data) {
|
8
|
+
let(:data) { MultiJson.load(fixture("clip.json").read) }
|
10
9
|
let(:attributes) {
|
11
10
|
[:url_domain, :updated, :is_starred, :title,
|
12
11
|
:url, :notes, :created, :list, :id, :resource_uri]
|
data/spec/kippt/clips_spec.rb
CHANGED
@@ -94,7 +94,7 @@ describe Kippt::Clips do
|
|
94
94
|
stub_request(:delete, "https://kippt.com/api/clips/100").
|
95
95
|
to_return(:status => 200, :headers => {})
|
96
96
|
|
97
|
-
clip = Kippt::Clip.new(id
|
97
|
+
clip = Kippt::Clip.new(:id => 100)
|
98
98
|
subject.destroy_resource(clip).should be_true
|
99
99
|
end
|
100
100
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "crack/json"
|
3
2
|
|
4
3
|
describe Kippt::ListCollection do
|
5
|
-
let(:data) {
|
4
|
+
let(:data) { MultiJson.load(fixture("lists.json").read) }
|
6
5
|
subject { Kippt::ListCollection.new(data) }
|
7
6
|
|
8
7
|
it_behaves_like "collection"
|
data/spec/kippt/list_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "crack/json"
|
3
2
|
require "kippt/list"
|
4
3
|
|
5
4
|
describe Kippt::List do
|
6
5
|
subject { Kippt::List.new(data, collection_resource) }
|
7
6
|
let(:collection_resource) { Kippt::Client.new(valid_user_credentials).lists }
|
8
7
|
|
9
|
-
let(:data) {
|
8
|
+
let(:data) { MultiJson.load(fixture("list.json").read) }
|
10
9
|
let(:attributes) {
|
11
10
|
[:id, :rss_url, :updated, :title,
|
12
11
|
:created, :slug, :resource_uri]
|
data/spec/spec_helper.rb
CHANGED
@@ -98,8 +98,8 @@ shared_examples_for "resource" do
|
|
98
98
|
describe "attribute accessors" do
|
99
99
|
it "delegates to attributes" do
|
100
100
|
attributes.each do |attribute_name|
|
101
|
-
|
102
|
-
|
101
|
+
subject.send(attribute_name).should eq data[attribute_name.to_s]
|
102
|
+
end
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -112,14 +112,14 @@ shared_examples_for "resource" do
|
|
112
112
|
|
113
113
|
it "returns true" do
|
114
114
|
collection_resource.stub(:save_resource).and_return(
|
115
|
-
{success
|
115
|
+
{:success => true})
|
116
116
|
subject.save.should be_true
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context "with invalid parameters" do
|
121
121
|
before do
|
122
|
-
collection_resource.stub(:save_resource).and_return({success
|
122
|
+
collection_resource.stub(:save_resource).and_return({:success => false, :error_message => "No url."})
|
123
123
|
end
|
124
124
|
|
125
125
|
it "sets an error messages" do
|
metadata
CHANGED
@@ -1,110 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kippt
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
12
|
+
authors:
|
13
|
+
- !binary |
|
14
|
+
VmVzYSBWw6Ruc2vDpA==
|
15
|
+
|
9
16
|
autorequire:
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
|
20
|
+
date: 2012-04-29 00:00:00 +03:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
15
24
|
name: faraday
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.7.6
|
22
|
-
type: :runtime
|
23
25
|
prerelease: false
|
24
|
-
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
27
|
none: false
|
26
|
-
requirements:
|
28
|
+
requirements:
|
27
29
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 15
|
32
|
+
segments:
|
33
|
+
- 0
|
34
|
+
- 7
|
35
|
+
- 6
|
29
36
|
version: 0.7.6
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: faraday_middleware
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.8.7
|
38
37
|
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: faraday_middleware
|
39
41
|
prerelease: false
|
40
|
-
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
43
|
none: false
|
42
|
-
requirements:
|
44
|
+
requirements:
|
43
45
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 49
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
- 8
|
51
|
+
- 7
|
45
52
|
version: 0.8.7
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: multi_json
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 1.3.4
|
54
53
|
type: :runtime
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: multi_json
|
55
57
|
prerelease: false
|
56
|
-
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
59
|
none: false
|
58
|
-
requirements:
|
60
|
+
requirements:
|
59
61
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 19
|
64
|
+
segments:
|
65
|
+
- 1
|
66
|
+
- 3
|
67
|
+
- 4
|
61
68
|
version: 1.3.4
|
62
|
-
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id003
|
71
|
+
- !ruby/object:Gem::Dependency
|
63
72
|
name: rspec
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 2.9.0
|
70
|
-
type: :development
|
71
73
|
prerelease: false
|
72
|
-
|
74
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
75
|
none: false
|
74
|
-
requirements:
|
76
|
+
requirements:
|
75
77
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 43
|
80
|
+
segments:
|
81
|
+
- 2
|
82
|
+
- 9
|
83
|
+
- 0
|
77
84
|
version: 2.9.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: webmock
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.8.6
|
86
85
|
type: :development
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: webmock
|
87
89
|
prerelease: false
|
88
|
-
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
91
|
none: false
|
90
|
-
requirements:
|
92
|
+
requirements:
|
91
93
|
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 59
|
96
|
+
segments:
|
97
|
+
- 1
|
98
|
+
- 8
|
99
|
+
- 6
|
93
100
|
version: 1.8.6
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id005
|
94
103
|
description: Client library for using Kippt.com API
|
95
|
-
email:
|
104
|
+
email:
|
96
105
|
- vesa@vesavanska.com
|
97
106
|
executables: []
|
107
|
+
|
98
108
|
extensions: []
|
109
|
+
|
99
110
|
extra_rdoc_files: []
|
100
|
-
|
111
|
+
|
112
|
+
files:
|
101
113
|
- .gitignore
|
102
114
|
- .rspec
|
115
|
+
- .travis.yml
|
103
116
|
- Gemfile
|
104
117
|
- LICENSE
|
105
118
|
- README.md
|
106
119
|
- Rakefile
|
107
120
|
- kippt.gemspec
|
121
|
+
- lib/core_ext/open_struct.rb
|
108
122
|
- lib/kippt.rb
|
109
123
|
- lib/kippt/account.rb
|
110
124
|
- lib/kippt/client.rb
|
@@ -132,31 +146,41 @@ files:
|
|
132
146
|
- spec/kippt/list_spec.rb
|
133
147
|
- spec/kippt/lists_spec.rb
|
134
148
|
- spec/spec_helper.rb
|
149
|
+
has_rdoc: true
|
135
150
|
homepage: https://github.com/vesan/kippt
|
136
151
|
licenses: []
|
152
|
+
|
137
153
|
post_install_message:
|
138
154
|
rdoc_options: []
|
139
|
-
|
155
|
+
|
156
|
+
require_paths:
|
140
157
|
- lib
|
141
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
159
|
none: false
|
143
|
-
requirements:
|
144
|
-
- -
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
|
147
|
-
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 3
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
version: "0"
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
168
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 3
|
173
|
+
segments:
|
174
|
+
- 0
|
175
|
+
version: "0"
|
153
176
|
requirements: []
|
177
|
+
|
154
178
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
179
|
+
rubygems_version: 1.3.7
|
156
180
|
signing_key:
|
157
181
|
specification_version: 3
|
158
182
|
summary: Client library for using Kippt.com API
|
159
|
-
test_files:
|
183
|
+
test_files:
|
160
184
|
- spec/fixtures/clip.json
|
161
185
|
- spec/fixtures/clips.json
|
162
186
|
- spec/fixtures/list.json
|