cauldron 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rspec +1 -0
  4. data/Gemfile +16 -9
  5. data/Gemfile.lock +134 -64
  6. data/README.md +26 -0
  7. data/Rakefile +24 -99
  8. data/build_sandbox.rb +41 -0
  9. data/cucumber.yml +8 -0
  10. data/features/chop.feature +23 -0
  11. data/features/create_dynamic_statements.feature +14 -0
  12. data/features/generate_known_solution.feature +42 -0
  13. data/features/generate_new_statement.feature +20 -0
  14. data/features/step_definitions/cauldron_steps.rb +47 -0
  15. data/features/support/env.rb +1 -1
  16. data/features/use_existing_statements.feature +23 -0
  17. data/lib/cauldron.rb +41 -5
  18. data/lib/cauldron/actualized_composite.rb +35 -0
  19. data/lib/cauldron/array_collect_template/default.rb +95 -0
  20. data/lib/cauldron/array_collect_template/template.rb +57 -0
  21. data/lib/cauldron/builder.rb +60 -0
  22. data/lib/cauldron/caret.rb +50 -0
  23. data/lib/cauldron/dynamic_operator.rb +90 -0
  24. data/lib/cauldron/dynamic_operator_module.rb +140 -0
  25. data/lib/cauldron/example.rb +18 -0
  26. data/lib/cauldron/example_set.rb +36 -0
  27. data/lib/cauldron/histories.rb +53 -0
  28. data/lib/cauldron/history.rb +34 -0
  29. data/lib/cauldron/if_relationship.rb +4 -6
  30. data/lib/cauldron/number_addition_template/add_five.rb +71 -0
  31. data/lib/cauldron/number_addition_template/template.rb +56 -0
  32. data/lib/cauldron/operator.rb +62 -0
  33. data/lib/cauldron/operator/array_reverse_operator.rb +160 -0
  34. data/lib/cauldron/operator/concat_operator.rb +72 -0
  35. data/lib/cauldron/operator/hash_key_value_operator.rb +74 -0
  36. data/lib/cauldron/operator/numeric_operator.rb +115 -0
  37. data/lib/cauldron/operator/string_asterisk_operator.rb +131 -0
  38. data/lib/cauldron/operator/to_s_operator.rb +18 -0
  39. data/lib/cauldron/operator/var_collect_operator.rb +29 -0
  40. data/lib/cauldron/pot.rb +136 -26
  41. data/lib/cauldron/scope.rb +24 -0
  42. data/lib/cauldron/solution/composite.rb +236 -0
  43. data/lib/cauldron/solution/one.rb +49 -0
  44. data/lib/cauldron/statement_generator.rb +298 -0
  45. data/lib/cauldron/template_base.rb +14 -0
  46. data/lib/cauldron/tracer.rb +55 -0
  47. data/lib/cauldron/version.rb +1 -1
  48. data/lib/pry_tester.rb +76 -0
  49. data/ruby_to_sexp.rb +74 -0
  50. data/sandbox.rb +7 -0
  51. data/sexp_to_ruby.rb +150 -0
  52. data/spec/cauldron/actualized_composite_spec.rb +140 -0
  53. data/spec/cauldron/array_collect_template/default_spec.rb +41 -0
  54. data/spec/cauldron/builder_spec.rb +186 -0
  55. data/spec/cauldron/dynamic/add_number_template_spec.rb +30 -0
  56. data/spec/cauldron/dynamic_operator_spec.rb +416 -0
  57. data/spec/cauldron/example_set_spec.rb +49 -0
  58. data/spec/cauldron/example_spec.rb +33 -0
  59. data/spec/cauldron/histories_spec.rb +135 -0
  60. data/spec/cauldron/history_spec.rb +118 -0
  61. data/spec/cauldron/if_relationship_spec.rb +1 -1
  62. data/spec/cauldron/operator/array_reverse_operator_spec.rb +73 -0
  63. data/spec/cauldron/{concat_operator_spec.rb → operator/concat_operator_spec.rb} +30 -12
  64. data/spec/cauldron/operator/hash_key_value_operator_spec.rb +98 -0
  65. data/spec/cauldron/operator/numeric_operator_spec.rb +110 -0
  66. data/spec/cauldron/operator/string_asterisk_operator_spec.rb +196 -0
  67. data/spec/cauldron/operator/var_collect_operator_spec.rb +38 -0
  68. data/spec/cauldron/pot_spec.rb +176 -14
  69. data/spec/cauldron/solution/composite_spec.rb +421 -0
  70. data/spec/cauldron/solution/one_spec.rb +24 -0
  71. data/spec/cauldron/statement_generator_spec.rb +211 -0
  72. data/spec/cauldron/terminal_spec.rb +2 -2
  73. data/spec/spec_helper.rb +5 -1
  74. data/spec/support/code_matcher.rb +55 -0
  75. data/spec/support/include_instance_of_matcher.rb +9 -0
  76. data/spec/support/shared_examples_for_leaf_operators.rb +22 -0
  77. data/spec/support/shared_examples_for_operators.rb +23 -0
  78. data/syntax_spec.txt +2 -0
  79. metadata +104 -41
  80. data/README +0 -1
  81. data/README.rdoc +0 -19
  82. data/VERSION +0 -1
  83. data/features/cauldron_new_approach.feature +0 -46
  84. data/lib/cauldron/array_reverse_operator.rb +0 -39
  85. data/lib/cauldron/concat_operator.rb +0 -34
  86. data/lib/cauldron/numeric_operator.rb +0 -45
  87. data/lib/cauldron/relationship.rb +0 -5
  88. data/spec/cauldron/array_reverse_operator_spec.rb +0 -59
  89. data/spec/cauldron/numeric_operator_spec.rb +0 -70
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  module Cauldron
4
4
 
5
- describe 'Terminal' do
5
+ describe 'Terminal' do
6
6
 
7
7
  end
8
8
 
9
- end
9
+ end
@@ -1,2 +1,6 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'cauldron'
2
- require 'pry'
4
+ require 'pry'
5
+
6
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
@@ -0,0 +1,55 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :match_code_of do |expected|
4
+ match do |actual|
5
+ #actual % expected == 0
6
+ Sorcerer.source(actual, indent: true).strip == Sorcerer.source(Ripper::SexpBuilder.new(expected).parse, indent: true).strip
7
+ end
8
+ failure_message_for_should do |actual|
9
+ "expected that '#{Sorcerer.source(actual, indent: true).strip}' to be '#{Sorcerer.source(Ripper::SexpBuilder.new(expected).parse, indent: true).strip}'"
10
+ end
11
+ end
12
+
13
+ RSpec::Matchers.define :include_statement do |expected|
14
+ match do |actual|
15
+ #actual % expected == 0
16
+ #Sorcerer.source(actual, indent: true).strip == Sorcerer.source(Ripper::SexpBuilder.new(expected).parse, indent: true).strip
17
+ actual.any? { |x| x.new([0]).to_desc == expected }
18
+ end
19
+ failure_message_for_should do |actual|
20
+ "expected that '#{actual.collect { |x| x.new([0]).to_desc }.join(',')}' to include '#{expected}'"
21
+ end
22
+ end
23
+
24
+ RSpec::Matchers.define :match_history do |expected|
25
+
26
+ lines = expected.split("\n").reject {|x| x.match(/^\s*$/) }
27
+ lines = lines.collect(&:strip)
28
+ lines = lines.collect { |line| line.gsub(/\|/,'') }
29
+
30
+ lines = lines.collect do |line|
31
+ eval(
32
+ Sorcerer.source(
33
+ Ripper::SexpBuilder.new(line).parse
34
+ )
35
+ )
36
+ end
37
+ match do |actual|
38
+ index = -1
39
+ actual.all? do |x|
40
+ index += 1
41
+ x == lines[index]
42
+ end
43
+ # next false unless actual.length == lines.length
44
+ # actual.each_with_index do |value,index|
45
+ # next false unless actual[index] == lines[index]
46
+ # end
47
+ # true
48
+ end
49
+
50
+ failure_message_for_should do |actual|
51
+ %Q{expected '#{expected}' == #{actual.inspect}}
52
+ end
53
+ #res = eval(Sorcerer.source(Ripper::SexpBuilder.new(%q{{line: 0, depth: 1, var0: ['lion', 'bear'], var1: 'lion'}}).parse))
54
+ #binding.pry
55
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :include_an_instance_of do |expected|
4
+ match do |actual|
5
+ #actual % expected == 0
6
+ #Sorcerer.source(actual, indent: false).strip == Sorcerer.source(Ripper::SexpBuilder.new(expected).parse, indent: false)
7
+ actual.any? { |x| x.kind_of?(expected) }
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ RSpec.shared_examples "leaf_operator" do
2
+
3
+ describe '#branch?' do
4
+
5
+ it 'is false' do
6
+ leaf_operator.branch?.should == false
7
+ end
8
+
9
+ end
10
+
11
+ describe '.uses_block?' do
12
+
13
+ it 'is false' do
14
+ leaf_operator.class.uses_block?.should == false
15
+ end
16
+
17
+ end
18
+
19
+ # it "is empty when first created" do
20
+ # expect(described_class.new).to be_empty
21
+ # end
22
+ end
@@ -0,0 +1,23 @@
1
+ RSpec.shared_examples "operator" do
2
+
3
+ describe '#to_ruby' do
4
+
5
+ it "doesn't raise an error" do
6
+ operator.to_sexp(initial_scope, initial_operators)
7
+ end
8
+ #to_sexp(scope, operators)
9
+ end
10
+
11
+ # describe '.respond_to?' do
12
+
13
+ # context 'passing "instances"' do
14
+
15
+ # it "doesn't raise an error" do
16
+ # operator.class.respond_to?(:instances).should == true
17
+ # end
18
+
19
+ # end
20
+
21
+ # end
22
+
23
+ end
@@ -0,0 +1,2 @@
1
+ var count is 1
2
+ var0 is Array
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cauldron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.1.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Warren Sangster
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-29 00:00:00.000000000 Z
11
+ date: 2019-08-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ruby2ruby
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.2.5
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.2.5
62
55
  description: Cauldron generates a methd from a number of examples that describe the
@@ -68,85 +61,155 @@ executables:
68
61
  extensions: []
69
62
  extra_rdoc_files: []
70
63
  files:
71
- - .document
72
- - .gitignore
64
+ - ".document"
65
+ - ".gitignore"
66
+ - ".rspec"
73
67
  - Gemfile
74
68
  - Gemfile.lock
75
69
  - History.md
76
70
  - LICENSE.txt
77
- - README
78
- - README.rdoc
71
+ - README.md
79
72
  - Rakefile
80
- - VERSION
81
73
  - bin/cauldron
74
+ - build_sandbox.rb
82
75
  - cauldron.gemspec
83
- - features/cauldron_new_approach.feature
76
+ - cucumber.yml
77
+ - features/chop.feature
78
+ - features/create_dynamic_statements.feature
79
+ - features/generate_known_solution.feature
80
+ - features/generate_new_statement.feature
84
81
  - features/step_definitions/cauldron_steps.rb
85
82
  - features/step_definitions/terminal_steps.rb
86
83
  - features/support/env.rb
87
84
  - features/support/hooks.rb
85
+ - features/use_existing_statements.feature
88
86
  - lib/cauldron.rb
89
- - lib/cauldron/array_reverse_operator.rb
90
- - lib/cauldron/concat_operator.rb
87
+ - lib/cauldron/actualized_composite.rb
88
+ - lib/cauldron/array_collect_template/default.rb
89
+ - lib/cauldron/array_collect_template/template.rb
90
+ - lib/cauldron/builder.rb
91
+ - lib/cauldron/caret.rb
92
+ - lib/cauldron/dynamic_operator.rb
93
+ - lib/cauldron/dynamic_operator_module.rb
94
+ - lib/cauldron/example.rb
95
+ - lib/cauldron/example_set.rb
96
+ - lib/cauldron/histories.rb
97
+ - lib/cauldron/history.rb
91
98
  - lib/cauldron/if_relationship.rb
92
- - lib/cauldron/numeric_operator.rb
99
+ - lib/cauldron/number_addition_template/add_five.rb
100
+ - lib/cauldron/number_addition_template/template.rb
101
+ - lib/cauldron/operator.rb
102
+ - lib/cauldron/operator/array_reverse_operator.rb
103
+ - lib/cauldron/operator/concat_operator.rb
104
+ - lib/cauldron/operator/hash_key_value_operator.rb
105
+ - lib/cauldron/operator/numeric_operator.rb
106
+ - lib/cauldron/operator/string_asterisk_operator.rb
107
+ - lib/cauldron/operator/to_s_operator.rb
108
+ - lib/cauldron/operator/var_collect_operator.rb
93
109
  - lib/cauldron/pot.rb
94
- - lib/cauldron/relationship.rb
110
+ - lib/cauldron/scope.rb
111
+ - lib/cauldron/solution/composite.rb
112
+ - lib/cauldron/solution/one.rb
113
+ - lib/cauldron/statement_generator.rb
114
+ - lib/cauldron/template_base.rb
95
115
  - lib/cauldron/terminal.rb
116
+ - lib/cauldron/tracer.rb
96
117
  - lib/cauldron/version.rb
97
118
  - lib/core/string.rb
119
+ - lib/pry_tester.rb
120
+ - ruby_to_sexp.rb
98
121
  - sandbox.rb
99
- - spec/cauldron/array_reverse_operator_spec.rb
100
- - spec/cauldron/concat_operator_spec.rb
122
+ - sexp_to_ruby.rb
123
+ - spec/cauldron/actualized_composite_spec.rb
124
+ - spec/cauldron/array_collect_template/default_spec.rb
125
+ - spec/cauldron/builder_spec.rb
126
+ - spec/cauldron/dynamic/add_number_template_spec.rb
127
+ - spec/cauldron/dynamic_operator_spec.rb
128
+ - spec/cauldron/example_set_spec.rb
129
+ - spec/cauldron/example_spec.rb
130
+ - spec/cauldron/histories_spec.rb
131
+ - spec/cauldron/history_spec.rb
101
132
  - spec/cauldron/if_relationship_spec.rb
102
- - spec/cauldron/numeric_operator_spec.rb
133
+ - spec/cauldron/operator/array_reverse_operator_spec.rb
134
+ - spec/cauldron/operator/concat_operator_spec.rb
135
+ - spec/cauldron/operator/hash_key_value_operator_spec.rb
136
+ - spec/cauldron/operator/numeric_operator_spec.rb
137
+ - spec/cauldron/operator/string_asterisk_operator_spec.rb
138
+ - spec/cauldron/operator/var_collect_operator_spec.rb
103
139
  - spec/cauldron/pot_spec.rb
140
+ - spec/cauldron/solution/composite_spec.rb
141
+ - spec/cauldron/solution/one_spec.rb
142
+ - spec/cauldron/statement_generator_spec.rb
104
143
  - spec/cauldron/terminal_spec.rb
105
144
  - spec/examples/adding_if_statement.yml
106
145
  - spec/examples/simple_head_theory.txt
107
146
  - spec/spec_helper.rb
147
+ - spec/support/code_matcher.rb
148
+ - spec/support/include_instance_of_matcher.rb
149
+ - spec/support/shared_examples_for_leaf_operators.rb
150
+ - spec/support/shared_examples_for_operators.rb
151
+ - syntax_spec.txt
108
152
  - tasks/development_tasks.rake
109
153
  - tasks/theory_tasks.rake
110
154
  homepage: http://github.com/theinbetweens/cauldron
111
155
  licenses:
112
156
  - MIT
157
+ metadata: {}
113
158
  post_install_message:
114
159
  rdoc_options: []
115
160
  require_paths:
116
161
  - lib
117
162
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
163
  requirements:
120
- - - ! '>='
164
+ - - ">="
121
165
  - !ruby/object:Gem::Version
122
166
  version: '0'
123
- segments:
124
- - 0
125
- hash: -3985939915823309173
126
167
  required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
168
  requirements:
129
- - - ! '>='
169
+ - - ">="
130
170
  - !ruby/object:Gem::Version
131
171
  version: '0'
132
172
  requirements: []
133
173
  rubyforge_project:
134
- rubygems_version: 1.8.23
174
+ rubygems_version: 2.6.14
135
175
  signing_key:
136
- specification_version: 3
176
+ specification_version: 4
137
177
  summary: Generate simple ruby methods from the input(s) and expected output
138
178
  test_files:
139
- - features/cauldron_new_approach.feature
179
+ - features/chop.feature
180
+ - features/create_dynamic_statements.feature
181
+ - features/generate_known_solution.feature
182
+ - features/generate_new_statement.feature
140
183
  - features/step_definitions/cauldron_steps.rb
141
184
  - features/step_definitions/terminal_steps.rb
142
185
  - features/support/env.rb
143
186
  - features/support/hooks.rb
144
- - spec/cauldron/array_reverse_operator_spec.rb
145
- - spec/cauldron/concat_operator_spec.rb
187
+ - features/use_existing_statements.feature
188
+ - spec/cauldron/actualized_composite_spec.rb
189
+ - spec/cauldron/array_collect_template/default_spec.rb
190
+ - spec/cauldron/builder_spec.rb
191
+ - spec/cauldron/dynamic/add_number_template_spec.rb
192
+ - spec/cauldron/dynamic_operator_spec.rb
193
+ - spec/cauldron/example_set_spec.rb
194
+ - spec/cauldron/example_spec.rb
195
+ - spec/cauldron/histories_spec.rb
196
+ - spec/cauldron/history_spec.rb
146
197
  - spec/cauldron/if_relationship_spec.rb
147
- - spec/cauldron/numeric_operator_spec.rb
198
+ - spec/cauldron/operator/array_reverse_operator_spec.rb
199
+ - spec/cauldron/operator/concat_operator_spec.rb
200
+ - spec/cauldron/operator/hash_key_value_operator_spec.rb
201
+ - spec/cauldron/operator/numeric_operator_spec.rb
202
+ - spec/cauldron/operator/string_asterisk_operator_spec.rb
203
+ - spec/cauldron/operator/var_collect_operator_spec.rb
148
204
  - spec/cauldron/pot_spec.rb
205
+ - spec/cauldron/solution/composite_spec.rb
206
+ - spec/cauldron/solution/one_spec.rb
207
+ - spec/cauldron/statement_generator_spec.rb
149
208
  - spec/cauldron/terminal_spec.rb
150
209
  - spec/examples/adding_if_statement.yml
151
210
  - spec/examples/simple_head_theory.txt
152
211
  - spec/spec_helper.rb
212
+ - spec/support/code_matcher.rb
213
+ - spec/support/include_instance_of_matcher.rb
214
+ - spec/support/shared_examples_for_leaf_operators.rb
215
+ - spec/support/shared_examples_for_operators.rb
data/README DELETED
@@ -1 +0,0 @@
1
- # Comming soon
@@ -1,19 +0,0 @@
1
- = cauldron
2
-
3
- Description goes here.
4
-
5
- == Contributing to cauldron
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 theinbetweens. See LICENSE.txt for
18
- further details.
19
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.4
@@ -1,46 +0,0 @@
1
- Feature: Cauldron generates single parameter methods
2
-
3
- Cauldron can generate runtime methods that accepts one parameters
4
-
5
- NOTE: it creates the file in tmp/aruba/launch.rb - so that loading path needs to be changed
6
- - use @pause to see if it's working.
7
-
8
- #TODO Change the method name
9
-
10
- @announce @slow_process
11
- Scenario: Method returns the passed in value
12
- Given a theory named "example_1.yml" with:
13
- """
14
- dependents:
15
- -
16
- "if RUNTIME_METHOD.kind_of?(RuntimeMethod)
17
- return true
18
- end"
19
- -
20
- "if ARG_1 == OUTPUT
21
- return true
22
- end"
23
- action:
24
- statement: "return x"
25
- values:
26
- x: ARG_1
27
- position: RUNTIME_METHOD.first.statement_id
28
- results:
29
- -
30
- RUNTIME_METHOD.all_pass(ARG_1)
31
- """
32
- And a file named "launch.rb" with:
33
- """
34
- $LOAD_PATH.unshift File.expand_path( File.join('lib') )
35
- require 'cauldron'
36
- cauldron = Cauldron::Pot.new
37
- cauldron.load_theory File.join('theories','example_1.yml')
38
- cauldron.generate [["sparky","sparky"],["kel","kel"]]
39
- """
40
- When I run `ruby launch.rb` interactively
41
- Then the output should contain:
42
- """
43
- def extend_function_test_method(var1)
44
- return var1
45
- end
46
- """