profigure 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Joel Friedman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = profigure
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Joel Friedman. See LICENSE for details.
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "profigure"
8
+ gem.summary = %Q{Replacing the cons with pros in configuration}
9
+ gem.description = %Q{profigure aims to be a drop in replacement for configuring your apps in a railsy way.}
10
+ gem.email = "asher.friedman@gmail.com"
11
+ gem.homepage = "http://github.com/joelash/profigure"
12
+ gem.authors = ["Joel Friedman"]
13
+ gem.add_dependency "mostash"
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "profigure #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 0
3
+ :major: 0
4
+ :patch: 1
@@ -0,0 +1,14 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+
4
+ require 'mostash'
5
+
6
+ require File.join(File.dirname(__FILE__), "profigure", "hash_extensions")
7
+ require File.join(File.dirname(__FILE__), "profigure", "profigure")
8
+
9
+ def dbg( msg )
10
+ file, line, method_raw = caller[0].split('/').last.split(':')
11
+ method = method_raw.match(/^in `(.+)'/)[1]
12
+ puts "#{method} (#{file}##{line}): #{msg}"
13
+ end
14
+
@@ -0,0 +1,12 @@
1
+ class Hash
2
+ def recursive_merge!(hash)
3
+ self.merge!( hash ) do |key, oldval, newval|
4
+ if oldval.class == Hash
5
+ oldval.recursive_merge! newval
6
+ else
7
+ newval
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,21 @@
1
+ class Profigure
2
+ class << self
3
+ def load(configs_dir, environment=nil)
4
+ hash = YAML.load(file_contents("defaults", configs_dir))
5
+ if environment
6
+ contents = file_contents(environment, configs_dir)
7
+ yaml_result = YAML.load(contents)
8
+ hash.recursive_merge! yaml_result
9
+ end
10
+ hash["environment"] = environment
11
+ MoStash.new hash
12
+ end
13
+
14
+ def file_contents(environment, configs_dir)
15
+ file = "#{configs_dir}/#{environment}.yml"
16
+ content = IO.read(file)
17
+ end
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{profigure}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Joel Friedman"]
12
+ s.date = %q{2010-05-04}
13
+ s.description = %q{profigure aims to be a drop in replacement for configuring your apps in a railsy way.}
14
+ s.email = %q{asher.friedman@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "lib/profigure.rb",
27
+ "lib/profigure/hash_extensions.rb",
28
+ "lib/profigure/profigure.rb",
29
+ "profigure.gemspec",
30
+ "spec/profigure_spec.rb",
31
+ "spec/spec.opts",
32
+ "spec/spec_helper.rb",
33
+ "spec/test_config/arrays.yml",
34
+ "spec/test_config/defaults.yml",
35
+ "spec/test_config/nested.yml",
36
+ "spec/test_config/overrides.yml",
37
+ "spec/test_config/test.yml"
38
+ ]
39
+ s.homepage = %q{http://github.com/joelash/profigure}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.6}
43
+ s.summary = %q{Replacing the cons with pros in configuration}
44
+ s.test_files = [
45
+ "spec/profigure_spec.rb",
46
+ "spec/spec_helper.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<mostash>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
56
+ else
57
+ s.add_dependency(%q<mostash>, [">= 0"])
58
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<mostash>, [">= 0"])
62
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
63
+ end
64
+ end
65
+
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Profigure" do
4
+ before do
5
+ @config_dir = File.join(File.dirname(__FILE__), "test_config")
6
+ end
7
+
8
+ it "loads from defaults" do
9
+ config = Profigure.load @config_dir
10
+
11
+ config.foo.should == "bar"
12
+ end
13
+
14
+ it "also loads from your environment" do
15
+ config = Profigure.load @config_dir, "test"
16
+
17
+ config.another.should == "example"
18
+ end
19
+
20
+ it "should override defaults with keys in env file" do
21
+ config = Profigure.load @config_dir, "overrides"
22
+
23
+ config.foo.should == "overridden"
24
+ end
25
+
26
+ it "should properly handle nested hashes" do
27
+ config = Profigure.load @config_dir, "nested"
28
+
29
+ config.top_level.second_level.third_level.bar.should == "baz"
30
+ end
31
+
32
+ it "should properly handle arrays" do
33
+ config = Profigure.load @config_dir, "arrays"
34
+
35
+ config.array.size.should == 2
36
+ config.array[1].should == "two"
37
+ end
38
+
39
+ it "should allow overriding after load" do
40
+ config = Profigure.load @config_dir, "test"
41
+ config.foo = "bar"
42
+
43
+ config.foo.should == "bar"
44
+ end
45
+
46
+ it "should allow reading via hash notation" do
47
+ config = Profigure.load @config_dir, "test"
48
+
49
+ config[:foo].should == "bar"
50
+ end
51
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ #$LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ #$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ #require 'profigure'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ require File.join(File.dirname(__FILE__), "..", "lib", "profigure")
8
+
9
+ Spec::Runner.configure do |config|
10
+
11
+ end
@@ -0,0 +1 @@
1
+ array: [one, two]
@@ -0,0 +1 @@
1
+ foo: bar
@@ -0,0 +1,5 @@
1
+ top_level:
2
+ second_level:
3
+ third_level:
4
+ bar: baz
5
+ time: now
@@ -0,0 +1 @@
1
+ foo: overridden
@@ -0,0 +1 @@
1
+ another: example
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: profigure
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Joel Friedman
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-04 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: mostash
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rspec
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 2
42
+ - 9
43
+ version: 1.2.9
44
+ type: :development
45
+ version_requirements: *id002
46
+ description: profigure aims to be a drop in replacement for configuring your apps in a railsy way.
47
+ email: asher.friedman@gmail.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - .document
57
+ - .gitignore
58
+ - LICENSE
59
+ - README.rdoc
60
+ - Rakefile
61
+ - VERSION.yml
62
+ - lib/profigure.rb
63
+ - lib/profigure/hash_extensions.rb
64
+ - lib/profigure/profigure.rb
65
+ - profigure.gemspec
66
+ - spec/profigure_spec.rb
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
69
+ - spec/test_config/arrays.yml
70
+ - spec/test_config/defaults.yml
71
+ - spec/test_config/nested.yml
72
+ - spec/test_config/overrides.yml
73
+ - spec/test_config/test.yml
74
+ has_rdoc: true
75
+ homepage: http://github.com/joelash/profigure
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --charset=UTF-8
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.6
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Replacing the cons with pros in configuration
104
+ test_files:
105
+ - spec/profigure_spec.rb
106
+ - spec/spec_helper.rb