settingslogic 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.0.1 released 2009-04-02
2
+
3
+ * Inherit from hash.
4
+
1
5
  == 1.0.0 released 2008-12-05
2
6
 
3
7
  * Only define methods if we have settings.
@@ -2,7 +2,7 @@ module Settingslogic
2
2
  # = Setting
3
3
  #
4
4
  # A simple settings solution using a YAML file. See README for more information.
5
- class Settings
5
+ class Settings < Hash
6
6
  class << self
7
7
  def name # :nodoc:
8
8
  instance._settings.key?("name") ? instance.name : super
@@ -37,12 +37,12 @@ module Settingslogic
37
37
  def initialize(name_or_hash = Config.settings_file)
38
38
  case name_or_hash
39
39
  when Hash
40
- self._settings = name_or_hash
40
+ self.update name_or_hash
41
41
  when String, Symbol
42
42
  root_path = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/" : ""
43
43
  file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash
44
- self._settings = YAML.load(ERB.new(File.read(file_path)).result)
45
- self._settings = _settings[RAILS_ENV] if defined?(RAILS_ENV)
44
+ self.update YAML.load(ERB.new(File.read(file_path)).result).to_hash
45
+ self.update self[RAILS_ENV] if defined?(RAILS_ENV)
46
46
  else
47
47
  raise ArgumentError.new("Your settings must be a hash, a symbol representing the name of the .yml file in your config directory, or a string representing the abosolute path to your settings file.")
48
48
  end
@@ -55,19 +55,18 @@ module Settingslogic
55
55
  end
56
56
 
57
57
  def define_settings!
58
- return if _settings.nil?
59
- _settings.each do |key, value|
58
+ self.each do |key, value|
60
59
  case value
61
60
  when Hash
62
61
  instance_eval <<-"end_eval", __FILE__, __LINE__
63
62
  def #{key}
64
- @#{key} ||= self.class.new(_settings["#{key}"])
63
+ @#{key} ||= self.class.new(self["#{key}"])
65
64
  end
66
65
  end_eval
67
66
  else
68
67
  instance_eval <<-"end_eval", __FILE__, __LINE__
69
68
  def #{key}
70
- @#{key} ||= _settings["#{key}"]
69
+ @#{key} ||= self["#{key}"]
71
70
  end
72
71
  end_eval
73
72
  end
@@ -67,7 +67,7 @@ module Settingslogic
67
67
 
68
68
  MAJOR = 1
69
69
  MINOR = 0
70
- TINY = 0
70
+ TINY = 1
71
71
 
72
72
  # The current version as a Version instance
73
73
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{settingslogic}
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Johnson of Binary Logic"]
9
- s.date = %q{2008-12-05}
9
+ s.date = %q{2009-04-02}
10
10
  s.description = %q{Simple and straightforward application wide settings}
11
11
  s.email = %q{bjohnson@binarylogic.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/settingslogic/config.rb", "lib/settingslogic/settings.rb", "lib/settingslogic/version.rb", "lib/settingslogic.rb", "README.rdoc"]
@@ -25,11 +25,8 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 2
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<echoe>, [">= 0"])
29
28
  else
30
- s.add_dependency(%q<echoe>, [">= 0"])
31
29
  end
32
30
  else
33
- s.add_dependency(%q<echoe>, [">= 0"])
34
31
  end
35
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: settingslogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-05 00:00:00 -05:00
12
+ date: 2009-04-02 00:00:00 -04:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: echoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
14
+ dependencies: []
15
+
25
16
  description: Simple and straightforward application wide settings
26
17
  email: bjohnson@binarylogic.com
27
18
  executables: []