behance 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +143 -63
  4. data/lib/behance/client.rb +3 -1
  5. data/lib/behance/collections.rb +24 -16
  6. data/lib/behance/creatives_to_follow.rb +23 -0
  7. data/lib/behance/fields.rb +12 -1
  8. data/lib/behance/project.rb +36 -30
  9. data/lib/behance/user.rb +91 -35
  10. data/lib/behance/version.rb +1 -1
  11. data/lib/behance/wips.rb +19 -22
  12. data/spec/behance/client_spec.rb +1 -1
  13. data/spec/behance/collections_spec.rb +5 -5
  14. data/spec/behance/creatives_to_follow_spec.rb +44 -0
  15. data/spec/behance/fields_spec.rb +20 -1
  16. data/spec/behance/project_spec.rb +4 -4
  17. data/spec/behance/user_spec.rb +122 -28
  18. data/spec/behance/wips_spec.rb +28 -13
  19. data/spec/fixtures/collection.json +218 -34
  20. data/spec/fixtures/collection_projects.json +688 -88
  21. data/spec/fixtures/collections.json +2192 -104
  22. data/spec/fixtures/creatives_to_follow.json +302 -0
  23. data/spec/fixtures/fields.json +323 -26
  24. data/spec/fixtures/project.json +716 -10
  25. data/spec/fixtures/project_comments.json +13140 -271
  26. data/spec/fixtures/projects.json +786 -339
  27. data/spec/fixtures/user.json +165 -31
  28. data/spec/fixtures/user_appreciations.json +1155 -211
  29. data/spec/fixtures/user_collections.json +2153 -70
  30. data/spec/fixtures/user_followers.json +319 -0
  31. data/spec/fixtures/user_following.json +362 -0
  32. data/spec/fixtures/user_projects.json +2076 -172
  33. data/spec/fixtures/user_stats.json +14 -13
  34. data/spec/fixtures/user_wips.json +2095 -46
  35. data/spec/fixtures/user_work_experience.json +37 -29
  36. data/spec/fixtures/users.json +347 -97
  37. data/spec/fixtures/wip.json +72 -23
  38. data/spec/fixtures/wip_revision.json +28 -8
  39. data/spec/fixtures/wip_revision_comments.json +184 -108
  40. data/spec/fixtures/wips.json +1015 -158
  41. metadata +26 -17
@@ -2,7 +2,7 @@
2
2
  module Behance
3
3
  class Client
4
4
  module Fields
5
- # Public: Retrieve all Creative Fields.
5
+ # Public: Retrieve all Creative Fields (in 'fields').
6
6
  #
7
7
  # Examples
8
8
  #
@@ -12,6 +12,17 @@ module Behance
12
12
  def fields
13
13
  request("fields")["fields"]
14
14
  end
15
+
16
+ # Public: Retrieve all Creative Fields (in 'popular').
17
+ #
18
+ # Examples
19
+ #
20
+ # @client.popular
21
+ #
22
+ # Returns an array of popular creative fields in JSON format.
23
+ def popular
24
+ request("fields")["popular"]
25
+ end
15
26
  end
16
27
  end
17
28
  end
@@ -3,29 +3,35 @@ module Behance
3
3
  class Client
4
4
  module Project
5
5
  # Public: Search for projects.
6
- #
7
- # options - The Hash of options that the API would expect:
8
- # :q - Free text query string.
9
- # :sort - The order the results are returned in.
10
- # Possible values: featured_date (default), apprecia-
11
- # tions, views, comments,
12
- # published_date.
13
- # :time - Limits the search by time.
14
- # Possible values: all (default), today, week, month.
15
- # :field - Limits the search by creative field.
16
- # Accepts a URL-encoded field name from the list of
17
- # defined creative fields.
18
- # :country - Limits the search by a 2-letter FIPS country code.
19
- # :state - Limits the search by state or province name.
20
- # :city - Limits the search by city name.
21
- # :page - The page number of the results, always starting
22
- # with 1.
23
- # :tags - Limits the search by tags.
24
- # Accepts one tag name or a pipe-separated list of
25
- # tag names.
6
+ #
7
+ # options - The Hash with options that the API would expect:
8
+ # :q - Free text query string.
9
+ # :sort - The order the results are returned in.
10
+ # Possible values: featured_date (default),
11
+ # appreciations, views, comments, published_date.
12
+ # :time - Limits the search by time.
13
+ # Possible values: all (default), today, week,
14
+ # month.
15
+ # :field - Limits the search by creative field.
16
+ # Accepts a URL-encoded field name from the list
17
+ # of defined creative fields.
18
+ # :country - Limits the search by a 2-letter FIPS country
19
+ # code.
20
+ # :state - Limits the search by state or province name.
21
+ # :city - Limits the search by city name.
22
+ # :page - The page number of the results, always starting
23
+ # with 1.
24
+ # :tags - Limits the search by tags. Accepts one tag name
25
+ # or a pipe-separated list of tag names.
26
+ # :color_hex - Limit results to an RGB hex value (without #)
27
+ # :color_range - How closely to match the requested color_hex,
28
+ # in color shades (default: 20) [0-255]
29
+ # :license - Filter by creative license.
30
+ # Acronyms found here:
31
+ # http://creativecommons.org/licenses/
26
32
  #
27
33
  # Examples
28
- #
34
+ #
29
35
  # @client.projects
30
36
  # @client.projects(q: "Freelance", state: "CA", field: "Branding")
31
37
  #
@@ -48,20 +54,20 @@ module Behance
48
54
  end
49
55
 
50
56
  # Public: Get the comments for a project
51
- #
52
- # project_id - The ID (Integer) of the project.
53
- # options - The Hash of options that the API would expect:
54
- # :page - The page number of the results, always
55
- # starting with 1.
56
- #
57
+ #
58
+ # project_id - The ID (Integer) of the project.
59
+ # options - The Hash with options that the API would expect:
60
+ # :page - The page number of the results, always starting
61
+ # with 1.
62
+ #
57
63
  # Examples
58
- #
64
+ #
59
65
  # @client.project_comments(1)
60
66
  # @client.project_comments(1, page: 1)
61
- #
67
+ #
62
68
  # Returns an array of project comments in JSON format.
63
69
  def project_comments(project_id, options={})
64
- request("projects/#{project_id}/comments", options)["comments"]
70
+ request("projects/#{project_id}/comments", options)["comments"]
65
71
  end
66
72
  end
67
73
  end
@@ -4,28 +4,28 @@ module Behance
4
4
  module User
5
5
  # Public: Search for users.
6
6
  #
7
- # options - The Hash of options that the API would expect:
7
+ # options - The Hash with options that the API would expect:
8
8
  # :q - Free text query string.
9
- # :field - Limits the search by creative field.
10
- # Accepts a URL-encoded field name from the list of
9
+ # :field - Limits the search by creative field.
10
+ # Accepts a URL-encoded field name from the list of
11
11
  # defined creative fields.
12
12
  # :country - Limits the search by a 2-letter FIPS country code.
13
13
  # :state - Limits the search by state or province name.
14
14
  # :city - Limits the search by city name.
15
- # :page - The page number of the results, always starting
15
+ # :page - The page number of the results, always starting
16
16
  # with 1.
17
- # :sort - The order the results are returned in.
18
- # Possible values: featured_date (default), apprecia-
19
- # tions, views, comments,
20
- # published_date, followed.
21
- # :tags - Limits the search by tags.
22
- # Accepts one tag name or a pipe-separated list of
17
+ # :sort - The order the results are returned in.
18
+ # Possible values: featured_date (default),
19
+ # appreciations, views, comments, published_date,
20
+ # followed.
21
+ # :tags - Limits the search by tags.
22
+ # Accepts one tag name or a pipe-separated list of
23
23
  # tag names.
24
24
  #
25
25
  # Examples
26
26
  #
27
27
  # @client.users
28
- # @client.users(q: "Juan", state: "California", :tags "freelance")
28
+ # @client.users(q: "Juan", state: "California", tags: "freelance")
29
29
  #
30
30
  # Returns an array of users in JSON format.
31
31
  def users(options={})
@@ -46,16 +46,16 @@ module Behance
46
46
  request("users/#{user}")["user"]
47
47
  end
48
48
 
49
- # Public: Get the projects published by an user.
49
+ # Public: Get the projects published by a user.
50
50
  #
51
51
  # user - Can be an ID (Integer) or username (String)
52
- # options - The Hash of options that the API would expect:
53
- # :sort - The order the results are returned in.
54
- # Possible values: featured_date (default), apprecia-
55
- # tions, views, comments, published_date.
56
- # :time - Limits the search by time.
52
+ # options - The Hash with options that the API would expect:
53
+ # :sort - The order the results are returned in.
54
+ # Possible values: featured_date (default),
55
+ # appreciations, views, comments, published_date.
56
+ # :time - Limits the search by time.
57
57
  # Possible values: all (default), today, week, month.
58
- # :page - The page number of the results, always starting
58
+ # :page - The page number of the results, always starting
59
59
  # with 1.
60
60
  #
61
61
  # Examples
@@ -64,7 +64,7 @@ module Behance
64
64
  # @client.user_projects("foo")
65
65
  # @client.user_projects("foo", page: 2, sort: "views")
66
66
  #
67
- # Returns an array of projects published an user in JSON format.
67
+ # Returns an array of projects in JSON format.
68
68
  def user_projects(user, options={})
69
69
  request("users/#{user}/projects", options)["projects"]
70
70
  end
@@ -72,13 +72,13 @@ module Behance
72
72
  # Public: Get the works-in-progress published by a user.
73
73
  #
74
74
  # user - can be an ID (Integer) or username (String).
75
- # options - The Hash of options that the API would expect:
75
+ # options - The Hash with options that the API would expect:
76
76
  # :sort - The order the results are returned in.
77
- # Possible values: featured_date (default), apprecia-
78
- # tions, views, comments, published_date.
79
- # :time - Limits the search by time. Possible values: all
80
- # (default), today, week, month.
81
- # :page - The page number of the results, always starting
77
+ # Possible values: featured_date (default),
78
+ # appreciations, views, comments, published_date.
79
+ # :time - Limits the search by time.
80
+ # Possible values: all (default), today, week, month.
81
+ # :page - The page number of the results, always starting
82
82
  # with 1.
83
83
  #
84
84
  # Examples
@@ -87,29 +87,37 @@ module Behance
87
87
  # @client.user_wips(1, page: 2)
88
88
  # @client.user_wips("foo", sort: "comments", page: 3)
89
89
  #
90
- # Returns an array of work-in-progress of an user in JSON format.
90
+ # Returns an array of work-in-progress in JSON format.
91
91
  def user_wips(user, options={})
92
92
  request("users/#{user}/wips", options)["wips"]
93
93
  end
94
94
 
95
95
  # Public: Get a list of user's recently appreciated projects.
96
96
  #
97
- # user - can be an ID (Integer) or username (String).
97
+ # user - can be an ID (Integer) or username (String).
98
+ # options - The Hash with options that the API would expect:
99
+ # :page - The page number of the results, always starting
100
+ # with 1.
98
101
  #
99
102
  # Examples
100
103
  #
101
104
  # @client.user_appreciations(1)
102
- # @client.user_appreciations("foo")
105
+ # @client.user_appreciations("foo", page: 2)
103
106
  #
104
107
  # Returns an array of user's recently appreciated projects in JSON
105
108
  # format.
106
- def user_appreciations(user)
107
- request("users/#{user}/appreciations")["appreciations"]
109
+ def user_appreciations(user, options={})
110
+ request("users/#{user}/appreciations", options)["appreciations"]
108
111
  end
109
112
 
110
- # Public: Get a list of user's public collections.
113
+ # Public: Get a list of a user's collections.
111
114
  #
112
- # user - can be an ID (Integer) or username (String).
115
+ # user - can be an ID (Integer) or username (String).
116
+ # options - The Hash with options that the API would expect:
117
+ # :time - Limits the search by time.
118
+ # Possible values: all (default), today, week, month.
119
+ # :page - The page number of the results, always starting
120
+ # with 1.
113
121
  #
114
122
  # Examples
115
123
  #
@@ -118,8 +126,8 @@ module Behance
118
126
  #
119
127
  # Returns an array of user's public collections in JSON
120
128
  # format.
121
- def user_collections(user)
122
- request("users/#{user}/collections")["collections"]
129
+ def user_collections(user, options={})
130
+ request("users/#{user}/collections", options)["collections"]
123
131
  end
124
132
 
125
133
  # Public: Get user's statistics (all-time and today).
@@ -136,7 +144,55 @@ module Behance
136
144
  request("users/#{user}/stats")["stats"]
137
145
  end
138
146
 
139
- # Public: A list of the user's professional experience.
147
+ # Public: Get a list of creatives who follow the user.
148
+ #
149
+ # user - can be an ID (Integer) or username (String).
150
+ # options - The Hash with options that the API would expect:
151
+ # :page - The page number of the results, always starting
152
+ # with 1.
153
+ # :sort - The order the results are returned in.
154
+ # Possible values: created_date (default),
155
+ # appreciations, views, comments, followed, alpha.
156
+ # :sort_order - The direction in which the results are returned.
157
+ # Possible values: asc, desc.
158
+ # :per_page - The number of results per page. (Max: 20)
159
+ #
160
+ # Examples
161
+ #
162
+ # @client.user_followers(1)
163
+ # @client.user_followers(1, page: 2)
164
+ # @client.user_followers("foo", sort: "alpha", page: 3)
165
+ #
166
+ # Returns an array of creatives who follow the user in JSON format.
167
+ def user_followers(user, options={})
168
+ request("users/#{user}/followers", options)["followers"]
169
+ end
170
+
171
+ # Public: Get a list of creatives followed by the user.
172
+ #
173
+ # user - can be an ID (Integer) or username (String).
174
+ # options - The Hash with options that the API would expect:
175
+ # :page - The page number of the results, always starting
176
+ # with 1.
177
+ # :sort - The order the results are returned in.
178
+ # Possible values: created_date (default),
179
+ # appreciations, views, comments, followed, alpha.
180
+ # :sort_order - The direction in which the results are returned.
181
+ # Possible values: asc, desc.
182
+ # :per_page - The number of results per page. (Max: 20)
183
+ #
184
+ # Examples
185
+ #
186
+ # @client.user_following(1)
187
+ # @client.user_following(1, page: 2)
188
+ # @client.user_following("foo", sort: "alpha", page: 3)
189
+ #
190
+ # Returns an array of creatives followed by the user in JSON format.
191
+ def user_following(user, options={})
192
+ request("users/#{user}/following", options)["following"]
193
+ end
194
+
195
+ # Public: A list of the user's professional experience
140
196
  #
141
197
  # user - can be an ID (Integer) or username (String).
142
198
  #
@@ -1,3 +1,3 @@
1
1
  module Behance
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -5,17 +5,14 @@ module Behance
5
5
  # Public: Search for works-in-progress.
6
6
  #
7
7
  # options - The Hash with options that the API would expect:
8
- # :time - Limits the search by time.
9
- # Possible values: all (default), today,
10
- # week, month.
11
- # :page - The page number of the results, always
12
- # starting with 1.
13
- # :sort - The order the results are returned in.
14
- # Possible values: comments (default),
15
- # views, last_item_added_date.
16
- # :tags - Limits the search by tags. Accepts one
17
- # tag name or a pipe-separated list of tag
18
- # names.
8
+ # :q - Free text query string.
9
+ # :page - The page number of the results, always starting
10
+ # with 1.
11
+ # :sort - The order the results are returned in.
12
+ # Possible values: comments (default), views,
13
+ # last_item_added_date.
14
+ # :time - Limits the search by time.
15
+ # Possible values: all, today (default), week, month.
19
16
  #
20
17
  # Examples
21
18
  #
@@ -32,7 +29,7 @@ module Behance
32
29
  # wip_id - The ID (Integer) of a wip.
33
30
  #
34
31
  # Examples
35
- #
32
+ #
36
33
  # @client.wip(69)
37
34
  #
38
35
  # Returns a wip in JSON format.
@@ -40,13 +37,11 @@ module Behance
40
37
  request("wips/#{wip_id}")["wip"]
41
38
  end
42
39
 
43
- # Public: Get information and contents of a revision of a
40
+ # Public: Get information and contents of a revision of a
44
41
  # work in progress.
45
42
  #
46
- # wip_id - The ID (Integer) from the work in progress
47
- # to look for.
48
- # revision_id - The ID (Integer) from the revision to look
49
- # for.
43
+ # wip_id - The ID (Integer) from the work in progress to look for.
44
+ # revision_id - The ID (Integer) from the revision to look for.
50
45
  #
51
46
  # Examples
52
47
  #
@@ -61,17 +56,19 @@ module Behance
61
56
  #
62
57
  # wip_id - The ID (Integer) from the work in progress
63
58
  # to look for.
64
- # revision_id - The ID (Integer) from the revision to look
59
+ # revision_id - The ID (Integer) from the revision to look
65
60
  # for.
61
+ # options - The Hash with options that the API would expect:
62
+ # :page - The page number of the results, always starting
63
+ # with 1.
66
64
  #
67
65
  # Examples
68
66
  #
69
67
  # @client.wip_revision_comments(69, 133)
70
68
  #
71
- # Returns a work-in-progress revision comments in JSON
72
- # format.
73
- def wip_revision_comments(wip_id, revision_id)
74
- request("wips/#{wip_id}/#{revision_id}/comments")["comments"]
69
+ # Returns a work-in-progress revision comments in JSON format.
70
+ def wip_revision_comments(wip_id, revision_id, options={})
71
+ request("wips/#{wip_id}/#{revision_id}/comments", options)["comments"]
75
72
  end
76
73
  end
77
74
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Behance::Client do
4
4
 
5
5
  before do
6
- @client = Behance::Client.new(:access_token => "abc123")
6
+ @client = Behance::Client.new(access_token: "abc123")
7
7
  end
8
8
 
9
9
  it "initializes properly" do
@@ -24,7 +24,7 @@ describe Behance::Client::Collections do
24
24
  end
25
25
 
26
26
  it "gets an collections list" do
27
- @collections.size.should == 3
27
+ @collections.size.should == 10
28
28
  end
29
29
  end
30
30
 
@@ -36,7 +36,7 @@ describe Behance::Client::Collections do
36
36
  end
37
37
 
38
38
  it "gets an collections list" do
39
- @collections = @client.collections(@options).size.should == 3
39
+ @collections = @client.collections(@options).size.should == 10
40
40
  end
41
41
  end
42
42
  end
@@ -54,7 +54,7 @@ describe Behance::Client::Collections do
54
54
  end
55
55
 
56
56
  it "gets a single collection" do
57
- @collection["id"].should == "4776629"
57
+ @collection["id"].should == 9866
58
58
  end
59
59
  end
60
60
 
@@ -72,7 +72,7 @@ describe Behance::Client::Collections do
72
72
  end
73
73
 
74
74
  it "gets a list of projects" do
75
- @projects.size.should == 2
75
+ @projects.size.should == 12
76
76
  end
77
77
  end
78
78
 
@@ -85,7 +85,7 @@ describe Behance::Client::Collections do
85
85
 
86
86
  it "gets a list of projects" do
87
87
  @projects = @client.collection_projects(1, @options).
88
- size.should == 2
88
+ size.should == 12
89
89
  end
90
90
  end
91
91
  end