vault-tools 0.4.6 → 0.4.7

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.
@@ -2,6 +2,7 @@ require 'uuidtools'
2
2
 
3
3
  module Vault
4
4
  module App
5
+ ID_CAPTURE = /^app(\d+)\@[\w\.]+com$/
5
6
  # Convert a core app ID into a Heroku app ID.
6
7
  #
7
8
  # @param app_id [Fixnum] A core app ID.
@@ -25,7 +26,7 @@ module Vault
25
26
  # @raise [ArgumentError] Raised if a malformed Heroku ID is provided.
26
27
  # @return [Fixnum] The core app ID that uniquely represents the app.
27
28
  def self.hid_to_id(heroku_id)
28
- if app_id = heroku_id.slice(/^app(\d+)\@heroku\.com$/, 1)
29
+ if app_id = heroku_id.slice(ID_CAPTURE, 1)
29
30
  app_id.to_i
30
31
  else
31
32
  raise ArgumentError,"#{heroku_id} is not a valid Heroku app ID."
@@ -38,7 +39,7 @@ module Vault
38
39
  # @raise [ArgumentError] Raised if a malformed Heroku ID is provided.
39
40
  # @return [String] A v5 UUID that uniquely represents the app.
40
41
  def self.hid_to_uuid(heroku_id)
41
- if app_id = heroku_id.slice(/^app(\d+)\@heroku\.com$/, 1)
42
+ if app_id = heroku_id.slice(ID_CAPTURE, 1)
42
43
  id_to_uuid(app_id)
43
44
  else
44
45
  raise ArgumentError, "#{heroku_id} is not a valid Heroku app ID."
@@ -2,6 +2,7 @@ require 'uuidtools'
2
2
 
3
3
  module Vault
4
4
  module User
5
+ ID_CAPTURE = /^user(\d+)\@[\w\.]+com$/
5
6
  # Convert a user ID into a Heroku user ID.
6
7
  #
7
8
  # @param user_id [Fixnum] A user ID.
@@ -26,7 +27,7 @@ module Vault
26
27
  # @raise [ArgumentError] Raised if a malformed Heroku ID is provided.
27
28
  # @return [Fixnum] The core user ID that uniquely represents the user.
28
29
  def self.hid_to_id(heroku_id)
29
- if user_id = heroku_id.slice(/^user(\d+)\@heroku\.com$/, 1)
30
+ if user_id = heroku_id.slice(ID_CAPTURE, 1)
30
31
  user_id.to_i
31
32
  else
32
33
  raise ArgumentError,"#{heroku_id} is not a valid Heroku user ID."
@@ -40,7 +41,7 @@ module Vault
40
41
  # @raise [ArgumentError] Raised if a malformed Heroku ID is provided.
41
42
  # @return [String] A v5 UUID that uniquely represents the user.
42
43
  def self.hid_to_uuid(heroku_id)
43
- if user_id = heroku_id.slice(/^user(\d+)\@heroku\.com$/, 1)
44
+ if user_id = heroku_id.slice(ID_CAPTURE, 1)
44
45
  id_to_uuid(user_id)
45
46
  else
46
47
  raise ArgumentError,"#{heroku_id} is not a valid Heroku user ID."
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Tools
3
- VERSION = '0.4.6'
3
+ VERSION = '0.4.7'
4
4
  end
5
5
  end
data/test/app_test.rb CHANGED
@@ -19,6 +19,11 @@ class AppTest < Vault::TestCase
19
19
  assert_equal(1234, Vault::App.hid_to_id('app1234@heroku.com'))
20
20
  end
21
21
 
22
+ # App.hid_to_id converts a staging Heroku app ID into a core integer app ID.
23
+ def test_staging_hid_to_id
24
+ assert_equal(1234, Vault::App.hid_to_id('app1234@staging.herokudev.com'))
25
+ end
26
+
22
27
  # App.hid_to_id raises an ArgumentError if the specified ID doesn't match
23
28
  # the expected format.
24
29
  def test_hid_to_id_with_invalid_heroku_id
data/test/user_test.rb CHANGED
@@ -19,6 +19,11 @@ class UserTest < Vault::TestCase
19
19
  assert_equal(1234, Vault::User.hid_to_id('user1234@heroku.com'))
20
20
  end
21
21
 
22
+ # User.hid_to_id converts a staging Heroku user ID into a core integer user ID.
23
+ def test_staging_hid_to_id
24
+ assert_equal(1234, Vault::User.hid_to_id('user1234@staging.herokudev.com'))
25
+ end
26
+
22
27
  # User.hid_to_id raises an ArgumentError if the specified ID doesn't match
23
28
  # the expected format.
24
29
  def test_hid_to_id_with_invalid_heroku_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-10 00:00:00.000000000 Z
13
+ date: 2013-12-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: scrolls
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  segments:
187
187
  - 0
188
- hash: -4115367332515730407
188
+ hash: -1924830184331930765
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  none: false
191
191
  requirements:
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: -4115367332515730407
197
+ hash: -1924830184331930765
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 1.8.23