kippt 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -0
- data/README.md +20 -3
- data/TODO.md +43 -0
- data/kippt.gemspec +6 -6
- data/lib/kippt/client.rb +46 -8
- data/lib/kippt/clip.rb +83 -4
- data/lib/kippt/clip_collection.rb +4 -0
- data/lib/kippt/clips.rb +8 -4
- data/lib/kippt/collection.rb +22 -9
- data/lib/kippt/collection_resource.rb +25 -8
- data/lib/kippt/comment.rb +25 -0
- data/lib/kippt/comment_collection.rb +10 -0
- data/lib/kippt/comments.rb +43 -0
- data/lib/kippt/connection.rb +14 -8
- data/lib/kippt/follow_relationship.rb +50 -0
- data/lib/kippt/followers.rb +26 -0
- data/lib/kippt/following.rb +26 -0
- data/lib/kippt/like.rb +48 -0
- data/lib/kippt/likes.rb +48 -0
- data/lib/kippt/list.rb +29 -4
- data/lib/kippt/list_collection.rb +4 -0
- data/lib/kippt/resource.rb +106 -9
- data/lib/kippt/saves.rb +25 -0
- data/lib/kippt/user.rb +59 -0
- data/lib/kippt/user_clips.rb +39 -0
- data/lib/kippt/user_collection.rb +14 -0
- data/lib/kippt/user_lists.rb +32 -0
- data/lib/kippt/users.rb +51 -0
- data/lib/kippt/version.rb +1 -1
- data/spec/fixtures/clip.json +1 -1
- data/spec/fixtures/comment.json +1 -0
- data/spec/fixtures/comments.json +1 -0
- data/spec/fixtures/feed.json +1 -0
- data/spec/fixtures/list.json +1 -1
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users.json +2 -0
- data/spec/fixtures/users_with_multiple_pages.json +1 -0
- data/spec/kippt/client_spec.rb +63 -8
- data/spec/kippt/clip_collection_spec.rb +3 -3
- data/spec/kippt/clip_spec.rb +109 -4
- data/spec/kippt/clips_spec.rb +18 -7
- data/spec/kippt/comment_spec.rb +25 -0
- data/spec/kippt/comments_spec.rb +103 -0
- data/spec/kippt/follow_relationship_spec.rb +34 -0
- data/spec/kippt/followers_spec.rb +17 -0
- data/spec/kippt/following_spec.rb +17 -0
- data/spec/kippt/list_collection_spec.rb +3 -3
- data/spec/kippt/list_spec.rb +92 -6
- data/spec/kippt/lists_spec.rb +2 -1
- data/spec/kippt/saves_spec.rb +20 -0
- data/spec/kippt/user_clips_spec.rb +29 -0
- data/spec/kippt/user_collection_spec.rb +14 -0
- data/spec/kippt/user_lists_spec.rb +13 -0
- data/spec/kippt/user_spec.rb +71 -0
- data/spec/kippt/users_spec.rb +59 -0
- data/spec/spec_helper.rb +60 -4
- metadata +106 -24
- data/lib/kippt/account.rb +0 -10
- data/spec/kippt/account_spec.rb +0 -28
data/lib/kippt/saves.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "kippt/user_collection"
|
2
|
+
require "kippt/user"
|
3
|
+
|
4
|
+
class Kippt::Saves
|
5
|
+
attr_reader :clip
|
6
|
+
|
7
|
+
def initialize(client, clip)
|
8
|
+
@client = client
|
9
|
+
@clip = clip
|
10
|
+
end
|
11
|
+
|
12
|
+
def collection_class
|
13
|
+
Kippt::UserCollection
|
14
|
+
end
|
15
|
+
|
16
|
+
def all(options = {})
|
17
|
+
collection_class.new({"objects" => @clip.saves_data}, client)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client
|
24
|
+
end
|
25
|
+
end
|
data/lib/kippt/user.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "kippt/users"
|
2
|
+
require "kippt/followers"
|
3
|
+
require "kippt/following"
|
4
|
+
require "kippt/follow_relationship"
|
5
|
+
require "kippt/user_clips"
|
6
|
+
require "kippt/user_lists"
|
7
|
+
|
8
|
+
class Kippt::User
|
9
|
+
include Kippt::Resource
|
10
|
+
|
11
|
+
attributes :username, :bio, :app_url, :avatar_url, :twitter,
|
12
|
+
:id, :github, :website_url, :full_name, :dribble,
|
13
|
+
:counts, :resource_uri, :api_token
|
14
|
+
|
15
|
+
boolean_attributes :is_pro
|
16
|
+
|
17
|
+
alias_method :token, :api_token
|
18
|
+
|
19
|
+
def collection_resource_class
|
20
|
+
Kippt::Users
|
21
|
+
end
|
22
|
+
|
23
|
+
def lists
|
24
|
+
Kippt::UserLists.new(client, self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def clips
|
28
|
+
Kippt::UserClips.new(client, self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def followers
|
32
|
+
Kippt::Followers.new(client, self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def following
|
36
|
+
Kippt::Following.new(client, self)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Tells if authenticated user is following the user.
|
40
|
+
def following?
|
41
|
+
Kippt::FollowRelationship.new(client, self).following?
|
42
|
+
end
|
43
|
+
|
44
|
+
def follower_count
|
45
|
+
counts["follows"]
|
46
|
+
end
|
47
|
+
|
48
|
+
def following_count
|
49
|
+
counts["followed_by"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def follow
|
53
|
+
Kippt::FollowRelationship.new(client, self).follow
|
54
|
+
end
|
55
|
+
|
56
|
+
def unfollow
|
57
|
+
Kippt::FollowRelationship.new(client, self).unfollow
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "kippt/connection"
|
2
|
+
require "kippt/collection_resource"
|
3
|
+
require "kippt/clip_collection"
|
4
|
+
require "kippt/clip"
|
5
|
+
|
6
|
+
class Kippt::UserClips
|
7
|
+
include Kippt::CollectionResource
|
8
|
+
|
9
|
+
attr_reader :user
|
10
|
+
|
11
|
+
def self.valid_filter_parameters
|
12
|
+
[:limit, :offset]
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(client, user)
|
16
|
+
@client = client
|
17
|
+
@user = user
|
18
|
+
end
|
19
|
+
|
20
|
+
def object_class
|
21
|
+
Kippt::Clip
|
22
|
+
end
|
23
|
+
|
24
|
+
def collection_class
|
25
|
+
Kippt::ClipCollection
|
26
|
+
end
|
27
|
+
|
28
|
+
def base_uri
|
29
|
+
"users/#{user.id}/clips"
|
30
|
+
end
|
31
|
+
|
32
|
+
def favorites
|
33
|
+
Kippt::ClipCollection.new(client.get("#{base_uri}/favorites").body, client)
|
34
|
+
end
|
35
|
+
|
36
|
+
def likes
|
37
|
+
Kippt::ClipCollection.new(client.get("#{base_uri}/likes").body, client)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "kippt/connection"
|
2
|
+
require "kippt/collection_resource"
|
3
|
+
require "kippt/list_collection"
|
4
|
+
require "kippt/list"
|
5
|
+
|
6
|
+
# Loads public lists for a user.
|
7
|
+
class Kippt::UserLists
|
8
|
+
include Kippt::CollectionResource
|
9
|
+
|
10
|
+
attr_reader :user
|
11
|
+
|
12
|
+
def self.valid_filter_parameters
|
13
|
+
[:limit, :offset]
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(client, user)
|
17
|
+
@client = client
|
18
|
+
@user = user
|
19
|
+
end
|
20
|
+
|
21
|
+
def object_class
|
22
|
+
Kippt::List
|
23
|
+
end
|
24
|
+
|
25
|
+
def collection_class
|
26
|
+
Kippt::ListCollection
|
27
|
+
end
|
28
|
+
|
29
|
+
def base_uri
|
30
|
+
"users/#{user.id}/lists"
|
31
|
+
end
|
32
|
+
end
|
data/lib/kippt/users.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "kippt/connection"
|
2
|
+
require "kippt/collection_resource"
|
3
|
+
require "kippt/user_collection"
|
4
|
+
require "kippt/user"
|
5
|
+
|
6
|
+
class Kippt::Users
|
7
|
+
include Kippt::CollectionResource
|
8
|
+
VALID_SEARCH_PARAMETERS = [:q]
|
9
|
+
|
10
|
+
def initialize(client)
|
11
|
+
@client = client
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.valid_filter_parameters
|
15
|
+
[:limit, :offset]
|
16
|
+
end
|
17
|
+
|
18
|
+
def object_class
|
19
|
+
Kippt::User
|
20
|
+
end
|
21
|
+
|
22
|
+
def collection_class
|
23
|
+
Kippt::UserCollection
|
24
|
+
end
|
25
|
+
|
26
|
+
def base_uri
|
27
|
+
"users"
|
28
|
+
end
|
29
|
+
|
30
|
+
def search(parameters)
|
31
|
+
if parameters.is_a?(String)
|
32
|
+
Kippt::UserCollection.new(
|
33
|
+
client.get("#{base_uri}/search", {:q => parameters}).body,
|
34
|
+
client)
|
35
|
+
else
|
36
|
+
validate_search_parameters(parameters)
|
37
|
+
|
38
|
+
Kippt::UserCollection.new(
|
39
|
+
client.get("#{base_uri}/search", parameters).body,
|
40
|
+
client)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def validate_search_parameters(parameters)
|
47
|
+
parameters.each do |key, value|
|
48
|
+
raise ArgumentError.new("'#{key}' is not a valid search parameter") unless VALID_SEARCH_PARAMETERS.include?(key)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/kippt/version.rb
CHANGED
data/spec/fixtures/clip.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"
|
1
|
+
{"via": null, "saves": {"count": 0, "data": []}, "favicon_url": "https://www.google.com/s2/u/0/favicons?domain=karrisaarinen.com", "is_favorite": false, "likes": {"count": 0, "data": []}, "app_url": "/vesan/inspiration/clips/10", "title": "Karri Saarinen", "media": {"description": "We had a talk recently at Slush 2012 startup conference about how we're building Kippt with hacking design and generally being nice guys. Zen and the Art of Motorcycle Maintenance is one of my favorite books. It's a bestseller, but I think it's a great journey into the philosophy of science and art, and the metaphysics of quality.", "title": "Karri Saarinen", "provider": {"url": "https://kippt.com", "name": "Kippt"}, "images": {"tile": {"url": "https://d19weqihs4yh5u.cloudfront.net/links/3bcb19bd1912598f244b289c42647e2eba790636/350x200", "width": 350, "height": 200}, "original": {"url": "https://d19weqihs4yh5u.cloudfront.net/links/3bcb19bd1912598f244b289c42647e2eba790636/original", "width": 600, "height": 257}}, "article": {"html": "", "author_url": null, "author": null}, "type": "article"}, "is_read_later": false, "comments": {"count": 0, "data": []}, "id": 10, "type": "link", "updated": 1361128164, "user": {"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "twitter": "vesan", "id": 33, "github": "vesan", "website_url": "http://vesavanska.com/", "full_name": "Vesa V\u00e4nsk\u00e4", "dribbble": "vesan", "counts": {"follows": 21, "followed_by": 26}, "is_pro": true, "resource_uri": "/api/users/33/"}, "article": null, "is_starred": false, "url_domain": "karrisaarinen.com", "created": 1335097767, "url": "http://karrisaarinen.com/", "notes": "Cool site, bro #karri", "list": {"app_url": "/vesan/inspiration", "rss_url": "https://kippt.com/vesan/inspiration/feed/ef6bc29ac10dce9ccfbc30c94b613d5f", "updated": 1355490811, "description": "", "title": "Inspiration!", "created": 1335072037, "collaborators": {"count": 0, "data": []}, "slug": "inspiration", "user": {"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "twitter": "vesan", "counts": {"follows": 21, "followed_by": 26}, "github": "vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "is_pro": true, "full_name": "Vesa V\u00e4nsk\u00e4", "dribbble": "vesan", "id": 33, "website_url": "http://vesavanska.com/", "resource_uri": "/api/users/33/"}, "id": 44525, "is_private": true, "resource_uri": "/api/lists/44525/"}, "resource_uri": "/api/clips/10/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"body": "Test comment!", "created": 1364752365, "id": 10, "resource_uri": "/api/clips/10400202/comments/10/", "user": {"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "counts": {"follows": 21, "followed_by": 26}, "dribbble": "vesan", "full_name": "Vesa Vänskä", "github": "vesan", "id": 33, "is_pro": true, "resource_uri": "/api/users/33/", "twitter": "vesan", "username": "vesan", "website_url": "http://vesavanska.com/"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{ "meta": { "next": null, "total_count": 1, "previous": null, "limit": 20, "offset": 0 }, "objects": [ {"body": "Test comment!", "created": 1364752365, "id": 10, "resource_uri": "/api/clips/10400202/comments/10/", "user": {"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "counts": {"follows": 21, "followed_by": 26}, "dribbble": "vesan", "full_name": "Vesa Vänskä", "github": "vesan", "id": 33, "is_pro": true, "resource_uri": "/api/users/33/", "twitter": "vesan", "username": "vesan", "website_url": "http://vesavanska.com/"}}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"meta": {"next": null, "previous": null, "limit": 20, "offset": 0}, "objects": [{"url_domain": "karrisaarinen.com", "updated": "1335090586", "is_starred": false, "title": "Karri Saarinen", "url": "http://karrisaarinen.com/", "notes": "Cool site, bro", "created": "1335090567", "list": "/api/lists/44525/", "id": 1589450, "resource_uri": "/api/clips/1589450/"}]}
|
data/spec/fixtures/list.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"rss_url": "https://kippt.com/
|
1
|
+
{"app_url": "/vesan/rails-girls", "rss_url": "https://kippt.com/vesan/rails-girls/feed", "updated": 1363728355, "description": null, "title": "Rails Girls", "created": 1363728355, "collaborators": {"count": 0, "data": []}, "slug": "rails-girls", "user": {"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "twitter": "vesan", "counts": {"follows": 21, "followed_by": 26}, "github": "vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "is_pro": true, "full_name": "Vesa V\u00e4nsk\u00e4", "dribbble": "vesan", "id": 33, "website_url": "http://vesavanska.com/", "resource_uri": "/api/users/33/"}, "id": 10, "is_private": false, "resource_uri": "/api/lists/10/"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"username": "vesan", "bio": "Ruby developer at Kisko Labs. Dangerous, but not foolish.", "app_url": "/vesan", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/3b2958fd-db1d-4b80-acd1-d7e344fe5124/160x160", "twitter": "vesan", "id": 10, "github": "vesan", "website_url": "http://vesavanska.com/", "full_name": "Vesa V\u00e4nsk\u00e4", "dribbble": "vesan", "counts": {"follows": 21, "followed_by": 26}, "is_pro": true, "resource_uri": "/api/users/10/"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
|
2
|
+
{"meta": {"total_count": 1277, "next": null, "limit": 20, "offset": 0, "query": "developer", "previous": null}, "objects": [{"username": "qzapaia", "bio": "developer", "app_url": "/qzapaia", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "qzapaia", "id": 4143, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/4143/"}, {"username": "erik_", "bio": "developer", "app_url": "/erik_", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "eriklieben", "id": 23427, "github": "", "website_url": "http://www.eriklieben.com", "full_name": "", "dribbble": "", "counts": {"follows": 10, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/23427/"}, {"username": "szahn", "bio": "Developer", "app_url": "/szahn", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/66fd7dfe-22b6-45a3-8fde-fe1ccb9fedcd/160x160", "twitter": "szahn", "id": 51839, "github": "", "website_url": "Stuart Zahn", "full_name": "", "dribbble": "", "counts": {"follows": 40, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/51839/"}, {"username": "aminudin", "bio": "Web Development, Hosting, IT Learning, Aplication Development", "app_url": "/aminudin", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "", "id": 35567, "github": "", "website_url": "http://www.aicsi.com/", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/35567/"}, {"username": "risico", "bio": "w3 Software Developer. Hobbyist game developer.", "app_url": "/risico", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/575922f4-2cba-4587-b9a2-ec84b3786172/160x160", "twitter": "risico", "id": 25897, "github": "", "website_url": "http://robert.zimtea.com", "full_name": "", "dribbble": "", "counts": {"follows": 15, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/25897/"}, {"username": "chitsaou", "bio": "Web Developer / Rails Developer", "app_url": "/chitsaou", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/f7d35db9-948f-4e57-9447-15bba539f27e/160x160", "twitter": "yorkxin", "id": 21531, "github": "chitsaou", "website_url": "http://blog.yorkxin.org/", "full_name": "", "dribbble": "", "counts": {"follows": 7, "followed_by": 10}, "is_pro": false, "resource_uri": "/api/users/21531/"}, {"username": "thedev", "bio": "Web developer, Software developer, Freelancer", "app_url": "/thedev", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/46ef210c-44f1-4dce-a0bd-8f5949016861/160x160", "twitter": "the_dev", "id": 23494, "github": "", "website_url": "http://www.thedev.ro", "full_name": "", "dribbble": "", "counts": {"follows": 1, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/23494/"}, {"username": "koopajah", "bio": "Linux embedded C developer starting web development", "app_url": "/koopajah", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "koopajah", "id": 44740, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 2, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/44740/"}, {"username": "ahmednadar", "bio": "Web developer", "app_url": "/ahmednadar", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "ahmednadar", "id": 14286, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 3, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/14286/"}, {"username": "yaandil", "bio": "Developer", "app_url": "/yaandil", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/fcd9078b-823f-49ba-8f0f-e56000eabf98/160x160", "twitter": "mkanski", "id": 10467, "github": "realez", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 7, "followed_by": 2}, "is_pro": false, "resource_uri": "/api/users/10467/"}, {"username": "julianosaless", "bio": "Software Developer", "app_url": "/julianosaless", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/cd2f2575-f4b5-4430-a941-eab804a0e303/160x160", "twitter": "JulianoSaless", "id": 40872, "github": "", "website_url": "http://www.devjulianosales.wordpress.com", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/40872/"}, {"username": "dynamik", "bio": "under development!!!", "app_url": "/dynamik", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "dynamikus", "id": 33627, "github": "", "website_url": "http://www.dynamik.us", "full_name": "", "dribbble": "", "counts": {"follows": 12, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/33627/"}, {"username": "danielveneg", "bio": "Web Developer", "app_url": "/danielveneg", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "danielveneg", "id": 32525, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/32525/"}, {"username": "mphome", "bio": "Software Developer", "app_url": "/mphome", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/5de37e1a-f190-4cc4-b579-70284be8582a/160x160", "twitter": "mphome", "id": 38248, "github": "", "website_url": "http://mphome.dp.ua", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/38248/"}, {"username": "nevron", "bio": "Designer / Developer", "app_url": "/nevron", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/237cb878-fcc9-4b97-af60-86e795630634/160x160", "twitter": "nevron", "id": 26380, "github": "", "website_url": "http://www.erhantunali.com/blog", "full_name": "", "dribbble": "", "counts": {"follows": 13, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/26380/"}, {"username": "garciademarina", "bio": "OSClass developer", "app_url": "/garciademarina", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/f73d31e5-8a97-4b50-adf8-b967e4331bc7/160x160", "twitter": "garciademarina", "id": 26878, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 14, "followed_by": 2}, "is_pro": false, "resource_uri": "/api/users/26878/"}, {"username": "sgcet", "bio": "web developer", "app_url": "/sgcet", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "sgcet", "id": 21324, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/21324/"}, {"username": "tzumby", "bio": "Rails developer", "app_url": "/tzumby", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/17d650d7-8874-416f-a1d7-27e85a42e3be/160x160", "twitter": "tzumby", "id": 28621, "github": "", "website_url": "http://www.razlab.com", "full_name": "", "dribbble": "", "counts": {"follows": 5, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/28621/"}, {"username": "arjoonkanth", "bio": "Web Developer", "app_url": "/arjoonkanth", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "", "id": 54311, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 11, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/54311/"}, {"username": "janerist", "bio": "Software developer", "app_url": "/janerist", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/ed084049-4d12-45c0-b2f1-d3d2d4a2f346/160x160", "twitter": "janerist", "id": 22629, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/22629/"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"meta": {"total_count": 1277, "next": "/api/users/search/?q=developer&limit=20&offset=20", "limit": 20, "offset": 20, "query": "developer", "previous": "/api/users/search/?q=developer&limit=20&offset=0"}, "objects": [{"username": "qzapaia", "bio": "developer", "app_url": "/qzapaia", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "qzapaia", "id": 4143, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/4143/"}, {"username": "erik_", "bio": "developer", "app_url": "/erik_", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "eriklieben", "id": 23427, "github": "", "website_url": "http://www.eriklieben.com", "full_name": "", "dribbble": "", "counts": {"follows": 10, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/23427/"}, {"username": "szahn", "bio": "Developer", "app_url": "/szahn", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/66fd7dfe-22b6-45a3-8fde-fe1ccb9fedcd/160x160", "twitter": "szahn", "id": 51839, "github": "", "website_url": "Stuart Zahn", "full_name": "", "dribbble": "", "counts": {"follows": 40, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/51839/"}, {"username": "aminudin", "bio": "Web Development, Hosting, IT Learning, Aplication Development", "app_url": "/aminudin", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "", "id": 35567, "github": "", "website_url": "http://www.aicsi.com/", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/35567/"}, {"username": "risico", "bio": "w3 Software Developer. Hobbyist game developer.", "app_url": "/risico", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/575922f4-2cba-4587-b9a2-ec84b3786172/160x160", "twitter": "risico", "id": 25897, "github": "", "website_url": "http://robert.zimtea.com", "full_name": "", "dribbble": "", "counts": {"follows": 15, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/25897/"}, {"username": "chitsaou", "bio": "Web Developer / Rails Developer", "app_url": "/chitsaou", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/f7d35db9-948f-4e57-9447-15bba539f27e/160x160", "twitter": "yorkxin", "id": 21531, "github": "chitsaou", "website_url": "http://blog.yorkxin.org/", "full_name": "", "dribbble": "", "counts": {"follows": 7, "followed_by": 10}, "is_pro": false, "resource_uri": "/api/users/21531/"}, {"username": "thedev", "bio": "Web developer, Software developer, Freelancer", "app_url": "/thedev", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/46ef210c-44f1-4dce-a0bd-8f5949016861/160x160", "twitter": "the_dev", "id": 23494, "github": "", "website_url": "http://www.thedev.ro", "full_name": "", "dribbble": "", "counts": {"follows": 1, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/23494/"}, {"username": "koopajah", "bio": "Linux embedded C developer starting web development", "app_url": "/koopajah", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "koopajah", "id": 44740, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 2, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/44740/"}, {"username": "ahmednadar", "bio": "Web developer", "app_url": "/ahmednadar", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "ahmednadar", "id": 14286, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 3, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/14286/"}, {"username": "yaandil", "bio": "Developer", "app_url": "/yaandil", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/fcd9078b-823f-49ba-8f0f-e56000eabf98/160x160", "twitter": "mkanski", "id": 10467, "github": "realez", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 7, "followed_by": 2}, "is_pro": false, "resource_uri": "/api/users/10467/"}, {"username": "julianosaless", "bio": "Software Developer", "app_url": "/julianosaless", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/cd2f2575-f4b5-4430-a941-eab804a0e303/160x160", "twitter": "JulianoSaless", "id": 40872, "github": "", "website_url": "http://www.devjulianosales.wordpress.com", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/40872/"}, {"username": "dynamik", "bio": "under development!!!", "app_url": "/dynamik", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "dynamikus", "id": 33627, "github": "", "website_url": "http://www.dynamik.us", "full_name": "", "dribbble": "", "counts": {"follows": 12, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/33627/"}, {"username": "danielveneg", "bio": "Web Developer", "app_url": "/danielveneg", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "danielveneg", "id": 32525, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/32525/"}, {"username": "mphome", "bio": "Software Developer", "app_url": "/mphome", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/5de37e1a-f190-4cc4-b579-70284be8582a/160x160", "twitter": "mphome", "id": 38248, "github": "", "website_url": "http://mphome.dp.ua", "full_name": "", "dribbble": "", "counts": {"follows": 9, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/38248/"}, {"username": "nevron", "bio": "Designer / Developer", "app_url": "/nevron", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/237cb878-fcc9-4b97-af60-86e795630634/160x160", "twitter": "nevron", "id": 26380, "github": "", "website_url": "http://www.erhantunali.com/blog", "full_name": "", "dribbble": "", "counts": {"follows": 13, "followed_by": 1}, "is_pro": false, "resource_uri": "/api/users/26380/"}, {"username": "garciademarina", "bio": "OSClass developer", "app_url": "/garciademarina", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/f73d31e5-8a97-4b50-adf8-b967e4331bc7/160x160", "twitter": "garciademarina", "id": 26878, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 14, "followed_by": 2}, "is_pro": false, "resource_uri": "/api/users/26878/"}, {"username": "sgcet", "bio": "web developer", "app_url": "/sgcet", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "sgcet", "id": 21324, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/21324/"}, {"username": "tzumby", "bio": "Rails developer", "app_url": "/tzumby", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/17d650d7-8874-416f-a1d7-27e85a42e3be/160x160", "twitter": "tzumby", "id": 28621, "github": "", "website_url": "http://www.razlab.com", "full_name": "", "dribbble": "", "counts": {"follows": 5, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/28621/"}, {"username": "arjoonkanth", "bio": "Web Developer", "app_url": "/arjoonkanth", "avatar_url": "https://d17f28g3dsa4vh.cloudfront.net/img/default-avatar.png", "twitter": "", "id": 54311, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 11, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/54311/"}, {"username": "janerist", "bio": "Software developer", "app_url": "/janerist", "avatar_url": "https://d19weqihs4yh5u.cloudfront.net/avatars/ed084049-4d12-45c0-b2f1-d3d2d4a2f346/160x160", "twitter": "janerist", "id": 22629, "github": "", "website_url": "", "full_name": "", "dribbble": "", "counts": {"follows": 0, "followed_by": 0}, "is_pro": false, "resource_uri": "/api/users/22629/"}]}
|
data/spec/kippt/client_spec.rb
CHANGED
@@ -5,21 +5,45 @@ describe Kippt::Client do
|
|
5
5
|
describe "#initialize" do
|
6
6
|
context "when there is no username" do
|
7
7
|
it "raises error" do
|
8
|
-
|
8
|
+
expect {
|
9
9
|
Kippt::Client.new(:password => "secret")
|
10
|
-
}.
|
10
|
+
}.to raise_error(ArgumentError, "username is required")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when there is no password or token" do
|
15
15
|
it "raises error" do
|
16
|
-
|
16
|
+
expect {
|
17
17
|
Kippt::Client.new(:username => "vesan")
|
18
|
-
}.
|
18
|
+
}.to raise_error(ArgumentError, "password or token is required")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when there is unauthenticated parameter" do
|
23
|
+
it "doesn't raise error" do
|
24
|
+
expect {
|
25
|
+
Kippt::Client.new(:unauthenticated => true)
|
26
|
+
}.to_not raise_error
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when debug is set to true" do
|
31
|
+
it "sets client to debug mode" do
|
32
|
+
client = Kippt::Client.new(:unauthenticated => true, :debug => true)
|
33
|
+
client.debug?.should be_true
|
19
34
|
end
|
20
35
|
end
|
21
36
|
end
|
22
37
|
|
38
|
+
context "#debug" do
|
39
|
+
it "can be set and read" do
|
40
|
+
client = Kippt::Client.new(:unauthenticated => true)
|
41
|
+
client.debug?.should be_false
|
42
|
+
client.debug = true
|
43
|
+
client.debug?.should be_true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
23
47
|
describe "connection" do
|
24
48
|
subject { Kippt::Client.new(:username => "bob", :password => "secret") }
|
25
49
|
|
@@ -37,9 +61,9 @@ describe Kippt::Client do
|
|
37
61
|
stub_request(:get, "https://bob:secret@kippt.com/error_path").
|
38
62
|
to_return(:status => 401, :body => "{\"message\": \"Something horrible.\"}")
|
39
63
|
|
40
|
-
|
64
|
+
expect {
|
41
65
|
subject.get("/error_path")
|
42
|
-
}.
|
66
|
+
}.to raise_error(Kippt::APIError, "Something horrible.")
|
43
67
|
end
|
44
68
|
end
|
45
69
|
end
|
@@ -48,12 +72,12 @@ describe Kippt::Client do
|
|
48
72
|
describe "#account" do
|
49
73
|
subject { Kippt::Client.new(:username => "bob", :password => "secret") }
|
50
74
|
|
51
|
-
it "returns a Kippt::
|
75
|
+
it "returns a Kippt::User instance" do
|
52
76
|
subject.should_receive(:get).with("account").and_return(
|
53
77
|
stub :body => {}
|
54
78
|
)
|
55
79
|
account = subject.account
|
56
|
-
account.should be_a(Kippt::
|
80
|
+
account.should be_a(Kippt::User)
|
57
81
|
end
|
58
82
|
end
|
59
83
|
|
@@ -74,4 +98,35 @@ describe Kippt::Client do
|
|
74
98
|
clips.should be_a(Kippt::Clips)
|
75
99
|
end
|
76
100
|
end
|
101
|
+
|
102
|
+
describe "#users" do
|
103
|
+
subject { Kippt::Client.new(:username => "bob", :password => "secret") }
|
104
|
+
|
105
|
+
it "returns a Kippt::Users instance" do
|
106
|
+
users = subject.users
|
107
|
+
users.should be_a(Kippt::Users)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#resource_from_url" do
|
112
|
+
subject { Kippt::Client.new(valid_user_credentials) }
|
113
|
+
|
114
|
+
it "returns correct resource" do
|
115
|
+
stub_get("/users/10").
|
116
|
+
to_return(:status => 200, :body => fixture("user.json"))
|
117
|
+
resource = subject.resource_from_url(Kippt::User, "/api/users/10")
|
118
|
+
resource.should be_a(Kippt::User)
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when passed URL is blank" do
|
122
|
+
it "raises ArgumentError" do
|
123
|
+
expect {
|
124
|
+
subject.resource_from_url(stub, "")
|
125
|
+
}.to raise_error(ArgumentError, "The parameter URL can't be blank")
|
126
|
+
expect {
|
127
|
+
subject.resource_from_url(stub, nil)
|
128
|
+
}.to raise_error(ArgumentError, "The parameter URL can't be blank")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
77
132
|
end
|
@@ -6,9 +6,9 @@ describe Kippt::ClipCollection do
|
|
6
6
|
let(:data_with_multiple_pages) {
|
7
7
|
MultiJson.load(fixture("clips_with_multiple_pages.json").read)
|
8
8
|
}
|
9
|
-
|
10
|
-
|
11
|
-
let(:
|
9
|
+
let(:client) { stub }
|
10
|
+
subject { Kippt::ClipCollection.new(data, client) }
|
11
|
+
let(:subject_with_multiple_pages) { Kippt::ClipCollection.new(data_with_multiple_pages, client) }
|
12
12
|
|
13
13
|
it_behaves_like "collection"
|
14
14
|
end
|
data/spec/kippt/clip_spec.rb
CHANGED
@@ -2,14 +2,119 @@ require "spec_helper"
|
|
2
2
|
require "kippt/clip"
|
3
3
|
|
4
4
|
describe Kippt::Clip do
|
5
|
-
subject { Kippt::Clip.new(data,
|
6
|
-
let(:
|
5
|
+
subject { Kippt::Clip.new(data, client) }
|
6
|
+
let(:client) { Kippt::Client.new(valid_user_credentials) }
|
7
|
+
let(:collection_resource_class) { Kippt::Clips }
|
7
8
|
|
8
9
|
let(:data) { MultiJson.load(fixture("clip.json").read) }
|
9
10
|
let(:attributes) {
|
10
|
-
[:url_domain, :
|
11
|
-
:url, :notes, :
|
11
|
+
[:url_domain, :is_starred, :title,
|
12
|
+
:url, :notes, :id, :resource_uri]
|
13
|
+
}
|
14
|
+
let(:mapped_attributes) {
|
15
|
+
{:updated => "Time", :created => "Time",
|
16
|
+
:user => "Kippt::User", :via => "Kippt::Clip"}
|
12
17
|
}
|
13
18
|
|
14
19
|
it_behaves_like "resource"
|
20
|
+
|
21
|
+
describe "#list_uri" do
|
22
|
+
context "when API data has an list URI" do
|
23
|
+
let(:data) { {"list" => "/api/lists/44525/"} }
|
24
|
+
|
25
|
+
it "returns the URI" do
|
26
|
+
subject.list_uri.should eq "/api/lists/44525/"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when API data has embedded list attributes" do
|
31
|
+
let(:data) { {"list" => {"resource_uri" => "/api/lists/44525/"}} }
|
32
|
+
|
33
|
+
it "returns the uri of the embedded list" do
|
34
|
+
subject.list_uri.should eq "/api/lists/44525/"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#list" do
|
40
|
+
context "when API data has an list URI" do
|
41
|
+
let(:data) { {"list" => "/api/lists/44525/"} }
|
42
|
+
|
43
|
+
it "fetches the data and creates an instance out of it" do
|
44
|
+
stub_get("/lists/44525/").
|
45
|
+
to_return(:status => 200, :body => fixture("list.json"))
|
46
|
+
|
47
|
+
subject.list.should be_a Kippt::List
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when API data has embedded list attributes" do
|
52
|
+
let(:data) { {"list" => {"resource_uri" => "/api/lists/44525/"}} }
|
53
|
+
|
54
|
+
it "returns an instance using the embedded list" do
|
55
|
+
subject.list.should be_a Kippt::List
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when a Kippt::List is passed" do
|
60
|
+
let(:list) { Kippt::List.new }
|
61
|
+
let(:data) { {"list" => list} }
|
62
|
+
|
63
|
+
it "returns the passed list" do
|
64
|
+
subject.list.should eq list
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#comments" do
|
70
|
+
it "returns Kippt::Comments" do
|
71
|
+
subject.comments.should be_a Kippt::Comments
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns object where clip is set" do
|
75
|
+
subject.comments.clip.should eq subject
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#all_comments_embedded?" do
|
80
|
+
context "when comment count and number of comment objects matches" do
|
81
|
+
let(:data) { {"comments" => {
|
82
|
+
"count" => 2, "data" => [{}, {}]
|
83
|
+
}} }
|
84
|
+
|
85
|
+
it "returns true" do
|
86
|
+
subject.all_comments_embedded?.should be_true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when comment count and number of comment objects doesn't match" do
|
91
|
+
let(:data) { {"comments" => {
|
92
|
+
"count" => 2, "data" => [{}]
|
93
|
+
}} }
|
94
|
+
|
95
|
+
it "returns true" do
|
96
|
+
subject.all_comments_embedded?.should be_false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#like" do
|
102
|
+
let(:like) { stub :like }
|
103
|
+
|
104
|
+
it "instantiates a Kippt::Like and saves it" do
|
105
|
+
Kippt::Like.should_receive(:new).with(client, subject).and_return(like)
|
106
|
+
like.should_receive(:save)
|
107
|
+
subject.like
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#unlike" do
|
112
|
+
let(:like) { stub :like }
|
113
|
+
|
114
|
+
it "instantiates a Kippt::Like and destroys it" do
|
115
|
+
Kippt::Like.should_receive(:new).with(client, subject).and_return(like)
|
116
|
+
like.should_receive(:destroy)
|
117
|
+
subject.unlike
|
118
|
+
end
|
119
|
+
end
|
15
120
|
end
|