gifmagazine 0.1.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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/gifmagazine.gemspec +30 -0
- data/lib/gifmagazine.rb +8 -0
- data/lib/gifmagazine/client.rb +69 -0
- data/lib/gifmagazine/resource_based_methods.rb +11 -0
- data/lib/gifmagazine/response.rb +22 -0
- data/lib/gifmagazine/version.rb +3 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff9832cbb2d9c72deaafc69b1db06f82ebd21928
|
4
|
+
data.tar.gz: 47041e4351b4a85f8c0ce790afcbb51a05b88cba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa8afa5d14a40b5375e1cae910265c3de363a6f25d72a65d4bb87dc6d09bd32b9cfa6fdf8d38e5256f4383701066cd16b716c01e666206feea6a9346e5d3f61e
|
7
|
+
data.tar.gz: f2005a42b7dc644219ebf5cd2b137883f14259af3194cbfef7f5554ee4145d0aa6c6b3860b2da1cd216bdbfb197dbf1103bb3d120eb6c52e6a439f363148da38
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 YuheiNakasaka
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Gifmagazine
|
2
|
+
|
3
|
+
Gifmagazine API v1 client library written in Ruby.
|
4
|
+
|
5
|
+
※This client gem is yet beta version.So, this is not covered all endpoints.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gifmagazine'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gifmagazine
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
require 'gifmagazine'
|
27
|
+
|
28
|
+
client = Gifmagazine::Client.new(token: '')
|
29
|
+
client.search({q: '猫', limit: 2, offset: 0})
|
30
|
+
client.emotion({q: 'joy', limit: 2, offset: 0})
|
31
|
+
```
|
32
|
+
|
33
|
+
Public api does not need a token.Token is for sales.
|
34
|
+
|
35
|
+
See [here](https://github.com/creative-box-inc/Gifmagazine-API-Documentation) for more detail.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
40
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gifmagazine"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "pry"
|
14
|
+
Pry.start
|
data/bin/setup
ADDED
data/gifmagazine.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gifmagazine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gifmagazine"
|
8
|
+
spec.version = Gifmagazine::VERSION
|
9
|
+
spec.authors = ["YuheiNakasaka"]
|
10
|
+
spec.email = ["yuhei.nakasaka@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Gifmagazine API v1 client library written in Ruby.}
|
13
|
+
spec.description = %q{Gifmagazine API v1 client library written in Ruby.}
|
14
|
+
spec.homepage = "http://api.gifmagazine.net/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
spec.add_dependency "faraday"
|
24
|
+
spec.add_dependency "faraday_middleware"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
end
|
data/lib/gifmagazine.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'gifmagazine/version'
|
2
|
+
require 'uri'
|
3
|
+
require 'gifmagazine/response'
|
4
|
+
require 'gifmagazine/resource_based_methods'
|
5
|
+
|
6
|
+
module Gifmagazine
|
7
|
+
class Client
|
8
|
+
DEFAULT_ACCEPT = "application/json"
|
9
|
+
|
10
|
+
DEFAULT_HOST = "api.gifmagazine.net"
|
11
|
+
|
12
|
+
DEFAULT_USER_AGENT = "Gifmagazine Ruby Gem #{Gifmagazine::VERSION}"
|
13
|
+
|
14
|
+
DEFAULT_HEADERS = {
|
15
|
+
"Accept" => DEFAULT_ACCEPT,
|
16
|
+
"User-Agent" => DEFAULT_USER_AGENT
|
17
|
+
}
|
18
|
+
|
19
|
+
include ResourceBasedMethods
|
20
|
+
|
21
|
+
def initialize(options={})
|
22
|
+
@opts = {
|
23
|
+
token: nil
|
24
|
+
}.merge!(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(path, params={}, headers=nil)
|
28
|
+
request(:get, path, params, headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
def con
|
32
|
+
@connection ||= Faraday.new(faraday_client_options) do |connection|
|
33
|
+
connection.request :json
|
34
|
+
connection.response :json
|
35
|
+
connection.adapter Faraday.default_adapter
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def faraday_client_options
|
41
|
+
{
|
42
|
+
headers: DEFAULT_HEADERS,
|
43
|
+
url: url_prefix
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def url_prefix
|
48
|
+
"http://#{DEFAULT_HOST}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def merged_params(params)
|
52
|
+
unless @opts[:token].nil?
|
53
|
+
params.merge!({token: @opts[:token]})
|
54
|
+
end
|
55
|
+
params
|
56
|
+
end
|
57
|
+
|
58
|
+
def request(request_method, path, params, headers)
|
59
|
+
Gifmagazine::Response.new(
|
60
|
+
con.send(
|
61
|
+
request_method,
|
62
|
+
URI.escape(path),
|
63
|
+
merged_params(params),
|
64
|
+
headers
|
65
|
+
)
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Gifmagazine
|
2
|
+
class Response
|
3
|
+
def initialize(faraday_response)
|
4
|
+
@header = faraday_response.headers
|
5
|
+
@body = faraday_response.body
|
6
|
+
@status = faraday_response.status
|
7
|
+
end
|
8
|
+
|
9
|
+
def body
|
10
|
+
@body
|
11
|
+
end
|
12
|
+
|
13
|
+
def header
|
14
|
+
@header
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
@status
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gifmagazine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- YuheiNakasaka
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday_middleware
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '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'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Gifmagazine API v1 client library written in Ruby.
|
126
|
+
email:
|
127
|
+
- yuhei.nakasaka@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/console
|
140
|
+
- bin/setup
|
141
|
+
- gifmagazine.gemspec
|
142
|
+
- lib/gifmagazine.rb
|
143
|
+
- lib/gifmagazine/client.rb
|
144
|
+
- lib/gifmagazine/resource_based_methods.rb
|
145
|
+
- lib/gifmagazine/response.rb
|
146
|
+
- lib/gifmagazine/version.rb
|
147
|
+
homepage: http://api.gifmagazine.net/
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.4.5
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Gifmagazine API v1 client library written in Ruby.
|
171
|
+
test_files: []
|