-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacques Crocker
committed
Aug 8, 2010
1 parent
66c7034
commit 3221dff
Showing
26 changed files
with
431 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
BUNDLE_DISABLE_SHARED_GEMS: "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem "rspec", ">= 2.0.0.beta.19" | ||
gem 'autotest' | ||
gem "growl-glue" | ||
|
||
gem "ruby-debug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
autotest (4.3.2) | ||
columnize (0.3.1) | ||
diff-lcs (1.1.2) | ||
growl-glue (1.0.7) | ||
linecache (0.43) | ||
rspec (2.0.0.beta.19) | ||
rspec-core (= 2.0.0.beta.19) | ||
rspec-expectations (= 2.0.0.beta.19) | ||
rspec-mocks (= 2.0.0.beta.19) | ||
rspec-core (2.0.0.beta.19) | ||
rspec-expectations (2.0.0.beta.19) | ||
diff-lcs (>= 1.1.2) | ||
rspec-mocks (2.0.0.beta.19) | ||
ruby-debug (0.10.3) | ||
columnize (>= 0.1) | ||
ruby-debug-base (~> 0.10.3.0) | ||
ruby-debug-base (0.10.3) | ||
linecache (>= 0.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
autotest | ||
growl-glue | ||
rspec (>= 2.0.0.beta.19) | ||
ruby-debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Autotest.add_discovery { "rspec2" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require 'rails_config/settings/deep_merge' unless defined?(DeepMerge) | ||
require 'rails_config/settings/builder' | ||
require 'rails_config/vendor/deep_merge' unless defined?(DeepMerge) | ||
require 'pathname' | ||
|
||
require 'rails_config/setting_builder' | ||
require 'rails_config/railtie' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'ostruct' | ||
require 'yaml' | ||
require 'erb' | ||
|
||
module RailsConfig | ||
module SettingBuilder | ||
@@load_paths = [] | ||
|
||
# Create a config object (OpenStruct) from a yaml file. If a second yaml file is given, then the sections of that file will overwrite the sections | ||
# if the first file if they exist in the first file. | ||
def self.load_files(*files) | ||
config = OpenStruct.new | ||
|
||
@@load_paths = [files].flatten.compact.uniq | ||
# add singleton method to our Settings that reloads its settings from the load_paths | ||
def config.reload! | ||
|
||
conf = {} | ||
SettingBuilder.load_paths.to_a.each do |path| | ||
file_conf = YAML.load(ERB.new(IO.read(path.to_s)).result) if path and File.exists?(path.to_s) | ||
next unless file_conf | ||
|
||
if conf.size > 0 | ||
DeepMerge.deep_merge!(file_conf, conf, :preserve_unmergeables => false) | ||
else | ||
conf = file_conf | ||
end | ||
end | ||
|
||
# load all the new values into the openstruct | ||
marshal_load(RailsConfig::SettingBuilder.convert(conf).marshal_dump) | ||
|
||
return self | ||
end | ||
|
||
config.reload! | ||
return config | ||
end | ||
|
||
def self.load_paths | ||
@@load_paths | ||
end | ||
|
||
# Recursively converts Hashes to OpenStructs (including Hashes inside Arrays) | ||
def self.convert(h) #:nodoc: | ||
s = OpenStruct.new | ||
h.each do |k, v| | ||
s.new_ostruct_member(k) | ||
if v.is_a?(Hash) | ||
s.send( (k+'=').to_sym, convert(v)) | ||
elsif v.is_a?(Array) | ||
converted_array = v.collect { |e| e.instance_of?(Hash) ? convert(e) : e } | ||
s.send("#{k}=".to_sym, converted_array) | ||
else | ||
s.send("#{k}=".to_sym, v) | ||
end | ||
end | ||
s | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.