cauldron 0.1.2 → 0.1.3

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.
Files changed (132) hide show
  1. data/Gemfile +6 -0
  2. data/Gemfile.lock +63 -0
  3. data/History.md +5 -0
  4. data/Rakefile +62 -16
  5. data/VERSION +1 -1
  6. data/cauldron.gemspec +463 -0
  7. data/cauldron/lib/cauldron.rb +1 -1
  8. data/features/cauldron_generates_runtime_method.feature +7 -4
  9. data/features/cauldron_generates_single_paramter_methods.feature +25 -0
  10. data/features/cauldron_interactive_start_terminal.feature +17 -0
  11. data/features/cauldron_quit_terminal.feature +9 -0
  12. data/features/cauldron_start_terminal.feature +0 -1
  13. data/features/step_definitions/cauldron_steps.rb +10 -5
  14. data/features/step_definitions/terminal_steps.rb +27 -0
  15. data/features/support/env.rb +2 -0
  16. data/features/support/hooks.rb +15 -0
  17. data/lib/Chain.rb +3 -3
  18. data/lib/Mapping.rb +1 -0
  19. data/lib/PartialChain.rb +253 -0
  20. data/lib/Theory.rb +28 -4
  21. data/lib/UnifiedChain.rb +94 -125
  22. data/lib/cauldron.rb +3 -0
  23. data/lib/cauldron/demos.rb +4 -4
  24. data/lib/cauldron/env.rb +1 -0
  25. data/lib/cauldron/pot.rb +42 -38
  26. data/lib/cauldron/terminal.rb +19 -3
  27. data/lib/cauldron/util/home.rb +21 -0
  28. data/lib/cauldron/util/saver.rb +45 -0
  29. data/lib/core/Container.rb +1 -1
  30. data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +28 -28
  31. data/lib/core/runtime_method/RuntimeMethod.rb +6 -23
  32. data/lib/core/statement/ActsAsStatement.rb +0 -96
  33. data/lib/core/statement/BlockStatement.rb +1 -1
  34. data/lib/core/statement/OpenStatement.rb +1 -1
  35. data/lib/core/statement/Statement.rb +39 -94
  36. data/lib/core/statement/TheoryStatement.rb +1 -1
  37. data/lib/core/syntax/BlockContainer.rb +0 -28
  38. data/lib/core/variable/MethodParameter.rb +1 -1
  39. data/lib/required.rb +2 -14
  40. data/lib/theories.rb +0 -1
  41. data/lib/theory/ActionImplementation.rb +1 -1
  42. data/lib/theory/TheoryAction.rb +2 -2
  43. data/lib/theory/TheoryConnector.rb +11 -14
  44. data/lib/theory/TheoryImplementation.rb +10 -9
  45. data/lib/util/MethodWriter.rb +10 -10
  46. data/sandbox.rb +23 -0
  47. data/spec/cauldron/pot_spec.rb +62 -10
  48. data/spec/cauldron/runtime_method_spec.rb +31 -17
  49. data/spec/cauldron/saver_spec.rb +45 -0
  50. data/spec/cauldron/terminal_spec.rb +10 -1
  51. data/spec/cauldron/theory_spec.rb +4 -4
  52. data/spec/cauldron/unified_chain_spec.rb +38 -0
  53. data/spec/spec_helper.rb +3 -1
  54. data/tasks/development_tasks.rake +4 -0
  55. data/tasks/theory_tasks.rake +16 -20
  56. data/test/fixtures/theories/0/desc +6 -6
  57. data/test/fixtures/theories/0/dump +0 -0
  58. data/test/fixtures/theories/1/desc +7 -7
  59. data/test/fixtures/theories/1/dump +0 -0
  60. data/test/fixtures/theories/10/desc +13 -13
  61. data/test/fixtures/theories/10/dump +0 -0
  62. data/test/fixtures/theories/11/desc +10 -10
  63. data/test/fixtures/theories/11/dump +0 -0
  64. data/test/fixtures/theories/12/desc +9 -9
  65. data/test/fixtures/theories/12/dump +0 -0
  66. data/test/fixtures/theories/13/desc +16 -16
  67. data/test/fixtures/theories/13/dump +0 -0
  68. data/test/fixtures/theories/14/desc +16 -16
  69. data/test/fixtures/theories/14/dump +0 -0
  70. data/test/fixtures/theories/15/desc +10 -10
  71. data/test/fixtures/theories/15/dump +0 -0
  72. data/test/fixtures/theories/16/desc +10 -10
  73. data/test/fixtures/theories/16/dump +0 -0
  74. data/test/fixtures/theories/17/desc +7 -7
  75. data/test/fixtures/theories/17/dump +0 -0
  76. data/test/fixtures/theories/18/desc +7 -7
  77. data/test/fixtures/theories/18/dump +0 -0
  78. data/test/fixtures/theories/19/desc +7 -7
  79. data/test/fixtures/theories/19/dump +0 -0
  80. data/test/fixtures/theories/2/desc +6 -6
  81. data/test/fixtures/theories/2/dump +0 -0
  82. data/test/fixtures/theories/20/desc +13 -13
  83. data/test/fixtures/theories/20/dump +0 -0
  84. data/test/fixtures/theories/3/desc +7 -7
  85. data/test/fixtures/theories/3/dump +0 -0
  86. data/test/fixtures/theories/4/desc +7 -7
  87. data/test/fixtures/theories/4/dump +0 -0
  88. data/test/fixtures/theories/5/desc +6 -6
  89. data/test/fixtures/theories/5/dump +0 -0
  90. data/test/fixtures/theories/6/desc +7 -7
  91. data/test/fixtures/theories/6/dump +0 -0
  92. data/test/fixtures/theories/7/desc +7 -7
  93. data/test/fixtures/theories/7/dump +0 -0
  94. data/test/fixtures/theories/8/desc +7 -7
  95. data/test/fixtures/theories/8/dump +0 -0
  96. data/test/fixtures/theories/9/desc +16 -16
  97. data/test/fixtures/theories/9/dump +0 -0
  98. data/test/fixtures/theory_implementations/0/dump +0 -0
  99. data/test/fixtures/theory_implementations/2/dump +0 -0
  100. data/test/ts_complete.rb +1 -10
  101. data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +1 -0
  102. data/test/unit/core/runtime_method/tc_runtime_method.rb +16 -39
  103. data/test/unit/core/statement/tc_block_statement.rb +3 -3
  104. data/test/unit/core/statement/tc_open_statement.rb +4 -4
  105. data/test/unit/core/statement/tc_statement.rb +2 -147
  106. data/test/unit/core/statement/tc_theory_statement.rb +1 -1
  107. data/test/unit/theory/tc_theory_dependent.rb +3 -3
  108. data/test/unit/theory/tc_theory_result.rb +5 -5
  109. data/test/unit/util/tc_method_validation.rb +45 -45
  110. data/test/unit/util/tc_parser.rb +1 -1
  111. data/test/unit/util/tc_string_to_theory.rb +2 -2
  112. metadata +74 -48
  113. data/lib/ScopeDependencies.rb +0 -8
  114. data/lib/core/statement/StatementDependencies.rb +0 -271
  115. data/lib/core/structure/DeclareNewInstanceStructure.rb +0 -49
  116. data/lib/core/structure/DeclareRuntimeMethodStructure.rb +0 -34
  117. data/lib/core/structure/DeclareVariableAsLiteralStructure.rb +0 -31
  118. data/lib/core/structure/DeclareVariableAsVariableStructure.rb +0 -52
  119. data/lib/core/structure/FixnumAdditionStructure.rb +0 -56
  120. data/lib/core/structure/InstanceCallContainerStructure.rb +0 -50
  121. data/lib/core/structure/InstanceCallStructure.rb +0 -53
  122. data/lib/core/structure/InstanceMethodCallStructure.rb +0 -21
  123. data/lib/core/structure/ReturnStructure.rb +0 -20
  124. data/lib/core/structure/StatementStructure.rb +0 -11
  125. data/test/unit/core/statement/tc_statement_dependencies.rb +0 -147
  126. data/test/unit/core/structure/tc_declare_new_instance_structure.rb +0 -41
  127. data/test/unit/core/structure/tc_declare_variable_as_literal_structure.rb +0 -41
  128. data/test/unit/core/structure/tc_declare_variable_as_variable_structure.rb +0 -66
  129. data/test/unit/core/structure/tc_instance_call_container_structure.rb +0 -41
  130. data/test/unit/core/structure/tc_return_structure.rb +0 -32
  131. data/test/unit/tc_instance_call_structure.rb +0 -35
  132. data/test/unit/tc_statement_structure_2.rb +0 -43
@@ -10,12 +10,12 @@ class MethodWriter
10
10
  def write(params,statements,tab=0,method_id=0,additional_comments='')
11
11
 
12
12
  line = "\n"
13
- tab.times {|x| line += "\t" }
13
+ tab.times {|x| line += " " }
14
14
  line += "#\n"
15
15
 
16
16
  params.each_with_index do |var,i|
17
- tab.times {|x| line += "\t" }
18
- line += "#\t@param\t"
17
+ tab.times {|x| line += " " }
18
+ line += "# @param "
19
19
 
20
20
  # Get a description of the requirements (this can multiple lines)
21
21
  line_prefix = ''
@@ -25,8 +25,8 @@ class MethodWriter
25
25
  line += line_prefix+l
26
26
 
27
27
  # Assides the first line pre-fix a "# " to the start
28
- (tab-1).times {|x| line += "\t" }
29
- line_prefix = "#\t\t\t"
28
+ (tab-1).times {|x| line += " " }
29
+ line_prefix = "# "
30
30
 
31
31
  end
32
32
 
@@ -34,16 +34,16 @@ class MethodWriter
34
34
 
35
35
  # Add some some additional comment if supplied
36
36
  unless additional_comments.nil?
37
- tab.times {|x| line += "\t" }
37
+ tab.times {|x| line += " " }
38
38
  line += "#"
39
- tab.times {|x| line += "\t" }
39
+ tab.times {|x| line += " " }
40
40
  line += additional_comments+"\n"
41
41
  end
42
42
 
43
- tab.times {|x| line += "\t" }
43
+ tab.times {|x| line += " " }
44
44
  line += "#\n"
45
45
 
46
- tab.times {|x| line += "\t"}
46
+ tab.times {|x| line += " "}
47
47
  line += 'def method_'+method_id.to_s
48
48
 
49
49
  #line += write_params(@parameters)
@@ -57,7 +57,7 @@ class MethodWriter
57
57
  line += "\n" if statements.empty?
58
58
 
59
59
  # Close the method
60
- tab.times {|x| line += "\t" }
60
+ tab.times {|x| line += " " }
61
61
  line += "end"+"\n"
62
62
 
63
63
  return line
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib',__FILE__)
2
+
3
+ require 'cauldron'
4
+
5
+ # unified_chain = Cauldron::Util::Saver.load(1)
6
+ #
7
+ # puts unified_chain.describe
8
+ # puts unified_chain.complete?
9
+ #
10
+ # puts 'Working'
11
+
12
+
13
+ unified_chain = Cauldron::Util::Saver.load(33)
14
+ runtime_method = Cauldron::Util::Saver.load(31)
15
+ test_cases = Cauldron::Util::Saver.load(32)
16
+
17
+ puts unified_chain.describe
18
+
19
+
20
+ #unified_chain.valid_mapping_permutations(runtime_method,test_cases)
21
+
22
+
23
+
@@ -5,21 +5,19 @@ module Cauldron
5
5
  describe 'Pot' do
6
6
 
7
7
  describe '#simmer' do
8
+ before(:each) {
9
+ @pot = Cauldron::Pot.new
10
+ @pot.clear
11
+ }
8
12
  it 'can simmer with demo one' do
9
- pot = Cauldron::Pot.new
10
- pot.clear
11
- lambda {pot.simmer(demo_one)}.should_not raise_error
13
+ lambda {@pot.simmer(demo_one)}.should_not raise_error
12
14
  end
13
15
  it 'can simmer with demo two' do
14
- pot = Cauldron::Pot.new
15
- pot.clear
16
- lambda {pot.simmer(demo_two)}.should_not raise_error
16
+ lambda {@pot.simmer(demo_two)}.should_not raise_error
17
17
  end
18
18
  it 'can simmer with both demo one and two' do
19
- pot = Cauldron::Pot.new
20
- pot.clear
21
- lambda {pot.simmer(demo_one)}.should_not raise_error
22
- lambda {pot.simmer(demo_two)}.should_not raise_error
19
+ lambda {@pot.simmer(demo_one)}.should_not raise_error
20
+ lambda {@pot.simmer(demo_two)}.should_not raise_error
23
21
  end
24
22
  end
25
23
 
@@ -86,6 +84,24 @@ module Cauldron
86
84
  sexp2cauldron = Sexp2Cauldron.new
87
85
  @pot.brew(cases).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
88
86
  end
87
+ it 'can repeatedly generate a demo 1 solution' do
88
+ case_set_one = []
89
+ case_set_one << convert_to_example(separate_values("'pip','pip'"))
90
+ case_set_one << convert_to_example(separate_values("'rowiage','rowiage'"))
91
+
92
+ case_set_two = []
93
+ case_set_two << convert_to_example(separate_values("'andy','andy'"))
94
+ case_set_two << convert_to_example(separate_values("'kel','kel'"))
95
+
96
+ ruby = "
97
+ def method_0(var_0)
98
+ \treturn var_0
99
+ end
100
+ "
101
+ sexp2cauldron = Sexp2Cauldron.new
102
+ @pot.brew(case_set_one).reset_ids!.basic_write.should == sexp2cauldron.process(RubyParser.new.process(ruby)).basic_write
103
+ @pot.brew(case_set_two).reset_ids!.basic_write.should == sexp2cauldron.process(RubyParser.new.process(ruby)).basic_write
104
+ end
89
105
  it 'can generate a solution like demo 2(it needs to discount the demo 1 solution)' do
90
106
  cases = []
91
107
  cases << convert_to_example(separate_values("'sparky','bro'"))
@@ -103,6 +119,42 @@ module Cauldron
103
119
  sexp2cauldron = Sexp2Cauldron.new
104
120
  @pot.brew(cases).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
105
121
  end
122
+ it 'can repeatedly generate a demo 2 solution' do
123
+ case_set_one = []
124
+ case_set_one << convert_to_example(separate_values("'sparky','bro'"))
125
+ case_set_one << convert_to_example(separate_values("'kel','sis'"))
126
+
127
+ ruby = "
128
+ def method_0(var_0)
129
+ \tif(var_0 == 'sparky')
130
+ \t\treturn 'bro'
131
+ \tend
132
+ \treturn 'sis'
133
+ end
134
+ "
135
+ parser = RubyParser.new
136
+ sexp = parser.process(ruby)
137
+ sexp2cauldron = Sexp2Cauldron.new
138
+ @pot.brew(case_set_one).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
139
+
140
+ case_set_two = []
141
+ case_set_two << convert_to_example(separate_values("'carrot','vegtable'"))
142
+ case_set_two << convert_to_example(separate_values("'apple','fruit'"))
143
+
144
+ ruby = "
145
+ def method_0(var_0)
146
+ \tif(var_0 == 'carrot')
147
+ \t\treturn 'vegtable'
148
+ \tend
149
+ \treturn 'fruit'
150
+ end
151
+ "
152
+ parser = RubyParser.new
153
+ sexp = parser.process(ruby)
154
+ sexp2cauldron = Sexp2Cauldron.new
155
+ @pot.brew(case_set_two).reset_ids!.basic_write.should == sexp2cauldron.process(sexp).basic_write
156
+
157
+ end
106
158
  end
107
159
 
108
160
  end
@@ -23,7 +23,7 @@ module Cauldron
23
23
  method_param = MethodParameter.new
24
24
  temporary_runtime_method = RuntimeMethod.new(MethodUsage.new(method_param))
25
25
  temporary_runtime_method << Statement.new(Return.new,method_param)
26
- temporary_runtime_method.reset_ids!.basic_write.should == "def method_0(var_0)\n\treturn var_0\nend\n"
26
+ temporary_runtime_method.reset_ids!.basic_write.should == "def method_0(var_0)\n return var_0\nend\n"
27
27
  end
28
28
  end
29
29
 
@@ -43,16 +43,16 @@ module Cauldron
43
43
  end
44
44
  end
45
45
  context 'using runtime method with if statement' do
46
- it 'it should reset all the ids to 0 and count up' do
46
+ it 'should reset all the ids to 0 and count up' do
47
47
  parser = RubyParser.new
48
- ruby = "
48
+ ruby = %q{
49
49
  def method_3(var_8)
50
- \tif(var_8 == 'apple')
51
- \t\treturn 'fruit'
52
- \tend
53
- \treturn 'vegetable'
50
+ if(var_8 == 'apple')
51
+ return 'fruit'
52
+ end
53
+ return 'vegetable'
54
54
  end
55
- "
55
+ }
56
56
  sexp = parser.process(ruby)
57
57
  sexp2cauldron = Sexp2Cauldron.new
58
58
  unprocessed_runtime_method = sexp2cauldron.process(sexp)
@@ -60,18 +60,32 @@ module Cauldron
60
60
  reset_runtime_method.method_id.should == '0'
61
61
  reset_runtime_method.variables.length.should == 1
62
62
 
63
- ruby_reset = "
64
- def method_0(var_0)
65
- \tif(var_0 == 'apple')
66
- \t\treturn 'fruit'
67
- \tend
68
- \treturn 'vegetable'
69
- end
70
- "
71
- reset_runtime_method.basic_write.should == strip_whitespace(ruby_reset)+"\n"
63
+ ruby_reset =
64
+ %q{def method_0(var_0)
65
+ if(var_0 == 'apple')
66
+ return 'fruit'
67
+ end
68
+ return 'vegetable'
69
+ end}
70
+ reset_runtime_method.basic_write.should == ruby_reset+"\n"
72
71
  end
73
72
  end
74
73
  end
74
+
75
+ describe '#realise2' do
76
+ it 'should be able to realise a very simple runtime method' do
77
+ parser = RubyParser.new
78
+ ruby = "
79
+ def method_3
80
+ var_13 = 8
81
+ end
82
+ "
83
+ sexp = parser.process(ruby)
84
+ sexp2cauldron = Sexp2Cauldron.new
85
+ runtime_method = sexp2cauldron.process(sexp)
86
+ runtime_method.realise2(ParametersContainer.new).class.should == RealisedRuntimeMethod
87
+ end
88
+ end
75
89
 
76
90
  end
77
91
 
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ module Cauldron
4
+
5
+ module Util
6
+
7
+ describe Saver do
8
+
9
+ describe '.save' do
10
+ it 'can save a string object without raising an exception' do
11
+ lambda {Cauldron::Util::Saver.save('geth')}.should_not raise_error
12
+ end
13
+ it 'will return the path to saved string object after saving it' do
14
+ Cauldron::Util::Saver.save('Normandy').should match(/cauldron\/debug/)
15
+ end
16
+ end
17
+
18
+ describe '.debug_directory' do
19
+ it 'should return the path to the debug directory' do
20
+ Cauldron::Util::Saver.debug_directory.should include("/cauldron/debug")
21
+ end
22
+ end
23
+
24
+ describe '.next_directory' do
25
+ it "should return the path to a directory that doesn't exist" do
26
+ Cauldron::Util::Saver.next_directory.should match(/cauldron\/debug\/\d+/)
27
+ end
28
+ it 'should not return the path to an existing directory' do
29
+ File.exists?(Cauldron::Util::Saver.next_directory).should_not == true
30
+ end
31
+ end
32
+
33
+ describe '.load' do
34
+ it 'can load a saved obj' do
35
+ path = Cauldron::Util::Saver.save('Adele & Kirk')
36
+ path_id = path.match(/(\d+)/)[0].to_i
37
+ Cauldron::Util::Saver.load(path_id).should == 'Adele & Kirk'
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -30,7 +30,16 @@ module Cauldron
30
30
  end
31
31
  its([0]) { should eq({:output=>"sparky", :params=>["sparky"]}) }
32
32
  its([1]) { should eq({:output=>"kel", :params=>["kel"]}) }
33
- end
33
+ end
34
+ context 'with example case "sparky", "sparky"' do
35
+ subject do
36
+ terminal.submit '"sparky","sparky"'
37
+ terminal.submit '"kel","kel"'
38
+ terminal.cases
39
+ end
40
+ its([0]) { should eq({:output=>"sparky", :params=>["sparky"]}) }
41
+ its([1]) { should eq({:output=>"kel", :params=>["kel"]}) }
42
+ end
34
43
  end
35
44
 
36
45
  end
@@ -24,11 +24,11 @@ module Cauldron
24
24
  if:
25
25
 
26
26
  action:
27
- \truntime_method.add_statement_at(Statement.new(Return.new, test_cases.params[0]),runtime_method.statement_id)
27
+ runtime_method.add_statement_at(Statement.new(Return.new, test_cases.params[0]),runtime_method.statement_id)
28
28
  result:
29
- \tif(runtime_method.all_pass?(test_cases))
30
- \t\treturn true
31
- \tend
29
+ if(runtime_method.all_pass?(test_cases))
30
+ return true
31
+ end
32
32
  "
33
33
  theory.map_to(mapping).write.strip.should == result.strip
34
34
 
@@ -95,6 +95,44 @@ module Cauldron
95
95
  end
96
96
  end
97
97
 
98
+ describe '#partial_chain' do
99
+ before(:each) {
100
+ temp = Object.new
101
+ temp.extend(Cauldron::Demos)
102
+ demo = temp.demo_one
103
+ @unified_chain = demo[:chain].unify_chain
104
+ }
105
+ it 'should return a chain of length 1 when passed the range 0..0' do
106
+ @unified_chain.partial_chain(0..0).length.should == 1
107
+ end
108
+
109
+ end
110
+
111
+ describe '#complete?' do
112
+ context 'when using demo 1' do
113
+ before(:each) {
114
+ temp = Object.new
115
+ temp.extend(Cauldron::Demos)
116
+ demo = temp.demo_one
117
+ @unified_chain = demo[:chain].unify_chain
118
+ }
119
+ it 'should be a complete chain' do
120
+ @unified_chain.complete?.should == true
121
+ end
122
+ end
123
+ context 'when using demo 2' do
124
+ before(:each){
125
+ temp = Object.new
126
+ temp.extend(Cauldron::Demos)
127
+ demo = temp.demo_two
128
+ @unified_chain = demo[:chain].unify_chain
129
+ }
130
+ it 'should be a complete chain' do
131
+ @unified_chain.complete?.should == true
132
+ end
133
+ end
134
+ end
135
+
98
136
  end
99
137
 
100
138
  end
@@ -6,7 +6,9 @@ require 'required'
6
6
  def strip_whitespace(ruby_code)
7
7
  #res = ruby_code.strip.gsub(/\t{1,}/,'\t').gsub(/\s{2,}/,'\n')
8
8
  res = ruby_code.strip.gsub(/\t/,'\t').gsub(/\s{2,}/,'\n')
9
- return res.gsub('\t',"\t").gsub('\n',"\n")
9
+ #res = ruby_code.strip.gsub(/\s{2,}/,'\n')
10
+ #return res.gsub('\t',"\t").gsub('\n',"\n")
11
+ return res.gsub('\t'," ").gsub('\n',"\n")
10
12
  end
11
13
 
12
14
  include Cauldron::Demos
@@ -0,0 +1,4 @@
1
+ # => Need to create the cauldron-rspec.txt file first
2
+ # => rspec spec/ --format progress --format documentation -o ~/cauldron-rspec.txt
3
+
4
+ # => rspec spec/ --format progress --format documentation -o ~/cauldron-rspec.txt --format html -o ~/cauldron-report.html
@@ -1,27 +1,27 @@
1
1
  # http://rake.rubyforge.org/
2
2
  # http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
3
3
 
4
- # TODO Need a test for the rake tasks as well
5
-
6
4
  namespace :cauldren do
7
5
 
8
6
  namespace :implementations do
9
7
 
10
- desc "Re-build the theory implementations"
11
- task :rebuild do
12
-
8
+ desc 'Rebuild the implementations'
9
+ task :rebuild do
10
+ Rake::Task["cauldren:theories:rebuild"].execute
11
+
13
12
  file_list = FileList.new('test/fixtures/theory_implementations/*')
14
- file_list.each do |x|
15
- implementation_id = x.match(/\d+$/)[0].to_i
16
-
17
- directory_path = $LOC+File.join('test','fixtures','theories',theory_id.to_s)
13
+ file_list.each do |folder_path|
14
+
15
+ implementation_id = folder_path.match(/\d+$/)[0].to_i
16
+ declaration = File.open(File.join(folder_path,'declaration.txt'),'r').read
17
+ theory_implementation = eval declaration
18
18
 
19
- end
20
-
21
- # TODO The current approach to saving the implementations - I'd like to be able
22
- # to right the declarations to file.
23
-
24
- puts 'Does not do anything'
19
+ dump_file = File.open(File.join(folder_path,'dump'),'w')
20
+ data = Marshal.dump(theory_implementation)
21
+ dump_file << data
22
+ dump_file.close
23
+
24
+ end
25
25
 
26
26
  end
27
27
 
@@ -242,10 +242,7 @@ namespace :cauldren do
242
242
  file_list = FileList.new('test/fixtures/theories/*')
243
243
  file_list.each do |x|
244
244
  theory_id = x.match(/\d+$/)[0].to_i
245
- puts '* theory_id: '+theory_id.to_s
246
- puts File.join('test','fixtures','theories',theory_id.to_s)
247
245
  directory_path = File.join('test','fixtures','theories',theory_id.to_s)
248
- puts directory_path
249
246
  declaration = File.open(File.join(directory_path,'declaration.txt'),'r').read
250
247
 
251
248
  # Save the declaration (incase the theory needs modified
@@ -256,9 +253,8 @@ namespace :cauldren do
256
253
  theory = eval declaration
257
254
  data = Marshal.dump(theory)
258
255
 
259
- # TODO Shouldn't include colours for this description
260
256
  desc_file = File.open(File.join(directory_path,'desc'),'w+')
261
- desc_file << theory.describe
257
+ desc_file << theory.write
262
258
  desc_file.close
263
259
 
264
260
  dump_file = File.open(File.join(directory_path,'dump'),'w+')