pixabay_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -1
- data/README.md +20 -8
- data/lib/pixabay_api/api_base.rb +1 -0
- data/lib/pixabay_api/request.rb +8 -6
- data/lib/version.rb +1 -1
- data/pixabay_api.gemspec +2 -0
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8d30eb1f0c56f697cf6834ccec6da4935e2d33
|
4
|
+
data.tar.gz: 8acd0de24924437cb650e69c0f8e57fe895ae315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e16c7f4376d8a068ad9fb1d564490eccea82c206326fa5cf70f346ee9131927cecf0607167c73af59f04873f25f0110415d806ed55ed7a8a3dec3f75c3272531
|
7
|
+
data.tar.gz: 48692dbf5a89a7c656cb83f06e662cdad70038376335a8e3cd9bca5adc93d8fc50932bb1fe7e8f6821a5de84c43efc3491f8a203ba62698371ae32fbb789ec1b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pixabay_api (0.0.
|
4
|
+
pixabay_api (0.0.3)
|
5
5
|
http (~> 2.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -11,9 +11,16 @@ GEM
|
|
11
11
|
public_suffix (>= 2.0.2, < 4.0)
|
12
12
|
ast (2.3.0)
|
13
13
|
coderay (1.1.2)
|
14
|
+
coveralls (0.8.21)
|
15
|
+
json (>= 1.8, < 3)
|
16
|
+
simplecov (~> 0.14.1)
|
17
|
+
term-ansicolor (~> 1.3)
|
18
|
+
thor (~> 0.19.4)
|
19
|
+
tins (~> 1.6)
|
14
20
|
crack (0.4.3)
|
15
21
|
safe_yaml (~> 1.0.0)
|
16
22
|
diff-lcs (1.3)
|
23
|
+
docile (1.1.5)
|
17
24
|
domain_name (0.5.20170404)
|
18
25
|
unf (>= 0.0.5, < 1.0.0)
|
19
26
|
hashdiff (0.3.6)
|
@@ -26,6 +33,7 @@ GEM
|
|
26
33
|
domain_name (~> 0.5)
|
27
34
|
http-form_data (1.0.3)
|
28
35
|
http_parser.rb (0.6.0)
|
36
|
+
json (2.1.0)
|
29
37
|
method_source (0.9.0)
|
30
38
|
parser (2.4.0.0)
|
31
39
|
ast (~> 2.2)
|
@@ -58,6 +66,15 @@ GEM
|
|
58
66
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
59
67
|
ruby-progressbar (1.9.0)
|
60
68
|
safe_yaml (1.0.4)
|
69
|
+
simplecov (0.14.1)
|
70
|
+
docile (~> 1.1.0)
|
71
|
+
json (>= 1.8, < 3)
|
72
|
+
simplecov-html (~> 0.10.0)
|
73
|
+
simplecov-html (0.10.2)
|
74
|
+
term-ansicolor (1.6.0)
|
75
|
+
tins (~> 1.0)
|
76
|
+
thor (0.19.4)
|
77
|
+
tins (1.15.0)
|
61
78
|
unf (0.1.4)
|
62
79
|
unf_ext
|
63
80
|
unf_ext (0.0.7.4)
|
@@ -72,10 +89,12 @@ PLATFORMS
|
|
72
89
|
|
73
90
|
DEPENDENCIES
|
74
91
|
bundler (~> 1.15)
|
92
|
+
coveralls (>= 0.7.0)
|
75
93
|
pixabay_api!
|
76
94
|
pry (~> 0.11.1)
|
77
95
|
rspec (~> 3.0)
|
78
96
|
rubocop (~> 0.47.1)
|
97
|
+
simplecov (>= 0.8.2)
|
79
98
|
webmock (~> 3.0)
|
80
99
|
|
81
100
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Pixabay_api
|
2
|
-
[![Code Climate](https://codeclimate.com/github/haanhduclinh/s3-to-ftp.png)](https://codeclimate.com/github/haanhduclinh/s3-to-ftp) [![CI](https://travis-ci.org/haanhduclinh/pixabay_api.svg?branch=master)](https://travis-ci.org/haanhduclinh/pixabay_api)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/pixabay_api.svg)](https://badge.fury.io/rb/pixabay_api) [![Code Climate](https://codeclimate.com/github/haanhduclinh/s3-to-ftp.png)](https://codeclimate.com/github/haanhduclinh/s3-to-ftp) [![CI](https://travis-ci.org/haanhduclinh/pixabay_api.svg?branch=master)](https://travis-ci.org/haanhduclinh/pixabay_api) [![Coverage Status](https://coveralls.io/repos/github/haanhduclinh/pixabay_api/badge.svg?branch=master)](https://coveralls.io/github/haanhduclinh/pixabay_api?branch=master)
|
3
3
|
|
4
4
|
# Background
|
5
5
|
- Use PixaBayApi to get image data from pixabay.com follow API - https://pixabay.com/api/docs/.
|
@@ -39,12 +39,11 @@ You can configure as below:
|
|
39
39
|
|
40
40
|
# Usage
|
41
41
|
|
42
|
-
##
|
42
|
+
## Get pictures data
|
43
43
|
|
44
44
|
```ruby
|
45
45
|
images_api = PixabayApi::ImagesApi.new
|
46
|
-
|
47
|
-
pictures = images_api.find(keyword: 'test', options: options)
|
46
|
+
pictures = images_api.find(keyword: 'test')
|
48
47
|
|
49
48
|
p pictures.success?
|
50
49
|
p pictures.body['totalHits']
|
@@ -85,7 +84,6 @@ samples return
|
|
85
84
|
]
|
86
85
|
}
|
87
86
|
```
|
88
|
-
- There is many options - https://github.com/haanhduclinh/pixabay_api#search-images
|
89
87
|
|
90
88
|
## Get picture array data
|
91
89
|
|
@@ -130,6 +128,23 @@ It will be return picture array
|
|
130
128
|
|
131
129
|
```
|
132
130
|
|
131
|
+
## Get pictures data with options
|
132
|
+
- we can use options like below
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
images_api = PixabayApi::ImagesApi.new
|
136
|
+
options = { category: 'animals', lang: 'vi' }
|
137
|
+
picture = images_api.find(keyword: 'test', options: options)
|
138
|
+
# or
|
139
|
+
pictures = images_api.find_and_return_array(keyword: 'test', options: options)
|
140
|
+
```
|
141
|
+
|
142
|
+
- There are several options for video and image. You can check:
|
143
|
+
|
144
|
+
images: https://github.com/haanhduclinh/pixabay_api#search-images
|
145
|
+
|
146
|
+
videos: https://github.com/haanhduclinh/pixabay_api#search-videos
|
147
|
+
|
133
148
|
## Get video data and return array_data
|
134
149
|
|
135
150
|
|
@@ -211,9 +226,6 @@ To keep the Pixabay API fast for everyone, requests must be cached for 24 hours.
|
|
211
226
|
# Run test
|
212
227
|
- `bundle exec rspec`
|
213
228
|
|
214
|
-
# Require
|
215
|
-
- ruby 2.3
|
216
|
-
|
217
229
|
|
218
230
|
# Author
|
219
231
|
|
data/lib/pixabay_api/api_base.rb
CHANGED
data/lib/pixabay_api/request.rb
CHANGED
@@ -4,10 +4,12 @@ require 'resolv-replace'
|
|
4
4
|
|
5
5
|
module PixabayApi
|
6
6
|
class Request
|
7
|
+
attr_accessor :query
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def create(api_key:, params: {}, endpoint: 'xxx')
|
9
|
-
|
10
|
-
uri = URI(query)
|
11
|
+
build_query(api_key, params, endpoint)
|
12
|
+
uri = URI(@query)
|
11
13
|
|
12
14
|
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
13
15
|
request = Net::HTTP::Get.new uri
|
@@ -15,14 +17,14 @@ module PixabayApi
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
private
|
19
|
-
|
20
20
|
def build_query(api_key, params, endpoint)
|
21
|
-
"#{endpoint}?key=#{api_key}&#{params_to_s(params)}"
|
21
|
+
@query = "#{endpoint}?key=#{api_key}&#{params_to_s(params)}"
|
22
22
|
end
|
23
23
|
|
24
|
+
private
|
25
|
+
|
24
26
|
def params_to_s(params)
|
25
|
-
|
27
|
+
URI.encode_www_form(params)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
data/lib/version.rb
CHANGED
data/pixabay_api.gemspec
CHANGED
@@ -24,5 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency 'rspec', '~> 3.0'
|
25
25
|
s.add_development_dependency 'rubocop', '~> 0.47.1'
|
26
26
|
s.add_development_dependency 'pry', '~> 0.11.1'
|
27
|
+
s.add_development_dependency 'simplecov', '>= 0.8.2'
|
28
|
+
s.add_development_dependency 'coveralls', '>= 0.7.0'
|
27
29
|
s.add_dependency 'http', '~> 2.2'
|
28
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixabay_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Duc Linh
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.11.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.7.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.7.0
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: http
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|