hover-ruby-client 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +30 -0
- data/.gitignore +64 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +161 -0
- data/README.md +50 -0
- data/Rakefile +14 -0
- data/hover-ruby-client.gemspec +38 -0
- data/lib/hover/client/basic_auth.rb +18 -0
- data/lib/hover/client/hmac.rb +20 -0
- data/lib/hover/client/hover.rb +29 -0
- data/lib/hover/client/http.rb +141 -0
- data/lib/hover/client/manowar.rb +17 -0
- data/lib/hover/client/midas.rb +120 -0
- data/lib/hover/client/static.rb +89 -0
- data/lib/hover/decoder/json_stream.rb +25 -0
- data/lib/hover/encoder/json_stream.rb +35 -0
- data/lib/hover/importer/active_record.rb +134 -0
- data/lib/hover/jobs/concerns/retry_network_errors.rb +45 -0
- data/lib/hover/version.rb +3 -0
- data/test/app/Gemfile +1 -0
- data/test/files/archive.zip +0 -0
- data/test/files/encoded.json +106 -0
- data/test/test_helper.rb +80 -0
- data/test/unit/client/basic_auth_test.rb +21 -0
- data/test/unit/client/hmac_test.rb +277 -0
- data/test/unit/client/hover_test.rb +62 -0
- data/test/unit/client/manowar_test.rb +34 -0
- data/test/unit/client/midas_test.rb +187 -0
- data/test/unit/client/static_test.rb +169 -0
- data/test/unit/decoder/json_stream_test.rb +8 -0
- data/test/unit/encoder/json_stream_test.rb +135 -0
- data/test/unit/importer/active_record_test.rb +354 -0
- data/test/unit/jobs/concerns/retry_network_errors_test.rb +23 -0
- metadata +286 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b2391e2c552304bb49a600e8dbf0f7ee54272a31865359458b8861bc2b80220e
|
4
|
+
data.tar.gz: 7ab4b5bed3b7821610f8ed33dcc7b5f4339905b341cb297decb1c0fa0a7228d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc76225239a7852cfa94c5943acf6063862ba2f4c0fad7735b22670fcf12c12a69fc6247048ab6152e73ea266cddcaa5cd07431006c0abd7b442d7919062d744
|
7
|
+
data.tar.gz: a920d7ee18a50b88e9a4c6373e6411b7ca1ad4056a1447d189446414384c262701cd7c38aaf2ff31d061a8268af8e1c5fb39525fc42ab3af9ac3c4f9671f973a
|
@@ -0,0 +1,30 @@
|
|
1
|
+
on: [push]
|
2
|
+
|
3
|
+
name: Tests
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- name: Install libraries
|
11
|
+
run: |
|
12
|
+
sudo apt-get update
|
13
|
+
sudo apt-get install -y sqlite3 libsqlite3-dev
|
14
|
+
|
15
|
+
- name: Checkout repository
|
16
|
+
uses: actions/checkout@v1
|
17
|
+
|
18
|
+
- name: Set up Ruby 2.6
|
19
|
+
uses: ruby/setup-ruby@master
|
20
|
+
with:
|
21
|
+
ruby-version: 2.6.6
|
22
|
+
|
23
|
+
- name: Install Ruby gems
|
24
|
+
run: |
|
25
|
+
gem install bundler
|
26
|
+
bundle install --jobs 4 --retry 3
|
27
|
+
|
28
|
+
- name: Run tests
|
29
|
+
run: |
|
30
|
+
bundle exec rake test
|
data/.gitignore
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
test/reports
|
3
|
+
reports
|
4
|
+
/.bundle
|
5
|
+
.bundle
|
6
|
+
|
7
|
+
/db/*.sqlite3
|
8
|
+
/db/*.sqlite3-journal
|
9
|
+
*.sqlite3
|
10
|
+
|
11
|
+
# Ignore all logfiles and tempfiles.
|
12
|
+
/log/*.log
|
13
|
+
/tmp
|
14
|
+
tmp/
|
15
|
+
|
16
|
+
.DS_Store
|
17
|
+
subl.sublime-project
|
18
|
+
storage/
|
19
|
+
storage
|
20
|
+
.idea/
|
21
|
+
database.yml
|
22
|
+
structure.sql
|
23
|
+
api_keys.yml
|
24
|
+
public/assets/
|
25
|
+
coverage/
|
26
|
+
*.sublime-workspace
|
27
|
+
node_modules
|
28
|
+
test-results.xml
|
29
|
+
|
30
|
+
config/deploy/jenkins.rb
|
31
|
+
doc/
|
32
|
+
.yardoc/
|
33
|
+
.vagrant/
|
34
|
+
*.box
|
35
|
+
|
36
|
+
# VIM Files
|
37
|
+
*.swp
|
38
|
+
*.swo
|
39
|
+
|
40
|
+
|
41
|
+
InstalledFiles
|
42
|
+
_yardoc
|
43
|
+
coverage
|
44
|
+
doc/
|
45
|
+
lib/bundler/man
|
46
|
+
pkg
|
47
|
+
rdoc
|
48
|
+
spec/reports
|
49
|
+
test/tmp
|
50
|
+
test/version_tmp
|
51
|
+
tmp
|
52
|
+
*.swp
|
53
|
+
*.swo
|
54
|
+
test/*.sqlite3
|
55
|
+
test/reports/
|
56
|
+
.DS_Store
|
57
|
+
coverage/
|
58
|
+
|
59
|
+
*.gem
|
60
|
+
*.rbc
|
61
|
+
.bundle
|
62
|
+
.config
|
63
|
+
.yardoc
|
64
|
+
.tool-versions
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hover-ruby-client (0.3.1)
|
5
|
+
api-auth (= 1.2.2)
|
6
|
+
json
|
7
|
+
rails (~> 5.2.3)
|
8
|
+
rubyzip (>= 0.9.9)
|
9
|
+
yajl-ruby (~> 1.4.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actioncable (5.2.4.2)
|
15
|
+
actionpack (= 5.2.4.2)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
actionmailer (5.2.4.2)
|
19
|
+
actionpack (= 5.2.4.2)
|
20
|
+
actionview (= 5.2.4.2)
|
21
|
+
activejob (= 5.2.4.2)
|
22
|
+
mail (~> 2.5, >= 2.5.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
actionpack (5.2.4.2)
|
25
|
+
actionview (= 5.2.4.2)
|
26
|
+
activesupport (= 5.2.4.2)
|
27
|
+
rack (~> 2.0, >= 2.0.8)
|
28
|
+
rack-test (>= 0.6.3)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
+
actionview (5.2.4.2)
|
32
|
+
activesupport (= 5.2.4.2)
|
33
|
+
builder (~> 3.1)
|
34
|
+
erubi (~> 1.4)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
37
|
+
activejob (5.2.4.2)
|
38
|
+
activesupport (= 5.2.4.2)
|
39
|
+
globalid (>= 0.3.6)
|
40
|
+
activemodel (5.2.4.2)
|
41
|
+
activesupport (= 5.2.4.2)
|
42
|
+
activerecord (5.2.4.2)
|
43
|
+
activemodel (= 5.2.4.2)
|
44
|
+
activesupport (= 5.2.4.2)
|
45
|
+
arel (>= 9.0)
|
46
|
+
activestorage (5.2.4.2)
|
47
|
+
actionpack (= 5.2.4.2)
|
48
|
+
activerecord (= 5.2.4.2)
|
49
|
+
marcel (~> 0.3.1)
|
50
|
+
activesupport (5.2.4.2)
|
51
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
52
|
+
i18n (>= 0.7, < 2)
|
53
|
+
minitest (~> 5.1)
|
54
|
+
tzinfo (~> 1.1)
|
55
|
+
ansi (1.5.0)
|
56
|
+
api-auth (1.2.2)
|
57
|
+
arel (9.0.0)
|
58
|
+
builder (3.2.4)
|
59
|
+
byebug (11.1.1)
|
60
|
+
ci_reporter (2.0.0)
|
61
|
+
builder (>= 2.1.2)
|
62
|
+
concurrent-ruby (1.1.6)
|
63
|
+
crass (1.0.6)
|
64
|
+
docile (1.3.2)
|
65
|
+
erubi (1.9.0)
|
66
|
+
globalid (0.4.2)
|
67
|
+
activesupport (>= 4.2.0)
|
68
|
+
i18n (1.8.2)
|
69
|
+
concurrent-ruby (~> 1.0)
|
70
|
+
json (2.3.0)
|
71
|
+
loofah (2.5.0)
|
72
|
+
crass (~> 1.0.2)
|
73
|
+
nokogiri (>= 1.5.9)
|
74
|
+
mail (2.7.1)
|
75
|
+
mini_mime (>= 0.1.1)
|
76
|
+
marcel (0.3.3)
|
77
|
+
mimemagic (~> 0.3.2)
|
78
|
+
method_source (1.0.0)
|
79
|
+
mimemagic (0.3.4)
|
80
|
+
mini_mime (1.0.2)
|
81
|
+
mini_portile2 (2.4.0)
|
82
|
+
minitest (5.11.3)
|
83
|
+
minitest-reporters (1.4.2)
|
84
|
+
ansi
|
85
|
+
builder
|
86
|
+
minitest (>= 5.0)
|
87
|
+
ruby-progressbar
|
88
|
+
mocha (1.11.2)
|
89
|
+
nio4r (2.5.2)
|
90
|
+
nokogiri (1.10.9)
|
91
|
+
mini_portile2 (~> 2.4.0)
|
92
|
+
rack (2.2.2)
|
93
|
+
rack-test (1.1.0)
|
94
|
+
rack (>= 1.0, < 3)
|
95
|
+
rails (5.2.4.2)
|
96
|
+
actioncable (= 5.2.4.2)
|
97
|
+
actionmailer (= 5.2.4.2)
|
98
|
+
actionpack (= 5.2.4.2)
|
99
|
+
actionview (= 5.2.4.2)
|
100
|
+
activejob (= 5.2.4.2)
|
101
|
+
activemodel (= 5.2.4.2)
|
102
|
+
activerecord (= 5.2.4.2)
|
103
|
+
activestorage (= 5.2.4.2)
|
104
|
+
activesupport (= 5.2.4.2)
|
105
|
+
bundler (>= 1.3.0)
|
106
|
+
railties (= 5.2.4.2)
|
107
|
+
sprockets-rails (>= 2.0.0)
|
108
|
+
rails-dom-testing (2.0.3)
|
109
|
+
activesupport (>= 4.2.0)
|
110
|
+
nokogiri (>= 1.6)
|
111
|
+
rails-html-sanitizer (1.3.0)
|
112
|
+
loofah (~> 2.3)
|
113
|
+
railties (5.2.4.2)
|
114
|
+
actionpack (= 5.2.4.2)
|
115
|
+
activesupport (= 5.2.4.2)
|
116
|
+
method_source
|
117
|
+
rake (>= 0.8.7)
|
118
|
+
thor (>= 0.19.0, < 2.0)
|
119
|
+
rake (13.0.1)
|
120
|
+
ruby-progressbar (1.10.1)
|
121
|
+
rubyzip (2.3.0)
|
122
|
+
simplecov (0.18.5)
|
123
|
+
docile (~> 1.1)
|
124
|
+
simplecov-html (~> 0.11)
|
125
|
+
simplecov-html (0.12.2)
|
126
|
+
simplecov-rcov (0.2.3)
|
127
|
+
simplecov (>= 0.4.1)
|
128
|
+
sprockets (4.0.0)
|
129
|
+
concurrent-ruby (~> 1.0)
|
130
|
+
rack (> 1, < 3)
|
131
|
+
sprockets-rails (3.2.1)
|
132
|
+
actionpack (>= 4.0)
|
133
|
+
activesupport (>= 4.0)
|
134
|
+
sprockets (>= 3.0.0)
|
135
|
+
sqlite3 (1.4.2)
|
136
|
+
thor (1.0.1)
|
137
|
+
thread_safe (0.3.6)
|
138
|
+
tzinfo (1.2.7)
|
139
|
+
thread_safe (~> 0.1)
|
140
|
+
websocket-driver (0.7.1)
|
141
|
+
websocket-extensions (>= 0.1.0)
|
142
|
+
websocket-extensions (0.1.4)
|
143
|
+
yajl-ruby (1.4.1)
|
144
|
+
|
145
|
+
PLATFORMS
|
146
|
+
ruby
|
147
|
+
|
148
|
+
DEPENDENCIES
|
149
|
+
bundler
|
150
|
+
byebug
|
151
|
+
ci_reporter
|
152
|
+
hover-ruby-client!
|
153
|
+
minitest
|
154
|
+
minitest-reporters
|
155
|
+
mocha
|
156
|
+
rake
|
157
|
+
simplecov-rcov
|
158
|
+
sqlite3
|
159
|
+
|
160
|
+
BUNDLED WITH
|
161
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
## Examples
|
2
|
+
|
3
|
+
### Midas
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
require 'hover/client/midas'
|
7
|
+
|
8
|
+
client = Hover::Client::Midas.new('access_id', 'secret_key', 'https://staging-midas.hover.to')
|
9
|
+
|
10
|
+
order = client.json_post('orders.json', {'order[address]' => '945 Bryant St, Suite 300, San Francisco, CA', 'order[advanced]' => false})
|
11
|
+
order = client.json_get("orders/#{order['id']}.json")
|
12
|
+
```
|
13
|
+
|
14
|
+
### Manowar
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'hover/client/manowar'
|
18
|
+
|
19
|
+
client = Hover::Client::Manowar.new('access_id', 'secret_key', 'https://staging-manownar.hover.to')
|
20
|
+
|
21
|
+
order = client.json_get("orders/2.json")
|
22
|
+
```
|
23
|
+
|
24
|
+
### Static
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'hover/client/static'
|
28
|
+
|
29
|
+
client = Hover::Client::Static.new('access_id', 'secret_key', 'https://staging-static.hover.to')
|
30
|
+
|
31
|
+
metric_name = 'order.state.time.modeling'
|
32
|
+
value = (60 * 40) # 40 minutes in seconds
|
33
|
+
happened_at = order_state_transition.created_at
|
34
|
+
tags = {
|
35
|
+
resource_type: 'human',
|
36
|
+
waiting: false,
|
37
|
+
order_id: order.id,
|
38
|
+
order_practice: order.practice?,
|
39
|
+
order_midas_identifier: order.midas_identifier,
|
40
|
+
user_email: order_state_transition.trigger_user.email
|
41
|
+
}
|
42
|
+
|
43
|
+
client.create_metric(metric_name, value, happened_at, tags)
|
44
|
+
```
|
45
|
+
|
46
|
+
### Importer
|
47
|
+
|
48
|
+
### Streaming JSON Encoder
|
49
|
+
|
50
|
+
### Streaming JSON Decoder
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
desc 'Run tests'
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.libs << 'test'
|
9
|
+
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.verbose = false
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Default: run all available test suites'
|
14
|
+
task :default => :test
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require "hover/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "hover-ruby-client"
|
10
|
+
spec.version = Hover::VERSION
|
11
|
+
spec.authors = ["Elise Wood"]
|
12
|
+
spec.email = ["elise@hover.to"]
|
13
|
+
spec.summary = %q{Hover ruby client}
|
14
|
+
spec.description = %q{Hover ruby client}
|
15
|
+
spec.homepage = "https://github.com/hoverinc/hover-ruby-client"
|
16
|
+
spec.license = "Private"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "minitest"
|
26
|
+
spec.add_development_dependency "mocha"
|
27
|
+
spec.add_development_dependency "ci_reporter"
|
28
|
+
spec.add_development_dependency "minitest-reporters"
|
29
|
+
spec.add_development_dependency "simplecov-rcov"
|
30
|
+
spec.add_development_dependency "sqlite3"
|
31
|
+
spec.add_development_dependency "byebug"
|
32
|
+
|
33
|
+
spec.add_dependency "api-auth", "1.2.2"
|
34
|
+
spec.add_dependency "json"
|
35
|
+
spec.add_dependency "rubyzip", ">= 0.9.9"
|
36
|
+
spec.add_dependency "rails", "~> 5.2.3"
|
37
|
+
spec.add_dependency "yajl-ruby", "~> 1.4.1"
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'hover/client/http'
|
2
|
+
|
3
|
+
module Hover
|
4
|
+
module Client
|
5
|
+
class BasicAuth < Hover::Client::HTTP
|
6
|
+
attr_accessor :username, :password
|
7
|
+
|
8
|
+
def initialize(username, password)
|
9
|
+
self.username = username
|
10
|
+
self.password = password
|
11
|
+
end
|
12
|
+
|
13
|
+
def authenticate(request)
|
14
|
+
request.basic_auth(username, password)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'hover/client/http'
|
2
|
+
|
3
|
+
module Hover
|
4
|
+
module Client
|
5
|
+
class HMAC < Hover::Client::HTTP
|
6
|
+
attr_accessor :client_id, :client_secret
|
7
|
+
|
8
|
+
def initialize(client_id, client_secret, site = 'http://localhost:3000', prefix = 'api/v1')
|
9
|
+
super(site, prefix)
|
10
|
+
|
11
|
+
self.client_id = client_id
|
12
|
+
self.client_secret = client_secret
|
13
|
+
end
|
14
|
+
|
15
|
+
def authenticate(request)
|
16
|
+
ApiAuth.sign!(request, client_id, client_secret)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'hover/client/hmac'
|
2
|
+
|
3
|
+
module Hover
|
4
|
+
module Client
|
5
|
+
class Hover < Hover::Client::HMAC
|
6
|
+
|
7
|
+
def json_get(*args)
|
8
|
+
parse_response(get(*args))
|
9
|
+
end
|
10
|
+
|
11
|
+
def json_put(*args)
|
12
|
+
parse_response(put(*args))
|
13
|
+
end
|
14
|
+
|
15
|
+
def json_post(*args)
|
16
|
+
parse_response(post(*args))
|
17
|
+
end
|
18
|
+
|
19
|
+
def json_patch(*args)
|
20
|
+
parse_response(patch(*args))
|
21
|
+
end
|
22
|
+
|
23
|
+
def json_delete(*args)
|
24
|
+
parse_response(delete(*args))
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|