dribbble 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +33 -0
  3. data/.travis.yml +3 -3
  4. data/CHANGELOG.md +40 -12
  5. data/Gemfile +10 -0
  6. data/Guardfile +4 -2
  7. data/README.md +38 -283
  8. data/Rakefile +2 -0
  9. data/dribbble.gemspec +9 -7
  10. data/lib/dribbble.rb +3 -1
  11. data/lib/dribbble/attachment.rb +9 -1
  12. data/lib/dribbble/base.rb +3 -1
  13. data/lib/dribbble/client.rb +4 -29
  14. data/lib/dribbble/errors.rb +3 -3
  15. data/lib/dribbble/project.rb +10 -2
  16. data/lib/dribbble/shot.rb +3 -33
  17. data/lib/dribbble/user.rb +1 -28
  18. data/lib/dribbble/utils.rb +5 -3
  19. data/lib/dribbble/utils/creatable.rb +3 -1
  20. data/lib/dribbble/utils/deletable.rb +3 -1
  21. data/lib/dribbble/utils/findable.rb +2 -0
  22. data/lib/dribbble/utils/has_children.rb +10 -6
  23. data/lib/dribbble/utils/updatable.rb +2 -0
  24. data/lib/dribbble/version.rb +3 -1
  25. data/spec/lib/dribbble/base_spec.rb +10 -8
  26. data/spec/lib/dribbble/client_spec.rb +16 -69
  27. data/spec/lib/dribbble/project_spec.rb +52 -16
  28. data/spec/lib/dribbble/shot_spec.rb +14 -197
  29. data/spec/lib/dribbble/user_spec.rb +5 -176
  30. data/spec/spec_helper.rb +5 -3
  31. data/spec/support/dribbble_api.rb +17 -88
  32. data/spec/support/fixtures/current_user_success.json +35 -24
  33. data/spec/support/fixtures/project_success.json +1 -1
  34. data/spec/support/fixtures/projects_accepted.json +8 -0
  35. data/spec/support/fixtures/projects_deleted.json +8 -0
  36. data/spec/support/fixtures/projects_success.json +1 -1
  37. data/spec/support/fixtures/projects_updated.json +8 -0
  38. data/spec/support/fixtures/shot_success.json +16 -16
  39. data/spec/support/fixtures/shot_updated.json +78 -78
  40. data/spec/support/fixtures/shots_success.json +81 -103
  41. data/spec/support/fixtures/user_success.json +35 -24
  42. metadata +28 -66
  43. data/lib/dribbble/bucket.rb +0 -33
  44. data/lib/dribbble/comment.rb +0 -29
  45. data/lib/dribbble/like.rb +0 -7
  46. data/lib/dribbble/team.rb +0 -6
  47. data/spec/lib/dribbble/bucket_spec.rb +0 -136
  48. data/spec/lib/dribbble/comment_spec.rb +0 -77
  49. data/spec/lib/dribbble/team_spec.rb +0 -43
  50. data/spec/support/fixtures/attachments_success.json +0 -11
  51. data/spec/support/fixtures/bucket_created.json +0 -8
  52. data/spec/support/fixtures/bucket_success.json +0 -8
  53. data/spec/support/fixtures/bucket_updated.json +0 -8
  54. data/spec/support/fixtures/buckets_success.json +0 -10
  55. data/spec/support/fixtures/comment_created.json +0 -38
  56. data/spec/support/fixtures/comment_likes_success.json +0 -40
  57. data/spec/support/fixtures/comment_success.json +0 -38
  58. data/spec/support/fixtures/comment_updated.json +0 -38
  59. data/spec/support/fixtures/comments_success.json +0 -37
  60. data/spec/support/fixtures/followers_success.json +0 -33
  61. data/spec/support/fixtures/following_success.json +0 -33
  62. data/spec/support/fixtures/shot_likes_success.json +0 -33
  63. data/spec/support/fixtures/team_success.json +0 -26
  64. data/spec/support/fixtures/teams_success.json +0 -28
  65. data/spec/support/fixtures/user_likes_success.json +0 -91
  66. data/spec/support/fixtures/users_success.json +0 -27
@@ -1,191 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RAW_USER = data_from_json 'user_success.json'
4
6
 
5
7
  describe Dribbble::User do
6
8
  describe 'on instance' do
7
- before :all do
8
- @user = Dribbble::User.new 'valid_token', RAW_USER
9
+ before do
10
+ @user = described_class.new 'valid_token', RAW_USER
9
11
  end
10
12
 
11
13
  describe 'after initialization' do
12
14
  RAW_USER.each do |field, value|
13
15
  it "respond to #{field}" do
14
- expect(@user.send field).to eq(value)
15
- end
16
- end
17
- end
18
-
19
- describe 'on #buckets' do
20
- subject do
21
- stub_dribbble :get, '/users/483195/buckets', DribbbleAPI::BucketsSuccess
22
- @user.buckets
23
- end
24
-
25
- it 'responds with buckets' do
26
- expect(subject.size).to eq 1
27
- expect(subject.first).to be_a Dribbble::Bucket
28
- end
29
- end
30
-
31
- describe '#followers' do
32
- subject do
33
- stub_dribbble :get, '/users/483195/followers', DribbbleAPI::FollowersSuccess
34
- @user.followers
35
- end
36
-
37
- it 'responds with users' do
38
- expect(subject.size).to eq 1
39
- expect(subject.first).to be_a Dribbble::User
40
- expect(subject.first.location).to eq 'Salem, MA'
41
- end
42
- end
43
-
44
- describe '#following' do
45
- subject do
46
- stub_dribbble :get, '/users/483195/following', DribbbleAPI::FollowingSuccess
47
- @user.following
48
- end
49
-
50
- it 'responds with users' do
51
- expect(subject.size).to eq 1
52
- expect(subject.first).to be_a Dribbble::User
53
- expect(subject.first.name).to eq('Dan Cederholm')
54
- end
55
- end
56
-
57
- describe 'on #following?' do
58
- describe 'for current logged user' do
59
- describe 'on a not followed user' do
60
- subject do
61
- stub_dribbble :get, '/user/following/483195', DribbbleAPI::UserFollowNotFound
62
- @user.following?
63
- end
64
-
65
- it 'return false' do
66
- expect(subject).to be_falsy
67
- end
16
+ expect(@user.send(field)).to eq(value)
68
17
  end
69
-
70
- describe 'on a followed user' do
71
- subject do
72
- stub_dribbble :get, '/user/following/483195', DribbbleAPI::UserFollowSuccess
73
- @user.following?
74
- end
75
-
76
- it 'return true' do
77
- expect(subject).to be_truthy
78
- end
79
- end
80
- end
81
-
82
- describe 'for another user' do
83
- describe 'on a not followed user' do
84
- subject do
85
- stub_dribbble :get, '/users/483195/following/1', DribbbleAPI::UserFollowNotFound
86
- @user.following? 1
87
- end
88
-
89
- it 'return false' do
90
- expect(subject).to be_falsy
91
- end
92
- end
93
-
94
- describe 'on a followed user' do
95
- subject do
96
- stub_dribbble :get, '/users/483195/following/1', DribbbleAPI::UserFollowSuccess
97
- @user.following? 1
98
- end
99
-
100
- it 'return true' do
101
- expect(subject).to be_truthy
102
- end
103
- end
104
- end
105
- end
106
-
107
- describe 'on #follow!' do
108
- subject do
109
- stub_dribbble :put, '/users/483195/follow', DribbbleAPI::UserFollowCreated
110
- @user.follow!
111
- end
112
-
113
- it 'return true' do
114
- expect(subject).to be_truthy
115
- end
116
- end
117
-
118
- describe 'on #unfollow!' do
119
- subject do
120
- stub_dribbble :delete, '/users/483195/follow', DribbbleAPI::UserFollowDeleted
121
- @user.unfollow!
122
- end
123
-
124
- it 'return true' do
125
- expect(subject).to be_truthy
126
- end
127
- end
128
-
129
- describe '#likes' do
130
- subject do
131
- stub_dribbble :get, '/users/483195/likes', DribbbleAPI::UserLikesSuccess
132
- @user.likes
133
- end
134
-
135
- it 'responds with shots' do
136
- expect(subject.size).to eq 1
137
- expect(subject.first).to be_a Dribbble::Shot
138
- expect(subject.first.title).to eq('Sasquatch')
139
- end
140
- end
141
-
142
- describe '#projects' do
143
- subject do
144
- stub_dribbble :get, '/users/483195/projects', DribbbleAPI::ProjectsSuccess
145
- @user.projects
146
- end
147
-
148
- it 'responds with projects' do
149
- expect(subject.size).to eq 1
150
- expect(subject.first).to be_a Dribbble::Project
151
- end
152
- end
153
-
154
- describe '#shots' do
155
- subject do
156
- stub_dribbble :get, '/users/483195/shots', DribbbleAPI::ShotsSuccess
157
- @user.shots
158
- end
159
-
160
- it 'responds with buckets' do
161
- expect(subject.size).to eq 2
162
- expect(subject.first).to be_a Dribbble::Shot
163
- end
164
- end
165
-
166
- describe '#teams' do
167
- subject do
168
- stub_dribbble :get, '/users/483195/teams', DribbbleAPI::TeamsSuccess
169
- @user.teams
170
- end
171
-
172
- it 'responds with teams' do
173
- expect(subject.size).to eq 1
174
- expect(subject.first).to be_a Dribbble::Team
175
- end
176
- end
177
- end
178
-
179
- describe 'on class' do
180
- describe 'on #find' do
181
- subject do
182
- stub_dribbble :get, '/users/483195', DribbbleAPI::UserSuccess
183
- Dribbble::User.find 'valid_token', 483_195
184
- end
185
-
186
- it 'return a user' do
187
- expect(subject).to be_a Dribbble::User
188
- expect(subject.id).to eq(483_195)
189
18
  end
190
19
  end
191
20
  end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dribbble'
2
4
  require 'webmock/rspec'
3
5
 
4
- Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
5
7
 
6
8
  # WebMock.disable_net_connect! allow_localhost: true, allow: 'codeclimate.com'
7
9
 
8
10
  RSpec.configure do |config|
9
- config.before :all do
11
+ config.before do
10
12
  WebMock.reset!
11
13
  end
12
14
  end
13
15
 
14
16
  def stub_dribbble(method, path, response_class)
15
- url = /api.dribbble.com\/v1#{Regexp.escape path}(\?.*)?$/
17
+ url = %r{api.dribbble.com/v2#{Regexp.escape path}(\?.*)?$}
16
18
  stub_request(method, url).to_rack(response_class)
17
19
  end
18
20
 
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sinatra/base'
2
4
 
3
5
  class String
4
6
  def underscore
5
- self.gsub(/::/, '/').
6
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
7
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
8
- tr("-", "_").
9
- downcase
7
+ gsub(/::/, '/')
8
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
9
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
10
+ .tr('-', '_')
11
+ .downcase
10
12
  end
11
13
  end
12
14
 
@@ -105,9 +107,9 @@ module DribbbleAPI
105
107
  headers response_headers
106
108
 
107
109
  {
108
- message: "Validation failed.",
110
+ message: 'Validation failed.',
109
111
  errors: [
110
- { attribute: "user", message: "reached the daily limit of 5 shots" }
112
+ { attribute: 'user', message: 'reached the daily limit of 5 shots' }
111
113
  ]
112
114
  }.to_json
113
115
  end
@@ -122,80 +124,25 @@ module DribbbleAPI
122
124
  class AttachmentDeleted < Deleted
123
125
  end
124
126
 
125
- class CommentsSuccess < Found
126
- end
127
-
128
- class CommentSuccess < Found
129
- end
130
-
131
- class CommentCreated < Created
132
- end
133
-
134
- class CommentUpdated < Updated
135
- end
136
-
137
- class CommentDeleted < Deleted
138
- end
139
-
140
- class CommentLikesSuccess < Found
141
- end
142
-
143
- class CommentLikeSuccess < Found
144
- end
145
-
146
- class CommentLikeNotFound < NotFound
147
- end
148
-
149
- class CommentLikeCreated < Created
150
- end
151
-
152
- class CommentLikeDeleted < Deleted
153
- end
154
-
155
127
  class CurrentUserSuccess < Found
156
128
  end
157
129
 
158
- class BucketSuccess < Found
159
- end
160
-
161
- class BucketCreated < Created
162
- end
163
-
164
- class BucketUpdated < Updated
165
- end
166
-
167
- class BucketDeleted < Deleted
168
- end
169
-
170
- class BucketsSuccess < Found
171
- end
172
-
173
- class FollowersSuccess < Found
174
- end
175
-
176
- class FollowingSuccess < Found
177
- end
178
-
179
- class UserFollowSuccess < Found
130
+ class ProjectSuccess < Found
180
131
  end
181
132
 
182
- class UserFollowNotFound < NotFound
133
+ # TODO: pending
134
+ class ProjectsSuccess < Found
183
135
  end
184
136
 
185
- class UserFollowCreated < NoContent
137
+ class ProjectsAccepted < Found
186
138
  end
187
139
 
188
- class UserFollowDeleted < Deleted
140
+ class ProjectsDeleted < Found
189
141
  end
190
142
 
191
- class UserLikesSuccess < Found
192
- end
193
-
194
- class ProjectSuccess < Found
195
- end
196
-
197
- class ProjectsSuccess < Found
143
+ class ProjectsUpdated < Found
198
144
  end
145
+ # END
199
146
 
200
147
  class ShotUpdated < Updated
201
148
  end
@@ -209,32 +156,14 @@ module DribbbleAPI
209
156
  class ShotAccepted < Accepted
210
157
  def response_headers
211
158
  {
212
- 'Location' => 'https://api.dribbble.com/v1/shots/471756'
159
+ 'Location' => 'https://api.dribbble.com/v2/shots/471756'
213
160
  }
214
161
  end
215
162
  end
216
163
 
217
- class ShotLikeSuccess < Found
218
- end
219
-
220
- class ShotLikeNotFound < NotFound
221
- end
222
-
223
- class ShotLikeCreated < Created
224
- end
225
-
226
- class ShotLikeDeleted < Deleted
227
- end
228
-
229
- class ShotLikesSuccess < Found
230
- end
231
-
232
164
  class ShotsSuccess < Found
233
165
  end
234
166
 
235
- class TeamsSuccess < Found
236
- end
237
-
238
167
  class UserSuccess < Found
239
168
  end
240
169
 
@@ -1,25 +1,36 @@
1
1
  {
2
- "id" : 8008135,
3
- "name" : "Charley D.",
4
- "username" : "Calyhre",
5
- "html_url" : "https://dribbble.com/Calyhre",
6
- "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/483195/avatars/normal/493064787.png?1390292526",
7
- "bio" : "",
8
- "location" : null,
9
- "links" : {},
10
- "followers_count" : 1,
11
- "followings_count" : 4,
12
- "likes_count" : 4,
13
- "shots_count" : 0,
14
- "type" : "Player",
15
- "pro" : false,
16
- "buckets_url" : "https://api.dribbble.com/v1/users/483195/buckets",
17
- "followers_url" : "https://api.dribbble.com/v1/users/483195/followers",
18
- "following_url" : "https://api.dribbble.com/v1/users/483195/following",
19
- "likes_url" : "https://api.dribbble.com/v1/users/483195/likes",
20
- "projects_url" : "https://api.dribbble.com/v1/users/483195/projects",
21
- "shots_url" : "https://api.dribbble.com/v1/users/483195/shots",
22
- "teams_url" : "https://api.dribbble.com/v1/users/483195/teams",
23
- "created_at" : "2014-01-21T08:22:06Z",
24
- "updated_at" : "2014-09-29T19:39:00Z"
25
- }
2
+ "id" : 1,
3
+ "name" : "Dan Cederholm",
4
+ "login" : "simplebits",
5
+ "html_url" : "https://dribbble.com/simplebits",
6
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/1/avatars/normal/dc.jpg?1371679243",
7
+ "bio" : "Co-founder &amp; designer of <a href=\"https://dribbble.com/dribbble\">@Dribbble</a>. Principal of SimpleBits. Aspiring clawhammer banjoist.",
8
+ "location" : "Salem, MA",
9
+ "links" : {
10
+ "web" : "http://simplebits.com",
11
+ "twitter" : "https://twitter.com/simplebits"
12
+ },
13
+ "can_upload_shot" : true,
14
+ "pro" : true,
15
+ "followers_count" : 66557,
16
+ "created_at" : "2009-07-08T02:51:22Z",
17
+ "type" : "User",
18
+ "teams" : [
19
+ {
20
+ "id" : 39,
21
+ "name" : "Dribbble",
22
+ "login" : "dribbble",
23
+ "html_url" : "https://dribbble.com/dribbble",
24
+ "avatar_url" : "https://d13yacurqjgara.cloudfront.net/users/39/avatars/normal/apple-flat-precomposed.png?1388527574",
25
+ "bio" : "Show and tell for designers. This is Dribbble on Dribbble.",
26
+ "location" : "Salem, MA",
27
+ "links" : {
28
+ "web" : "http://dribbble.com",
29
+ "twitter" : "https://twitter.com/dribbble"
30
+ },
31
+ "type" : "Team",
32
+ "created_at" : "2009-08-18T18:34:31Z",
33
+ "updated_at" : "2014-02-14T22:32:11Z"
34
+ }
35
+ ]
36
+ }
@@ -5,4 +5,4 @@
5
5
  "shots_count" : 4,
6
6
  "created_at" : "2011-04-14T03:43:47Z",
7
7
  "updated_at" : "2012-04-04T22:39:53Z"
8
- }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id" : 3,
3
+ "name" : "Project title",
4
+ "description" : "Project description",
5
+ "shots_count" : 4,
6
+ "created_at" : "2011-04-14T03:43:47Z",
7
+ "updated_at" : "2012-04-04T22:39:53Z"
8
+ }