config_newton 0.1.0 → 0.1.1

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.
@@ -15,10 +15,8 @@ A common pattern for Ruby libraries is to have some kind of configuration that c
15
15
  module MyLibrary
16
16
  include ConfigNewton
17
17
 
18
- configurable do
19
- property :email
20
- property :special_sauce, :default => true
21
- end
18
+ config :email
19
+ config :special_sauce, :default => true
22
20
  end
23
21
 
24
22
  # And the end user can set it like this:
@@ -42,7 +40,7 @@ A common pattern for Ruby libraries is to have some kind of configuration that c
42
40
  There are a few other useful features of ConfigNewton. For instance, you can convert the configuration to a hash at any time, or just access it like one:
43
41
 
44
42
  MyLibrary.config.to_hash # => {:email => 'dude@somewhere.com', :special_sauce => false}
45
- MyLibrary[:special_sauce] # => false
43
+ MyLibrary.config[:special_sauce] # => false
46
44
 
47
45
  You can also load user settings from a YAML file quite easily. Let's say you're developing a Rails plugin. You can easily load a <tt>config</tt> directory YAML file like this:
48
46
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,57 @@
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{config_newton}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Bleigh"]
12
+ s.date = %q{2010-07-24}
13
+ s.description = %q{Library authors can now easily add class-level configuration including YAML loading with just a few lines of code.}
14
+ s.email = %q{michael@intridea.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",
26
+ "config_newton.gemspec",
27
+ "lib/config_newton.rb",
28
+ "spec/config_newton/configuration_spec.rb",
29
+ "spec/config_newton_spec.rb",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/intridea/config_newton}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.6}
37
+ s.summary = %q{A simple tool to add class-level configuration to libraries.}
38
+ s.test_files = [
39
+ "spec/config_newton/configuration_spec.rb",
40
+ "spec/config_newton_spec.rb",
41
+ "spec/spec_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
+ else
51
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
+ end
56
+ end
57
+
@@ -23,7 +23,13 @@ module ConfigNewton
23
23
  def configuration
24
24
  @configuration
25
25
  end
26
- alias :config :configuration
26
+
27
+ # Retrieve the configuration object or pass arguments
28
+ # identical to #configurable to add a new configuration
29
+ # property.
30
+ def config(*args)
31
+ args.any?? self.configurable(*args) : configuration
32
+ end
27
33
 
28
34
  protected
29
35
 
@@ -41,6 +47,7 @@ module ConfigNewton
41
47
  @configuration.add(property, options)
42
48
  end
43
49
  end
50
+ alias :cfg :configurable
44
51
  end
45
52
 
46
53
  class Configuration
@@ -43,9 +43,19 @@ describe ConfigNewton do
43
43
  }
44
44
  end
45
45
  end
46
+ end
47
+
48
+ describe '.config' do
49
+ before do
50
+ SampleClass.send(:configurable, :abc)
51
+ end
46
52
 
47
- it 'should accept a block with an argument' do
48
-
53
+ it 'should return the configuration if called without arguments' do
54
+ SampleClass.config.should be_kind_of(ConfigNewton::Configuration)
55
+ end
56
+
57
+ it 'should make a protected call if called with arguments' do
58
+ SampleClass.config(:def)
49
59
  end
50
60
  end
51
61
 
@@ -1 +1,3 @@
1
1
  --color
2
+ --backtrace
3
+ --format=nested
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Bleigh
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-23 00:00:00 -05:00
17
+ date: 2010-07-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,7 @@ files:
47
47
  - README.rdoc
48
48
  - Rakefile
49
49
  - VERSION
50
+ - config_newton.gemspec
50
51
  - lib/config_newton.rb
51
52
  - spec/config_newton/configuration_spec.rb
52
53
  - spec/config_newton_spec.rb