vufer 1.0.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/.env.example +2 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +27 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +19 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +83 -0
- data/LICENSE +21 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +16 -0
- data/lib/vufer/configure.rb +35 -0
- data/lib/vufer/signature.rb +46 -0
- data/lib/vufer/target.rb +182 -0
- data/lib/vufer/version.rb +3 -0
- data/lib/vufer.rb +35 -0
- data/vufer.gemspec +32 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 37b1f7eabe4d44ddbed09b792ea708797399ac040d251531ed107d0f61fb2031
|
4
|
+
data.tar.gz: 0a52113db5b1ca594645d9ca0958052c9d80eed138350f41558d45fd64a609db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '05258d5f26375ce25a8b68bad6e65acacb45c895dbb4fed89ab9ad794404a7c36b8f224a35388dcece5be457ecce6723e99cdaa21fef5e49e316f9bc12481091'
|
7
|
+
data.tar.gz: 61911e13a78b6e960804078fcf8c72abbcb514188b2fe0563d2571eebf946bd0c03d01a7c6e0b328ea2c6fb71e51bd66bd045300782cb2859bcb0d4864fa13b8
|
data/.env.example
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.3
|
data/.travis.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.6.3
|
6
|
+
before_install: gem install bundler -v 2.0.2
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- secure: XliWUXF9Ezv/QbLY1OqP9KzOq9++7yab5iQJuF0Lvh7tJwH6e9EoB2/0ndrsYhHxTjrBZWn99CDRbbOle9vBdl7sCnQyIHk387FXD0hygduiKohFsYiCWathA6g++Kymsp8Avs3brvJACvArZndVXDQBa/7ElV6kx/eRvIZJy5cXdZyHIsFNuCJrqrzS8I9sZaafvwTmOutmGxqfd/yLxG+3uONbC6UO3y9lrUaquMia2ojDCQH1/ftV4EPFKhXkngUTftyp1ncDycgZIO8o4IH98eYpdrltHnzAShL44SHTg5lX2f/Bn0YyQBpyHcrVgLCwhtPxJ42SIFQ1p5Agepz7KfgWapvzTH2oBwmX2kFMsqBwgn6JeEwgfQoCh5oq7i9xA4eaBOhzv4RV9/s2/Vw2bGV3k2HKpjeUtBkirQquzN0BbnzcDgul81YdefVtr+jDjQuDpBskZQlx1Mv3wEZ6r8h3W+WtKsCfpDOAWzxKZ/Pozw2zaWj83wR5RwEOOE/t/M+TvECG89bl/s4O7La3gvKHDBjj8mlB7XCOd3uWn62BGw23o2GHjB+JbXSdCaNit2HP/Rwd/fiGwITGezoFSNhwETWFZgp63LsTYCD6NMOc8ImYOZhodwysG0MLXUnwKdCxG1uPzuOEK04Mrio3KtfGKjyJI6jMqS2PVN0=
|
10
|
+
- secure: dZJZ6lAQh0Q5r42r1yqAySbLdGVdkTvy0LSp3s802yFUMYKXKSmvuY9LjG6vrSDNymIvP2yRn0uEXFnFWf78SeJV81CmkJLaF4dxURsID058tmZIjs7HqmVQLVQPELscnGxFa1pkb0wmaumCSRfTIzEluay98UdksjnlItW+6nalLX8cx8oOzfwy5RYO+UOxMXbbzNNAQoXSMRK8LnbnYlLtbiUmPU9lT7wmCobOQNerjIYHzKGQyDwzYthzkp7LgRL7JOOD0mx15qvRmeDPcmdLWYVgOTGw+Xy+HMk3f3/K3P0X56BopaibWl9NC3IjheOFqGQGnc2l5807jCC3Nx8mqZrVBKe5lXUAFGdxfRa7wRU/OlWOUBJZ2DQ/G6YjkNIuChkTJ6t7uK4EA1+/ByvPL2RhSUSeqh5fEUFBUvQP1kaW8HIsj+TQxLg9T7efyBti7p6/u7OX25PSgYwPhV5gx8AG0T28l+d4HYzpjmZabBgSQxg8XiR7EHvK2RYLYXrFzYeMiPH0eyW2YYwQDvHYyA9Bjhyce5JkwqeY5OEIC/a5YZZGU8r/yWEflT1q84+Q28hY8dfnyQJA1gWpsdKNC2QiUfO4Bzgq8WLcpdJJn3U/CqC+NYRUC5sOLtLxmr+foITDM7ItbAQuqXzrqkS5wDUb5DyD3W3KZZezjCM=
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# v1.0.0
|
2
|
+
|
3
|
+
- Create `Vufer::Target.dups` to view duplated related targets.
|
4
|
+
- Create `Vufer::Target.summary` to get a summary of a target.
|
5
|
+
|
6
|
+
# v0.5.1
|
7
|
+
|
8
|
+
- Create `Vufer::Target.destroy` to delete a specific target on the database.
|
9
|
+
|
10
|
+
# v0.4.1
|
11
|
+
|
12
|
+
- Create `Vufer::Target.create` method to add a new target on the database.
|
13
|
+
- Create `Vufer::Target.update` to update a created target on the database.
|
14
|
+
|
15
|
+
# v0.3.1
|
16
|
+
|
17
|
+
- Create `Vufer::Target.all` method to load all ids from Vuforia associated with the server key.
|
18
|
+
|
19
|
+
# v0.2.1
|
20
|
+
|
21
|
+
- Create `Vufer.summary` to load info about targets, quota, requests, etc.. from Vuforia.
|
22
|
+
- Implement a proper CI to run tests.
|
23
|
+
|
24
|
+
# v0.1.1
|
25
|
+
|
26
|
+
- Create `Vufer::Target.find(target_id)` method to get target from Vuforia.
|
27
|
+
- Enable `.env.example` example on how to use environment variables.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at orandson@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
FROM ruby:2.6.5
|
2
|
+
|
3
|
+
ENV APP_HOME /app
|
4
|
+
|
5
|
+
RUN mkdir $APP_HOME
|
6
|
+
|
7
|
+
WORKDIR $APP_HOME
|
8
|
+
|
9
|
+
COPY Gemfile $APP_HOME/Gemfile
|
10
|
+
COPY Gemfile.lock $APP_HOME/Gemfile.lock
|
11
|
+
COPY vufer.gemspec $APP_HOME/vufer.gemspec
|
12
|
+
|
13
|
+
COPY . $APP_HOME
|
14
|
+
|
15
|
+
ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile BUNDLE_JOBS=2 BUNDLE_PATH=/bundle
|
16
|
+
|
17
|
+
RUN gem install bundler
|
18
|
+
RUN bundle install
|
19
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vufer (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
ast (2.4.0)
|
12
|
+
coderay (1.1.2)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
docile (1.3.2)
|
17
|
+
faraday (0.17.0)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
hashdiff (1.0.0)
|
20
|
+
jaro_winkler (1.5.4)
|
21
|
+
json (2.2.0)
|
22
|
+
method_source (0.9.2)
|
23
|
+
multipart-post (2.1.1)
|
24
|
+
parallel (1.19.0)
|
25
|
+
parser (2.6.5.0)
|
26
|
+
ast (~> 2.4.0)
|
27
|
+
pry (0.12.2)
|
28
|
+
coderay (~> 1.1.0)
|
29
|
+
method_source (~> 0.9.0)
|
30
|
+
public_suffix (4.0.1)
|
31
|
+
rainbow (3.0.0)
|
32
|
+
rake (10.5.0)
|
33
|
+
rspec (3.9.0)
|
34
|
+
rspec-core (~> 3.9.0)
|
35
|
+
rspec-expectations (~> 3.9.0)
|
36
|
+
rspec-mocks (~> 3.9.0)
|
37
|
+
rspec-core (3.9.0)
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-expectations (3.9.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-mocks (3.9.0)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.9.0)
|
45
|
+
rspec-support (3.9.0)
|
46
|
+
rubocop (0.76.0)
|
47
|
+
jaro_winkler (~> 1.5.1)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 2.6)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
53
|
+
ruby-progressbar (1.10.1)
|
54
|
+
safe_yaml (1.0.5)
|
55
|
+
simplecov (0.17.1)
|
56
|
+
docile (~> 1.1)
|
57
|
+
json (>= 1.8, < 3)
|
58
|
+
simplecov-html (~> 0.10.0)
|
59
|
+
simplecov-html (0.10.2)
|
60
|
+
unicode-display_width (1.6.0)
|
61
|
+
vcr (5.0.0)
|
62
|
+
webmock (3.7.6)
|
63
|
+
addressable (>= 2.3.6)
|
64
|
+
crack (>= 0.3.2)
|
65
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
bundler (~> 2.0)
|
72
|
+
faraday
|
73
|
+
pry
|
74
|
+
rake
|
75
|
+
rspec (~> 3.0)
|
76
|
+
rubocop
|
77
|
+
simplecov
|
78
|
+
vcr
|
79
|
+
vufer!
|
80
|
+
webmock
|
81
|
+
|
82
|
+
BUNDLED WITH
|
83
|
+
2.0.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Randson
|
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,56 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img alt="Vufer logo" width="200" src="https://s3.amazonaws.com/arpia.pro/images/arpia-logo-rounded.png">
|
3
|
+
</p>
|
4
|
+
|
5
|
+
# Vufer [](https://travis-ci.org/rands0n/vufer)
|
6
|
+
|
7
|
+
A Ruby Gem to Interact with Vuforia Web Service API.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'vufer'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install vufer
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Configure your access and secret keys from Vuforia.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Vufer.configure do |config|
|
31
|
+
config.access_key = 'MY_ACCESS_KEY'
|
32
|
+
config.secret_key = 'MY_SECRET_KEY'
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
If you have `VWS_ACCESS_KEY` and `VWS_SECRET_KEY` set in your environment, Vufer will try to get these keys from the environment.
|
37
|
+
|
38
|
+
[Use the docs](https://github.com/rands0n/vufer/wiki) to see on how to manage targets, view database and target summary.
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
43
|
+
|
44
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rands0n/vufer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
53
|
+
|
54
|
+
## Code of Conduct
|
55
|
+
|
56
|
+
Everyone interacting in the Vufer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rands0n/vufer/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vufer
|
4
|
+
module Configure
|
5
|
+
@@access_key = ''
|
6
|
+
@@secret_key = ''
|
7
|
+
|
8
|
+
def configure
|
9
|
+
yield self if block_given?
|
10
|
+
end
|
11
|
+
|
12
|
+
def access_key=(key)
|
13
|
+
@@access_key = key
|
14
|
+
end
|
15
|
+
|
16
|
+
def access_key
|
17
|
+
@@access_key
|
18
|
+
end
|
19
|
+
|
20
|
+
def secret_key=(key)
|
21
|
+
@@secret_key = key
|
22
|
+
end
|
23
|
+
|
24
|
+
def secret_key
|
25
|
+
@@secret_key
|
26
|
+
end
|
27
|
+
|
28
|
+
def use_defaults
|
29
|
+
configure do |config|
|
30
|
+
config.access_key ||= ENV['VWS_ACCESS_KEY']
|
31
|
+
config.secret_key ||= ENV['VWS_SECRET_KEY']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openssl'
|
4
|
+
require 'base64'
|
5
|
+
require 'digest/md5'
|
6
|
+
require 'json'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
module Vufer
|
10
|
+
class Signature
|
11
|
+
HEX_DIGEST = 'd41d8cd98f00b204e9800998ecf8427e'.freeze
|
12
|
+
|
13
|
+
class << self
|
14
|
+
##
|
15
|
+
# Generates the signature based on path, body, http verb and time.
|
16
|
+
#
|
17
|
+
# @param Path [String] the actual path you're sending the request, eg: '/targets'.
|
18
|
+
# @param Body [Hash] the content when request is in POST or PUT formats.
|
19
|
+
# @param Verb [String] the HTTP verb used to send the request, eg: POST, PUT, GET, etc...
|
20
|
+
# @param Time [Time] time in GMT the request is made.
|
21
|
+
#
|
22
|
+
# @return [String] contains an encrypted token with all the above informartion.
|
23
|
+
def generate(path, body, verb, time)
|
24
|
+
raise KeyEnvironmentError if Vufer.access_key.empty? || Vufer.secret_key.empty?
|
25
|
+
|
26
|
+
hex_digest = HEX_DIGEST
|
27
|
+
content_type = ''
|
28
|
+
|
29
|
+
if verb == 'POST' || verb == 'PUT'
|
30
|
+
content_type = 'application/json'
|
31
|
+
hex_digest = Digest::MD5.hexdigest(body.to_json)
|
32
|
+
end
|
33
|
+
|
34
|
+
to_digest = "#{verb}\n#{hex_digest}\n#{content_type}\n#{time}\n#{path}"
|
35
|
+
|
36
|
+
Base64.encode64(
|
37
|
+
OpenSSL::HMAC.digest(
|
38
|
+
OpenSSL::Digest::SHA1.new,
|
39
|
+
Vufer.secret_key,
|
40
|
+
to_digest
|
41
|
+
)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/vufer/target.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'faraday'
|
5
|
+
|
6
|
+
module Vufer
|
7
|
+
class Target
|
8
|
+
class << self
|
9
|
+
##
|
10
|
+
# Find a specific target on Vuforia Web Services API.
|
11
|
+
#
|
12
|
+
# @param ID [String] The identifier that exists on Vuforia.
|
13
|
+
#
|
14
|
+
# @return [JSON] the object parsed in JSON from Vuforia.
|
15
|
+
def find(id)
|
16
|
+
time = Time.now.httpdate
|
17
|
+
signature = Vufer::Signature.generate("/targets/#{id}", nil, 'GET', time)
|
18
|
+
|
19
|
+
res = Faraday.get("#{Vufer::BASE_URI}/targets/#{id}", {}, {
|
20
|
+
Date: time,
|
21
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}"
|
22
|
+
})
|
23
|
+
|
24
|
+
JSON.parse(res.body)
|
25
|
+
rescue StandardError => e
|
26
|
+
e.message
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# List all targets associated with server access keys and cloud database.
|
31
|
+
#
|
32
|
+
# @return [Array] A list of target ids associated with the account
|
33
|
+
def all
|
34
|
+
time = Time.now.httpdate
|
35
|
+
signature = Vufer::Signature.generate('/targets', nil, 'GET', time)
|
36
|
+
|
37
|
+
res = Faraday.get("#{Vufer::BASE_URI}/targets", {}, {
|
38
|
+
Date: time,
|
39
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}"
|
40
|
+
})
|
41
|
+
|
42
|
+
JSON.parse(res.body)
|
43
|
+
rescue StandardError => e
|
44
|
+
e.message
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Creates a new target on Vuforia Web Services API.
|
49
|
+
#
|
50
|
+
# @param Name [String] The name of the image to create
|
51
|
+
# @param FileURL [String] Contains the base64 encoded binary recognition image data
|
52
|
+
# @param Width [Fixnum] Width of the target in scene unit
|
53
|
+
# @param ActiveFlag [Boolean] Indicates whether or not the target is active for query, default: false
|
54
|
+
# @param Metadata [Hash] The base64 encoded application metadata associated with the target
|
55
|
+
#
|
56
|
+
# @return [JSON] A newly target id from Vuforia.
|
57
|
+
def create(name, file_path, width = 50.0, active_flag = false, metadata = nil)
|
58
|
+
time = Time.now.httpdate
|
59
|
+
file_encoded = Base64.encode64(open(file_path) { |io| io.read })
|
60
|
+
metadata_encoded = Base64.encode64(metadata.to_s)
|
61
|
+
|
62
|
+
body_hash = {
|
63
|
+
name: name, width: width, image: file_encoded,
|
64
|
+
active_flag: active_flag, application_metadata: metadata_encoded
|
65
|
+
}
|
66
|
+
|
67
|
+
signature = Vufer::Signature.generate(
|
68
|
+
'/targets', body_hash, 'POST', time
|
69
|
+
)
|
70
|
+
|
71
|
+
res = Faraday.post("#{Vufer::BASE_URI}/targets", body_hash.to_json, {
|
72
|
+
Date: time,
|
73
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}",
|
74
|
+
'Content-Type': 'application/json',
|
75
|
+
Accept: 'application/json'
|
76
|
+
})
|
77
|
+
|
78
|
+
JSON.parse(res.body)
|
79
|
+
rescue StandardError => e
|
80
|
+
e.message
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Performs an update for a specific target on the database.
|
85
|
+
#
|
86
|
+
# @param ID [String] The ID(identifier) of the target on Vuforia.
|
87
|
+
# @param Name [String] The name of the image to create
|
88
|
+
# @param FileURL [String] Contains the base64 encoded binary recognition image data
|
89
|
+
# @param Width [Fixnum] Width of the target in scene unit
|
90
|
+
# @param ActiveFlag [Boolean] Indicates whether or not the target is active for query
|
91
|
+
# @param Metadata [Hash] The base64 encoded application metadata associated with the target
|
92
|
+
#
|
93
|
+
# @return [JSON] A info showing success that the target was updated.
|
94
|
+
def update(id, name = nil, file_path = nil, width = nil, active_flag = nil, metadata = nil)
|
95
|
+
time = Time.now.httpdate
|
96
|
+
contents_encoded = file_path ? Base64.encode64(open(file_path) { |io| io.read }) : nil
|
97
|
+
metadata_encoded = metadata ? Base64.encode64(metadata.to_s) : nil
|
98
|
+
|
99
|
+
body_hash = {}.merge(name ? { name: name } : {})
|
100
|
+
body_hash = body_hash.merge(width ? { width: width } : {})
|
101
|
+
body_hash = body_hash.merge(contents_encoded ? { image: contents_encoded } : {})
|
102
|
+
body_hash = body_hash.merge(!active_flag.nil? ? { active_flag: active_flag } : {})
|
103
|
+
body_hash = body_hash.merge(metadata_encoded ? { application_metadata: metadata_encoded } : {})
|
104
|
+
|
105
|
+
signature = Vufer::Signature.generate("/targets/#{id}", body_hash, 'PUT', time)
|
106
|
+
|
107
|
+
res = Faraday.put("#{Vufer::BASE_URI}/targets/#{id}", body_hash.to_json, {
|
108
|
+
Date: time,
|
109
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}",
|
110
|
+
'Content-Type': 'application/json',
|
111
|
+
Accept: 'application/json'
|
112
|
+
})
|
113
|
+
|
114
|
+
JSON.parse(res.body)
|
115
|
+
rescue StandardError => e
|
116
|
+
e.message
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
# Deletes a specific targets from the database.
|
121
|
+
#
|
122
|
+
# Note: Targets in a processing status cannot be deleted.
|
123
|
+
#
|
124
|
+
# @param ID [String] The ID(identifier) of the target on the database.
|
125
|
+
#
|
126
|
+
# @return [JSON] The result code and transaction id indicating the update was ok.
|
127
|
+
def destroy(id)
|
128
|
+
time = Time.now.httpdate
|
129
|
+
signature = Vufer::Signature.generate("/targets/#{id}", nil, 'DELETE', time)
|
130
|
+
|
131
|
+
res = Faraday.delete("#{Vufer::BASE_URI}/targets/#{id}", {}, {
|
132
|
+
Date: time,
|
133
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}"
|
134
|
+
})
|
135
|
+
|
136
|
+
JSON.parse(res.body)
|
137
|
+
rescue StandardError => e
|
138
|
+
e.message
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Review all duplicates targets from the database.
|
143
|
+
#
|
144
|
+
# @param ID [String] The identifier of the target on database.
|
145
|
+
#
|
146
|
+
# @return [JSON] An Array of ids of similar targets
|
147
|
+
def dups(id)
|
148
|
+
time = Time.now.httpdate
|
149
|
+
signature = Vufer::Signature.generate("/duplicates/#{id}", nil, 'GET', time)
|
150
|
+
|
151
|
+
res = Faraday.get("#{Vufer::BASE_URI}/duplicates/#{id}", {}, {
|
152
|
+
Date: time,
|
153
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}"
|
154
|
+
})
|
155
|
+
|
156
|
+
JSON.parse(res.body)
|
157
|
+
rescue StandardError =>
|
158
|
+
e.message
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Load a summary of a specific target on the database.
|
163
|
+
#
|
164
|
+
# @param ID [String] The identifier of the target on database.
|
165
|
+
#
|
166
|
+
# @return [JSON] All the info about database and target.
|
167
|
+
def summary(id)
|
168
|
+
time = Time.now.httpdate
|
169
|
+
signature = Vufer::Signature.generate("/summary/#{id}", nil, 'GET', time)
|
170
|
+
|
171
|
+
res = Faraday.get("#{Vufer::BASE_URI}/summary/#{id}", {}, {
|
172
|
+
Date: time,
|
173
|
+
Authorization: "VWS #{Vufer.access_key}:#{signature}"
|
174
|
+
})
|
175
|
+
|
176
|
+
JSON.parse(res.body)
|
177
|
+
rescue StandardError =>
|
178
|
+
e.message
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
data/lib/vufer.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
require 'vufer/version'
|
4
|
+
require 'vufer/configure'
|
5
|
+
require 'vufer/signature'
|
6
|
+
require 'vufer/target'
|
7
|
+
|
8
|
+
module Vufer
|
9
|
+
extend Configure
|
10
|
+
|
11
|
+
BASE_URI = 'https://vws.vuforia.com'.freeze
|
12
|
+
|
13
|
+
class Error < StandardError; end
|
14
|
+
class KeyEnvironmentError < Error; end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
##
|
18
|
+
# Returns a summary from targets, quota and images from Vuforia.
|
19
|
+
#
|
20
|
+
# @result [JSON] object containing all the info about targets, quota and images.
|
21
|
+
def summary
|
22
|
+
time = Time.now.httpdate
|
23
|
+
signature = Vufer::Signature.generate('/summary', nil, 'GET', time)
|
24
|
+
|
25
|
+
res = Faraday.get("#{Vufer::BASE_URI}/summary", {}, {
|
26
|
+
'Date': time,
|
27
|
+
'Authorization': "VWS #{Vufer.access_key}:#{signature}"
|
28
|
+
})
|
29
|
+
|
30
|
+
JSON.parse(res.body)
|
31
|
+
rescue StandardError => e
|
32
|
+
e.message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/vufer.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'vufer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'vufer'
|
8
|
+
spec.version = Vufer::VERSION
|
9
|
+
spec.authors = ['Randson']
|
10
|
+
spec.email = ['orandson@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'A Ruby Gem to Interact with Vuforia Web Service API'
|
13
|
+
spec.homepage = 'https://github.com/rands0n/vufer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
18
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/tree/master/CHANGELOG.md"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vufer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Randson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- orandson@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".env.example"
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".ruby-version"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CHANGELOG.md
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Dockerfile
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- docker-compose.yml
|
78
|
+
- lib/vufer.rb
|
79
|
+
- lib/vufer/configure.rb
|
80
|
+
- lib/vufer/signature.rb
|
81
|
+
- lib/vufer/target.rb
|
82
|
+
- lib/vufer/version.rb
|
83
|
+
- vufer.gemspec
|
84
|
+
homepage: https://github.com/rands0n/vufer
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata:
|
88
|
+
homepage_uri: https://github.com/rands0n/vufer
|
89
|
+
source_code_uri: https://github.com/rands0n/vufer
|
90
|
+
changelog_uri: https://github.com/rands0n/vufer/tree/master/CHANGELOG.md
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.0.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: A Ruby Gem to Interact with Vuforia Web Service API
|
110
|
+
test_files: []
|