vault-tools 0.3.0 → 0.3.1

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,9 @@ require 'uuidtools'
2
2
 
3
3
  module Vault
4
4
  module HID
5
+ USER_HID_REGEX = /\Auser(\d+)@heroku.com/
6
+ APP_HID_REGEX = /\Aapp(\d+)@heroku.com/
7
+
5
8
  # Convert a Heroku app ID or user ID into a v5 UUID.
6
9
  #
7
10
  # @param heroku_id [String] A Heroku app ID or user ID.
@@ -18,5 +21,12 @@ module Vault
18
21
  "user ID."
19
22
  end
20
23
  end
24
+
25
+ def self.hid?(string)
26
+ case string
27
+ when APP_HID_REGEX; :app;
28
+ when USER_HID_REGEX; :user;
29
+ end
30
+ end
21
31
  end
22
32
  end
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Tools
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
data/test/hid_test.rb CHANGED
@@ -3,6 +3,13 @@ require 'uuidtools'
3
3
 
4
4
  class HIDTest < Vault::TestCase
5
5
 
6
+ # HID.hid? is true(ish) when given HIDs and false(ish) when not
7
+ def test_hid?
8
+ assert_equal(:user, Vault::HID.hid?('user1@heroku.com'))
9
+ assert_equal(:app, Vault::HID.hid?('app123@heroku.com'))
10
+ refute Vault::HID.hid?('employee@heroku.com')
11
+ end
12
+
6
13
  # HID.hid_to_uuid converts an app ID to a v5 UUID based on a URL scheme.
7
14
  def test_app_id_to_uuid
8
15
  url = "https://vault.heroku.com/apps/1234"
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.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  segments:
130
130
  - 0
131
- hash: 2678711332955431565
131
+ hash: 3619778048086262088
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  none: false
134
134
  requirements:
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  segments:
139
139
  - 0
140
- hash: 2678711332955431565
140
+ hash: 3619778048086262088
141
141
  requirements: []
142
142
  rubyforge_project:
143
143
  rubygems_version: 1.8.23