motion-config-vars 0.1.0
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 +7 -0
- data/.gitignore +35 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +109 -0
- data/Rakefile +11 -0
- data/app/app_delegate.rb +5 -0
- data/lib/motion-config-vars.rb +76 -0
- data/lib/motion-config-vars/embed/config_vars_loader.rb +19 -0
- data/lib/motion-config-vars/embed/configuration_error.rb +4 -0
- data/lib/motion-config-vars/embed/hashlike_object_configurer.rb +86 -0
- data/lib/motion-config-vars/templates/app.yml +7 -0
- data/lib/motion-config-vars/version.rb +3 -0
- data/motion-config-vars.gemspec +23 -0
- data/resources/app.yml +2 -0
- data/spec/hashlike_object_configurer_spec.rb +126 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03fe7e08ee3986a30b83bd0a5d7cef39b14587ad
|
4
|
+
data.tar.gz: 62e331e8b0e041b67e5085edd70e8f5c9fd3676a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 338a73be0ad0581aa2b25663c3675f2cdd14fe23cd2b815cec3eb7e7604a1748b3fd8e6df720b3dc59b955c607d060ee4f34025ec37b1aa43545023f928161f5
|
7
|
+
data.tar.gz: 7bc6b0f6ba6d9160e29407673b45cf88fa2efeab986fa2fde7a686e94a4886908135c5363c5fb5b96b57988cacb02c9d67d211b8b4c3b4a051a2cfd1be6c69e1
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
# RM-specific additions
|
20
|
+
.repl_history
|
21
|
+
build
|
22
|
+
tags
|
23
|
+
app/pixate_code.rb
|
24
|
+
resources/*.nib
|
25
|
+
resources/*.momd
|
26
|
+
resources/*.storyboardc
|
27
|
+
.DS_Store
|
28
|
+
nbproject
|
29
|
+
.redcar
|
30
|
+
#*#
|
31
|
+
*~
|
32
|
+
*.sw[po]
|
33
|
+
.eprj
|
34
|
+
.sass-cache
|
35
|
+
.idea
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brent Hargrave
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# motion-config-vars
|
2
|
+
## Configure RubyMotion's ENV with a YAML file
|
3
|
+
|
4
|
+
This gem brings Rails-on-Heroku-style environment configuration to Rubymotion
|
5
|
+
development. Fill out a YAML configuration file with top-level keys containing
|
6
|
+
mutually-exclusive environments, and nest keys below them with values
|
7
|
+
specific to each environment configuration.
|
8
|
+
|
9
|
+
For example, setting up an env.yml like so...
|
10
|
+
```yaml
|
11
|
+
API_ENV:
|
12
|
+
development:
|
13
|
+
HOST: "lvh.me:3000"
|
14
|
+
test:
|
15
|
+
HOST: "lvh.me:3001"
|
16
|
+
production:
|
17
|
+
HOST: "domain.com"
|
18
|
+
```
|
19
|
+
|
20
|
+
...and then passing a value for your top-level key, like so:
|
21
|
+
```bash
|
22
|
+
rake archive API_ENV=development
|
23
|
+
```
|
24
|
+
|
25
|
+
...exposes the following in both RM's rake tasks *and* the app's runtime:
|
26
|
+
```ruby
|
27
|
+
ENV["API_ENV"] #=> development
|
28
|
+
ENV["HOST"] #=> lvh.me:3000
|
29
|
+
```
|
30
|
+
|
31
|
+
If touching ENV makes you queasy, not to worry. Pre-existing values aren't
|
32
|
+
overwritten and an alternative hash-like constant, RMENV, is configured as well.
|
33
|
+
|
34
|
+
You might ask why not make "development", "production", etc. the top-level
|
35
|
+
keys? Why bother requiring an API_ENV? In my experience configuring environements
|
36
|
+
for API-backed clients is more complex because their configs depend on both the
|
37
|
+
build style (for example, "development", "adhoc" or "release") *and* the API
|
38
|
+
they are backed by ("development", "staging", "production"). Using these
|
39
|
+
"facets" for top-level keys enables much more flexible configuration.
|
40
|
+
|
41
|
+
For example, you could expand the above app.yml with...
|
42
|
+
```yaml
|
43
|
+
AUDIENCE_ENV:
|
44
|
+
- developer
|
45
|
+
- adhoc
|
46
|
+
- release
|
47
|
+
```
|
48
|
+
|
49
|
+
...and then easily point a dev build at your production API
|
50
|
+
```bash
|
51
|
+
rake device API_ENV=production AUDIENCE_ENV=developer
|
52
|
+
```
|
53
|
+
...or restrict new features to beta-testers, but only beta-testers:
|
54
|
+
```bash
|
55
|
+
rake device API_ENV=production AUDIENCE_ENV=adhoc
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
## Install
|
60
|
+
|
61
|
+
Add it to your app's Gemfile:
|
62
|
+
|
63
|
+
gem 'motion-config-vars'
|
64
|
+
|
65
|
+
Require it in the app's Rakefile:
|
66
|
+
|
67
|
+
require 'motion-config-vars'
|
68
|
+
|
69
|
+
Generate the sample YAML config file:
|
70
|
+
|
71
|
+
rake config:vars:init # generates "./resources/app.yml"
|
72
|
+
|
73
|
+
|
74
|
+
## Usage, with an IMPORTANT caveat
|
75
|
+
|
76
|
+
After generating the "resources/app.yml" and filling it out you're *almost*
|
77
|
+
ready to roll. One more detail.
|
78
|
+
|
79
|
+
It seems that RM currently monitors changes to your project's Rakefile, and only
|
80
|
+
rebuilds your app from the Rakefile's configuration if the file itself has
|
81
|
+
been modified since the last build. While using this gem, however, your app's
|
82
|
+
configuration is *dynamically* updated (specifically, the "app.info_plist"
|
83
|
+
configuration variable is edited), which RM won't pick up by default. So, to
|
84
|
+
ensure RM rebuilds from the latest, dynamically-defined values in your Rakefile
|
85
|
+
it will automatically [touch](http://en.wikipedia.org/wiki/Touch_(Unix)) your
|
86
|
+
project's Rakefile before any of RM's default, build-triggering tasks.
|
87
|
+
|
88
|
+
Git won't care, but you might: use of this gem may increase your project's
|
89
|
+
average build time. The tradeoff for cleaner configuration has been more than
|
90
|
+
worthwhile for me, but YMMV.
|
91
|
+
|
92
|
+
|
93
|
+
## Tests
|
94
|
+
|
95
|
+
To run the tests, run
|
96
|
+
```bash
|
97
|
+
touch Rakefile; bundle exec rake spec BUILD_ENV=test
|
98
|
+
```
|
99
|
+
(The gem only embeds its code in the app if a config file is present, so it's
|
100
|
+
necessary to include a test app.yml to ensure the specs have code to exercise.)
|
101
|
+
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
1. Fork it
|
106
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
107
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
108
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
109
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
$:.unshift("/Library/RubyMotion/lib")
|
4
|
+
require 'motion/project'
|
5
|
+
require 'rubygems'
|
6
|
+
require './lib/motion-config-vars'
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
app.name = 'motion-config-vars'
|
10
|
+
end
|
11
|
+
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
vars_yml_filename = "app.yml"
|
6
|
+
vars_yml_path = "resources/#{vars_yml_filename}"
|
7
|
+
|
8
|
+
namespace "config:vars" do
|
9
|
+
desc "Generate starter #{vars_yml_filename}, append it to your .gitignore"
|
10
|
+
task :init do
|
11
|
+
# write out the file
|
12
|
+
template_filepath = File.join(File.dirname(File.realdirpath(__FILE__)),
|
13
|
+
"/motion-config-vars/templates/#{vars_yml_filename}")
|
14
|
+
content = File.read template_filepath
|
15
|
+
if File.exists? vars_yml_path
|
16
|
+
puts "ERROR: file already exists #{vars_yml_path}"
|
17
|
+
else
|
18
|
+
puts "writing #{vars_yml_path}"
|
19
|
+
puts content
|
20
|
+
File.open(vars_yml_path, "w") { |file| file.write content }
|
21
|
+
end
|
22
|
+
# append filepath to project's .gitignore
|
23
|
+
if File.exists? '.gitignore'
|
24
|
+
File.open('.gitignore', "a") do |file|
|
25
|
+
file.puts "\n# Ignore motion-config-vars config file\n#{vars_yml_path}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
require 'rake/hooks'
|
33
|
+
|
34
|
+
before *%w{ spec
|
35
|
+
config
|
36
|
+
default
|
37
|
+
build build:device build:simulator
|
38
|
+
archive archive:distribution } do
|
39
|
+
|
40
|
+
unless File.exists? vars_yml_path
|
41
|
+
puts "WARNING: '#{vars_yml_path}' missing. Run 'rake config:vars:init' to generate one."
|
42
|
+
else
|
43
|
+
|
44
|
+
# NOTE: RM appears to monitor a project Rakefile's modified-at timestamp,
|
45
|
+
# so we force-update it before every build to ensure the build reflects
|
46
|
+
# the latest passed-in environment variable(s).
|
47
|
+
`touch Rakefile`
|
48
|
+
|
49
|
+
require 'yaml' # TODO: how to exclude from build?
|
50
|
+
require 'motion-yaml'
|
51
|
+
|
52
|
+
Motion::Project::App.setup do |app|
|
53
|
+
vars_yaml = File.read vars_yml_path
|
54
|
+
vars_data = YAML.load vars_yaml
|
55
|
+
|
56
|
+
%w{ configuration_error hashlike_object_configurer }.each do |filename|
|
57
|
+
require File.join(File.dirname(__FILE__), "motion-config-vars/embed/#{filename}")
|
58
|
+
end
|
59
|
+
MotionConfigVars::HashlikeObjectConfigurer.new({
|
60
|
+
config_vars_data: vars_data,
|
61
|
+
hashlike_object: app.info_plist,
|
62
|
+
config_name_for_facet_named: lambda { |facet_name| ENV[facet_name] }
|
63
|
+
}).perform!
|
64
|
+
|
65
|
+
# once app.info_plist successfully configured, insert code necessary to
|
66
|
+
# configure app's ENV as well.
|
67
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'motion-config-vars/embed/*.rb')).each do |file|
|
68
|
+
app.files.unshift file
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
if path = NSBundle.mainBundle.pathForResource("app", ofType:"yml")
|
2
|
+
|
3
|
+
vars_data = YAML.load File.read path
|
4
|
+
|
5
|
+
RMENV = {} # alternative to ENV for the squimish
|
6
|
+
[ENV, RMENV].each do |env|
|
7
|
+
MotionConfigVars::HashlikeObjectConfigurer.new({
|
8
|
+
config_vars_data: vars_data,
|
9
|
+
hashlike_object: env,
|
10
|
+
config_name_for_facet_named: lambda { |facet_name|
|
11
|
+
NSBundle.mainBundle.objectForInfoDictionaryKey facet_name
|
12
|
+
}
|
13
|
+
}).perform!
|
14
|
+
end
|
15
|
+
|
16
|
+
else
|
17
|
+
puts "WARNING! main bundle missing app.yml"
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module MotionConfigVars
|
2
|
+
class HashlikeObjectConfigurer
|
3
|
+
|
4
|
+
def initialize options={}
|
5
|
+
@hashlike_object = options[:hashlike_object]
|
6
|
+
raise ArgumentError, "'hashlike_object' missing" unless @hashlike_object
|
7
|
+
@config_vars_data = options[:config_vars_data]
|
8
|
+
raise ArgumentError, "'config_vars_data' missing" unless @config_vars_data
|
9
|
+
@config_name_for_facet_named = options[:config_name_for_facet_named]
|
10
|
+
raise ArgumentError, "'config_name_for_facet_named' missing" unless @config_name_for_facet_named
|
11
|
+
self.validate_config_name_for_facet_named_is_closure
|
12
|
+
self.validate_hashlike_object_is_hashlike
|
13
|
+
self.validate_all_configured_facets_are_requested
|
14
|
+
self.validate_all_facets_requested_configurations_available
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform!
|
18
|
+
self.requested_facets_names.each do |requested_facet_name|
|
19
|
+
configuration_name = @config_name_for_facet_named.call requested_facet_name
|
20
|
+
self.set requested_facet_name, configuration_name
|
21
|
+
facet_data = @config_vars_data[requested_facet_name]
|
22
|
+
return unless facet_data.is_a? Hash
|
23
|
+
configuration_data = facet_data[configuration_name]
|
24
|
+
configuration_data.each { |key, value| self.set key, value }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def set key, value
|
31
|
+
@hashlike_object[key] ||= value
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate_config_name_for_facet_named_is_closure
|
35
|
+
unless @config_name_for_facet_named.respond_to? :call
|
36
|
+
raise ArgumentError, "'config_name_for_facet_named' must be a closure"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_hashlike_object_is_hashlike
|
41
|
+
unless @hashlike_object.respond_to?(:[]=)
|
42
|
+
raise ArgumentError, "hashlike_object must respond to []="
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_all_configured_facets_are_requested
|
47
|
+
unless self.all_configured_facets_are_requested?
|
48
|
+
names = self.unrequested_configured_facets_names.join ", "
|
49
|
+
raise ConfigurationError, "configured facet not specified: #{names}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def all_configured_facets_are_requested?
|
54
|
+
self.configured_facets_names.all? do |facet_name|
|
55
|
+
self.requested_facets_names.include? facet_name
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def configured_facets_names
|
60
|
+
@config_vars_data.keys
|
61
|
+
end
|
62
|
+
|
63
|
+
def unrequested_configured_facets_names
|
64
|
+
self.configured_facets_names - requested_facets_names
|
65
|
+
end
|
66
|
+
|
67
|
+
def requested_facets_names
|
68
|
+
self.configured_facets_names.map do |facet_name|
|
69
|
+
facet_name if @config_name_for_facet_named.call(facet_name)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def validate_all_facets_requested_configurations_available
|
74
|
+
self.requested_facets_names.each do |requested_facet_name|
|
75
|
+
configuration_name = @config_name_for_facet_named.call requested_facet_name
|
76
|
+
facet_data = @config_vars_data[requested_facet_name]
|
77
|
+
unless (facet_data.is_a?(Hash) && facet_data[configuration_name]) or
|
78
|
+
(facet_data.is_a?(Array) && facet_data.include?(configuration_name))
|
79
|
+
raise ConfigurationError, "configuration '#{configuration_name}' unavailable for '#{requested_facet_name}'"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path('../lib/motion-config-vars/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "motion-config-vars"
|
6
|
+
spec.version = MotionConfigVars::VERSION
|
7
|
+
spec.authors = ["Brent Hargrave"]
|
8
|
+
spec.email = ["brent@brent.is"]
|
9
|
+
spec.description = %q{Heroku-style config vars for RubyMotion}
|
10
|
+
spec.summary = %q{Heroku-style config vars for RubyMotion}
|
11
|
+
spec.homepage = "https://github.com/jamescallmebrent/motion-config-vars"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency('motion-yaml', '>= 1.0')
|
20
|
+
spec.add_dependency('rake-hooks', '~> 1.2.3')
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/resources/app.yml
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
describe MotionConfigVars::HashlikeObjectConfigurer do
|
2
|
+
|
3
|
+
before{ @described_class = MotionConfigVars::HashlikeObjectConfigurer }
|
4
|
+
|
5
|
+
shared "a configuration-robust configurer" do
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "with valid arguments does not raise exception" do
|
10
|
+
lambda do
|
11
|
+
begin
|
12
|
+
@described_class.new @options
|
13
|
+
rescue => exception
|
14
|
+
puts exception
|
15
|
+
end
|
16
|
+
end.should.not.raise(Exception)
|
17
|
+
end
|
18
|
+
|
19
|
+
[:hashlike_object, :config_vars_data, :config_name_for_facet_named].each do |attr|
|
20
|
+
it "raises ArgumentError without #{attr}" do
|
21
|
+
lambda do
|
22
|
+
@described_class.new @options.tap { |options| options.delete(attr) }
|
23
|
+
end.should.raise(ArgumentError).
|
24
|
+
message.should.eql "'#{attr}' missing"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises ArgumentError if :config_name_for_facet_named isn't a closure" do
|
29
|
+
@options[:config_name_for_facet_named] = "not-a-closure"
|
30
|
+
lambda do
|
31
|
+
@described_class.new @options
|
32
|
+
end.should.raise(ArgumentError).
|
33
|
+
message.should.eql "'config_name_for_facet_named' must be a closure"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "raises ArgumentError if :hashlike_object isn't hashlike" do
|
37
|
+
unhashlike_object = Object.new
|
38
|
+
@options[:hashlike_object] = unhashlike_object
|
39
|
+
lambda do
|
40
|
+
@described_class.new(@options).perform!
|
41
|
+
end.should.raise(ArgumentError).
|
42
|
+
message.should.eql "hashlike_object must respond to []="
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises ConfigurationError unless all configured facets are specified" do
|
46
|
+
@options[:config_name_for_facet_named] = lambda { |facet_name| {}[facet_name] }
|
47
|
+
lambda do
|
48
|
+
@described_class.new @options
|
49
|
+
end.should.raise(MotionConfigVars::ConfigurationError).
|
50
|
+
message.should.eql "configured facet not specified: API_ENV"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "raises ConfigurationError if specified configuration of any facet unavailable" do
|
54
|
+
@options[:config_vars_data]["API_ENV"].delete "production"
|
55
|
+
lambda do
|
56
|
+
@described_class.new @options
|
57
|
+
end.should.raise(MotionConfigVars::ConfigurationError).
|
58
|
+
message.should.eql "configuration 'production' unavailable for 'API_ENV'"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#perform!" do
|
64
|
+
|
65
|
+
before { @described_class.new(@options).perform! }
|
66
|
+
|
67
|
+
it "sets top-level key on hashlike_object" do
|
68
|
+
@hashlike_object["API_ENV"].should.eql "production"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "provided a standard, hash of hashes configuration structure" do
|
76
|
+
|
77
|
+
before do
|
78
|
+
@hashlike_object = {}
|
79
|
+
@valid_config_vars_data = {
|
80
|
+
"API_ENV" => {
|
81
|
+
"development" => { "HOST" => "lvh.me:3000" },
|
82
|
+
"test" => { "HOST" => "lvh.me:3001" },
|
83
|
+
"production" => { "HOST" => "domain.com" }
|
84
|
+
}
|
85
|
+
}
|
86
|
+
@options = {
|
87
|
+
hashlike_object: @hashlike_object,
|
88
|
+
config_vars_data: @valid_config_vars_data,
|
89
|
+
config_name_for_facet_named: lambda { |facet_name| "production" }
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
behaves_like "a configuration-robust configurer"
|
94
|
+
|
95
|
+
describe "#perform!" do
|
96
|
+
|
97
|
+
before { @described_class.new(@options).perform! }
|
98
|
+
|
99
|
+
it "also sets configuration key/value pairs" do
|
100
|
+
@hashlike_object["HOST"].should.eql "domain.com"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "provided an environment-names-array configuration structure" do
|
108
|
+
|
109
|
+
before do
|
110
|
+
@hashlike_object = {}
|
111
|
+
@valid_config_vars_data = {
|
112
|
+
"API_ENV" => %w{ development test production }
|
113
|
+
}
|
114
|
+
@options = {
|
115
|
+
hashlike_object: @hashlike_object,
|
116
|
+
config_vars_data: @valid_config_vars_data,
|
117
|
+
config_name_for_facet_named: lambda { |facet_name| "production" }
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
behaves_like "a configuration-robust configurer"
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-config-vars
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brent Hargrave
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: motion-yaml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-hooks
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Heroku-style config vars for RubyMotion
|
70
|
+
email:
|
71
|
+
- brent@brent.is
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- app/app_delegate.rb
|
82
|
+
- lib/motion-config-vars.rb
|
83
|
+
- lib/motion-config-vars/embed/config_vars_loader.rb
|
84
|
+
- lib/motion-config-vars/embed/configuration_error.rb
|
85
|
+
- lib/motion-config-vars/embed/hashlike_object_configurer.rb
|
86
|
+
- lib/motion-config-vars/templates/app.yml
|
87
|
+
- lib/motion-config-vars/version.rb
|
88
|
+
- motion-config-vars.gemspec
|
89
|
+
- resources/app.yml
|
90
|
+
- spec/hashlike_object_configurer_spec.rb
|
91
|
+
homepage: https://github.com/jamescallmebrent/motion-config-vars
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.0.0
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Heroku-style config vars for RubyMotion
|
115
|
+
test_files:
|
116
|
+
- spec/hashlike_object_configurer_spec.rb
|