pixabay-api 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f96db1663965c645ddcc87f1508db059f0f4e1e2
4
- data.tar.gz: 7c6cdae2b38dc404abf0e7bd2c96560c994de05d
3
+ metadata.gz: fbeddc67dbd49cd5ba5cf6ad6f588ef7a6142b87
4
+ data.tar.gz: 1efd514807ce1edd9f3a8a83d2a57e824625542d
5
5
  SHA512:
6
- metadata.gz: 3265121f3bb56598cffff5f7e773115bebb45b09533cc4e222a559eb1999e838b2979e86cd79c9c8509afce96bc86cc3f99ea94207868565ab0270147256fd90
7
- data.tar.gz: 330c8e0f0dae04d9944551aaf99245d932456b080fc77b4035f22343117d69732b083c8fac2164686f442ba6612a71df7de5708ea47fdba77d75b23201ecde52
6
+ metadata.gz: 49c4f40411da4dd62529e44e6bc2e8cd2c4bfce936f1342b9d5223acf42e6c2b39d75a2c3f9a7e78aa7ae96038f6c35a91838433f7fa15ce9d1f8b1dbcfeaf8a
7
+ data.tar.gz: d708d3d87cb85d24f8699ae348fb742e29d5ba457eaa8770bee21f8a427733db9a4d66b0e37c5146fced2bb7acb8834067fd36bb3924c1b79f5cb02d6c8fde8d
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
- before_install: gem install bundler -v 1.11.2
4
+ before_install: gem install bundler
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Pixabay
2
+ [![Build Status](https://travis-ci.org/kimsuelim/pixabay.svg?branch=master)](https://travis-ci.org/kimsuelim/pixabay)
2
3
 
3
4
  ## DESCRIPTION:
4
5
 
@@ -28,60 +29,134 @@ If you want to configure pixabay through an initializer (e.g. `config/initialize
28
29
 
29
30
  ```ruby
30
31
  Pixabay.configure do |config|
31
- config.api_key = 'API_KEY'
32
+ config.key = "Your API key"
32
33
  config.timeout = 10
33
34
  end
34
35
  ```
35
36
 
36
- Using `Pixabay.new` to get the client, use `pixabay.client`:
37
+ ### Search Images
37
38
 
38
39
  ```ruby
40
+ require 'pixabay'
39
41
  client = Pixabay.new
40
- client.photos(lang: 'ko', safesearch: true, page: 1, per_page: 30)
42
+ res = client.photos(q: "yellow flower", safesearch: true, page: 1, per_page: 30)
43
+ res["total"] # 15526
44
+ res["totalHits"] # 500
45
+ res["hits"] # pictures
41
46
  ```
42
47
 
43
- Avalable Request parameters, see [https://pixabay.com/api/docs/](https://pixabay.com/api/docs/)
48
+ This will find 30 yellow flower pictures.
49
+ If you want high resolution pictures, see (https://pixabay.com/api/docs/?request_full_access)
50
+
51
+ Avalable Request parameters see [https://pixabay.com/api/docs/](https://pixabay.com/api/docs/)
52
+
53
+ ```ruby
54
+ # Default Request parameters
55
+ {
56
+ q: nil, lang: "en", id: nil,
57
+ response_group: "image_details", image_type: "all", orientation: "all", category: nil,
58
+ min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
59
+ order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
60
+ }
61
+ ```
62
+
63
+ Example responses
64
+
65
+ ```ruby
66
+ {
67
+ "totalHits"=>500,
68
+ "hits"=>[
69
+ {
70
+ "previewHeight"=>93,
71
+ "likes"=>87,
72
+ "favorites"=>61,
73
+ "tags"=>"blossom, bloom, flower",
74
+ "webformatHeight"=>400,
75
+ "views"=>28270,
76
+ "webformatWidth"=>640,
77
+ "previewWidth"=>150,
78
+ "comments"=>3,
79
+ "downloads"=>10382,
80
+ "pageURL"=>"https://pixabay.com/en/blossom-bloom-flower-yellow-close-195897/",
81
+ "previewURL"=>"https://cdn.pixabay.com/photo/2013/10/15/09/20/flower-195897_150.jpg",
82
+ "webformatURL"=>"https://pixabay.com/get/e83cb40721f31c2ad65a5854e74b4f94e471e6c818b5184690f0c97faeea_640.jpg",
83
+ "imageWidth"=>4000,
84
+ "user_id"=>48777,
85
+ "user"=>"Josch13", "type"=>"photo",
86
+ "id"=>195897,
87
+ "userImageURL"=>"https://cdn.pixabay.com/user/2013/11/05/02-10-23-764_250x250.jpg",
88
+ "imageHeight"=>2501
89
+ },
90
+ {
91
+ "previewHeight"=>99,
92
+ ...
93
+ },
94
+ ...
95
+ ],
96
+ "total"=>15526
97
+ }
98
+ ```
99
+
100
+ ### Search Videos
101
+
102
+ ```ruby
103
+ require 'pixabay'
104
+ client = Pixabay.new
105
+ res = client.videos(q: "yellow flower", safesearch: true, page: 1, per_page: 30)
106
+ res["total"] # 5593
107
+ res["totalHits"] # 500
108
+ res["hits"] # videos
109
+ ```
110
+
111
+ This will find 30 yellow flower videos.
112
+
113
+ Avalable Request parameters see [https://pixabay.com/api/docs/](https://pixabay.com/api/docs/)
44
114
 
45
115
  ```ruby
46
116
  # Default Request parameters
47
117
  {
48
- response_group: 'image_details', id: nil, q: nil, lang: 'en',
49
- image_type: 'all', orientation: 'all', category: nil, min_width: 0,
50
- min_height: 0, editors_choice: false, safesearch: false,
51
- order: 'popular', page: 1, per_page: 20, callback: nil, pretty: false
118
+ q: nil, lang: "en", id: nil,
119
+ video_type: "all", category: nil,
120
+ min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
121
+ order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
52
122
  }
53
123
  ```
54
124
 
55
125
  Example responses
56
126
 
57
127
  ```ruby
58
- [
59
- {
60
- "previewHeight"=>150,
61
- "likes"=>7,
62
- "favorites"=>7,
63
- "tags"=>"사람, 사람의, 여성",
64
- "webformatHeight"=>640,
65
- "views"=>107,
66
- "webformatWidth"=>427,
67
- "previewWidth"=>100,
68
- "comments"=>2,
69
- "downloads"=>37,
70
- "pageURL"=>"https://pixabay.com/ko/%EC%82%AC%EB%9E%8C-%EC%82%AC%EB%9E%8C%EC%9D%98-%EC%97%AC%EC%84%B1-%EC%86%8C%EB%85%80-1166368/",
71
- "previewURL"=>"https://pixabay.com/static/uploads/photo/2016/01/28/14/59/person-1166368_150.jpg",
72
- "webformatURL"=>"https://pixabay.com/get/e834b7092bf2093ed95c4518b74d419fe170e4d104b0154491f3c17caeedb7_640.jpg",
73
- "imageWidth"=>2667,
74
- "user_id"=>526143,
75
- "user"=>"Pezibear",
76
- "type"=>"photo",
77
- "id"=>1166368,
78
- "userImageURL"=>"https://pixabay.com/static/uploads/user/2015/01/09/23-10-25-395_250x250.jpg",
79
- "imageHeight"=>4000
80
- },
81
- {
128
+ {
129
+ "totalHits"=>500,
130
+ "hits"=>[
131
+ {
132
+ "picture_id"=>"583475757",
133
+ "videos"=>{
134
+ "large"=>{"url"=>"", "width"=>0, "size"=>0, "height"=>0},
135
+ "small"=>{"url"=>"https://player.vimeo.com/external/176277723.sd.mp4?s=a9a3531634d2c42b6e62d10bea241133267589aa&profile_id=165", "width"=>960, "size"=>17298015, "height"=>540},
136
+ "medium"=>{"url"=>"https://player.vimeo.com/external/176277723.hd.mp4?s=9eb4ad96f20973877ff433d12751cd792c5a905d&profile_id=174", "width"=>1280, "size"=>27090188, "height"=>720},
137
+ "tiny"=>{"url"=>"https://player.vimeo.com/external/176277723.sd.mp4?s=a9a3531634d2c42b6e62d10bea241133267589aa&profile_id=164", "width"=>640, "size"=>6193727, "height"=>360}
138
+ },
139
+ "tags"=>"beach, holiday, greece",
140
+ "downloads"=>176636,
141
+ "likes"=>166,
142
+ "favorites"=>120,
143
+ "duration"=>80,
144
+ "id"=>3998,
145
+ "user_id"=>2978946,
146
+ "views"=>40781,
147
+ "comments"=>63,
148
+ "userImageURL"=>"https://cdn.pixabay.com/user/2016/07/25/18-27-26-130_250x250.png",
149
+ "pageURL"=>"https://pixabay.com/videos/id-3998/",
150
+ "type"=>"film", "user"=>"Rc-Aero-Tech"
151
+ },
152
+ {
153
+ "picture_id"=>"583475757",
154
+ ...
155
+ },
82
156
  ...
83
- }
84
- ]
157
+ ],
158
+ "total"=>5593
159
+ }
85
160
  ```
86
161
 
87
162
  ## Development
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
- task :default => :spec
10
+ task :default => :test
@@ -1,5 +1,5 @@
1
1
  require 'pixabay/config'
2
- require "pixabay/version"
2
+ require 'pixabay/version'
3
3
 
4
4
  require 'httparty'
5
5
 
@@ -7,34 +7,40 @@ module Pixabay
7
7
  extend Config
8
8
 
9
9
  def self.new
10
- Pixabay::Client.new(api_key: api_key, timeout: 10)
10
+ Pixabay::Client.new(key: key, timeout: 10)
11
11
  end
12
12
 
13
13
  class Client
14
14
  include HTTParty
15
- base_uri 'https://pixabay.com/api'
15
+ base_uri "https://pixabay.com/api"
16
16
 
17
- options = {
18
- response_group: 'image_details', id: nil, q: nil, lang: 'en',
19
- image_type: 'all', orientation: 'all', category: nil, min_width: 0,
20
- min_height: 0, editors_choice: false, safesearch: false,
21
- order: 'popular', page: 1, per_page: 20, callback: nil, pretty: false
22
-
23
- }
24
-
25
- def initialize(api_key: nil, timeout: 10)
26
- @api_key = api_key
17
+ def initialize(key: nil, timeout: 10)
18
+ @key = key
27
19
  @timeout = timeout
28
20
  end
29
21
 
30
22
  def photos(**options)
31
- options = {
32
- query: {
33
- key: @api_key
34
- }.merge(options)
23
+ default_options = {
24
+ q: nil, lang: "en", id: nil,
25
+ response_group: "image_details", image_type: "all", orientation: "all", category: nil,
26
+ min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
27
+ order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
28
+ }
29
+
30
+ options = { query: { key: @key }.merge(options) }
31
+ self.class.get("", options)
32
+ end
33
+
34
+ def videos(**options)
35
+ default_options = {
36
+ q: nil, lang: "en", id: nil,
37
+ video_type: "all", category: nil,
38
+ min_width: 0, min_height: 0, editors_choice: false, safesearch: false,
39
+ order: "popular", page: 1, per_page: 20, callback: nil, pretty: false
35
40
  }
36
41
 
37
- self.class.get('', options)
42
+ options = { query: { key: @key }.merge(options) }
43
+ self.class.get("/videos", options)
38
44
  end
39
45
  end
40
46
  end
@@ -2,7 +2,7 @@ module Pixabay
2
2
  module Config
3
3
  # pixabay client options
4
4
  OPTION_KEYS = [
5
- :api_key,
5
+ :key,
6
6
  :timeout,
7
7
  ]
8
8
 
@@ -1,3 +1,3 @@
1
1
  module Pixabay
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "httparty", "~> 0.13.7"
22
+ spec.add_dependency "httparty", "~> 0.14.0"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.11"
25
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
26
  spec.add_development_dependency "minitest", "~> 5.0"
27
- spec.add_development_dependency "rubocop", "~> 0.35.1"
27
+ spec.add_development_dependency "rubocop", "~> 0.49.1"
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixabay-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Surim Kim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.7
19
+ version: 0.14.0
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
- version: 0.13.7
26
+ version: 0.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.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
- version: '10.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.35.1
75
+ version: 0.49.1
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
- version: 0.35.1
82
+ version: 0.49.1
83
83
  description: A ruby wrapper for the pixabay API
84
84
  email:
85
85
  - kimsuelim@gmail.com
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.5.1
123
+ rubygems_version: 2.6.11
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: A ruby wrapper for the pixabay API