proteus 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/COPYING +674 -0
  2. data/README +88 -0
  3. data/Rakefile +33 -0
  4. data/bin/pro +189 -0
  5. data/lib/ClassParser.rb +84 -0
  6. data/lib/ComponentClass.rb +51 -0
  7. data/lib/ComponentInstance.rb +76 -0
  8. data/lib/DefinitionHelper.rb +157 -0
  9. data/lib/DefinitionParser.rb +107 -0
  10. data/lib/Facade.rb +116 -0
  11. data/lib/FileHelper.rb +80 -0
  12. data/lib/InputParser.rb +241 -0
  13. data/lib/InstanceParser.rb +65 -0
  14. data/lib/InstanceProxy.rb +100 -0
  15. data/lib/PropertyHash.rb +64 -0
  16. data/lib/TemplateRenderer.rb +128 -0
  17. data/lib/exceptions.rb +50 -0
  18. data/test/spec/ClassParser_spec.rb +314 -0
  19. data/test/spec/ComponentClass_spec.rb +44 -0
  20. data/test/spec/ComponentInstance_spec.rb +50 -0
  21. data/test/spec/DefinitionHelper_spec.rb +134 -0
  22. data/test/spec/DefinitionParser_spec.rb +236 -0
  23. data/test/spec/Facade_spec.rb +44 -0
  24. data/test/spec/FileHelper_spec.rb +113 -0
  25. data/test/spec/InputParser_spec.rb +424 -0
  26. data/test/spec/InstanceParser_spec.rb +125 -0
  27. data/test/spec/TemplateRenderer_spec.rb +54 -0
  28. data/test/spec/lib/NS1/TestComponent10.def +4 -0
  29. data/test/spec/lib/NS1/TestComponent11.def +4 -0
  30. data/test/spec/lib/NS1/TestComponent4.def +4 -0
  31. data/test/spec/lib/NS1/TestComponent5.def +4 -0
  32. data/test/spec/lib/NS1/TestComponent8.def +4 -0
  33. data/test/spec/lib/NS1/TestComponent9.def +4 -0
  34. data/test/spec/lib/NS2/TestComponent6.def +4 -0
  35. data/test/spec/lib/TestComponent1.def +4 -0
  36. data/test/spec/lib/TestComponent3.def +4 -0
  37. data/test/spec/test_lib_dir1/File1.def +0 -0
  38. data/test/spec/test_lib_dir1/File3.def +0 -0
  39. data/test/spec/test_lib_dir1/NS1/File4.def +0 -0
  40. data/test/spec/test_lib_dir1/NS1/NS2/File5.def +0 -0
  41. data/test/spec/test_lib_dir2/File1.def +0 -0
  42. data/test/spec/test_lib_dir2/File2.def +0 -0
  43. metadata +113 -0
@@ -0,0 +1,125 @@
1
+ ################################################################################
2
+ # (C) Copyright 2009 William Madden
3
+ #
4
+ # This file is part of Proteus.
5
+ #
6
+ # Proteus is free software: you can redistribute it and/or modify it under the
7
+ # terms of the GNU General Public License as published by the Free Software
8
+ # Foundation, either version 3 of the License, or (at your option) any later
9
+ # version.
10
+ #
11
+ # Proteus is distributed in the hope that it will be useful, but WITHOUT ANY
12
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # Proteus. If not, see <http://www.gnu.org/licenses/>.
17
+ ################################################################################
18
+
19
+ require File.expand_path( 'lib/InstanceParser.rb' )
20
+
21
+ include Proteus
22
+
23
+
24
+ describe InstanceParser do
25
+
26
+ #-----------------------------------------------------------------------------
27
+ #
28
+ # Input Constants
29
+ #
30
+ #-----------------------------------------------------------------------------
31
+
32
+ @@HASH_1 = {
33
+ "property1" => "value1",
34
+ "property2" => "value2",
35
+ "property3" => "value3"
36
+ }
37
+
38
+ @@CHILDREN_1 = [
39
+ "child 1",
40
+ "child 2",
41
+ "child 3"
42
+ ]
43
+
44
+ @@HASH_2 = {
45
+ "property1" => "value1",
46
+ "property2" => "value2",
47
+ "property3" => "value3",
48
+ "children" => @@CHILDREN_1
49
+ }
50
+
51
+ @@SCALAR_1 = "child 1"
52
+
53
+ @@CHILDREN_2 = [ @@SCALAR_1 ]
54
+
55
+ @@LIST_1 = @@CHILDREN_1
56
+
57
+ #-----------------------------------------------------------------------------
58
+ #
59
+ # Set up, tear down
60
+ #
61
+ #-----------------------------------------------------------------------------
62
+
63
+ #------------------------------
64
+ # before(:all)
65
+ #------------------------------
66
+
67
+ before(:all) do
68
+ @instance_parser = InstanceParser.new
69
+ end
70
+
71
+ #-----------------------------------------------------------------------------
72
+ #
73
+ # Tests
74
+ #
75
+ #-----------------------------------------------------------------------------
76
+
77
+
78
+ it "should interpret a hash as properties" do
79
+
80
+ comp = @instance_parser.parse_yaml( @@HASH_1 )
81
+ comp.properties.should == @@HASH_1
82
+
83
+ end
84
+
85
+
86
+ it "should interpret a 'children' property as children" do
87
+
88
+ comp = @instance_parser.parse_yaml( @@HASH_2 )
89
+
90
+ comp.children.should == @@CHILDREN_1
91
+ comp.properties.should == @@HASH_1
92
+
93
+ end
94
+
95
+
96
+ it "should interpret a list as children" do
97
+
98
+ comp = @instance_parser.parse_yaml( @@LIST_1 )
99
+
100
+ comp.properties.should == {}
101
+ comp.children.should == @@CHILDREN_1
102
+
103
+ end
104
+
105
+
106
+ it "should interpret a scalar as a single child" do
107
+
108
+ comp = @instance_parser.parse_yaml( @@SCALAR_1 )
109
+
110
+ comp.children.should == @@CHILDREN_2
111
+ comp.properties.should == {}
112
+
113
+ end
114
+
115
+
116
+ it "should interpret nil as a blank component" do
117
+
118
+ comp = @instance_parser.parse_yaml( nil )
119
+
120
+ comp.properties.should == {}
121
+ comp.children.should == []
122
+
123
+ end
124
+
125
+ end
@@ -0,0 +1,54 @@
1
+ ################################################################################
2
+ # (C) Copyright 2009 William Madden
3
+ #
4
+ # This file is part of Proteus.
5
+ #
6
+ # Proteus is free software: you can redistribute it and/or modify it under the
7
+ # terms of the GNU General Public License as published by the Free Software
8
+ # Foundation, either version 3 of the License, or (at your option) any later
9
+ # version.
10
+ #
11
+ # Proteus is distributed in the hope that it will be useful, but WITHOUT ANY
12
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # Proteus. If not, see <http://www.gnu.org/licenses/>.
17
+ ################################################################################
18
+
19
+ require File.expand_path( 'lib/TemplateRenderer.rb' )
20
+
21
+ include Proteus
22
+
23
+
24
+ describe TemplateRenderer do
25
+
26
+ #-----------------------------------------------------------------------------
27
+ #
28
+ # Input Constants
29
+ #
30
+ #-----------------------------------------------------------------------------
31
+
32
+ #-----------------------------------------------------------------------------
33
+ #
34
+ # Set up, tear down
35
+ #
36
+ #-----------------------------------------------------------------------------
37
+
38
+ #-----------------------------------------------------------------------------
39
+ #
40
+ # Tests
41
+ #
42
+ #-----------------------------------------------------------------------------
43
+
44
+ it "should render components by parsing the template property using ERB"
45
+
46
+ it "should render component templates in the scope of the component instance"
47
+
48
+ it "should render scalars by calling their to_s method"
49
+
50
+ it "should render arrays by concatenating their rendered elements"
51
+
52
+ it "should render hashes by rendering their values, then calling the hash's to_s method"
53
+
54
+ end
@@ -0,0 +1,4 @@
1
+ TestComponent10 < TestComponent9:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ SomeComponent:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent4:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent5:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent8 < TestComponent8:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent9 < TestComponent10:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent6:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent1:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
@@ -0,0 +1,4 @@
1
+ TestComponent3:
2
+ prop1: value1
3
+ prop2: value2
4
+ prop3: value3
File without changes
File without changes
File without changes
File without changes
File without changes
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proteus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - William Madden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-20 00:00:00 +10:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Proteus is an abstraction of general document definition and display markup that allows you to create and reuse complex patterns of structured content.
17
+ email: w.a.madden@gmail.com
18
+ executables:
19
+ - pro
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/TemplateRenderer.rb
26
+ - lib/ClassParser.rb
27
+ - lib/DefinitionParser.rb
28
+ - lib/ComponentInstance.rb
29
+ - lib/InstanceProxy.rb
30
+ - lib/ComponentClass.rb
31
+ - lib/FileHelper.rb
32
+ - lib/DefinitionHelper.rb
33
+ - lib/PropertyHash.rb
34
+ - lib/InstanceParser.rb
35
+ - lib/exceptions.rb
36
+ - lib/InputParser.rb
37
+ - lib/Facade.rb
38
+ - bin/pro
39
+ - Rakefile
40
+ - README
41
+ - COPYING
42
+ - test/spec
43
+ - test/spec/Facade_spec.rb
44
+ - test/spec/test_lib_dir2
45
+ - test/spec/test_lib_dir2/File1.def
46
+ - test/spec/test_lib_dir2/File2.def
47
+ - test/spec/DefinitionHelper_spec.rb
48
+ - test/spec/DefinitionParser_spec.rb
49
+ - test/spec/lib
50
+ - test/spec/lib/TestComponent3.def
51
+ - test/spec/lib/TestComponent1.def
52
+ - test/spec/lib/NS2
53
+ - test/spec/lib/NS2/TestComponent6.def
54
+ - test/spec/lib/NS1
55
+ - test/spec/lib/NS1/TestComponent10.def
56
+ - test/spec/lib/NS1/TestComponent5.def
57
+ - test/spec/lib/NS1/TestComponent11.def
58
+ - test/spec/lib/NS1/TestComponent4.def
59
+ - test/spec/lib/NS1/TestComponent9.def
60
+ - test/spec/lib/NS1/TestComponent8.def
61
+ - test/spec/FileHelper_spec.rb
62
+ - test/spec/ClassParser_spec.rb
63
+ - test/spec/InstanceParser_spec.rb
64
+ - test/spec/ComponentClass_spec.rb
65
+ - test/spec/test_lib_dir1
66
+ - test/spec/test_lib_dir1/File1.def
67
+ - test/spec/test_lib_dir1/NS1
68
+ - test/spec/test_lib_dir1/NS1/NS2
69
+ - test/spec/test_lib_dir1/NS1/NS2/File5.def
70
+ - test/spec/test_lib_dir1/NS1/File4.def
71
+ - test/spec/test_lib_dir1/File3.def
72
+ - test/spec/InputParser_spec.rb
73
+ - test/spec/ComponentInstance_spec.rb
74
+ - test/spec/TemplateRenderer_spec.rb
75
+ has_rdoc: true
76
+ homepage: http://proteus.rubyforge.org
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --title
80
+ - Proteus
81
+ - --line-numbers
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project: proteus
99
+ rubygems_version: 1.3.1
100
+ signing_key:
101
+ specification_version: 2
102
+ summary: Tool for generating structured text documents from abstract markup.
103
+ test_files:
104
+ - test/spec/Facade_spec.rb
105
+ - test/spec/DefinitionHelper_spec.rb
106
+ - test/spec/DefinitionParser_spec.rb
107
+ - test/spec/FileHelper_spec.rb
108
+ - test/spec/ClassParser_spec.rb
109
+ - test/spec/InstanceParser_spec.rb
110
+ - test/spec/ComponentClass_spec.rb
111
+ - test/spec/InputParser_spec.rb
112
+ - test/spec/ComponentInstance_spec.rb
113
+ - test/spec/TemplateRenderer_spec.rb