configy 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,18 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Gabe Varela
14
+ - Brian Marini
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2009-10-08 00:00:00 -06:00
19
+ date: 2011-04-21 00:00:00 -06:00
13
20
  default_executable:
14
- dependencies: []
15
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: bundler
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 23
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 0
35
+ version: 1.0.0
36
+ type: :development
37
+ version_requirements: *id001
16
38
  description:
17
39
  email: gvarela@gmail.com
18
40
  executables: []
@@ -25,15 +47,38 @@ extra_rdoc_files:
25
47
  files:
26
48
  - .document
27
49
  - .gitignore
50
+ - .travis.yml
51
+ - Gemfile
52
+ - Gemfile.lock
28
53
  - LICENSE
29
54
  - README.rdoc
30
55
  - Rakefile
56
+ - Rakefile.compiled.rbc
31
57
  - VERSION
32
58
  - configy.gemspec
33
59
  - lib/configy.rb
34
- - lib/configy/configuration.rb
60
+ - lib/configy.rbc
61
+ - lib/configy/base.rb
62
+ - lib/configy/base.rbc
63
+ - lib/configy/config_file.rb
64
+ - lib/configy/config_file.rbc
65
+ - lib/configy/config_store.rb
66
+ - lib/configy/config_store.rbc
67
+ - test/base_test.rb
68
+ - test/base_test.rbc
69
+ - test/config_file_test.rb
70
+ - test/config_file_test.rbc
71
+ - test/config_store_test.rb
72
+ - test/config_store_test.rbc
35
73
  - test/configy_test.rb
74
+ - test/configy_test.rbc
75
+ - test/load_path_test.rb
76
+ - test/load_path_test.rbc
77
+ - test/scratch/.gitkeep
78
+ - test/section_test.rb
79
+ - test/section_test.rbc
36
80
  - test/test_helper.rb
81
+ - test/test_helper.rbc
37
82
  has_rdoc: true
38
83
  homepage: http://github.com/gvarela/configy
39
84
  licenses: []
@@ -44,24 +89,31 @@ rdoc_options:
44
89
  require_paths:
45
90
  - lib
46
91
  required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
47
93
  requirements:
48
94
  - - ">="
49
95
  - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
50
99
  version: "0"
51
- version:
52
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
53
102
  requirements:
54
103
  - - ">="
55
104
  - !ruby/object:Gem::Version
56
- version: "0"
57
- version:
105
+ hash: 23
106
+ segments:
107
+ - 1
108
+ - 3
109
+ - 6
110
+ version: 1.3.6
58
111
  requirements: []
59
112
 
60
113
  rubyforge_project:
61
- rubygems_version: 1.3.5
114
+ rubygems_version: 1.3.7
62
115
  signing_key:
63
116
  specification_version: 3
64
- summary: simple application configuration
65
- test_files:
66
- - test/configy_test.rb
67
- - test/test_helper.rb
117
+ summary: Simple yaml driven configuration gem
118
+ test_files: []
119
+
@@ -1,123 +0,0 @@
1
- require 'erb'
2
-
3
- module Configy
4
- @@load_path = nil
5
- @@section = nil
6
-
7
- def self.load_path=(val)
8
- @@load_path = val
9
- end
10
-
11
- def self.section=(val)
12
- @@section = val
13
- end
14
-
15
- def self.load_path
16
- if @@load_path
17
- return @@load_path
18
- elsif defined? RAILS_ROOT
19
- return "#{RAILS_ROOT}/config"
20
- elsif defined? RACK_ROOT
21
- return "#{RACK_ROOT}/config"
22
- else
23
- return 'config'
24
- end
25
- end
26
-
27
- def self.section
28
- if @@section
29
- return @@section
30
- elsif defined? RAILS_ENV
31
- return RAILS_ENV
32
- elsif defined? RACK_ENV
33
- return RACK_ENV
34
- else
35
- return 'development'
36
- end
37
- end
38
-
39
- def self.camelize(phrase)
40
- camelized = phrase.gsub(/^[a-z]|\s+[a-z]|_+[a-z]|-+[a-z]/i) { |a| a.upcase }
41
- camelized.gsub!(/\s/, '')
42
- camelized.gsub!(/_/, '')
43
- camelized.gsub!(/-/, '')
44
- return camelized
45
- end
46
-
47
-
48
- def self.create(file)
49
- instance_eval <<-"end;"
50
- module ::#{camelize(file.to_s)}
51
- class << self
52
- @app_config
53
- @file_mtime
54
- @local_file_mtime
55
-
56
- def file_path
57
- File.join(Configy.load_path, "#{file.to_s}.yml")
58
- end
59
-
60
- def local_file_path
61
- File.join(Configy.load_path, "#{file.to_s}.local.yml")
62
- end
63
-
64
- def method_missing(param)
65
- build_config if can_build_config?
66
- @app_config.send(param)
67
- end
68
-
69
- def can_build_config?
70
- @app_config.nil? ||
71
- @file_mtime && @file_mtime < File.mtime(file_path) ||
72
- @local_file_mtime && @local_file_mtime < File.mtime(local_file_path)
73
- end
74
-
75
- def build_config
76
- @app_config = Configy::Configuration.new
77
- @app_config.use_file!(file_path)
78
- @file_mtime = File.mtime(file_path)
79
-
80
- if File.exists?(local_file_path)
81
- @app_config.use_file!(local_file_path)
82
- @local_file_mtime = File.mtime(local_file_path)
83
- end
84
-
85
- @app_config.use_section!(Configy.section)
86
- end
87
- end
88
- end
89
- end;
90
- end
91
-
92
- class Configuration
93
-
94
- def initialize(file = nil)
95
- @sections = {}
96
- @params = {}
97
- use_file!(file) if file
98
- end
99
-
100
- def use_file!(file)
101
- begin
102
- hash = YAML::load(ERB.new(IO.read(file)).result)
103
- @sections.merge!(hash) {|key, old_val, new_val| (old_val || new_val).merge new_val }
104
- @params.merge!(@sections['common'])
105
- rescue; end
106
- end
107
-
108
- def use_section!(section)
109
- @params.merge!(@sections[section.to_s]) if @sections.key?(section.to_s)
110
- end
111
-
112
- def method_missing(param)
113
- param = param.to_s
114
- if @params.key?(param)
115
- @params[param]
116
- else
117
- raise "Invalid Configy::Configuration Parameter " + param
118
- end
119
- end
120
-
121
- end
122
-
123
- end