dribbble 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18244d8f44973748844ce57d3de8bb36e597749b
4
- data.tar.gz: b82d095959b81603f2fbed82ae435ff8f3084535
3
+ metadata.gz: 7a4bac3f73ec6a37100e5e7d27683578fa8e9281
4
+ data.tar.gz: faf1c7057e4337d9ffbbc412924bbd28692067b2
5
5
  SHA512:
6
- metadata.gz: 64c1ab8b2f3aa5cd9696037f1af805ea52573cff3bec34daa454c6f5d49558ee43c9664fac11ebd936912bbf87848227ca05e1ad0d256cde8f36e60ddbc46c46
7
- data.tar.gz: 048b0c14059f97a379360fe09f41a342d7e8af23300f338962056273941f673b28e9f1bcfa0ff87d99e85aa7311432d32a75213cf6a59678de225a9e25c443e9
6
+ metadata.gz: 94f4953e92a8948c304ece38c95f9252c4f4dc76b9a01586e117ad093c2901f944eb3c509c622631fd45929218daeb8cb6ce47e41e087c757c33503ab9feae35
7
+ data.tar.gz: bb3eea4ba60ff043153fa98c7c85d2086f1667a8c3147dfd71ae132fcb5bd368da26ba7afb60c8ad11ccd617d2719199be702f7873f3f507abf61bc2fbc98d22
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .rvmrc
5
6
  coverage
6
7
  InstalledFiles
7
8
  lib/bundler/man
data/README.md CHANGED
@@ -65,6 +65,13 @@ user.buckets
65
65
  #=> [#<Dribbble::Bucket ...>, #<Dribbble::Bucket ...>]
66
66
  ```
67
67
 
68
+ ... And shots :
69
+
70
+ ```ruby
71
+ user.shots
72
+ #=> [#<Dribbble::Shot ...>, #<Dribbble::Shot ...>]
73
+ ```
74
+
68
75
  ### Shots
69
76
 
70
77
  You can create a shot by calling `client.create_shot`
@@ -81,8 +88,25 @@ client.create_shot(shot)
81
88
  #=> True
82
89
  ```
83
90
 
91
+ ### Pagination & parameters
92
+
93
+ All requests are paginated, defaults params are :
94
+
95
+ | Param | Default |
96
+ |---------|--------:|
97
+ |page | 1|
98
+ |per_page | 100|
99
+
100
+ You override them or adding some by passing a `Hash` to every request :
101
+
102
+ ```ruby
103
+ client.user page: 2, custom_param: 'My param'
104
+ ```
105
+
84
106
  ## Contributing
85
107
 
108
+ [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Calyhre/dribbble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
109
+
86
110
  Feel free to help me make this gem awesome !
87
111
 
88
112
  [Contributors](https://github.com/Calyhre/dribbble/graphs/contributors) and [CONTRIBUTING](https://github.com/Calyhre/dribbble/blob/master/CONTRIBUTING.md)
@@ -0,0 +1,4 @@
1
+ module Dribbble
2
+ class Shot < Dribbble::Base
3
+ end
4
+ end
data/lib/dribbble/user.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'dribbble/bucket'
2
+ require 'dribbble/shot'
2
3
 
3
4
  module Dribbble
4
5
  class User < Dribbble::Base
@@ -7,8 +8,12 @@ module Dribbble
7
8
  get_user(id)
8
9
  end
9
10
 
10
- def buckets
11
- Dribbble::Bucket.batch_new token, get("/users/#{id}/buckets")
11
+ def buckets(attrs = {})
12
+ Dribbble::Bucket.batch_new token, get("/users/#{id}/buckets", attrs)
13
+ end
14
+
15
+ def shots(attrs = {})
16
+ Dribbble::Shot.batch_new token, get("/users/#{id}/shots", attrs)
12
17
  end
13
18
  end
14
19
  end
@@ -1,7 +1,15 @@
1
+ require 'uri'
2
+
1
3
  module Dribbble
2
4
  module Utils
3
- def full_url(path)
4
- "#{Dribbble::API_URI}#{path}"
5
+ DEFAULT_ATTRIBUTES = {
6
+ page: 1,
7
+ per_page: 100
8
+ }
9
+
10
+ def full_url(path, attrs = {})
11
+ query = URI.encode_www_form DEFAULT_ATTRIBUTES.merge(attrs)
12
+ "#{Dribbble::API_URI}#{path}?#{query}"
5
13
  end
6
14
 
7
15
  def headers
@@ -12,16 +20,16 @@ module Dribbble
12
20
  end
13
21
  end
14
22
 
15
- def get(path)
16
- RestClient.get full_url(path), headers
23
+ def get(path, attrs = {})
24
+ RestClient.get full_url(path, attrs), headers
17
25
  rescue RestClient::Unauthorized => e
18
26
  raise Dribbble::Error::Unauthorized, e
19
27
  end
20
28
 
21
- def post(path)
29
+ def post(path, attrs = {})
22
30
  payload = {}
23
31
  yield payload
24
- RestClient.post full_url(path), payload, headers
32
+ RestClient.post full_url(path, attrs), payload, headers
25
33
  rescue RestClient::Unauthorized => e
26
34
  raise Dribbble::Error::Unauthorized, e
27
35
  rescue RestClient::UnprocessableEntity => e
@@ -1,4 +1,4 @@
1
1
  # Dribbble Version
2
2
  module Dribbble
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dribbble::Client do
4
+ before :all do
5
+ @base = Dribbble::Base.new 'valid_token', {}
6
+ end
7
+
8
+ describe 'on #full_url' do
9
+ describe 'without params' do
10
+ subject { @base.full_url '/shots' }
11
+
12
+ it 'return a valid url' do
13
+ expect(subject).to eq('https://api.dribbble.com/v1/shots?page=1&per_page=100')
14
+ end
15
+ end
16
+
17
+ describe 'with default params overrided' do
18
+ subject { @base.full_url '/shots', page: 2, per_page: 10 }
19
+
20
+ it 'return a valid url' do
21
+ expect(subject).to eq('https://api.dribbble.com/v1/shots?page=2&per_page=10')
22
+ end
23
+ end
24
+
25
+ describe 'with extra params' do
26
+ subject { @base.full_url '/shots', params1: 'custom' }
27
+
28
+ it 'return a valid url' do
29
+ expect(subject).to eq('https://api.dribbble.com/v1/shots?page=1&per_page=100&params1=custom')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -26,4 +26,16 @@ describe Dribbble::User do
26
26
  expect(subject.first).to be_a Dribbble::Bucket
27
27
  end
28
28
  end
29
+
30
+ describe "#shots" do
31
+ subject do
32
+ stub_dribbble_with DribbbleAPI::ShotsSuccess
33
+ @user.shots
34
+ end
35
+
36
+ it 'responds with buckets' do
37
+ expect(subject.size).to eq 2
38
+ expect(subject.first).to be_a Dribbble::Shot
39
+ end
40
+ end
29
41
  end
@@ -23,6 +23,12 @@ module DribbbleAPI
23
23
  end
24
24
  end
25
25
 
26
+ class ShotsSuccess < Base
27
+ get '/*' do
28
+ json_response 200, 'shots_success.json'
29
+ end
30
+ end
31
+
26
32
  class Created < Base
27
33
  post '/*' do
28
34
  status 202
@@ -0,0 +1,172 @@
1
+ [
2
+ {
3
+ "id" : 471756,
4
+ "title" : "Sasquatch",
5
+ "description" : "<p>Quick, messy, five minute sketch of something that might become a fictional something.</p>",
6
+ "width" : 400,
7
+ "height" : 300,
8
+ "images" : {
9
+ "hidpi" : null,
10
+ "normal" : "https://d13yacurqjgara.cloudfront.net/users/1/screenshots/471756/sasquatch.png",
11
+ "teaser" : "https://d13yacurqjgara.cloudfront.net/users/1/screenshots/471756/sasquatch_teaser.png"
12
+ },
13
+ "views_count" : 4372,
14
+ "likes_count" : 149,
15
+ "comments_count" : 27,
16
+ "attachments_count" : 0,
17
+ "rebounds_count" : 2,
18
+ "buckets_count" : 8,
19
+ "created_at" : "2012-03-15T01:52:33Z",
20
+ "updated_at" : "2012-03-15T02:12:57Z",
21
+ "html_url" : "https://dribbble.com/shots/471756-Sasquatch",
22
+ "attachments_url" : "https://api.dribbble.com/v1/shots/471756/attachments",
23
+ "comments_url" : "https://api.dribbble.com/v1/shots/471756/comments",
24
+ "likes_url" : "https://api.dribbble.com/v1/shots/471756/likes",
25
+ "projects_url" : "https://api.dribbble.com/v1/shots/471756/projects",
26
+ "rebounds_url" : "https://api.dribbble.com/v1/shots/471756/rebounds",
27
+ "tags" : [
28
+ "fiction",
29
+ "sasquatch",
30
+ "sketch",
31
+ "wip"
32
+ ],
33
+ "user" : {
34
+ "id" : 1,
35
+ "name" : "Dan Cederholm",
36
+ "username" : "simplebits",
37
+ "html_url" : "https://dribbble.com/simplebits",
38
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/1/avatars/normal/dc.jpg?1371679243",
39
+ "bio" : "Co-founder &amp; designer of <a href=\"https://dribbble.com/dribbble\">@Dribbble</a>. Principal of SimpleBits. Aspiring clawhammer banjoist.",
40
+ "location" : "Salem, MA",
41
+ "links" : {
42
+ "web" : "http://simplebits.com",
43
+ "twitter" : "https://twitter.com/simplebits"
44
+ },
45
+ "followers_count" : 29262,
46
+ "followings_count" : 1728,
47
+ "likes_count" : 34954,
48
+ "shots_count" : 214,
49
+ "type" : "User",
50
+ "pro" : true,
51
+ "buckets_url" : "https://dribbble.com/v1/users/1/buckets",
52
+ "followers_url" : "https://dribbble.com/v1/users/1/followers",
53
+ "following_url" : "https://dribbble.com/v1/users/1/following",
54
+ "likes_url" : "https://dribbble.com/v1/users/1/likes",
55
+ "shots_url" : "https://dribbble.com/v1/users/1/shots",
56
+ "teams_url" : "https://dribbble.com/v1/users/1/teams",
57
+ "created_at" : "2009-07-08T02:51:22Z",
58
+ "updated_at" : "2014-02-22T17:10:33Z"
59
+ },
60
+ "team" : {
61
+ "id" : 39,
62
+ "name" : "Dribbble",
63
+ "username" : "dribbble",
64
+ "html_url" : "https://dribbble.com/dribbble",
65
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/39/avatars/normal/apple-flat-precomposed.png?1388527574",
66
+ "bio" : "Show and tell for designers. This is Dribbble on Dribbble.",
67
+ "location" : "Salem, MA",
68
+ "links" : {
69
+ "web" : "http://dribbble.com",
70
+ "twitter" : "https://twitter.com/dribbble"
71
+ },
72
+ "followers_count" : 25011,
73
+ "followings_count" : 6120,
74
+ "likes_count" : 44,
75
+ "shots_count" : 91,
76
+ "type" : "Team",
77
+ "pro" : false,
78
+ "buckets_url" : "https://dribbble.com/v1/users/39/buckets",
79
+ "followers_url" : "https://dribbble.com/v1/users/39/followers",
80
+ "likes_url" : "https://dribbble.com/v1/users/39/likes",
81
+ "shots_url" : "https://dribbble.com/v1/users/39/shots",
82
+ "teams_url" : "https://dribbble.com/v1/users/39/teams",
83
+ "created_at" : "2009-08-18T18:34:31Z",
84
+ "updated_at" : "2014-02-14T22:32:11Z"
85
+ }
86
+ },
87
+ {
88
+ "id" : 471756,
89
+ "title" : "Sasquatch",
90
+ "description" : "<p>Quick, messy, five minute sketch of something that might become a fictional something.</p>",
91
+ "width" : 400,
92
+ "height" : 300,
93
+ "images" : {
94
+ "hidpi" : null,
95
+ "normal" : "https://d13yacurqjgara.cloudfront.net/users/1/screenshots/471756/sasquatch.png",
96
+ "teaser" : "https://d13yacurqjgara.cloudfront.net/users/1/screenshots/471756/sasquatch_teaser.png"
97
+ },
98
+ "views_count" : 4372,
99
+ "likes_count" : 149,
100
+ "comments_count" : 27,
101
+ "attachments_count" : 0,
102
+ "rebounds_count" : 2,
103
+ "buckets_count" : 8,
104
+ "created_at" : "2012-03-15T01:52:33Z",
105
+ "updated_at" : "2012-03-15T02:12:57Z",
106
+ "html_url" : "https://dribbble.com/shots/471756-Sasquatch",
107
+ "attachments_url" : "https://api.dribbble.com/v1/shots/471756/attachments",
108
+ "comments_url" : "https://api.dribbble.com/v1/shots/471756/comments",
109
+ "likes_url" : "https://api.dribbble.com/v1/shots/471756/likes",
110
+ "projects_url" : "https://api.dribbble.com/v1/shots/471756/projects",
111
+ "rebounds_url" : "https://api.dribbble.com/v1/shots/471756/rebounds",
112
+ "tags" : [
113
+ "fiction",
114
+ "sasquatch",
115
+ "sketch",
116
+ "wip"
117
+ ],
118
+ "user" : {
119
+ "id" : 1,
120
+ "name" : "Dan Cederholm",
121
+ "username" : "simplebits",
122
+ "html_url" : "https://dribbble.com/simplebits",
123
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/1/avatars/normal/dc.jpg?1371679243",
124
+ "bio" : "Co-founder &amp; designer of <a href=\"https://dribbble.com/dribbble\">@Dribbble</a>. Principal of SimpleBits. Aspiring clawhammer banjoist.",
125
+ "location" : "Salem, MA",
126
+ "links" : {
127
+ "web" : "http://simplebits.com",
128
+ "twitter" : "https://twitter.com/simplebits"
129
+ },
130
+ "followers_count" : 29262,
131
+ "followings_count" : 1728,
132
+ "likes_count" : 34954,
133
+ "shots_count" : 214,
134
+ "type" : "User",
135
+ "pro" : true,
136
+ "buckets_url" : "https://dribbble.com/v1/users/1/buckets",
137
+ "followers_url" : "https://dribbble.com/v1/users/1/followers",
138
+ "following_url" : "https://dribbble.com/v1/users/1/following",
139
+ "likes_url" : "https://dribbble.com/v1/users/1/likes",
140
+ "shots_url" : "https://dribbble.com/v1/users/1/shots",
141
+ "teams_url" : "https://dribbble.com/v1/users/1/teams",
142
+ "created_at" : "2009-07-08T02:51:22Z",
143
+ "updated_at" : "2014-02-22T17:10:33Z"
144
+ },
145
+ "team" : {
146
+ "id" : 39,
147
+ "name" : "Dribbble",
148
+ "username" : "dribbble",
149
+ "html_url" : "https://dribbble.com/dribbble",
150
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/39/avatars/normal/apple-flat-precomposed.png?1388527574",
151
+ "bio" : "Show and tell for designers. This is Dribbble on Dribbble.",
152
+ "location" : "Salem, MA",
153
+ "links" : {
154
+ "web" : "http://dribbble.com",
155
+ "twitter" : "https://twitter.com/dribbble"
156
+ },
157
+ "followers_count" : 25011,
158
+ "followings_count" : 6120,
159
+ "likes_count" : 44,
160
+ "shots_count" : 91,
161
+ "type" : "Team",
162
+ "pro" : false,
163
+ "buckets_url" : "https://dribbble.com/v1/users/39/buckets",
164
+ "followers_url" : "https://dribbble.com/v1/users/39/followers",
165
+ "likes_url" : "https://dribbble.com/v1/users/39/likes",
166
+ "shots_url" : "https://dribbble.com/v1/users/39/shots",
167
+ "teams_url" : "https://dribbble.com/v1/users/39/teams",
168
+ "created_at" : "2009-08-18T18:34:31Z",
169
+ "updated_at" : "2014-02-14T22:32:11Z"
170
+ }
171
+ }
172
+ ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dribbble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calyhre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest_client
@@ -157,10 +157,12 @@ files:
157
157
  - lib/dribbble/bucket.rb
158
158
  - lib/dribbble/client.rb
159
159
  - lib/dribbble/errors.rb
160
+ - lib/dribbble/shot.rb
160
161
  - lib/dribbble/user.rb
161
162
  - lib/dribbble/utils.rb
162
163
  - lib/dribbble/version.rb
163
164
  - spec/factories.rb
165
+ - spec/lib/dribbble/base_spec.rb
164
166
  - spec/lib/dribbble/client_spec.rb
165
167
  - spec/lib/dribbble/user_spec.rb
166
168
  - spec/spec_helper.rb
@@ -168,6 +170,7 @@ files:
168
170
  - spec/support/fixtures/buckets_success.json
169
171
  - spec/support/fixtures/image.jpg
170
172
  - spec/support/fixtures/not_found.json
173
+ - spec/support/fixtures/shots_success.json
171
174
  - spec/support/fixtures/unauthorized.json
172
175
  - spec/support/fixtures/user_success.json
173
176
  homepage: http://github.com/Calyhre/dribbble
@@ -196,6 +199,7 @@ specification_version: 4
196
199
  summary: Dribbble API ruby wrapper
197
200
  test_files:
198
201
  - spec/factories.rb
202
+ - spec/lib/dribbble/base_spec.rb
199
203
  - spec/lib/dribbble/client_spec.rb
200
204
  - spec/lib/dribbble/user_spec.rb
201
205
  - spec/spec_helper.rb
@@ -203,5 +207,6 @@ test_files:
203
207
  - spec/support/fixtures/buckets_success.json
204
208
  - spec/support/fixtures/image.jpg
205
209
  - spec/support/fixtures/not_found.json
210
+ - spec/support/fixtures/shots_success.json
206
211
  - spec/support/fixtures/unauthorized.json
207
212
  - spec/support/fixtures/user_success.json