vault-tools 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  test.profile*
19
+ bin/*
20
+ test/.test.profile*
@@ -0,0 +1,21 @@
1
+ module Vault
2
+ module Config
3
+ extend self
4
+
5
+ def env(key)
6
+ ENV[key]
7
+ end
8
+
9
+ def env!(key)
10
+ env(key) || raise("missing #{key}")
11
+ end
12
+
13
+ def app_name; env("APP_NAME"); end
14
+ def port; env!("PORT").to_i; end
15
+
16
+ def database_url(kind = '')
17
+ kind = "#{kind}_".upcase unless kind.empty?
18
+ env!("#{kind}DATABASE_URL")
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Tools
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
data/lib/vault-tools.rb CHANGED
@@ -14,3 +14,4 @@ end
14
14
  require 'vault-tools/sinatra_helpers/html_serializer'
15
15
  require 'vault-tools/log'
16
16
  require 'vault-tools/web'
17
+ require 'vault-tools/config'
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+
3
+ class ConfigTest < Vault::TestCase
4
+
5
+ # Returns DATABASE_URL with no params
6
+ def test_database_url
7
+ set_env 'DATABASE_URL', "postgres:///foo"
8
+ Vault::Config.database_url.must_equal 'postgres:///foo'
9
+ end
10
+
11
+ # Returns #{kind}_DATABASE_URL with one param
12
+ def test_database_url_takes_and_capitalizes_params
13
+ set_env 'FOO_DATABASE_URL', "postgres:///foo"
14
+ Vault::Config.database_url('foo').must_equal 'postgres:///foo'
15
+ end
16
+
17
+ def test_database_url_raises_when_not_found
18
+ assert_raises RuntimeError do
19
+ Vault::Config.database_url('foo')
20
+ end
21
+ end
22
+
23
+ def test_app_name
24
+ Vault::Config.app_name.must_equal nil
25
+ set_env 'APP_NAME', "my-app"
26
+ Vault::Config.app_name.must_equal 'my-app'
27
+ end
28
+
29
+ def test_port_raises
30
+ assert_raises RuntimeError do
31
+ Vault::Config.port
32
+ end
33
+ end
34
+
35
+ def test_port_convert_to_int
36
+ set_env 'PORT', "3000"
37
+ Vault::Config.port.must_equal 3000
38
+ end
39
+ end
data/test/helper.rb CHANGED
@@ -1 +1,6 @@
1
- require 'vault-tools/test'
1
+ require 'vault-test-tools'
2
+ require 'vault-tools'
3
+
4
+ module Vault::Test
5
+ include_in_all EnvironmentHelpers
6
+ end
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.0.4
4
+ version: 0.0.5
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: 2012-12-08 00:00:00.000000000 Z
13
+ date: 2012-12-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
@@ -68,10 +68,12 @@ files:
68
68
  - bin/turn
69
69
  - bin/vault-tools
70
70
  - lib/vault-tools.rb
71
+ - lib/vault-tools/config.rb
71
72
  - lib/vault-tools/log.rb
72
73
  - lib/vault-tools/sinatra_helpers/html_serializer.rb
73
74
  - lib/vault-tools/version.rb
74
75
  - lib/vault-tools/web.rb
76
+ - test/config_test.rb
75
77
  - test/helper.rb
76
78
  - test/test_spec.rb
77
79
  - vault-tools.gemspec
@@ -89,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
91
  version: '0'
90
92
  segments:
91
93
  - 0
92
- hash: 960943119997423505
94
+ hash: 3663262642643653617
93
95
  required_rubygems_version: !ruby/object:Gem::Requirement
94
96
  none: false
95
97
  requirements:
@@ -98,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  version: '0'
99
101
  segments:
100
102
  - 0
101
- hash: 960943119997423505
103
+ hash: 3663262642643653617
102
104
  requirements: []
103
105
  rubyforge_project:
104
106
  rubygems_version: 1.8.23
@@ -106,5 +108,7 @@ signing_key:
106
108
  specification_version: 3
107
109
  summary: Test classes, base web classes, and helpers - oh my!
108
110
  test_files:
111
+ - test/config_test.rb
109
112
  - test/helper.rb
110
113
  - test/test_spec.rb
114
+ has_rdoc: