canfig 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7686f83819affed0626a5c03d10095e967145a3
4
- data.tar.gz: cadad6f53d9f3c4e5d995227365e5201d5290fea
3
+ metadata.gz: 943269b9166513da09c866d6d4bae9e8bdb7f79c
4
+ data.tar.gz: d1988d15d10df3182c134075461db5640f0bd595
5
5
  SHA512:
6
- metadata.gz: 67698f05ac1436391cb05c0c5422c2def1784305c465c1a1c63a5b76161673e60ce02a3fc56a25c08b209da0ab0f00d90ece4456d99c7f62d22993b495940d63
7
- data.tar.gz: bf303df834a439f2227c13bda00a8f59352d81fe4af5096153549c069f0e8d55d6cb8468513e3f6182f121c881dab330a239159e4ae8f09421bcd8e964f2239e
6
+ metadata.gz: 23d2195e6ae6b208e3a411b2de8904bef726a15c8dc5a4bf06f787fede78161485e3c24404655e63adf450d7fb0a8c7302453f87ee659d87ed171b2f7b39c2b0
7
+ data.tar.gz: d04944fa211c31db6f20df83f45824bf486c22de4568ce92b38860f875526edf197915d7619b6b07530948534c3449f747c423c6265c08e475eb90ff27de6444
@@ -0,0 +1,15 @@
1
+ module Canfig
2
+ module Class
3
+ def self.included(base)
4
+ base.send :cattr_reader, :configuration
5
+ base.send :class_variable_set, :@@configuration, Canfig::OpenConfig.new
6
+ base.send :extend, Canfig::Class::ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def configure(&block)
11
+ (send :class_variable_get, :@@configuration).configure &block
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Canfig
2
- class Configuration
2
+ class Config
3
3
 
4
4
  def configure(argh={}, &block)
5
5
  @options ||= {}
@@ -23,7 +23,7 @@ module Canfig
23
23
  end
24
24
 
25
25
  def configure_option(key, val)
26
- raise ArgumentError, "#{key} is not an allowed configuration option" unless @allowed.include?(key)
26
+ raise ArgumentError, "#{key} is not an allowed configuration option" unless allowed?(key)
27
27
 
28
28
  save_state! do
29
29
  @changed[key] = [@options[key], val]
@@ -71,12 +71,16 @@ module Canfig
71
71
  @save_state
72
72
  end
73
73
 
74
+ def allowed?(opt)
75
+ @allowed.include?(opt)
76
+ end
77
+
74
78
  def method_missing(meth, *args, &block)
75
79
  if meth.to_s.match(/=\Z/)
76
80
  opt = meth.to_s.gsub(/=/,'').to_sym
77
- return configure_option(opt, args.first) if @allowed.include?(opt)
81
+ return configure_option(opt, args.first) if allowed?(meth)
78
82
  else
79
- return @options[meth] if @allowed.include?(meth)
83
+ return @options[meth] if allowed?(meth)
80
84
  end
81
85
 
82
86
  super
@@ -0,0 +1,17 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+
3
+ module Canfig
4
+ module Module
5
+ def self.included(base)
6
+ base.send :cattr_reader, :configuration
7
+ base.send :class_variable_set, :@@configuration, Canfig::OpenConfig.new
8
+ base.send :extend, ClassMethods
9
+ end
10
+
11
+ module ClassMethods
12
+ def configure(&block)
13
+ (send :class_variable_get, :@@configuration).configure &block
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Canfig
2
+ module Object
3
+ def configuration
4
+ @configuration ||= Canfig::OpenConfig.new
5
+ end
6
+
7
+ def configure(&block)
8
+ @configuration.configure &block
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Canfig
2
+ class OpenConfig < Config
3
+ def allowed?(opt)
4
+ true
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Canfig
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/canfig.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'active_support/core_ext/array/extract_options'
2
2
  require 'active_support/core_ext/hash/keys'
3
3
  require 'canfig/version'
4
- require 'canfig/configuration'
4
+ require 'canfig/config'
5
+ require 'canfig/open_config'
6
+ require 'canfig/module'
7
+ require 'canfig/class'
8
+ require 'canfig/object'
5
9
 
6
10
  module Canfig
7
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
@@ -60,7 +60,11 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - lib/canfig.rb
63
- - lib/canfig/configuration.rb
63
+ - lib/canfig/class.rb
64
+ - lib/canfig/config.rb
65
+ - lib/canfig/module.rb
66
+ - lib/canfig/object.rb
67
+ - lib/canfig/open_config.rb
64
68
  - lib/canfig/version.rb
65
69
  - spec/spec_helper.rb
66
70
  homepage: http://github.com/markrebec/canfig