configurator 1.0.0 → 1.0.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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.0.1 2008-03-23
2
+
3
+ * Tiny changes
4
+
1
5
  == 1.0.0 2008-03-23
2
6
 
3
7
  * 1 major enhancement:
data/lib/configurator.rb CHANGED
@@ -1,124 +1,6 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
- #
4
- # Configurator extends configuration behavior to class.
5
- #
6
- # ==make class with configurator extension
7
- # Configurator allows you to delcare config paramaters with keys to class. It works as hash.
8
- # require 'rubygems'
9
- # require 'configurator'
10
- # class Klass
11
- # extend Congigurator
12
- # config :name, 'Matsumoto'
13
- # config :age, 18
14
- # end
15
- #
16
- # ==refer to config paramaters
17
- # Paramaters are referable from both Class and Instance.
18
- #
19
- # from class
20
- # Klass.config[:name] #=> 'Matsumoto'
21
- # Klass.config[:age] #=> 18
22
- # from instance
23
- # kls = Klass.new
24
- # kls.config[:name] #=> 'Matsumoto'
25
- # kls.config[:age] #=> 18
26
- #
27
- # ==inherite and rewrite
28
- # Paramaters are also inheritable and rewritable.
29
- # class SubKlass < Klass
30
- # config :name, 'Matz'
31
- # config :sex, 'm'
32
- # end
33
- # sub = SubKlass.new
34
- # sub.config[:name] # => 'Matz'
35
- # sub.config[:age] # => 18
36
- # sub.config[:sex] # => 'm'
37
- # kls.config[:name] # => 'Matsumoto'
38
- #
39
- # ==instance specific config paramaters
40
- # It works as like as instance specific method.
41
- # Klass.config :name, 'Matz'
42
- # kls = Klass.new
43
- # kls.config :name, 'Yukihiro'
44
- # kls.config[:name] # => 'Yukihiro'
45
- # kls2 = Klass.new
46
- # kls2.config[:name] # => 'Matz'
47
3
  module Configurator
48
-
49
- public
50
- # set config paramaters within class block code.
51
- # class Klass
52
- # extend Configurator
53
- # config key, value
54
- # end
55
- #
56
- # Another way to set paramaters.
57
- # Klass.config key, value
58
- # Klass.config[key] = value
59
- # Klass.new.config key, value
60
- # Klass.new.config[key] = value
61
- #
62
- # Reffer to config paramaters.
63
- # Klass.config[key] # => value
64
- # Klass.new.config[key] # => value
65
- #
66
- # This method also works as instance method because instance includes this module automatically.
67
- # kls = Klass.new
68
- # kls.config[key] # => value
69
- #
70
- def config( key = nil, value = nil )
71
- @__self_config ||= {}
72
- @__config = __check_config
73
- case
74
- when ( key and value ) : @__self_config[ key ] = value; @__config = __merge_config; return value
75
- when key : return @__config[ key ]
76
- else return @__config
77
- end
78
- end
79
-
80
- private
81
-
82
- def __merge_config
83
- __inherited_config.merge( @__self_config )
84
- end
85
-
86
- def __check_config
87
- @__config ||= {}
88
- __config = __merge_config
89
- @__config.each do |k, v|
90
- unless __config[ k ] == v
91
- @__self_config[ k ] = v
92
- end
93
- end
94
- @__config = __merge_config
95
- end
96
-
97
- def __inherited_config
98
- if self.respond_to?( :ancestors )
99
- @__inherited_config = {}
100
- ancestors[ 1 .. ( ancestors.size - 1 ) ].each do |ancestor|
101
- if ancestor.respond_to?( :config ) and Hash === ancestor.config
102
- @__inherited_config = ancestor.config.merge( @__inherited_config || {} )
103
- end
104
- end
105
- else
106
- @__inherited_config = self.class.config
107
- end
108
- return @__inherited_config
109
- end
110
-
111
- def method_missing( name, *args, &block )
112
- if @__config.keys.include?( name.to_sym )
113
- @__config[ name.to_sym ]
114
- else
115
- super
116
- end
117
- end
118
-
119
- def self.extended( mod )
120
- mod.module_eval { include Configurator } #::InstanceMethods }
121
- end
122
-
123
4
  end
124
5
 
6
+ require 'configurator/configurator'
@@ -2,7 +2,7 @@ module Configurator #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [ MAJOR, MINOR, TINY ].join( '.' )
8
8
  end
data/website/index.html CHANGED
@@ -82,7 +82,7 @@
82
82
 
83
83
  <p>Comments are welcome. Send an email to <a href="mailto:FIXME"><span class="caps">FIXME</span> full name</a> email via the <a href="http://groups.google.com/group/configurator">forum</a></p>
84
84
  <p class="coda">
85
- <a href="FIXME email">FIXME full name</a>, 21st March 2008<br>
85
+ <a href="FIXME email">FIXME full name</a>, 23rd March 2008<br>
86
86
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
87
87
  </p>
88
88
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configurator
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
  - wz