unsplash 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +68 -7
- data/lib/unsplash.rb +1 -0
- data/lib/unsplash/collection.rb +117 -0
- data/lib/unsplash/user.rb +10 -0
- data/lib/unsplash/version.rb +1 -1
- data/unsplash.gemspec +1 -1
- metadata +26 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c270d06e73d9951fcb6808fa645cbd9c57266e46
|
4
|
+
data.tar.gz: ea1891f304977f90e205c526688cc74b793a3a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e568f428a4e6573c902f8fd76646401fa3caa4ccce7f03ac73ada9fb631683bba2c4fdcff218a35a7eec9eb9b252b106abb5e86b16151ca8464f77d946a01f
|
7
|
+
data.tar.gz: 069e2c2255abd6dce7892ae7ee97cfdf86e955f2f9eb3a9e0c14a524867b0eabd1a418a1775d0d4bd74203821b307ea465e86f807d349b7a1d0734c9c18db70f
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,13 +1,74 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
3
|
+
## Our Pledge
|
4
4
|
|
5
|
-
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
6
11
|
|
7
|
-
|
12
|
+
## Our Standards
|
8
13
|
|
9
|
-
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
10
16
|
|
11
|
-
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
12
22
|
|
13
|
-
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dev@unsplash.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/lib/unsplash.rb
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
module Unsplash # :nodoc:
|
2
|
+
|
3
|
+
# Unsplash Collection operations.
|
4
|
+
class Collection < Client
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# Get a specific collection.
|
9
|
+
# @param id [Integer] The ID of the collection.
|
10
|
+
# @return [Unsplash::Collection] The requested collection.
|
11
|
+
def find(id, curated = false)
|
12
|
+
url = ["/collections", (curated ? "curated" : nil), id].compact.join("/")
|
13
|
+
Unsplash::Collection.new JSON.parse(connection.get(url).body)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get a list of all collections.
|
17
|
+
# @param page [Integer] Which page of search results to return.
|
18
|
+
# @param per_page [Integer] The number of search results per page.
|
19
|
+
# @return [Array] A single page of the +Unsplash::Collection+ list.
|
20
|
+
def all(page = 1, per_page = 10)
|
21
|
+
params = {
|
22
|
+
page: page,
|
23
|
+
per_page: per_page
|
24
|
+
}
|
25
|
+
list = JSON.parse(connection.get("/collections/", params).body)
|
26
|
+
list.map { |data| Unsplash::Collection.new(data) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get a list of all curated collections.
|
30
|
+
# @param page [Integer] Which page of search results to return.
|
31
|
+
# @param per_page [Integer] The number of search results per page.
|
32
|
+
# @return [Array] A single page of the +Unsplash::Collection+ list.
|
33
|
+
def curated(page = 1, per_page = 10)
|
34
|
+
params = {
|
35
|
+
page: page,
|
36
|
+
per_page: per_page
|
37
|
+
}
|
38
|
+
list = JSON.parse(connection.get("/collections/curated", params).body)
|
39
|
+
list.map { |data| Unsplash::Collection.new(data) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new collection on behalf of current user.
|
43
|
+
# @param title [String] The title of the collection.
|
44
|
+
# @param description [String] The collection's description. (optional)
|
45
|
+
# @param private [Boolean] Whether to make the collection private. (optional, default +false+)
|
46
|
+
def create(title: "", description: "", private: false)
|
47
|
+
params = {
|
48
|
+
title: title,
|
49
|
+
description: description,
|
50
|
+
private: private
|
51
|
+
}
|
52
|
+
Unsplash::Collection.new JSON.parse(connection.post("/collections", params).body)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(options = {})
|
58
|
+
options["user"] = Unsplash::User.new options["user"]
|
59
|
+
options["cover_photo"] = Unsplash::Photo.new options["cover_photo"]
|
60
|
+
super(options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Update the collection's attributes.
|
64
|
+
# @param title [String] The title of the collection.
|
65
|
+
# @param description [String] The collection's description. (optional)
|
66
|
+
# @param private [Boolean] Whether to make the collection private. (optional)
|
67
|
+
def update(title: nil, description: nil, private: nil)
|
68
|
+
params = {
|
69
|
+
title: title,
|
70
|
+
description: description,
|
71
|
+
private: private
|
72
|
+
}.select { |k,v| v }
|
73
|
+
updated = JSON.parse(connection.put("/collections/#{id}", params).body)
|
74
|
+
self.title = updated["title"]
|
75
|
+
self.description = updated["description"]
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
# Delete the collection. This does not delete the photos it contains.
|
80
|
+
# @return [Boolean] +true+ on success.
|
81
|
+
def destroy
|
82
|
+
response = connection.delete("/collections/#{id}")
|
83
|
+
response.status == 204
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get a list of the photos contained in this collection.
|
87
|
+
# @return [Array] The list of +Unsplash::Photo+s in the collection.
|
88
|
+
def photos
|
89
|
+
list = JSON.parse(connection.get("/collections/#{id}/photos").body)
|
90
|
+
list.map { |photo| Unsplash::Photo.new photo }
|
91
|
+
end
|
92
|
+
|
93
|
+
# Add a photo to the collection. If the photo is already in the collection,
|
94
|
+
# this action has no effect.
|
95
|
+
# @param [Unsplash::Photo] The photo to add.
|
96
|
+
# @return [Hash] Collected photo metadata.
|
97
|
+
def add(photo)
|
98
|
+
response = JSON.parse(connection.post("/collections/#{id}/add", { photo_id: photo.id }).body)
|
99
|
+
{
|
100
|
+
photo_id: response["photo"]["id"],
|
101
|
+
collection_id: response["collection"]["id"],
|
102
|
+
user_id: response["user"]["id"],
|
103
|
+
created_at: response["created_at"]
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
# Remove a photo from the collection. If the photo is not in the collection,
|
108
|
+
# this action has no effect.
|
109
|
+
# @param [Unsplash::Photo] The photo to remove.
|
110
|
+
# @return [Boolean] +true+ on success.
|
111
|
+
def remove(photo)
|
112
|
+
response = connection.delete("/collections/#{id}/remove", photo_id: photo.id)
|
113
|
+
response.status == 204
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
data/lib/unsplash/user.rb
CHANGED
@@ -44,6 +44,16 @@ module Unsplash # nodoc:
|
|
44
44
|
Unsplash::Photo.new photo.to_hash
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
# Get a list of photos liked by the user.
|
49
|
+
# @return [Array] a list of +Unsplash::Collection+ objects.
|
50
|
+
def collections
|
51
|
+
list = JSON.parse(connection.get("/users/#{username}/collections").body)
|
52
|
+
list.map do |collection|
|
53
|
+
Unsplash::Collection.new collection.to_hash
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
47
57
|
end
|
48
58
|
|
49
59
|
end
|
data/lib/unsplash/version.rb
CHANGED
data/unsplash.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["aaron@crew.co"]
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby wrapper for the Unsplash API.}
|
13
|
-
spec.homepage = "https://github.com/
|
13
|
+
spec.homepage = "https://github.com/unsplash/unsplash_rb"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unsplash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Klaassen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.13.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.13.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oauth2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.3.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 2.9.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.9.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.20.4
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.20.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: pry
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description:
|
@@ -115,11 +115,11 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .ruby-version
|
121
|
+
- .travis.yml
|
122
|
+
- .yardopts
|
123
123
|
- CODE_OF_CONDUCT.md
|
124
124
|
- Gemfile
|
125
125
|
- LICENSE.txt
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/unsplash.rb
|
131
131
|
- lib/unsplash/category.rb
|
132
132
|
- lib/unsplash/client.rb
|
133
|
+
- lib/unsplash/collection.rb
|
133
134
|
- lib/unsplash/configuration.rb
|
134
135
|
- lib/unsplash/connection.rb
|
135
136
|
- lib/unsplash/curated_batch.rb
|
@@ -139,7 +140,7 @@ files:
|
|
139
140
|
- lib/unsplash/user.rb
|
140
141
|
- lib/unsplash/version.rb
|
141
142
|
- unsplash.gemspec
|
142
|
-
homepage: https://github.com/
|
143
|
+
homepage: https://github.com/unsplash/unsplash_rb
|
143
144
|
licenses:
|
144
145
|
- MIT
|
145
146
|
metadata: {}
|
@@ -149,17 +150,17 @@ require_paths:
|
|
149
150
|
- lib
|
150
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
152
|
requirements:
|
152
|
-
- -
|
153
|
+
- - '>='
|
153
154
|
- !ruby/object:Gem::Version
|
154
155
|
version: 2.0.0
|
155
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
157
|
requirements:
|
157
|
-
- -
|
158
|
+
- - '>='
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
requirements: []
|
161
162
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.4.
|
163
|
+
rubygems_version: 2.4.6
|
163
164
|
signing_key:
|
164
165
|
specification_version: 4
|
165
166
|
summary: Ruby wrapper for the Unsplash API.
|