vws 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -10
- data/lib/vws.rb +36 -5
- data/lib/vws/version.rb +1 -1
- data/spec/vws_spec.rb +8 -8
- data/vws.gemspec +4 -4
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40511c3687d64aad2e56ad82ff056af559a59284
|
4
|
+
data.tar.gz: bb459c1ccb87491297b8cb913e5d6371527b4ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1be173437a87bd840936aa81131febdd10b095cda78cd45c8095c0058c50b7fc36b76f231baf6109426ec0ad14192d18eb0087ccf1687efc2768722c3eada774
|
7
|
+
data.tar.gz: 000b3675378731035b85351b6cf55f62195d64d916301e335bb690fa15ac9221b38ddad3652f8213dbe8b632df2681085c1c740c42dec95be23e8445f5277724
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Vws (Vuforia Web Services ruby gem for API access)
|
1
|
+
# Vws (Vuforia Web Services ruby gem for API access for target management)
|
2
2
|
|
3
3
|
This is a ruby gem to interact with Vuforia web services api for managing the targets:
|
4
4
|
https://developer.vuforia.com/resources/dev-guide/managing-targets-cloud-database-using-developer-api
|
@@ -6,7 +6,7 @@ https://developer.vuforia.com/resources/dev-guide/managing-targets-cloud-databas
|
|
6
6
|
It uses the excellent rest-client (https://github.com/rest-client/rest-client) to handle the
|
7
7
|
HTTP/REST requests required by the Vuforia Web Services API.
|
8
8
|
|
9
|
-
## Installation from source
|
9
|
+
## Installation from source:
|
10
10
|
|
11
11
|
|
12
12
|
Clone this repo onto your hard drive and cd into the root folder.
|
@@ -43,22 +43,26 @@ And then execute:
|
|
43
43
|
|
44
44
|
bundle install
|
45
45
|
|
46
|
-
This should work if you have installed the gem from source. I have not
|
47
|
-
uploaded the gem to rubygems.org yet
|
48
46
|
|
47
|
+
The gem has been uploaded to rubygems.org (http://rubygems.org/gems/vws), therefore you can simply issue:
|
49
48
|
|
50
|
-
|
49
|
+
gem install vws
|
50
|
+
|
51
|
+
and you'll be set.
|
52
|
+
|
53
|
+
|
54
|
+
## Usage:
|
51
55
|
|
52
56
|
Instantiate a connection to the api with:
|
53
57
|
|
54
58
|
connection = Vws::Api.new("your_server_vws_access_key", "your_server_vws_secret_key")
|
55
59
|
|
56
60
|
After a successful connection, you should have access to the vuforia api as shown here:
|
57
|
-
https://developer.vuforia.com/
|
61
|
+
https://developer.vuforia.com/library//articles/Solution/How-To-Use-the-Vuforia-Web-Services-API
|
58
62
|
|
59
63
|
So, if you want to get a summary of the cloud database, you issue:
|
60
64
|
|
61
|
-
|
65
|
+
connection.summary
|
62
66
|
|
63
67
|
For a list of targets in your database:
|
64
68
|
|
@@ -74,7 +78,8 @@ To activate or deactivate a target:
|
|
74
78
|
|
75
79
|
To add a target to the database:
|
76
80
|
|
77
|
-
connection.add_target(target_name, file_path, width, active_flag)
|
81
|
+
connection.add_target(target_name, file_path, width, active_flag, application_metadata)
|
82
|
+
You may set application_metadata = nil if you do not use this attribute
|
78
83
|
|
79
84
|
To delete a target:
|
80
85
|
|
@@ -87,6 +92,15 @@ Change a target flag to inactive/active:
|
|
87
92
|
|
88
93
|
connection.set_active_flag(target_id, active_flag), where active_flag=true/false
|
89
94
|
|
95
|
+
List duplicates for target:
|
96
|
+
|
97
|
+
connection.list_duplicates(target_id)
|
98
|
+
|
99
|
+
## Attributes of the uploaded file:
|
100
|
+
Vuforia has a great article about what makes a target ideal:
|
101
|
+
https://developer.vuforia.com/library/articles/Best_Practices/Attributes-of-an-Ideal-Image-Target
|
102
|
+
Currently, this ruby gem does not check for file size or any other attributes addressed in the article above.
|
103
|
+
|
90
104
|
|
91
105
|
## Spec
|
92
106
|
|
@@ -95,15 +109,32 @@ of the folder by issuing:
|
|
95
109
|
|
96
110
|
rspec spec
|
97
111
|
|
98
|
-
## To do:
|
99
112
|
|
100
|
-
|
113
|
+
##Caveats
|
114
|
+
|
115
|
+
Setting a target from on to off and vice versa takes some time. It may take up to
|
116
|
+
0-10 minutes and it's based on Vuforia's infrastucture. It is your responsibilty
|
117
|
+
to poll for the changes on the target since no such feature has been implemented
|
118
|
+
in this gem.
|
101
119
|
|
102
120
|
|
121
|
+
|
122
|
+
## To do:
|
123
|
+
|
124
|
+
Implement some of the new vws apis
|
125
|
+
|
103
126
|
## Contributing
|
104
127
|
|
128
|
+
Please, if you use it, report back any bugs/problems.
|
129
|
+
|
105
130
|
1. Fork it
|
106
131
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
107
132
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
108
133
|
4. Push to the branch (`git push origin my-new-feature`)
|
109
134
|
5. Create new Pull Request
|
135
|
+
|
136
|
+
## License
|
137
|
+
|
138
|
+
This software is licensed under the MIT License (MIT).
|
139
|
+
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/vws.rb
CHANGED
@@ -13,6 +13,7 @@ module Vws
|
|
13
13
|
BASE_URL = "https://vws.vuforia.com"
|
14
14
|
TARGETS_URL = BASE_URL + "/targets"
|
15
15
|
SUMMARY_URL = BASE_URL + "/summary"
|
16
|
+
DUPLICATES_URL = BASE_URL + "/duplicates"
|
16
17
|
|
17
18
|
class Api
|
18
19
|
|
@@ -39,7 +40,7 @@ module Vws
|
|
39
40
|
# json body data
|
40
41
|
hexDigest = Digest::MD5.hexdigest(body_hash.to_json)
|
41
42
|
else
|
42
|
-
puts "Invalid request method"
|
43
|
+
puts "Invalid request method for signature method: " + http_verb
|
43
44
|
return nil
|
44
45
|
end
|
45
46
|
|
@@ -55,12 +56,15 @@ module Vws
|
|
55
56
|
|
56
57
|
# Calls the api end point for the list of targets associated with
|
57
58
|
# server access key and cloud database
|
59
|
+
# https://developer.vuforia.com/library/articles/Solution/How-To-Get-a-Target-List-for-a-Cloud-Database-Using-the-VWS-API
|
58
60
|
def list_targets
|
59
61
|
#Date is the current date per RFC 2616, section 3.3.1,
|
60
62
|
#rfc1123-date format, e.g.: Sun, 22 Apr #2012 08:49:37 GMT.
|
61
63
|
date_timestamp = Time.now.httpdate #ruby provides this date format
|
62
64
|
#with httpdate method
|
63
65
|
signature = self.build_signature('/targets', nil, 'GET', date_timestamp)
|
66
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
67
|
+
|
64
68
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
65
69
|
begin
|
66
70
|
RestClient.get(TARGETS_URL, :'Date' => date_timestamp,
|
@@ -70,7 +74,9 @@ module Vws
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
|
-
def add_target(target_name, file_path, width, active_flag)
|
77
|
+
def add_target(target_name, file_path, width, active_flag, application_metadata=nil)
|
78
|
+
raise "file path is required" if file_path.nil?
|
79
|
+
raise "target name is required" if target_name.nil?
|
74
80
|
date_timestamp = Time.now.httpdate
|
75
81
|
#for file uploads, read file contents data and Base 64 encode it:
|
76
82
|
contents_encoded = Base64.encode64(File.open(file_path, 'rb').read)
|
@@ -79,6 +85,7 @@ module Vws
|
|
79
85
|
:image => contents_encoded,
|
80
86
|
:active_flag => active_flag }
|
81
87
|
signature = self.build_signature('/targets', body_hash, 'POST', date_timestamp)
|
88
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
82
89
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
83
90
|
begin
|
84
91
|
RestClient.post(TARGETS_URL, body_hash.to_json,
|
@@ -91,7 +98,10 @@ module Vws
|
|
91
98
|
end
|
92
99
|
end
|
93
100
|
|
101
|
+
# Updates an existing target. Target_id must already exist
|
102
|
+
# https://developer.vuforia.com/library/articles/Solution/How-To-Update-a-Target-Using-the-VWS-API
|
94
103
|
def update_target(target_id, target_name=nil, file_path=nil, width=nil, active_flag=nil)
|
104
|
+
raise "target id should be be nil" if target_id == nil
|
95
105
|
date_timestamp = Time.now.httpdate
|
96
106
|
target_id_url = TARGETS_URL + '/' + target_id
|
97
107
|
target_id_suburl = '/targets' + '/' + target_id
|
@@ -102,6 +112,7 @@ module Vws
|
|
102
112
|
:image => contents_encoded,
|
103
113
|
:active_flag => active_flag }
|
104
114
|
signature = self.build_signature(target_id_suburl, body_hash, 'PUT', date_timestamp)
|
115
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
105
116
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
106
117
|
begin
|
107
118
|
RestClient.put(target_id_url, body_hash.to_json,
|
@@ -118,7 +129,8 @@ module Vws
|
|
118
129
|
# https://developer.vuforia.com/resources/dev-guide/database-summary-report
|
119
130
|
def summary
|
120
131
|
date_timestamp = Time.now.httpdate
|
121
|
-
signature = self.build_signature('/summary', nil, 'GET', date_timestamp)
|
132
|
+
signature = self.build_signature('/summary', nil, 'GET', date_timestamp)
|
133
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
122
134
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
123
135
|
begin
|
124
136
|
RestClient.get(SUMMARY_URL, :'Date' => date_timestamp,
|
@@ -135,6 +147,7 @@ module Vws
|
|
135
147
|
target_id_url = TARGETS_URL + '/' + target_id
|
136
148
|
target_id_suburl = '/targets' + '/' + target_id
|
137
149
|
signature = self.build_signature(target_id_suburl, nil, 'GET', date_timestamp)
|
150
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
138
151
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
139
152
|
begin
|
140
153
|
RestClient.get(target_id_url, :'Date' => date_timestamp,
|
@@ -166,8 +179,8 @@ module Vws
|
|
166
179
|
target_id_suburl = '/targets' + '/' + target_id
|
167
180
|
body_hash = {:active_flag => active_flag}
|
168
181
|
signature = self.build_signature(target_id_suburl, body_hash, 'PUT', date_timestamp)
|
182
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
169
183
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
170
|
-
|
171
184
|
begin
|
172
185
|
RestClient.put(target_id_url, body_hash.to_json,
|
173
186
|
:'Date' => date_timestamp,
|
@@ -180,7 +193,7 @@ module Vws
|
|
180
193
|
end
|
181
194
|
|
182
195
|
# Delete a target in a cloud database
|
183
|
-
# https://developer.vuforia.com/
|
196
|
+
# https://developer.vuforia.com/library/articles/Solution/How-To-Delete-a-Target-Using-the-VWS-API
|
184
197
|
def delete_target(target_id)
|
185
198
|
# In order to delete the target, we have to set it to non-active.
|
186
199
|
# Therefore,first retrieve target info and act accordingly to target info
|
@@ -202,6 +215,7 @@ module Vws
|
|
202
215
|
target_id_url = TARGETS_URL + '/' + target_id
|
203
216
|
target_id_suburl = '/targets' + '/' + target_id
|
204
217
|
signature = self.build_signature(target_id_suburl, nil, 'DELETE', date_timestamp)
|
218
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
205
219
|
authorization_header = "VWS " + @accesskey + ":" + signature
|
206
220
|
begin
|
207
221
|
RestClient.delete(target_id_url,
|
@@ -221,6 +235,23 @@ module Vws
|
|
221
235
|
return {:result_code => "AuthenticationFailure"}.to_json
|
222
236
|
end
|
223
237
|
end
|
238
|
+
|
239
|
+
def list_duplicates(target_id)
|
240
|
+
date_timestamp = Time.now.httpdate
|
241
|
+
|
242
|
+
target_id_url = DUPLICATES_URL + '/' + target_id
|
243
|
+
target_id_suburl = '/duplicates' + '/' + target_id
|
244
|
+
|
245
|
+
signature = self.build_signature(target_id_suburl, nil, 'GET', date_timestamp)
|
246
|
+
raise ArgumentError.new('Signature returned nil. Aborting...') if signature == nil
|
247
|
+
authorization_header = "VWS " + @accesskey + ":" + signature
|
248
|
+
begin
|
249
|
+
RestClient.get(target_id_url, :'Date' => date_timestamp,
|
250
|
+
:'Authorization' => authorization_header)
|
251
|
+
rescue => e
|
252
|
+
e.response
|
253
|
+
end
|
254
|
+
end
|
224
255
|
|
225
256
|
end
|
226
257
|
end
|
data/lib/vws/version.rb
CHANGED
data/spec/vws_spec.rb
CHANGED
@@ -51,8 +51,8 @@ describe Vws do
|
|
51
51
|
|
52
52
|
describe "should retrieve a single target info" do
|
53
53
|
conn = Vws::Api.new(VWS_ACCESSKEY, VWS_SECRETKEY)
|
54
|
-
puts "Info for targetid =
|
55
|
-
response = conn.retrieve_target("
|
54
|
+
puts "Info for targetid = your_test_target_id \n"
|
55
|
+
response = conn.retrieve_target("your_test_target_id")
|
56
56
|
puts JSON.pretty_generate(JSON.parse(response))
|
57
57
|
end
|
58
58
|
|
@@ -60,8 +60,8 @@ describe Vws do
|
|
60
60
|
|
61
61
|
describe "should retrieve a summary report of a single target" do
|
62
62
|
conn = Vws::Api.new(VWS_ACCESSKEY, VWS_SECRETKEY)
|
63
|
-
puts "Summary report targetid =
|
64
|
-
response = conn.target_summary("
|
63
|
+
puts "Summary report targetid = your_test_target_id \n"
|
64
|
+
response = conn.target_summary("your_test_target_id")
|
65
65
|
puts JSON.pretty_generate(JSON.parse(response))
|
66
66
|
end
|
67
67
|
|
@@ -69,8 +69,8 @@ describe Vws do
|
|
69
69
|
|
70
70
|
describe "delete target" do
|
71
71
|
conn = Vws::Api.new(VWS_ACCESSKEY, VWS_SECRETKEY)
|
72
|
-
puts "What happens if try to delete a file with targetid =
|
73
|
-
response = conn.delete_target("
|
72
|
+
puts "What happens if try to delete a file with targetid = your_test_target_id ?: \n"
|
73
|
+
response = conn.delete_target("your_test_target_id")
|
74
74
|
puts JSON.pretty_generate(JSON.parse(response))
|
75
75
|
end
|
76
76
|
|
@@ -78,8 +78,8 @@ describe Vws do
|
|
78
78
|
|
79
79
|
describe "set active to false" do
|
80
80
|
conn = Vws::Api.new(VWS_ACCESSKEY, VWS_SECRETKEY)
|
81
|
-
puts "Set target to false for targetid =
|
82
|
-
response = conn.set_active_flag("
|
81
|
+
puts "Set target to false for targetid = your_test_target_id \n"
|
82
|
+
response = conn.set_active_flag("your_test_target_id", false)
|
83
83
|
puts JSON.pretty_generate(JSON.parse(response))
|
84
84
|
end
|
85
85
|
|
data/vws.gemspec
CHANGED
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
|
22
22
|
#development depedencies
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
-
spec.add_development_dependency "rake", "~> 10.
|
25
|
-
spec.add_development_dependency "rspec","~> 2.
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.8.5"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.4.2"
|
25
|
+
spec.add_development_dependency "rspec","~> 3.2.0"
|
26
26
|
#spec.add_development_dependency "json","~> 1.8"
|
27
27
|
|
28
28
|
#runtime dependencies
|
29
|
-
spec.add_runtime_dependency "rest-client", "~> 1.
|
29
|
+
spec.add_runtime_dependency "rest-client", "~> 1.7.3"
|
30
30
|
spec.add_runtime_dependency "json", "~> 1.8"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Kokkos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.8.5
|
20
20
|
type: :development
|
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:
|
26
|
+
version: 1.8.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 10.4.2
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 10.4.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.2.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:
|
54
|
+
version: 3.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rest-client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.7.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.7.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.4.6
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: This is a ruby gem that interacts with Vuforia Web service API for Cloud
|