unsplash 1.5.0 → 1.5.1

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: 6e38d0698ca01b7ff19c93da8ee6485081268d23
4
- data.tar.gz: 6ee07125feb0c023259edc2fccb028f182ea1f7c
3
+ metadata.gz: fddaa858d2caa8978e2114873406405b6f176e3c
4
+ data.tar.gz: 85e9830ea66bcc617b5feda502f01a316a4c6a5a
5
5
  SHA512:
6
- metadata.gz: 50b9cc311c3268802f4c04e873efeee092aec52419427d300b654dc4e8b8534c4fdc93c7719914e4733e48f4aa8d0d2b28ddb437f1d1a166bfa8a360da88230e
7
- data.tar.gz: f2c9cca9709aba66789c67a40ef8eb37f61d315e7c8b857b04844775c987dc9c3bc65bd5e3b55bfb21ff201c9621fdae0215fd7f3cf8a477c8fda8afb0734a42
6
+ metadata.gz: dc7ca8088cea2e1c701f21b2e94e9f61c300d13b8a0b24828ae78a661dcfead1bd3b666f5181b4afecbbac07f85ca2a0fa44f7f5cb17295e4b604f2008190210
7
+ data.tar.gz: d6db9727af1da4f57373187c52c3a22b21fd52314aa7b539900c30b5e488ea55f56e98d9df3dd50538f2e07a513bc52a4cdc8370d98ed3ca0393afe823809c73
@@ -1,5 +1,6 @@
1
1
  require "oauth2"
2
2
  require "httparty"
3
+ require "delegate"
3
4
 
4
5
  require "unsplash/version"
5
6
  require "unsplash/configuration"
@@ -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 [Array] a list of +Unsplash::Collection+ objects.
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
@@ -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 [Array] a list of +Unsplash::Photo+ objects.
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,
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Unsplash # :nodoc:
2
2
  # :nodoc:
3
- VERSION = "1.5.0"
3
+ VERSION = "1.5.1"
4
4
  end
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.0
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-04-17 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty