lab419-config 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/Manifest +27 -0
- data/Rakefile +20 -0
- data/config.rb +7 -0
- data/lab419-config.gemspec +30 -0
- data/lib/doc/Lab419.html +156 -0
- data/lib/doc/Lab419/Config.html +184 -0
- data/lib/doc/Lab419/Config/Data.html +372 -0
- data/lib/doc/Lab419/Config/Parser.html +469 -0
- data/lib/doc/Lab419/Config/Reader.html +604 -0
- data/lib/doc/Lab419/Config/Source.html +429 -0
- data/lib/doc/created.rid +6 -0
- data/lib/doc/index.html +115 -0
- data/lib/doc/lab419/config/data_rb.html +54 -0
- data/lib/doc/lab419/config/parser_rb.html +52 -0
- data/lib/doc/lab419/config/reader_rb.html +58 -0
- data/lib/doc/lab419/config/source_rb.html +52 -0
- data/lib/doc/lab419/config_rb.html +54 -0
- data/lib/doc/rdoc.css +701 -0
- data/lib/lab419/config.rb +2 -0
- data/lib/lab419/config/data.rb +58 -0
- data/lib/lab419/config/parser.rb +81 -0
- data/lib/lab419/config/reader.rb +80 -0
- data/lib/lab419/config/source.rb +56 -0
- data/specs/config_data_spec.rb +68 -0
- data/specs/config_reader_spec.rb +133 -0
- data/specs/config_source_spec.rb +74 -0
- data/specs/custom_handler_spec.rb +40 -0
- metadata +109 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.join( File.dirname( __FILE__ ), %w{ .. lib } )
|
3
|
+
require 'lab419/config/source'
|
4
|
+
|
5
|
+
describe Lab419::Config::Source do
|
6
|
+
before :each do
|
7
|
+
@source = Lab419::Config::Source::new %w{a b c}
|
8
|
+
end
|
9
|
+
describe "#next" do
|
10
|
+
it "shall be nextable" do
|
11
|
+
@source.next.should == "b"
|
12
|
+
end # it "shall be nextable"
|
13
|
+
it "shall change the state of the nexted objet" do
|
14
|
+
@source.next
|
15
|
+
@source.next.should == "c"
|
16
|
+
end # it "shall change the state of the nexted objet"
|
17
|
+
it "shall eventually become nil" do
|
18
|
+
@source.next
|
19
|
+
@source.next
|
20
|
+
@source.next.should be_nil
|
21
|
+
end # it "shall eventually become nil"
|
22
|
+
describe "nexted to the end" do
|
23
|
+
before :each do
|
24
|
+
3.times do @source.next end
|
25
|
+
end # before :each
|
26
|
+
it "shall be empty" do
|
27
|
+
@source.eos?.should == true
|
28
|
+
end
|
29
|
+
it "next next shall be nil" do
|
30
|
+
@source.next.should be_nil
|
31
|
+
end
|
32
|
+
it "current shall be nil too" do
|
33
|
+
@source.current.should be_nil
|
34
|
+
end
|
35
|
+
end # describe "nexted to the end"
|
36
|
+
end
|
37
|
+
describe "#current" do
|
38
|
+
it "shall return the correct initial value" do
|
39
|
+
@source.current.should == "a"
|
40
|
+
end # it "shall return the correct value"
|
41
|
+
end # describe "#current"
|
42
|
+
|
43
|
+
describe "#eos?" do
|
44
|
+
it "shall return the correct initial value" do
|
45
|
+
@source.eos?.should == false
|
46
|
+
end # it "shall return the correct initial value"
|
47
|
+
end # describe "#eos?"
|
48
|
+
describe "line positions" do
|
49
|
+
it "shall be at line 1" do
|
50
|
+
@source.line_nb.should == 1
|
51
|
+
end
|
52
|
+
it "shall be at line 2 after next" do
|
53
|
+
@source.next
|
54
|
+
@source.line_nb.should == 2
|
55
|
+
end # it "shall be at line 2 after next"
|
56
|
+
it "shall never exceed 3" do
|
57
|
+
4.times do @source.next end
|
58
|
+
@source.line_nb.should == 3
|
59
|
+
end # it "shall never exceed 3"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "sources with names" do
|
64
|
+
before :each do
|
65
|
+
@a = Lab419::Config::Source::new %w{alpha beta}
|
66
|
+
@s = Lab419::Config::Source::new %w{alpha beta}, "mysource"
|
67
|
+
end
|
68
|
+
it "shall have the given name" do
|
69
|
+
@s.name.should == "mysource"
|
70
|
+
end # it "shall have the given name"
|
71
|
+
it "or it shall have the default name" do
|
72
|
+
@a.name.should == "<annon>"
|
73
|
+
end # it "or it shall have the default name"
|
74
|
+
end # describe "sources with names"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.join( File.dirname( __FILE__ ), %w{ .. lib } )
|
3
|
+
require 'lab419/config'
|
4
|
+
|
5
|
+
class Object
|
6
|
+
def def_sgt_method name, &blk
|
7
|
+
class << self; self end.module_eval do
|
8
|
+
define_method( name, &blk )
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe Lab419::Config::Reader do
|
13
|
+
before :all do
|
14
|
+
@cr = Lab419::Config::Reader::new
|
15
|
+
@cr.handle /\s*\{/, :as_hash
|
16
|
+
@cr.with_string "a={ a: 1,
|
17
|
+
b:2 }"
|
18
|
+
@cr.def_sgt_method :as_hash do
|
19
|
+
x=[]
|
20
|
+
loop do
|
21
|
+
x << @source.current
|
22
|
+
if @source.current =~ /\}/ then
|
23
|
+
return x
|
24
|
+
end
|
25
|
+
@source.next
|
26
|
+
end # loop
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "shall parse correctly" do
|
31
|
+
lambda{ @cr.parse }.should_not raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it "shall parse and give a correct result" do
|
35
|
+
@cr.parse
|
36
|
+
@cr.config.a.should == ["a={ a: 1, ", "b:2 }"]
|
37
|
+
end # it "shall parse and give a correct result"
|
38
|
+
|
39
|
+
|
40
|
+
end # describe Lab419::Config::Reader
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lab419-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Robert Dober
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2010-05-23 00:00:00 +02:00
|
17
|
+
default_executable:
|
18
|
+
dependencies: []
|
19
|
+
|
20
|
+
description: Lab419, Labrador for Ruby1.9, Configuration File and DSL Tool
|
21
|
+
email: robert.dober@gmail.com
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions: []
|
25
|
+
|
26
|
+
extra_rdoc_files:
|
27
|
+
- lib/doc/Lab419.html
|
28
|
+
- lib/doc/Lab419/Config.html
|
29
|
+
- lib/doc/Lab419/Config/Data.html
|
30
|
+
- lib/doc/Lab419/Config/Parser.html
|
31
|
+
- lib/doc/Lab419/Config/Reader.html
|
32
|
+
- lib/doc/Lab419/Config/Source.html
|
33
|
+
- lib/doc/created.rid
|
34
|
+
- lib/doc/index.html
|
35
|
+
- lib/doc/lab419/config/data_rb.html
|
36
|
+
- lib/doc/lab419/config/parser_rb.html
|
37
|
+
- lib/doc/lab419/config/reader_rb.html
|
38
|
+
- lib/doc/lab419/config/source_rb.html
|
39
|
+
- lib/doc/lab419/config_rb.html
|
40
|
+
- lib/doc/rdoc.css
|
41
|
+
- lib/lab419/config.rb
|
42
|
+
- lib/lab419/config/data.rb
|
43
|
+
- lib/lab419/config/parser.rb
|
44
|
+
- lib/lab419/config/reader.rb
|
45
|
+
- lib/lab419/config/source.rb
|
46
|
+
files:
|
47
|
+
- Manifest
|
48
|
+
- Rakefile
|
49
|
+
- config.rb
|
50
|
+
- lab419-config.gemspec
|
51
|
+
- lib/doc/Lab419.html
|
52
|
+
- lib/doc/Lab419/Config.html
|
53
|
+
- lib/doc/Lab419/Config/Data.html
|
54
|
+
- lib/doc/Lab419/Config/Parser.html
|
55
|
+
- lib/doc/Lab419/Config/Reader.html
|
56
|
+
- lib/doc/Lab419/Config/Source.html
|
57
|
+
- lib/doc/created.rid
|
58
|
+
- lib/doc/index.html
|
59
|
+
- lib/doc/lab419/config/data_rb.html
|
60
|
+
- lib/doc/lab419/config/parser_rb.html
|
61
|
+
- lib/doc/lab419/config/reader_rb.html
|
62
|
+
- lib/doc/lab419/config/source_rb.html
|
63
|
+
- lib/doc/lab419/config_rb.html
|
64
|
+
- lib/doc/rdoc.css
|
65
|
+
- lib/lab419/config.rb
|
66
|
+
- lib/lab419/config/data.rb
|
67
|
+
- lib/lab419/config/parser.rb
|
68
|
+
- lib/lab419/config/reader.rb
|
69
|
+
- lib/lab419/config/source.rb
|
70
|
+
- specs/config_data_spec.rb
|
71
|
+
- specs/config_reader_spec.rb
|
72
|
+
- specs/config_source_spec.rb
|
73
|
+
- specs/custom_handler_spec.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://bitbucket.org/robertdober/lab419/
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- --line-numbers
|
81
|
+
- --inline-source
|
82
|
+
- --title
|
83
|
+
- Lab419-config
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 2
|
100
|
+
version: "1.2"
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project: lab419-config
|
104
|
+
rubygems_version: 1.3.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Create configuration file readers or DSLs with a highly adaptable configuration reader
|
108
|
+
test_files: []
|
109
|
+
|