unsplash 1.0.0 → 1.1.0

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: 3c3b0a55df308e108c6686fca4ab24543ecc3f35
4
- data.tar.gz: 46c10585ae04725bd4b9d473f43956dad42ec72f
3
+ metadata.gz: 225c7f132cc0a217b99815db374ffc07623930cb
4
+ data.tar.gz: bf58f236014eff003ba68afc41889856d7dbc866
5
5
  SHA512:
6
- metadata.gz: f32b686cc96389aabc529b0483a0f7bcd727dd79c3044153d8f38a8a6e44abc2be154c5aa97b6d2c84a40272dab3759c0ea5390fca2d3fe779ef5478869753f7
7
- data.tar.gz: c3f25050f557dae7210fb3fa481ae7e184f92bc5addc1396c3224c6fb367fda5a13af982d6e9b1e1fcf3ffc50fbb380930e4374fd8c9990114673865fc949a20
6
+ metadata.gz: ecd2faeada759be7f8413f5e27c6b6b6c69790b675de3f59846bce26d291cbb2514e3cf58104850564f4bbb1da32f05267309a0d19110e2d14cead608b27620f
7
+ data.tar.gz: 91ebafb974c916f86f96dbc4e105c4e06bb713dc62176b28f865433cb4f46a11452ee3f38462d0f1158d79d8b72fda72098341231779650bb952d5a666636fdb
@@ -16,12 +16,36 @@ module Unsplash # :nodoc:
16
16
  w: width,
17
17
  h: height,
18
18
  rect: crop_rect
19
- }.delete_if { |k,v| !v }
19
+ }.select { |k,v| v }
20
20
  photo = Unsplash::Photo.new JSON.parse(connection.get("/photos/#{id}", custom).body)
21
21
  photo.user = Unsplash::User.new photo.user
22
22
  photo
23
23
  end
24
24
 
25
+ # Get a random photo. The photo selection pool can be narrowed using
26
+ # a combination of optional parameters. Can also optionally specify a custom image size.
27
+ # @param categories [Array] Limit selection to given category ID's.
28
+ # @param featured [Boolean] Limit selection to featured photos.
29
+ # @param user [String] Limit selection to given User's ID.
30
+ # @param query [String] Limit selection to given search query.
31
+ # @param width [Integer] Width of customized version of the photo.
32
+ # @param height [Integer] Height of the customized version of the photo.
33
+ # @return [Unsplash::Photo] An Unsplash Photo.
34
+ def random(categories: nil, featured: nil, user: nil, query: nil, width: nil, height: nil)
35
+ params = {
36
+ category: (categories && categories.join(",")),
37
+ featured: featured,
38
+ username: user,
39
+ query: query,
40
+ w: width,
41
+ h: height
42
+ }.select { |k,v| v }
43
+
44
+ photo = Unsplash::Photo.new JSON.parse(connection.get("/photos/random", params).body)
45
+ photo.user = Unsplash::User.new photo.user
46
+ photo
47
+ end
48
+
25
49
  # Search for photos by keyword.
26
50
  # @param query [String] Keywords to search for.
27
51
  # @param page [Integer] Which page of search results to return.
@@ -1,4 +1,4 @@
1
1
  module Unsplash # :nodoc:
2
2
  # :nodoc:
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
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.0.0
4
+ version: 1.1.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: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty