o 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +1 -296
  2. data/README_old.md +296 -0
  3. data/lib/o/version.rb +1 -1
  4. data/o.gemspec +2 -2
  5. metadata +5 -4
data/README.md CHANGED
@@ -1,296 +1 @@
1
- O, a configuration gem for Ruby
2
- ====================================
3
-
4
- **Homepage**: [https://github.com/GutenYe/o](https://github.com/GutenYe/o) <br/>
5
- **Author**: Guten <br/>
6
- **License**: MIT-LICENSE <br/>
7
- **Documentation**: [http://rubydoc.info/gems/o/frames](http://rubydoc.info/gems/o/frames) <br/>
8
- **Issue Tracker**: [https://github.com/GutenYe/o/issues](https://github.com/GutenYe/o/issues) <br/>
9
-
10
- The name `o` comes from option/setting, short and handy, eh-ah~
11
-
12
- Features
13
- --------
14
-
15
- * Variable and computed attribute support
16
- * Pure Ruby DSL syntax
17
- * Multiple configuration levels including system, user, and command-line.
18
- * Hash compatibility
19
-
20
- Introduction
21
- -------------
22
-
23
- The three levels of configuration include system, user, and cmdline:
24
-
25
- APP/lib/guten/rc.rb # system level
26
- ~/.gutenrc # user level
27
- $ guten --list or ENV[GEMFILE]=x guten # cmdline level
28
-
29
- module Guten
30
- Rc = O.require("guten/rc") + O.require("~/.gutenrc") # require use $:
31
- Rc.list = true or Rc.gemfile = ENV[GEMFILE] # from cmdline.
32
- end
33
-
34
- a constant works very well in many places, but you are free to use any variable.
35
-
36
- ### An example ###
37
-
38
- Rc = O do
39
- host "localhost"
40
- port 8080
41
- mail.stmp.address "stmp.gmail.com"
42
-
43
- my.development do # namespace
44
- adapter "postgresql"
45
- database "hello_development"
46
- username "guten"
47
- end
48
-
49
- time proc{|offset| Time.now} # computed attribute
50
- end
51
-
52
- ### An example using alternative syntax ###
53
-
54
- Rc = O do |c|
55
- c.host = "localhost"
56
- c.port = 8080
57
- c.mail.stmp.address "stmp.gmail.com"
58
-
59
- my.development do |c|
60
- c.adapter = "mysql2"
61
- c.database = "hello"
62
- c.username = "guten"
63
- end
64
-
65
- c.time = proc{|offset| Time.now}
66
- end
67
-
68
- ### An example of some sugar syntax. _works in a file only_ ###
69
-
70
- # file: guten/rc.rb
71
- development:
72
- adapter "mysql2"
73
- database "hello"
74
- username "guten"
75
-
76
- #=>
77
-
78
- development do
79
- adapter "mysql2"
80
- database "hello"
81
- username "guten"
82
- end
83
-
84
-
85
-
86
- **NOTE**: This is not pure ruby syntax, but it works.
87
- In order for this to work, a tab ("\t") must be used for indention.
88
-
89
- ### Initialize ###
90
-
91
- In order to initialize the configuration object either of the two ways can be used.
92
-
93
- Rc = O.new
94
- Rc = O.require "guten/rc" # from file
95
- Rc = O do
96
- a 1
97
- end
98
- Rc = O[a: 1] # from a hash data
99
- Rc._merge!(a: 1)
100
-
101
- file: "guten/rc.rb"
102
-
103
- a 1
104
-
105
- Initalize with a default value
106
-
107
- Rc = O.new
108
- p Rc[:hello] #=> nil
109
- Rc = O.new 1
110
- p Rc[:hello] #=> 1
111
- p Rc.hello #=> <#O> be careful here
112
-
113
- ### Assignment & Access ###
114
-
115
- Flexibility has been built in to allow for various ways to assign configuration
116
- data values and access the same values within your application. Here are some
117
- examples of how this can be done:
118
-
119
- Assignment:
120
-
121
- Rc.age 1
122
- Rc.age = 1
123
- Rc[:age] = 1
124
- Rc["age"] = 1
125
-
126
- Access:
127
-
128
- Rc.age #=> 1
129
- Rc.age? #=> true
130
- Rc[:age] #=> 1
131
- Rc["age"] #=> 1
132
- ---
133
- O do |c|
134
- age 2
135
- c.age = 2
136
- c[:age] = 2
137
- end
138
-
139
- ### Node ###
140
-
141
- Rc = O.new
142
- Rc.a.b.c = 1
143
- p Rc.a.b.c #=> <#Fixnum 1>
144
- p Rc.a.b #=> <#O>
145
- p Rc.a #=> <#O>
146
- p Rc.i.dont.exists #=> <#O>
147
-
148
- Rc = O.new
149
- p Rc.a._empty? #=> true # if a node is empty?
150
- Rc.a.b = 1
151
- p Rc.a._empty? #=> false
152
- p O===Rc.a #=> true # if it is a node?
153
- p O===Rc.a.b #=> false
154
-
155
- ### Variable & Path ###
156
-
157
- O do
158
- age 1
159
- p age #=> 1
160
- my do
161
- age 2
162
- friend do
163
- age 3
164
- p age #=> 3
165
- p __.age #=> 2 __ is relative up to 1 times
166
- p ___.age #=> 1 ___ and so on is relative up to 2 and so on times
167
- p _.age #=> 1 _ is root
168
- end
169
- end
170
- end
171
-
172
- ### Namespace ###
173
-
174
- Either way is fine:
175
-
176
- O do
177
- mail.stmp.address "stmp.gmail.com"
178
- mail.stmp do
179
- address "stmp.gmail.com"
180
- end
181
- end
182
-
183
- Another namespace example:
184
-
185
- O do
186
- age 1
187
-
188
- my do
189
- age 2
190
- end
191
-
192
- my.friend do
193
- age 3
194
- end
195
- end
196
-
197
-
198
- ### Group ###
199
-
200
- Use namespace or use some separate files like rails.
201
-
202
- config/
203
- applications.rb
204
- environments/
205
- development.rb
206
- test.rb
207
- production.rb
208
-
209
- ### Computed attribute ###
210
-
211
- Rc = O do
212
- time proc{|n| Time.now}
213
- end
214
- p Rc.time # print current time. no need Rc.time.call()
215
- p Rc.time(2) # call time
216
- Rc.time = 2 # assign new value
217
- p Rc[:time] #=> <#Proc>
218
-
219
- ### Semantic ###
220
-
221
- O do
222
- is_started no # yes ...
223
- end
224
-
225
- Note: for a list of semantic methods, see O::Semantics
226
-
227
- ### Hash compatibility ###
228
-
229
- Internal, datas are stored as a Hash. You can access all hash methods via `_method`
230
-
231
- Rc = O.new
232
- Rc.a = 1
233
- Rc._child #=> {:a=>1}
234
-
235
- Rc._keys #=> [:a]
236
-
237
- ### Temporarily change ###
238
-
239
- Rc.a = 1
240
- Rc._temp do
241
- Rc.a = 2
242
- end
243
- p Rc.a #=> 1
244
-
245
-
246
- ### Access built-in method inside block ###
247
-
248
- Rc = O do
249
- sleep 10 # is a data. Rc.sleep #=> 10
250
- O.sleep 10 # call builtin 'sleep' method
251
- end
252
-
253
- Note: for a list of blocked methods, see O::BUILTIN_METHODS
254
-
255
- ### Additional examples ###
256
-
257
- O do
258
- name do
259
- first "Guten"
260
- last "Ye"
261
- is "#{first} #{last}"
262
- end
263
- end
264
-
265
- \# file: a.rb
266
-
267
- c = self
268
- c.host = "localhost"
269
- c.port = 8080
270
- c.name do |c|
271
- c.first = "Guten"
272
- end
273
-
274
- Contributing
275
- -------------
276
-
277
- * Feel free to join the project and make contributions (by submitting a pull request)
278
- * Submit any bugs/features/ideas to github issue tracker
279
- * Codeing style: https://gist.github.com/1105334
280
-
281
- Install
282
- ----------
283
-
284
- gem install o
285
-
286
- Resources
287
- ---------
288
-
289
- * [konfigurator](https://github.com/nu7hatch/konfigurator) Small and flexible configuration toolkit inspired i.a. by Sinatra settings
290
- * [configatron](https://github.com/markbates/configatron) A super cool, simple, and feature rich configuration system for Ruby apps
291
- * [simpleconfig](https://github.com/lukeredpath/simpleconfig) make application-wide configuration settings easy to set and access in an object-oriented fashion
292
- * [configuration](https://github.com/ahoward/configuration) pure ruby scoped configuration files
293
-
294
- Copyright
295
- ---------
296
- Copyright &copy; 2011 by Guten. this library released under MIT-LICENSE, See {file:LICENSE} for futher details.
1
+ it renamed to optimism. new home page is [github.com/GutenYe/optimism](https://github.com/GutenYe/optimism)
@@ -0,0 +1,296 @@
1
+ O, a configuration gem for Ruby
2
+ ====================================
3
+
4
+ **Homepage**: [https://github.com/GutenYe/o](https://github.com/GutenYe/o) <br/>
5
+ **Author**: Guten <br/>
6
+ **License**: MIT-LICENSE <br/>
7
+ **Documentation**: [http://rubydoc.info/gems/o/frames](http://rubydoc.info/gems/o/frames) <br/>
8
+ **Issue Tracker**: [https://github.com/GutenYe/o/issues](https://github.com/GutenYe/o/issues) <br/>
9
+
10
+ The name `o` comes from option/setting, short and handy, eh-ah~
11
+
12
+ Features
13
+ --------
14
+
15
+ * Variable and computed attribute support
16
+ * Pure Ruby DSL syntax
17
+ * Multiple configuration levels including system, user, and command-line.
18
+ * Hash compatibility
19
+
20
+ Introduction
21
+ -------------
22
+
23
+ The three levels of configuration include system, user, and cmdline:
24
+
25
+ APP/lib/guten/rc.rb # system level
26
+ ~/.gutenrc # user level
27
+ $ guten --list or ENV[GEMFILE]=x guten # cmdline level
28
+
29
+ module Guten
30
+ Rc = O.require("guten/rc") + O.require("~/.gutenrc") # require use $:
31
+ Rc.list = true or Rc.gemfile = ENV[GEMFILE] # from cmdline.
32
+ end
33
+
34
+ a constant works very well in many places, but you are free to use any variable.
35
+
36
+ ### An example ###
37
+
38
+ Rc = O do
39
+ host "localhost"
40
+ port 8080
41
+ mail.stmp.address "stmp.gmail.com"
42
+
43
+ my.development do # namespace
44
+ adapter "postgresql"
45
+ database "hello_development"
46
+ username "guten"
47
+ end
48
+
49
+ time proc{|offset| Time.now} # computed attribute
50
+ end
51
+
52
+ ### An example using alternative syntax ###
53
+
54
+ Rc = O do |c|
55
+ c.host = "localhost"
56
+ c.port = 8080
57
+ c.mail.stmp.address "stmp.gmail.com"
58
+
59
+ my.development do |c|
60
+ c.adapter = "mysql2"
61
+ c.database = "hello"
62
+ c.username = "guten"
63
+ end
64
+
65
+ c.time = proc{|offset| Time.now}
66
+ end
67
+
68
+ ### An example of some sugar syntax. _works in a file only_ ###
69
+
70
+ # file: guten/rc.rb
71
+ development:
72
+ adapter "mysql2"
73
+ database "hello"
74
+ username "guten"
75
+
76
+ #=>
77
+
78
+ development do
79
+ adapter "mysql2"
80
+ database "hello"
81
+ username "guten"
82
+ end
83
+
84
+
85
+
86
+ **NOTE**: This is not pure ruby syntax, but it works.
87
+ In order for this to work, a tab ("\t") must be used for indention.
88
+
89
+ ### Initialize ###
90
+
91
+ In order to initialize the configuration object either of the two ways can be used.
92
+
93
+ Rc = O.new
94
+ Rc = O.require "guten/rc" # from file
95
+ Rc = O do
96
+ a 1
97
+ end
98
+ Rc = O[a: 1] # from a hash data
99
+ Rc._merge!(a: 1)
100
+
101
+ file: "guten/rc.rb"
102
+
103
+ a 1
104
+
105
+ Initalize with a default value
106
+
107
+ Rc = O.new
108
+ p Rc[:hello] #=> nil
109
+ Rc = O.new 1
110
+ p Rc[:hello] #=> 1
111
+ p Rc.hello #=> <#O> be careful here
112
+
113
+ ### Assignment & Access ###
114
+
115
+ Flexibility has been built in to allow for various ways to assign configuration
116
+ data values and access the same values within your application. Here are some
117
+ examples of how this can be done:
118
+
119
+ Assignment:
120
+
121
+ Rc.age 1
122
+ Rc.age = 1
123
+ Rc[:age] = 1
124
+ Rc["age"] = 1
125
+
126
+ Access:
127
+
128
+ Rc.age #=> 1
129
+ Rc.age? #=> true
130
+ Rc[:age] #=> 1
131
+ Rc["age"] #=> 1
132
+ ---
133
+ O do |c|
134
+ age 2
135
+ c.age = 2
136
+ c[:age] = 2
137
+ end
138
+
139
+ ### Node ###
140
+
141
+ Rc = O.new
142
+ Rc.a.b.c = 1
143
+ p Rc.a.b.c #=> <#Fixnum 1>
144
+ p Rc.a.b #=> <#O>
145
+ p Rc.a #=> <#O>
146
+ p Rc.i.dont.exists #=> <#O>
147
+
148
+ Rc = O.new
149
+ p Rc.a._empty? #=> true # if a node is empty?
150
+ Rc.a.b = 1
151
+ p Rc.a._empty? #=> false
152
+ p O===Rc.a #=> true # if it is a node?
153
+ p O===Rc.a.b #=> false
154
+
155
+ ### Variable & Path ###
156
+
157
+ O do
158
+ age 1
159
+ p age #=> 1
160
+ my do
161
+ age 2
162
+ friend do
163
+ age 3
164
+ p age #=> 3
165
+ p __.age #=> 2 __ is relative up to 1 times
166
+ p ___.age #=> 1 ___ and so on is relative up to 2 and so on times
167
+ p _.age #=> 1 _ is root
168
+ end
169
+ end
170
+ end
171
+
172
+ ### Namespace ###
173
+
174
+ Either way is fine:
175
+
176
+ O do
177
+ mail.stmp.address "stmp.gmail.com"
178
+ mail.stmp do
179
+ address "stmp.gmail.com"
180
+ end
181
+ end
182
+
183
+ Another namespace example:
184
+
185
+ O do
186
+ age 1
187
+
188
+ my do
189
+ age 2
190
+ end
191
+
192
+ my.friend do
193
+ age 3
194
+ end
195
+ end
196
+
197
+
198
+ ### Group ###
199
+
200
+ Use namespace or use some separate files like rails.
201
+
202
+ config/
203
+ applications.rb
204
+ environments/
205
+ development.rb
206
+ test.rb
207
+ production.rb
208
+
209
+ ### Computed attribute ###
210
+
211
+ Rc = O do
212
+ time proc{|n| Time.now}
213
+ end
214
+ p Rc.time # print current time. no need Rc.time.call()
215
+ p Rc.time(2) # call time
216
+ Rc.time = 2 # assign new value
217
+ p Rc[:time] #=> <#Proc>
218
+
219
+ ### Semantic ###
220
+
221
+ O do
222
+ is_started no # yes ...
223
+ end
224
+
225
+ Note: for a list of semantic methods, see O::Semantics
226
+
227
+ ### Hash compatibility ###
228
+
229
+ Internal, datas are stored as a Hash. You can access all hash methods via `_method`
230
+
231
+ Rc = O.new
232
+ Rc.a = 1
233
+ Rc._child #=> {:a=>1}
234
+
235
+ Rc._keys #=> [:a]
236
+
237
+ ### Temporarily change ###
238
+
239
+ Rc.a = 1
240
+ Rc._temp do
241
+ Rc.a = 2
242
+ end
243
+ p Rc.a #=> 1
244
+
245
+
246
+ ### Access built-in method inside block ###
247
+
248
+ Rc = O do
249
+ sleep 10 # is a data. Rc.sleep #=> 10
250
+ O.sleep 10 # call builtin 'sleep' method
251
+ end
252
+
253
+ Note: for a list of blocked methods, see O::BUILTIN_METHODS
254
+
255
+ ### Additional examples ###
256
+
257
+ O do
258
+ name do
259
+ first "Guten"
260
+ last "Ye"
261
+ is "#{first} #{last}"
262
+ end
263
+ end
264
+
265
+ \# file: a.rb
266
+
267
+ c = self
268
+ c.host = "localhost"
269
+ c.port = 8080
270
+ c.name do |c|
271
+ c.first = "Guten"
272
+ end
273
+
274
+ Contributing
275
+ -------------
276
+
277
+ * Feel free to join the project and make contributions (by submitting a pull request)
278
+ * Submit any bugs/features/ideas to github issue tracker
279
+ * Coding Style Guide: https://gist.github.com/1105334
280
+
281
+ Install
282
+ ----------
283
+
284
+ gem install o
285
+
286
+ Resources
287
+ ---------
288
+
289
+ * [konfigurator](https://github.com/nu7hatch/konfigurator) Small and flexible configuration toolkit inspired i.a. by Sinatra settings
290
+ * [configatron](https://github.com/markbates/configatron) A super cool, simple, and feature rich configuration system for Ruby apps
291
+ * [simpleconfig](https://github.com/lukeredpath/simpleconfig) make application-wide configuration settings easy to set and access in an object-oriented fashion
292
+ * [configuration](https://github.com/ahoward/configuration) pure ruby scoped configuration files
293
+
294
+ Copyright
295
+ ---------
296
+ Copyright &copy; 2011 by Guten. this library released under MIT-LICENSE, See {file:LICENSE} for futher details.
@@ -2,7 +2,7 @@ class O
2
2
  module VERSION
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- PATCH = 3
5
+ PATCH = 4
6
6
  PRE = ''
7
7
  IS = [MAJOR, MINOR, PATCH].join(".") + PRE
8
8
  end
data/o.gemspec CHANGED
@@ -6,12 +6,12 @@ Gem::Specification.new do |s|
6
6
  s.version = O::VERSION::IS
7
7
  s.summary = "a configuration library for Ruby"
8
8
  s.description = <<-EOF
9
- a coonfiguration library for Ruby
9
+ from version 2.0.4, it renamed to optimism, new home page is github.com/GutenYe/optimism
10
10
  EOF
11
11
 
12
12
  s.author = "Guten"
13
13
  s.email = "ywzhaifei@Gmail.com"
14
- s.homepage = "http://github.com/GutenYe/o"
14
+ s.homepage = "http://github.com/GutenYe/optimism"
15
15
  s.rubyforge_project = "xx"
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: o
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.3
5
+ version: 2.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Guten
@@ -10,11 +10,11 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-27 00:00:00 Z
13
+ date: 2011-07-28 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: |
17
- a coonfiguration library for Ruby
17
+ from version 2.0.4, it renamed to optimism, new home page is github.com/GutenYe/optimism
18
18
 
19
19
  email: ywzhaifei@Gmail.com
20
20
  executables: []
@@ -29,6 +29,7 @@ files:
29
29
  - Gemfile
30
30
  - LICENSE
31
31
  - README.md
32
+ - README_old.md
32
33
  - Ragfile
33
34
  - lib/o.rb
34
35
  - lib/o/hash_method_fix.rb
@@ -46,7 +47,7 @@ files:
46
47
  - spec/o_spec.rb
47
48
  - spec/spec_helper.rb
48
49
  - spec/test_spec.rb
49
- homepage: http://github.com/GutenYe/o
50
+ homepage: http://github.com/GutenYe/optimism
50
51
  licenses: []
51
52
 
52
53
  post_install_message: