iqeo-conf 0.0.10 → 0.0.11

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/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
1
  .idea/
2
- .bundle/
2
+ .rspec
3
3
  .rvmrc
4
-
4
+ pkg/
data/.yardoc/checksums ADDED
@@ -0,0 +1,2 @@
1
+ lib/iqeo/configuration.rb 0790c6ed002a1b1e69afc4f38e218756c5ac480f
2
+ lib/iqeo/configuration/version.rb dad9c52c1d00b3028d333907df8e3ad45d475d93
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ {I" Object:EF:
2
+ class
data/Gemfile.lock CHANGED
@@ -2,14 +2,16 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  iqeo-conf (0.0.11)
5
- blankslate (~> 2.1.2.4)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
- blankslate (2.1.2.4)
11
9
  diff-lcs (1.1.3)
10
+ json (1.7.1)
12
11
  rake (0.9.2.2)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+ redcarpet (2.1.1)
13
15
  rspec (2.9.0)
14
16
  rspec-core (~> 2.9.0)
15
17
  rspec-expectations (~> 2.9.0)
@@ -18,6 +20,7 @@ GEM
18
20
  rspec-expectations (2.9.1)
19
21
  diff-lcs (~> 1.1.3)
20
22
  rspec-mocks (2.9.0)
23
+ yard (0.8.1)
21
24
 
22
25
  PLATFORMS
23
26
  ruby
@@ -25,4 +28,7 @@ PLATFORMS
25
28
  DEPENDENCIES
26
29
  iqeo-conf!
27
30
  rake (~> 0.9.2)
31
+ rdoc (~> 3.12.0)
32
+ redcarpet (~> 2.1.1)
28
33
  rspec (~> 2.9.0)
34
+ yard (~> 0.8.1)
data/README.md CHANGED
@@ -1,108 +1,136 @@
1
1
  # Iqeo::Configuration
2
2
 
3
- A DSL for writing configuration files.
3
+ A DSL representing configuration files.
4
4
 
5
5
  ## Installation
6
6
 
7
- It's a gem...
7
+ It`s a gem...
8
8
 
9
- ```
10
- $ gem install iqeo-conf
11
- ```
9
+ $ gem install iqeo-conf
12
10
 
13
11
  ## Usage
14
12
 
15
- Require it...
13
+ Require 'iqeo/configuration' and optionally include Iqeo namespace:
16
14
 
17
15
  ```ruby
18
16
  require 'iqeo/configuration'
17
+ include Iqeo
19
18
  ```
20
19
 
21
- ### Create a configuration
20
+ ### Create configuration
22
21
 
23
- Set values...
22
+ There are three ways to create configurations; explicit, block DSL, eval DSL.
24
23
 
25
- #### Directly on a configuration object
24
+ #### Explicit
26
25
 
27
- ```ruby
28
- conf = Iqeo::Configuration.new
26
+ Call Configuration#new without a block.
27
+ Explicitly call methods on instance to configure instance.
29
28
 
30
- # add some settings
31
-
32
- conf.alpha 42
33
- conf.bravo "foobar"
34
- conf.charlie { :a => 1, :b => 2, :c => 3 }
35
- conf.delta [ 1, 2, 3 ]
29
+ ```ruby
30
+ conf = Configuration.new
31
+ conf.alpha 1
32
+ conf.bravo 2.0
33
+ conf.charlie :three
34
+ conf.delta "four"
36
35
  ```
37
36
 
38
- #### Configuration DSL block yield style
37
+ #### Block DSL
38
+
39
+ Call Configuration#new with a block that expects a variable, a new instance will be yielded.
40
+ Within block, call methods on yielded instance to configure.
39
41
 
40
42
  ```ruby
41
- conf = Iqeo::Configuration.new do |c|
43
+ conf = Configuration.new do |c|
44
+ c.alpha 1
45
+ c.bravo 2.0
46
+ c.charlie :three
47
+ c.delta "four"
48
+ end
49
+ ```
42
50
 
43
- c.alpha 42
44
- c.bravo "foobar"
45
- c.charlie { :a => 1, :b => 2, :c => 3 }
46
- c.delta [ 1, 2, 3 ]
51
+ #### Eval DSL
47
52
 
53
+ Call Configuration#new with a block that does not expect a variable, contents of the block are eval`d in the context of the new instance.
54
+ Call methods with implied self to configure instance.
55
+
56
+ ```ruby
57
+ conf = Configuration.new do
58
+ alpha 1
59
+ bravo 2.0
60
+ charlie :three
61
+ delta "four"
48
62
  end
49
63
  ```
50
64
 
51
- #### Configuration DSL instance_eval style
65
+ ### Read configuration
52
66
 
53
- ```ruby
54
- conf = Iqeo::Configuration.new do
67
+ All examples above result in the same configuration.
68
+ Configuration settings can be retrieved directly or indirectly.
55
69
 
56
- alpha 42
57
- bravo "foobar"
58
- charlie { :a => 1, :b => 2, :c => 3 }
59
- delta [ 1, 2, 3 ]
70
+ #### Directly
60
71
 
61
- end
72
+ ##### Named method
73
+
74
+ ```ruby
75
+ conf.alpha # => 1
76
+ conf.bravo # => 2.0
77
+ conf.charlie # => :three
78
+ conf.delta # => "four"
62
79
  ```
63
80
 
64
- ### Reading a configuration
81
+ ##### [ 'string' ]
65
82
 
66
- Retrieve settings...
83
+ ```ruby
84
+ conf['alpha'] # => 1
85
+ conf['bravo'] # => 2.0
86
+ conf['charlie'] # => :three
87
+ conf['delta'] # => "four"
88
+ ```
89
+
90
+ ##### [ :symbol ]
67
91
 
68
92
  ```ruby
69
- conf.alpha => 42
70
- conf.bravo => "foobar"
71
- conf.charlie => { :a => 1, :b => 2, :c => 3 }
72
- conf.delta => [ 1, 2, 3 ]
93
+ conf[:alpha] # => 1
94
+ conf[:bravo] # => 2.0
95
+ conf[:charlie] # => :three
96
+ conf[:delta] # => "four"
73
97
  ```
74
98
 
75
- ## Other features
99
+ #### Indirectly
76
100
 
77
- This README may not be complete, see rspec tests for all working features.
101
+ The underlying storage is an indifferent hash, so the usual Hash and Enumerable methods work.
78
102
 
79
- ## Done
103
+ ##### Hash & Enumerable methods
80
104
 
81
- Need docs...
105
+ ```ruby
106
+ conf.size # => 4
107
+ conf.keys # => [ 'alpha', 'bravo', 'charlie', 'delta' ]
108
+ conf.collect { |key,value| value } # => [ 1, 2.0, :three, 'four' ]
109
+ ```
82
110
 
83
- * Hash operators [] & []=
84
- * Nested configurations
85
- * Nested configurations inherit settings
86
- * Nested configurations override inherited settings
87
- * Load configurations from a string or file at creation
88
- * Iterate over items hash - by delegation to hash
89
- * Indifferent hash access - using ActiveSupport/HashWithIndifferentAccess
90
- * Clean DSL syntax for creating a nested configuration - just a block ?
91
- * Load configurations from a string or file after creation / in DSL block
111
+ ## Features
92
112
 
93
- ## Todo
113
+ * settings by named methods
114
+ * settings by '[]' & '[]='
115
+ * settings & locals with '='
116
+ * referencing existing settings
117
+ * nested configurations
118
+ * inheritance & override
119
+ * read from string, at creation, or after - merged & nested
120
+ * load from filename, at creation, or after - merged & nested
121
+ * todo: merge configurations
122
+ * todo: defaults
123
+ * todo: blank slate
94
124
 
95
- Need time (have motivation)...
125
+ ## Fancy usage
96
126
 
97
- * Configuration file load path
98
- * Use an existing configuration for defaults
99
- * Blank slate for DSL ? - optional ?
100
- * Option to get hash directly to prevent polluting namespace with delegated hash methods
101
- * Consider issues around deferred interpolation / procs / lambdas etc...
102
- * Load other formats into configuration - YAML, CSV, ...anything Enumerable should be easy enough.
127
+ * Dynamic settings by '[]' & '[]=' & 'self'
128
+ * Multiple configuration files
129
+ * Hierarchial configuration files
103
130
 
104
131
  ## License
105
132
 
106
- Licensed under GPL Version 3 license
107
- See LICENSE file
133
+ Copyright Gerard Fowley (gerard.fowley@iqeo.net).
108
134
 
135
+ Licensed under GPL Version 3 license.
136
+ See LICENSE file.
data/Rakefile CHANGED
@@ -1,14 +1,22 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require "rake/testtask"
4
-
5
- Rake::TestTask.new do |t|
6
- t.libs << "test"
7
- t.test_files = FileList['test/test*.rb']
8
- t.verbose = true
9
- end
10
3
 
11
4
  require 'rspec/core/rake_task'
12
5
  RSpec::Core::RakeTask.new('spec')
13
6
 
7
+ require 'rdoc/task'
8
+ RDoc::Task.new do |rdoc|
9
+ rdoc.main = "README.rdoc"
10
+ rdoc.rdoc_files.include "README.rdoc", "lib/**/*.rb"
11
+ rdoc.rdoc_files.exclude "lib/**/hash_with_indifferent_access.rb"
12
+ rdoc.options << "--all" << "--verbose"
13
+ end
14
+
15
+ require 'yard'
16
+ #require 'yard/rake/yardoc_task'
17
+ YARD::Rake::YardocTask.new do |yard|
18
+ yard.files = %w( lib/**/*.rb )
19
+ yard.options = %w( --main README.md --exclude hash_with_indifferent_access.rb )
20
+ end
21
+
14
22
  task :default => :spec