unsplash 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/lib/unsplash.rb +1 -0
- data/lib/unsplash/collection.rb +5 -5
- data/lib/unsplash/photo.rb +1 -1
- data/lib/unsplash/search.rb +18 -4
- data/lib/unsplash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fddaa858d2caa8978e2114873406405b6f176e3c
|
4
|
+
data.tar.gz: 85e9830ea66bcc617b5feda502f01a316a4c6a5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc7ca8088cea2e1c701f21b2e94e9f61c300d13b8a0b24828ae78a661dcfead1bd3b666f5181b4afecbbac07f85ca2a0fa44f7f5cb17295e4b604f2008190210
|
7
|
+
data.tar.gz: d6db9727af1da4f57373187c52c3a22b21fd52314aa7b539900c30b5e488ea55f56e98d9df3dd50538f2e07a513bc52a4cdc8370d98ed3ca0393afe823809c73
|
data/lib/unsplash.rb
CHANGED
data/lib/unsplash/collection.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module Unsplash # :nodoc:
|
1
|
+
module Unsplash # :nodoc:
|
2
2
|
|
3
3
|
# Unsplash Collection operations.
|
4
4
|
class Collection < Client
|
@@ -30,7 +30,7 @@ module Unsplash # :nodoc:
|
|
30
30
|
# Get a list of all featured collections.
|
31
31
|
# @param page [Integer] Which page of results to return.
|
32
32
|
# @param per_page [Integer] The number of results per page. (default: 10, maximum: 30)
|
33
|
-
# @return [Array] A single page of the +Unsplash::Collection+ list.
|
33
|
+
# @return [Array] A single page of the +Unsplash::Collection+ list.
|
34
34
|
def featured(page = 1, per_page = 10)
|
35
35
|
params = {
|
36
36
|
page: page,
|
@@ -58,7 +58,7 @@ module Unsplash # :nodoc:
|
|
58
58
|
# @param description [String] The collection's description. (optional)
|
59
59
|
# @param private [Boolean] Whether to make the collection private. (optional, default +false+)
|
60
60
|
def create(title: "", description: "", private: false)
|
61
|
-
params = {
|
61
|
+
params = {
|
62
62
|
title: title,
|
63
63
|
description: description,
|
64
64
|
private: private
|
@@ -70,7 +70,7 @@ module Unsplash # :nodoc:
|
|
70
70
|
# @param query [String] Keywords to search for.
|
71
71
|
# @param page [Integer] Which page of search results to return.
|
72
72
|
# @param per_page [Integer] The number of collections search result per page. (default: 10, maximum: 30)
|
73
|
-
# @return [
|
73
|
+
# @return [SearchResult] a list of +Unsplash::Collection+ objects.
|
74
74
|
def search(query, page = 1, per_page = 10)
|
75
75
|
params = {
|
76
76
|
query: query,
|
@@ -93,7 +93,7 @@ module Unsplash # :nodoc:
|
|
93
93
|
# @param description [String] The collection's description. (optional)
|
94
94
|
# @param private [Boolean] Whether to make the collection private. (optional)
|
95
95
|
def update(title: nil, description: nil, private: nil)
|
96
|
-
params = {
|
96
|
+
params = {
|
97
97
|
title: title,
|
98
98
|
description: description,
|
99
99
|
private: private
|
data/lib/unsplash/photo.rb
CHANGED
@@ -77,7 +77,7 @@ module Unsplash # :nodoc:
|
|
77
77
|
# @param query [String] Keywords to search for.
|
78
78
|
# @param page [Integer] Which page of search results to return.
|
79
79
|
# @param per_page [Integer] The number of users search result per page. (default: 10, maximum: 30)
|
80
|
-
# @return [
|
80
|
+
# @return [SearchResult] a list of +Unsplash::Photo+ objects.
|
81
81
|
def search(query, page = 1, per_page = 10)
|
82
82
|
params = {
|
83
83
|
query: query,
|
data/lib/unsplash/search.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
module Unsplash # :nodoc:
|
2
2
|
|
3
|
+
# Decorates Array of klass-type objects with total and total_pages attributes
|
4
|
+
class SearchResult < SimpleDelegator
|
5
|
+
attr_reader :total, :total_pages
|
6
|
+
|
7
|
+
def initialize(decorated, klass)
|
8
|
+
@total = decorated["total"]
|
9
|
+
@total_pages = decorated["total_pages"]
|
10
|
+
|
11
|
+
list = decorated["results"].map do |content|
|
12
|
+
klass.new content.to_hash
|
13
|
+
end
|
14
|
+
|
15
|
+
super(list)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
# Unsplash Search operations
|
4
20
|
class Search < Client
|
5
21
|
|
@@ -8,12 +24,10 @@ module Unsplash # :nodoc:
|
|
8
24
|
# @param url [String] Url to be searched into
|
9
25
|
# @param klass [Class] Class to instantiate the contents with
|
10
26
|
# @param params [Hash] Params for the search
|
27
|
+
# @return [SearchResult] Decorated Array of klass-type objects
|
11
28
|
def search(url, klass, params)
|
12
29
|
list = JSON.parse(connection.get(url, params).body)
|
13
|
-
|
14
|
-
list["results"].map do |content|
|
15
|
-
klass.new content.to_hash
|
16
|
-
end
|
30
|
+
SearchResult.new(list, klass)
|
17
31
|
end
|
18
32
|
end
|
19
33
|
end
|
data/lib/unsplash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unsplash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Klaassen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|