vault-usage-client 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 102e34a7cb1dd30db607612394f6b8b8d3b94af9
4
- data.tar.gz: a901605e7da73791d57631ea4a726d2d051d8f42
3
+ metadata.gz: 5537f1ed6faba6000f84cf0e909715e907713f3d
4
+ data.tar.gz: 1b99454688ff02d2bd9fbb75b220283a7d4de29d
5
5
  SHA512:
6
- metadata.gz: 3adb16ddbb8a0883730202843aa845f50a1f0fde8d274cf60ce1cb11025acf5b34fb29952ab33faf11fc25965626dfd0389a43bba27ffe502bb6aba2af3ab6ff
7
- data.tar.gz: 2708bea990ecff179dbefe9542092ff28927610bac75e28778f2e28c7526b3995bdfe724fadba6f29de492c4efea79e904ca527db5d0984440bb936d20273f0e
6
+ metadata.gz: f95383bfb53f250db7dbe4a1e09546f103a9f8392bb3d6c1a6ecfcaa2f8e448afdf2fd6e5573014a579c93e2a7ffba1014f69e7e0c5e50e22548df1716b012b2
7
+ data.tar.gz: 12db53a91b8b6e9bd3c022f5c0b9905f38f5306ef6ed5d6896daa1c53479663a9789f3c298c96326cfc76778498c17d84eda8608c9f34b7c16734ec693386834
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ vault-usage-client
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3-p545
4
+ - 2.0.0-p353
5
+ - 2.1.0
data/Gemfile CHANGED
@@ -4,9 +4,11 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem 'rake'
7
+ gem 'yard'
7
8
  end
8
9
 
9
10
  group :test do
10
11
  gem 'rr'
12
+ gem 'scrolls'
11
13
  gem 'vault-test-tools'
12
14
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vault-usage-client (0.0.6)
4
+ vault-usage-client (0.0.8)
5
5
  colorize
6
6
  excon
7
7
  multi_json
@@ -10,40 +10,65 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ansi (1.4.3)
13
+ blankslate (2.1.2.4)
14
+ celluloid (0.15.2)
15
+ timers (~> 1.1.0)
16
+ coderay (1.1.0)
13
17
  colorize (0.6.0)
14
18
  excon (0.27.1)
15
- json (1.8.0)
16
- mini_portile (0.5.1)
17
- minitest (4.7.4)
19
+ ffi (1.9.3)
20
+ formatador (0.2.5)
21
+ guard (2.6.1)
22
+ formatador (>= 0.2.4)
23
+ listen (~> 2.7)
24
+ lumberjack (~> 1.0)
25
+ pry (>= 0.9.12)
26
+ thor (>= 0.18.1)
27
+ guard-minitest (2.3.1)
28
+ guard (~> 2.0)
29
+ minitest (>= 3.0)
30
+ listen (2.7.9)
31
+ celluloid (>= 0.15.2)
32
+ rb-fsevent (>= 0.9.3)
33
+ rb-inotify (>= 0.9)
34
+ logfmt (0.0.4)
35
+ parslet (~> 1.5)
36
+ lumberjack (1.0.9)
37
+ method_source (0.8.2)
38
+ mini_portile (0.6.0)
39
+ minitest (4.7.5)
18
40
  multi_json (1.8.1)
19
- nokogiri (1.6.0)
20
- mini_portile (~> 0.5.0)
21
- open4 (1.3.0)
22
- perftools.rb (2.0.1)
41
+ nokogiri (1.6.2.1)
42
+ mini_portile (= 0.6.0)
43
+ parslet (1.6.1)
44
+ blankslate (~> 2.0)
45
+ pry (0.10.0)
46
+ coderay (~> 1.1.0)
47
+ method_source (~> 0.8.1)
48
+ slop (~> 3.4)
23
49
  rack (1.5.2)
24
- rack-perftools_profiler (0.6.1)
25
- open4 (~> 1.0)
26
- perftools.rb (~> 2.0.1)
27
- rack (~> 1.0)
28
50
  rack-test (0.6.2)
29
51
  rack (>= 1.0)
30
52
  rake (10.1.0)
31
- rdoc (4.0.1)
32
- json (~> 1.4)
33
- redcarpet (3.0.0)
53
+ rb-fsevent (0.9.4)
54
+ rb-inotify (0.9.5)
55
+ ffi (>= 0.5.0)
34
56
  rr (1.1.2)
35
- turn (0.9.6)
57
+ scrolls (0.3.8)
58
+ slop (3.5.0)
59
+ thor (0.19.1)
60
+ timers (1.1.0)
61
+ turn (0.9.7)
36
62
  ansi
37
- vault-test-tools (0.3.4)
38
- minitest (= 4.7.4)
63
+ minitest (~> 4)
64
+ vault-test-tools (0.3.7)
65
+ guard-minitest
66
+ logfmt
67
+ minitest (~> 4.7.4)
39
68
  nokogiri
40
- rack-perftools_profiler
41
69
  rack-test
42
- rdoc
43
- redcarpet
44
70
  rr
45
71
  turn
46
- yard
47
72
  yard (0.8.7.2)
48
73
 
49
74
  PLATFORMS
@@ -52,5 +77,7 @@ PLATFORMS
52
77
  DEPENDENCIES
53
78
  rake
54
79
  rr
80
+ scrolls
55
81
  vault-test-tools
56
82
  vault-usage-client!
83
+ yard
data/README.md CHANGED
@@ -41,7 +41,7 @@ You must supply these when you create a new client:
41
41
  ```ruby
42
42
  require 'vault-usage-client'
43
43
 
44
- client = Vault::Usage::Client::Client.new(
44
+ client = Vault::Usage::Client.new(
45
45
  'https://username:secret@vault-usage.herokuapp.com')
46
46
  ```
47
47
 
@@ -163,3 +163,27 @@ app_hid = 'app1234@heroku.com'
163
163
  stop_time = Time.now.getutc
164
164
  client.close_app_ownership_event(event_id, user_hid, app_hid, stop_time)
165
165
  ```
166
+
167
+ ## License
168
+
169
+ The MIT License (MIT)
170
+
171
+ Copyright (c) 2014 Heroku
172
+
173
+ Permission is hereby granted, free of charge, to any person obtaining a copy
174
+ of this software and associated documentation files (the "Software"), to deal
175
+ in the Software without restriction, including without limitation the rights
176
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
177
+ copies of the Software, and to permit persons to whom the Software is
178
+ furnished to do so, subject to the following conditions:
179
+
180
+ The above copyright notice and this permission notice shall be included in all
181
+ copies or substantial portions of the Software.
182
+
183
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
184
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
186
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
187
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
188
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
189
+ SOFTWARE.
@@ -170,6 +170,40 @@ module Vault::Usage
170
170
  end
171
171
  end
172
172
 
173
+ # Get the open dyno usage events for the specified app
174
+ #
175
+ # @param app_hid [String] The app HID, such as `app1234@heroku.com`, to
176
+ # fetch open dyno usage data for.
177
+ # @raise [Excon::Errors::HTTPStatusError] Raised if the server returns an
178
+ # unsuccessful HTTP status code.
179
+ # @return [Array] A list of usage events for the specified app, matching
180
+ # the following format:
181
+ #
182
+ # ```
183
+ # [{id: '<event-uuid>',
184
+ # product: '<name>',
185
+ # consumer: '<heroku-id>',
186
+ # start_time: <Time>,
187
+ # stop_time: <Time>,
188
+ # detail: {<key1>: <value1>,
189
+ # <key2>: <value2>,
190
+ # ...}},
191
+ # ...]}
192
+ # ```
193
+ def open_dynos_for_app(app_hid)
194
+ path = "/apps/#{app_hid}/ps/open"
195
+ query = {}
196
+ connection = Excon.new(@url)
197
+ response = connection.get(path: path, expects: [200], query: query)
198
+ payload = MultiJson.load(response.body, {symbolize_keys: true})
199
+ events = payload[:events]
200
+ events.each do |event|
201
+ event.each do |key, value|
202
+ event[key] = parse_date(value) if date?(value)
203
+ end
204
+ end
205
+ end
206
+
173
207
  # Report that ownership of an app by a user started at a particular time.
174
208
  #
175
209
  # @param event_id [String] A UUID that uniquely identifies the ownership
@@ -2,7 +2,7 @@ module Vault
2
2
  module Usage
3
3
  class Client
4
4
  # The `Vault::Usage::Client` gem version.
5
- VERSION = '0.0.7'
5
+ VERSION = '0.0.8'
6
6
  end
7
7
  end
8
8
  end
data/test/client_test.rb CHANGED
@@ -424,4 +424,20 @@ class ClientTest < Vault::TestCase
424
424
  @stop_time)
425
425
  end
426
426
  end
427
+
428
+ # Client.open_dynos_for_ap makes a GET request to the Vault::Usage HTTP API,
429
+ # passing the supplied credentials using HTTP basic auth, to retrieve the
430
+ # open dyno usage events for a particular app
431
+ def test_usage_for_user
432
+ Excon.stub(method: :get) do |request|
433
+ assert_equal('Basic dXNlcm5hbWU6c2VjcmV0',
434
+ request[:headers]['Authorization'])
435
+ assert_equal('vault-usage.herokuapp.com', request[:host])
436
+ assert_equal('443', request[:port])
437
+ assert_equal("/apps/#{@app_hid}/ps/open", request[:path])
438
+ Excon.stubs.pop
439
+ {status: 200, body: MultiJson.dump({events: []})}
440
+ end
441
+ assert_equal([], @client.open_dynos_for_app(@app_hid))
442
+ end
427
443
  end
@@ -3,20 +3,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'vault-usage-client/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
- gem.name = "vault-usage-client"
6
+ gem.name = 'vault-usage-client'
7
7
  gem.version = Vault::Usage::Client::VERSION
8
- gem.authors = ["Chris Continanza", "Jamu Kakar"]
9
- gem.email = ["csquared@heroku.com", "jkakar@heroku.com"]
10
- gem.description = "Client for Vault::Usage"
11
- gem.summary = "A simple wrapper around the Vault::Usage HTTP API"
12
- gem.homepage = "https://github.com/heroku/vault-usage-client"
8
+ gem.authors = ['Chris Continanza', 'Jamu Kakar']
9
+ gem.email = ['csquared@heroku.com', 'jkakar@heroku.com']
10
+ gem.description = 'Client for Vault::Usage'
11
+ gem.summary = 'A simple wrapper around the Vault::Usage HTTP API'
12
+ gem.homepage = 'https://github.com/heroku/vault-usage-client'
13
+ gem.license = 'MIT'
13
14
 
14
15
  gem.files = `git ls-files`.split($/)
15
16
  gem.test_files = gem.files.grep('^(test|spec|features)/')
16
- gem.require_paths = ["lib"]
17
+ gem.require_paths = ['lib']
17
18
  gem.executables = ['vault-usage']
18
19
 
19
20
  gem.add_dependency 'excon'
20
- gem.add_dependency "multi_json"
21
+ gem.add_dependency 'multi_json'
21
22
  gem.add_dependency 'colorize'
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-usage-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
@@ -9,48 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-07 00:00:00.000000000 Z
12
+ date: 2014-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: multi_json
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: colorize
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: Client for Vault::Usage
@@ -62,8 +62,11 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - .gitignore
66
- - .yardopts
65
+ - ".gitignore"
66
+ - ".ruby-gemset"
67
+ - ".ruby-version"
68
+ - ".travis.yml"
69
+ - ".yardopts"
67
70
  - Gemfile
68
71
  - Gemfile.lock
69
72
  - README.md
@@ -77,7 +80,8 @@ files:
77
80
  - test/version_test.rb
78
81
  - vault-usage-client.gemspec
79
82
  homepage: https://github.com/heroku/vault-usage-client
80
- licenses: []
83
+ licenses:
84
+ - MIT
81
85
  metadata: {}
82
86
  post_install_message:
83
87
  rdoc_options: []
@@ -85,12 +89,12 @@ require_paths:
85
89
  - lib
86
90
  required_ruby_version: !ruby/object:Gem::Requirement
87
91
  requirements:
88
- - - '>='
92
+ - - ">="
89
93
  - !ruby/object:Gem::Version
90
94
  version: '0'
91
95
  required_rubygems_version: !ruby/object:Gem::Requirement
92
96
  requirements:
93
- - - '>='
97
+ - - ">="
94
98
  - !ruby/object:Gem::Version
95
99
  version: '0'
96
100
  requirements: []