imagga_auto_tag 0.1.0 → 0.2.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 +4 -4
- data/README.md +5 -1
- data/imagga_auto_tag.gemspec +2 -3
- data/lib/imagga_auto_tag/client.rb +25 -10
- data/lib/imagga_auto_tag/tagged_image.rb +5 -1
- data/lib/imagga_auto_tag/version.rb +1 -1
- data/spec/imagga_auto_tag_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0f79257f3870199b4fe58456689d1a662df130
|
4
|
+
data.tar.gz: e9bac6cf0ea659bd41bc3ebfbbd4a6d9ec3faa1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f1006744a9f922271ebb57105b1b90863e011d113a85be8bf6021080884b61e9c58a4b7584413057c6853cbb34d395280bf321f20c97d91bde508d98c95b573
|
7
|
+
data.tar.gz: 8e2654c3102ae01a2c9637b16754550f95d0d3922dc328a60b94e1eda9d0f704c0d43f09855040e96e2dda949c5f52546b290c4dc3707034e20c8c369c1439ae
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
client = ImaggaAutoTag::Client.new(your_imagga_api_key)
|
24
|
+
client = ImaggaAutoTag::Client.new(your_imagga_api_key, your_imagga_api_secret)
|
25
25
|
results = client.fetch("http://static.ddmcdn.com/gif/landscape-photography-1.jpg")
|
26
26
|
|
27
27
|
results.tags
|
@@ -47,3 +47,7 @@ results.to_csv
|
|
47
47
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
48
|
4. Push to the branch (`git push origin my-new-feature`)
|
49
49
|
5. Create a new Pull Request
|
50
|
+
|
51
|
+
## Version
|
52
|
+
|
53
|
+
**0.2.0** : Change the API endpoint and the way authentication is done.
|
data/imagga_auto_tag.gemspec
CHANGED
@@ -8,9 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ImaggaAutoTag::VERSION
|
9
9
|
spec.authors = ["Luke Chesser"]
|
10
10
|
spec.email = ["luke@unsplash.com"]
|
11
|
-
spec.summary = %q{Imagga Auto Tagging API
|
12
|
-
spec.
|
13
|
-
spec.homepage = "https://github.com/lukechesser/imagga-auto-tag"
|
11
|
+
spec.summary = %q{Simple wrapper around the Imagga Auto Tagging API}
|
12
|
+
spec.homepage = ""
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -1,23 +1,38 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
1
3
|
module ImaggaAutoTag
|
2
4
|
|
3
5
|
class Client
|
4
6
|
|
5
|
-
IMAGGA_API_BASE_URL = "https://api.imagga.com"
|
6
|
-
IMAGGA_API_TAG_PATH = "/
|
7
|
+
IMAGGA_API_BASE_URL = "https://api.imagga.com"
|
8
|
+
IMAGGA_API_TAG_PATH = "/v1/tagging"
|
7
9
|
|
8
10
|
attr_reader :response
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
# Initialize a new client to fetch information from IMAGGA
|
13
|
+
#
|
14
|
+
# ==== Attributes
|
15
|
+
# * +api_key+ `String` of your IMAGGA api key
|
16
|
+
# * +api_secret+ `String` of your IMAGGA api secret
|
17
|
+
#
|
18
|
+
# ===== Examples
|
19
|
+
# client = ImaggaAutoTag::Client.new(api_key, api_secret)
|
20
|
+
def initialize(api_key, api_secret)
|
21
|
+
@conn = Faraday.new(url: IMAGGA_API_BASE_URL)
|
22
|
+
@conn.basic_auth api_key, api_secret
|
13
23
|
end
|
14
24
|
|
25
|
+
# Fetch the JSON information for a specific image
|
26
|
+
#
|
27
|
+
# ==== Attributes
|
28
|
+
# * +url+ `String` of the image URL to analyse
|
29
|
+
#
|
30
|
+
# ==== Examples
|
31
|
+
# # Create a new client
|
32
|
+
# client = ImaggaAutoTag::Client.new(api_key, api_secret)
|
33
|
+
# client.fetch(image_url_string)
|
15
34
|
def fetch(url)
|
16
|
-
@response = @conn.get
|
17
|
-
req.url IMAGGA_API_TAG_PATH
|
18
|
-
req.params['api_key'] = @api_key
|
19
|
-
req.params['url'] = url
|
20
|
-
end
|
35
|
+
@response = @conn.get IMAGGA_API_TAG_PATH, {url: url}
|
21
36
|
|
22
37
|
TaggedImage.new(@response)
|
23
38
|
end
|
@@ -5,11 +5,15 @@ module ImaggaAutoTag
|
|
5
5
|
attr_reader :status, :tags
|
6
6
|
|
7
7
|
def initialize(api_response)
|
8
|
+
# The response from Imagga is now wrap in a results envelop
|
9
|
+
#
|
10
|
+
# ==== Result
|
11
|
+
# { "results" => [{ "image" => "", "tags" => [{}, {}, {}] }] }
|
8
12
|
body = JSON.parse(api_response.body)
|
9
13
|
|
10
14
|
@tags = []
|
11
15
|
|
12
|
-
body['tags'].each do |tag|
|
16
|
+
body['results'][0]['tags'].each do |tag|
|
13
17
|
@tags.push Tag.new(tag)
|
14
18
|
end
|
15
19
|
|
@@ -5,7 +5,7 @@ describe "An Imagga Auto Tag API" do
|
|
5
5
|
context "client" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@client = ImaggaAutoTag::Client.new(ENV['IMAGGA_API_KEY'])
|
8
|
+
@client = ImaggaAutoTag::Client.new(ENV['IMAGGA_API_KEY'], ENV['IMAGGA_API_SECRET'])
|
9
9
|
end
|
10
10
|
|
11
11
|
it "connects" do
|
@@ -22,7 +22,7 @@ describe "An Imagga Auto Tag API" do
|
|
22
22
|
|
23
23
|
before do
|
24
24
|
VCR.use_cassette('image') do
|
25
|
-
@client = ImaggaAutoTag::Client.new(ENV['IMAGGA_API_KEY'])
|
25
|
+
@client = ImaggaAutoTag::Client.new(ENV['IMAGGA_API_KEY'], ENV['IMAGGA_API_SECRET'])
|
26
26
|
@results = @client.fetch("http://static.ddmcdn.com/gif/landscape-photography-1.jpg")
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagga_auto_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Chesser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- luke@unsplash.com
|
114
114
|
executables: []
|
@@ -130,7 +130,7 @@ files:
|
|
130
130
|
- spec/cassettes/image.yml
|
131
131
|
- spec/imagga_auto_tag_spec.rb
|
132
132
|
- spec/spec_helper.rb
|
133
|
-
homepage:
|
133
|
+
homepage: ''
|
134
134
|
licenses:
|
135
135
|
- MIT
|
136
136
|
metadata: {}
|
@@ -153,7 +153,7 @@ rubyforge_project:
|
|
153
153
|
rubygems_version: 2.2.2
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
|
-
summary: Imagga Auto Tagging API
|
156
|
+
summary: Simple wrapper around the Imagga Auto Tagging API
|
157
157
|
test_files:
|
158
158
|
- spec/cassettes/image.yml
|
159
159
|
- spec/imagga_auto_tag_spec.rb
|