cloudsight 0.0.9.1 → 0.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: b9d0460a23e0f0707d9ddb9f2bb55498c620f850
4
- data.tar.gz: 20c8412535ce925d41a25e69d1d5df650d4ac11b
3
+ metadata.gz: 478811edc71cf94a43fbbb5c6f90523abcff2566
4
+ data.tar.gz: 4ec2871c44911b853f97412d83d69cc4e97668b3
5
5
  SHA512:
6
- metadata.gz: 4aaaf8b6c0a018ddd99b54e1b486c250a5f63240ed37d899797765fe5ba72f7396df4bd693c38bd45386c6c219789e8c0dc19341554f53a344089ad952f37b5c
7
- data.tar.gz: 8a6dcc5478f4047437e5a045b702f8b320b72ebcb0ebef12dcbe06dac0a1c361409fb5ec6620b3928357a72dba22f8af33fa1d782696c09a27838e9b21806c56
6
+ metadata.gz: 2c638e70d37ba3ebafd51ec85e3f7d524cad69edf42513351fe22ec41124106ef99a6e2eebfd500224a68c6fb27df60030e046afeecf6de291b44a210e51489a
7
+ data.tar.gz: 17608322f8b79f1e7ba8ba229a3d05dd96fc1615f07a350414e58992e0bf22819a2f2408b0111be7898f487b89a67b763265fd1adbb2a09f84c4d2d54ffcd60e
data/README.md CHANGED
@@ -51,25 +51,25 @@ Usage
51
51
  Send the image request using a file:
52
52
 
53
53
  ```ruby
54
- requestData = Cloudsight::Request.send(locale: 'en', file: File.open('image.jpg'))
54
+ request_data = Cloudsight::Request.send(locale: 'en', file: File.open('image.jpg'))
55
55
  ```
56
56
 
57
57
  Or, you can send the image request using a URL:
58
58
 
59
59
  ```ruby
60
- requestData = Cloudsight::Request.send(locale: 'en', url: 'http://www.google.com/images/srpr/logo11w.png')
60
+ request_data = Cloudsight::Request.send(locale: 'en', url: 'http://www.google.com/images/srpr/logo11w.png')
61
61
  ```
62
62
 
63
63
  Then, use the token to retrieve the response:
64
64
 
65
65
  ```ruby
66
- responseData = Cloudsight::Response.get(requestData['token'])
66
+ response_data = Cloudsight::Response.get(request_data['token'])
67
67
  ```
68
68
 
69
69
  You can also use the `retrieve` method which will poll for the response for you:
70
70
 
71
71
  ```ruby
72
- Cloudsight::Response.retrieve(requestData['token']) do |responseData|
73
- p responseData
72
+ Cloudsight::Response.retrieve(request_data['token']) do |response_data|
73
+ p response_data
74
74
  end
75
75
  ```
data/Rakefile CHANGED
@@ -1,4 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- task :default do
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.fail_on_error = false
8
+ end
9
+
10
+ task :default => :spec
11
+ rescue LoadError
12
+ # no rspec available
4
13
  end
@@ -3,7 +3,7 @@ module Cloudsight
3
3
  class << self
4
4
  def send(options = {})
5
5
  raise RuntimeError.new("Need to define either oauth_options or api_key") unless Cloudsight.api_key || Cloudsight.oauth_options
6
- url = "#{Cloudsight::base_url}/image_requests"
6
+ url = "#{Cloudsight::base_url}/v1/images"
7
7
 
8
8
  params = construct_params(options)
9
9
  response = Api.post(url, params)
@@ -15,7 +15,7 @@ module Cloudsight
15
15
  end
16
16
 
17
17
  def repost(token, options = {})
18
- url = "#{Cloudsight::base_url}/image_requests/#{token}/repost"
18
+ url = "#{Cloudsight::base_url}/v1/images/#{token}/repost"
19
19
 
20
20
  response = Api.post(url, options)
21
21
  return true if response.code == 200 and response.body.to_s.strip.empty?
@@ -29,17 +29,17 @@ module Cloudsight
29
29
 
30
30
  def construct_params(options)
31
31
  params = {}
32
- [:locale, :language, :latitude, :longitude, :altitude, :device_id, :ttl].each do |attr|
33
- params["image_request[#{attr}]"] = options[attr] if options.has_key?(attr)
32
+ [:locale, :language, :latitude, :longitude, :altitude, :device_id, :ttl, :focus_x, :focus_y].each do |attr|
33
+ params[attr.to_s] = options[attr] if options.has_key?(attr)
34
34
  end
35
35
 
36
36
  if options[:focus]
37
- params['focus[x]'] = options[:focus][:x]
38
- params['focus[y]'] = options[:focus][:y]
37
+ params['focus_x'] = options[:focus][:x]
38
+ params['focus_y'] = options[:focus][:y]
39
39
  end
40
40
 
41
- params['image_request[remote_image_url]'] = options[:url] if options.has_key?(:url)
42
- params['image_request[image]'] = options[:file] if options.has_key?(:file)
41
+ params['remote_image_url'] = options[:url] if options.has_key?(:url)
42
+ params['image'] = options[:file] if options.has_key?(:file)
43
43
  params
44
44
  end
45
45
  end
@@ -2,7 +2,7 @@ module Cloudsight
2
2
  class Response
3
3
  class << self
4
4
  def get(token, options = {})
5
- url = "#{Cloudsight::base_url}/image_responses/#{token}"
5
+ url = "#{Cloudsight::base_url}/v1/images/#{token}"
6
6
 
7
7
  response = Api.get(url)
8
8
  data = JSON.parse(response.body)
@@ -1,3 +1,3 @@
1
1
  module Cloudsight
2
- VERSION = "0.0.9.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -29,17 +29,17 @@ RSpec.describe Cloudsight::Request do
29
29
  options = described_class.construct_params(params)
30
30
  expect(options).to eq(
31
31
  {
32
- 'image_request[locale]' => 'en',
33
- 'image_request[language]' => 'en',
34
- 'image_request[latitude]' => '5',
35
- 'image_request[longitude]' => '5',
36
- 'image_request[altitude]' => '5',
37
- 'image_request[device_id]' => '5',
38
- 'image_request[ttl]' => '5',
39
- 'image_request[remote_image_url]' => 'test_url',
40
- 'image_request[image]' => 'test_file',
41
- 'focus[x]' => '5',
42
- 'focus[y]' => '5'
32
+ 'locale' => 'en',
33
+ 'language' => 'en',
34
+ 'latitude' => '5',
35
+ 'longitude' => '5',
36
+ 'altitude' => '5',
37
+ 'device_id' => '5',
38
+ 'ttl' => '5',
39
+ 'remote_image_url' => 'test_url',
40
+ 'image' => 'test_file',
41
+ 'focus_x' => '5',
42
+ 'focus_y' => '5'
43
43
  }
44
44
  )
45
45
  end
@@ -50,8 +50,8 @@ RSpec.describe Cloudsight::Request do
50
50
 
51
51
  it 'returns the proper result' do
52
52
  stub_post(
53
- path: '/image_requests',
54
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
53
+ path: '/v1/images',
54
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
55
55
  response: fixture_file('image_request.json')
56
56
  )
57
57
 
@@ -64,8 +64,8 @@ RSpec.describe Cloudsight::Request do
64
64
 
65
65
  it 'responds correctly to a response exception error' do
66
66
  stub_post(
67
- path: '/image_requests',
68
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
67
+ path: '/v1/images',
68
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
69
69
  response: fixture_file('error_response.json')
70
70
  )
71
71
 
@@ -74,8 +74,8 @@ RSpec.describe Cloudsight::Request do
74
74
 
75
75
  it 'responds correctly to an unexpected response' do
76
76
  stub_post(
77
- path: '/image_requests',
78
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
77
+ path: '/v1/images',
78
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
79
79
  response: fixture_file('unexpected_response.json')
80
80
  )
81
81
 
@@ -84,12 +84,12 @@ RSpec.describe Cloudsight::Request do
84
84
  end
85
85
 
86
86
  describe '#repost' do
87
- let(:params) { { image_request: { locale: 'en', remote_image_url: 'test_url' } } }
87
+ let(:params) { { locale: 'en', remote_image_url: 'test_url' } }
88
88
 
89
89
  it 'returns the proper result' do
90
90
  stub_post(
91
- path: '/image_requests/sample_token/repost',
92
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
91
+ path: '/v1/images/sample_token/repost',
92
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
93
93
  response: fixture_file('image_request.json')
94
94
  )
95
95
 
@@ -102,8 +102,8 @@ RSpec.describe Cloudsight::Request do
102
102
 
103
103
  it 'responds correctly to a response exception error' do
104
104
  stub_post(
105
- path: '/image_requests/sample_token/repost',
106
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
105
+ path: '/v1/images/sample_token/repost',
106
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
107
107
  response: fixture_file('error_response.json')
108
108
  )
109
109
 
@@ -112,8 +112,8 @@ RSpec.describe Cloudsight::Request do
112
112
 
113
113
  it 'responds correctly to an unexpected response' do
114
114
  stub_post(
115
- path: '/image_requests/sample_token/repost',
116
- body: { "image_request"=>{ "locale"=>"en", "remote_image_url"=>"test_url" } },
115
+ path: '/v1/images/sample_token/repost',
116
+ body: { "locale" => "en", "remote_image_url" => "test_url" },
117
117
  response: fixture_file('unexpected_response.json')
118
118
  )
119
119
 
@@ -8,7 +8,7 @@ RSpec.describe Cloudsight::Response do
8
8
  describe '#get' do
9
9
  it 'returns the proper result' do
10
10
  stub_get(
11
- path: '/image_responses/sample_token',
11
+ path: '/v1/images/sample_token',
12
12
  response: fixture_file('completed_response.json')
13
13
  )
14
14
 
@@ -21,7 +21,7 @@ RSpec.describe Cloudsight::Response do
21
21
 
22
22
  it 'responds correctly to a response exception error' do
23
23
  stub_get(
24
- path: '/image_responses/sample_token',
24
+ path: '/v1/images/sample_token',
25
25
  response: fixture_file('error_response.json')
26
26
  )
27
27
 
@@ -30,7 +30,7 @@ RSpec.describe Cloudsight::Response do
30
30
 
31
31
  it 'responds correctly to an unexpected response' do
32
32
  stub_get(
33
- path: '/image_responses/sample_token',
33
+ path: '/v1/images/sample_token',
34
34
  response: fixture_file('unexpected_response.json')
35
35
  )
36
36
 
@@ -40,7 +40,7 @@ RSpec.describe Cloudsight::Response do
40
40
 
41
41
  describe '#retrieve' do
42
42
  it 'returns the proper result' do
43
- stub_polling(3, 'image_request.json', 'completed_response.json', '/image_responses/sample_token')
43
+ stub_polling(3, 'image_request.json', 'completed_response.json', '/v1/images/sample_token')
44
44
 
45
45
  response = described_class.retrieve('sample_token', poll_wait: 0.01)
46
46
 
@@ -50,13 +50,13 @@ RSpec.describe Cloudsight::Response do
50
50
  end
51
51
 
52
52
  it 'responds correctly to a response exception error' do
53
- stub_polling(3, 'image_request.json', 'error_response.json', '/image_responses/sample_token')
53
+ stub_polling(3, 'image_request.json', 'error_response.json', '/v1/images/sample_token')
54
54
 
55
55
  expect { described_class.retrieve('sample_token', poll_wait: 0.01) }.to raise_error Cloudsight::ResponseException
56
56
  end
57
57
 
58
58
  it 'responds correctly to an unexpected response' do
59
- stub_polling(3, 'image_request.json', 'unexpected_response.json', '/image_responses/sample_token')
59
+ stub_polling(3, 'image_request.json', 'unexpected_response.json', '/v1/images/sample_token')
60
60
 
61
61
  expect { described_class.retrieve('sample_token', poll_wait: 0.01) }.to raise_error Cloudsight::UnexpectedResponseException
62
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudsight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Folkens
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-11 00:00:00.000000000 Z
13
+ date: 2017-12-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.6.12
179
+ rubygems_version: 2.6.13
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: CloudSight API Client