configify 0.0.2

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.
@@ -0,0 +1,39 @@
1
+ # Configify
2
+
3
+ Really simple configuration.
4
+
5
+ # Usage
6
+
7
+ Basic:
8
+
9
+ require "configify"
10
+
11
+ class MyApp
12
+ include Configify::Config
13
+
14
+ end
15
+
16
+ MyApp.configure do |config|
17
+ config.company = "Curve21"
18
+ config.website = "http://www.curve21.com"
19
+ end
20
+
21
+ MyApp.config.company
22
+ => "Curve21"
23
+
24
+ MyApp.config.website
25
+ => "http://www.curve21.com"
26
+
27
+ You can also set defaults into the sub-class:
28
+
29
+ class MyApp
30
+ include Configify::Config
31
+
32
+ config.website = "http://www.curve21.com"
33
+ end
34
+
35
+ # Bugs
36
+
37
+ http://c21.lighthouseapp.com/projects/38725-configify/overview
38
+
39
+ Patches welcome.
@@ -0,0 +1,22 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "configify"
7
+ gemspec.summary = "Really simple configuration"
8
+ gemspec.email = "Stephen Bartholomew"
9
+ gemspec.homepage = "http://github.com/curve21/configify"
10
+ gemspec.description = ""
11
+ gemspec.authors = ["Stephen Bartholomew"]
12
+ gemspec.files = FileList["[A-Z]*", "{lib,spec}/**/*"]
13
+ end
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
+ end
17
+
18
+ Spec::Rake::SpecTask.new(:spec) do |spec|
19
+ spec.libs << 'lib' << 'spec'
20
+ spec.spec_files = FileList['spec/**/*_spec.rb']
21
+ # spec.spec_opts = ['--options', 'spec/spec.opts']
22
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), "configify", "config")
@@ -0,0 +1,37 @@
1
+ module Configify
2
+ module Config
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ base.send :include, InstanceMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def configure(config_values = {}, &block)
11
+ if block_given?
12
+ yield(config)
13
+ else
14
+ config_values.each do |key, value|
15
+ config.send("#{key}=", value)
16
+ end
17
+ end
18
+ end
19
+
20
+ def config
21
+ @@config ||= new
22
+ end
23
+ end
24
+
25
+ module InstanceMethods
26
+ def method_missing(method_id, *args)
27
+ if !self.respond_to? method_id
28
+ attribute = method_id.to_s.gsub(/\=/, "")
29
+ self.class.send :attr_accessor, attribute
30
+ self.send(method_id, args.first)
31
+ else
32
+ super
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "configify")
2
+
3
+ class MyApp
4
+ include Configify::Config
5
+ end
6
+
7
+ describe "the configuration class" do
8
+ context "setting variables using a block" do
9
+ before do
10
+ MyApp.configure do |config|
11
+ config.username = "blockset@curve21.com"
12
+ config.password = "test"
13
+ config.debug = true
14
+ end
15
+ end
16
+
17
+ it "should return set variables" do
18
+ MyApp.config.username.should == "blockset@curve21.com"
19
+ end
20
+ end
21
+
22
+ context "setting variables using a hash" do
23
+ before do
24
+ MyApp.configure(
25
+ :username => "hashset@curve21.com",
26
+ :password => "test",
27
+ :debug => true
28
+ )
29
+ end
30
+
31
+ it "should return set variables" do
32
+ MyApp.config.username.should == "hashset@curve21.com"
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: configify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Bartholomew
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-06 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ""
17
+ email: Stephen Bartholomew
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - README.markdown
26
+ - Rakefile
27
+ - VERSION
28
+ - lib/configify.rb
29
+ - lib/configify/config.rb
30
+ - spec/config_spec.rb
31
+ has_rdoc: true
32
+ homepage: http://github.com/curve21/configify
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --charset=UTF-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Really simple configuration
59
+ test_files:
60
+ - spec/config_spec.rb