subelsky_power_tools 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v1.1.0
2
+ ======
3
+ * Changed signature of variable enforcer and made it return extracted values
4
+
1
5
  v1.0.2
2
6
  ======
3
7
  * Added environment variable enforcer; I use this all the time in rake tasks
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- subelsky_power_tools (1.0.1)
4
+ subelsky_power_tools (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,11 +1,15 @@
1
+ require "subelsky_power_tools"
2
+
1
3
  module SubelskyPowerTools::Environment
2
4
  extend self
3
5
 
4
- def enforce_variables(*vals)
5
- msg = "Must specify #{vals.map(&:upcase).join(",")}"
6
+ def extract(*keys)
7
+ keys.map! { |k| k.upcase.to_s }
8
+ msg = "Must specify #{keys.join(", ")}"
6
9
 
7
- vals.each do |val|
8
- fail msg if ENV[val].to_s.strip.empty?
10
+ keys.inject([]) do |total,key|
11
+ fail msg if ENV[key].to_s.strip.empty?
12
+ total << ENV[key]
9
13
  end
10
14
  end
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module SubelskyPowerTools
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -5,7 +5,7 @@ describe SubelskyPowerTools::Environment do
5
5
  def conduct_test(val1 = "shaz",val2 = "bot")
6
6
  ENV['_SPT_EE_TEST_VALUE1'] = val1
7
7
  ENV['_SPT_EE_TEST_VALUE2'] = val2
8
- SubelskyPowerTools::Environment.enforce_variables('_SPT_EE_TEST_VALUE1','_SPT_EE_TEST_VALUE2')
8
+ SubelskyPowerTools::Environment.extract(:'_spt_ee_test_value1',:'_spt_ee_test_value2')
9
9
  end
10
10
 
11
11
  it "succeeds if all specified variables are non-blank" do
@@ -23,4 +23,10 @@ describe SubelskyPowerTools::Environment do
23
23
  it "fails the program if any specified variable is nil" do
24
24
  expect { conduct_test("",nil) }.to raise_error(RuntimeError)
25
25
  end
26
+
27
+ it "returns the value of the extracted variables" do
28
+ val1, val2 = conduct_test("alpha","beta")
29
+ val1.should == "alpha"
30
+ val2.should == "beta"
31
+ end
26
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subelsky_power_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-12 00:00:00.000000000 -04:00
12
+ date: 2011-08-14 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &2156325000 !ruby/object:Gem::Requirement
17
+ requirement: &2160525580 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2156325000
25
+ version_requirements: *2160525580
26
26
  description: ! "This is a collection of Ruby extensions and utilities I've been carting
27
27
  around from project to project. \nMany are taken from the Facets project (I just
28
28
  don't want to include that whole gem in my codebases).\n"