nudge 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/foobar.rb'}"
9
+ puts "Loading foobar gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,11 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), "/../spec_helper")
2
2
  include Nudge
3
-
4
3
  describe "Code Type" do
5
- it "should be a Singleton" do
6
- CodeType.instance.should be_a_kind_of(Singleton)
7
- end
8
-
9
4
 
10
5
  it "should return the result of self.randomize when it receives an #any_value call" do
11
6
  CodeType.should_receive(:random_value).and_return("hi there!")
@@ -90,7 +90,7 @@ describe "erc" do
90
90
  @ii.disable_all_types
91
91
  @ii.enable(IntType)
92
92
  myErc.randomize(@ii)
93
- myErc.type.should == "int"
93
+ myErc.type.should == :int
94
94
  end
95
95
  end
96
96
 
@@ -106,7 +106,7 @@ describe "erc" do
106
106
  @ii.disable_all_types
107
107
  @ii.enable(BoolType)
108
108
  rE = Erc.any(@ii)
109
- rE.type.should == "bool"
109
+ rE.type.should == :bool
110
110
  end
111
111
  end
112
112
 
@@ -187,7 +187,7 @@ describe "initialization" do
187
187
  @ii.enable(IntType)
188
188
  @ii.enable(BoolType)
189
189
  @ii.disable(IntType)
190
- @ii.active?(IntType).should == false
190
+ @ii.active?(NudgeType::IntType).should == false
191
191
  @ii.active?(BoolType).should == true
192
192
  @ii.enable(IntType)
193
193
  @ii.active?(IntType).should == true
@@ -78,7 +78,7 @@ describe "LiteralPoint" do
78
78
  @ii.disable_all_types
79
79
  @ii.enable(BoolType)
80
80
  myL.randomize(@ii)
81
- myL.type.should == "bool"
81
+ myL.type.should == :bool
82
82
  end
83
83
  end
84
84
 
@@ -0,0 +1,27 @@
1
+ module TreetopParserMatchers
2
+ class ParserMatcher
3
+ def initialize(input_string)
4
+ @input_string = input_string
5
+ end
6
+ def matches?(parser)
7
+ @parser = parser
8
+ !@parser.parse(@input_string).nil?
9
+ end
10
+ def failure_message_for_should
11
+ "expected #{@parser} to parse '#{@input_string}'\n" +
12
+ "failure column: #{@parser.failure_column}\n" +
13
+ "failure index: #{@parser.failure_index}\n" +
14
+ "failure line: #{@parser.failure_line}\n" +
15
+ "failure reason: #{@parser.failure_reason}\n"
16
+ end
17
+ def failure_message_for_should_not
18
+ "expected #{@parser} not to parse '#{@input_string}'"
19
+ end
20
+ def description
21
+ "parse `#{@input_string}'"
22
+ end
23
+ end
24
+ def treetop_parse(input_string)
25
+ ParserMatcher.new(input_string)
26
+ end
27
+ end
@@ -4,15 +4,41 @@ include Nudge
4
4
  describe "Type list" do
5
5
  it "should have an #all_types [getter] method to return a list of every defined type" do
6
6
  # will be a list of every type subclassed from NudgeType
7
- NudgeType.all_types.should include(IntType)
7
+ p NudgeType.all_types
8
+ NudgeType.all_types.should include(NudgeType::IntType)
8
9
  end
9
10
  end
10
11
 
11
- describe "Int Type" do
12
- it "should be a Singleton" do
13
- IntType.instance.should be_a_kind_of(Singleton)
12
+ describe "base class" do
13
+ before(:all) do
14
+ class FooType < BasicType; end
15
+ @klass = FooType
16
+ end
17
+
18
+ {:from_s => "thing", :any_value => nil, :random_value => {}}.each do |method_name, arg|
19
+ it "should raise an error when #{method_name} is missing" do
20
+ args = [method_name, arg].compact
21
+ lambda{@klass.send(*args)}.should raise_error("This class must implement #{@klass.inspect}.#{method_name}")
22
+ end
23
+ end
24
+
25
+ it "self.from_s should require a parameter" do
26
+ @klass.method(:from_s).arity.should == 1
14
27
  end
15
28
 
29
+ it "self.random_value should require a parameter" do
30
+ @klass.method(:random_value).arity.should == 1
31
+ end
32
+
33
+ it "self.any_value should require a parameter" do
34
+ @klass.method(:any_value).arity.should == 0
35
+ end
36
+
37
+
38
+ end
39
+
40
+ describe "Int Type" do
41
+
16
42
  it "should parse a string from code and produce the actual value" do
17
43
  IntType.from_s("3").should == 3
18
44
  lambda{IntType.from_s()}.should raise_error
@@ -47,9 +73,6 @@ end
47
73
 
48
74
 
49
75
  describe "Bool Type" do
50
- it "should be a Singleton" do
51
- BoolType.instance.should be_a_kind_of(Singleton)
52
- end
53
76
  it "should parse a string from code and produce the actual value" do
54
77
  BoolType.from_s("false").should == false
55
78
  lambda{BoolType.from_s()}.should raise_error
@@ -75,9 +98,6 @@ end
75
98
 
76
99
 
77
100
  describe "Float Type" do
78
- it "should be a Singleton" do
79
- FloatType.instance.should be_a_kind_of(Singleton)
80
- end
81
101
  it "should return the result of self.randomize when it receives an #any_value call" do
82
102
  FloatType.should_receive(:random_value).and_return(-9.2)
83
103
  FloatType.any_value.should == -9.2
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  $: << File.join(File.dirname(__FILE__), "/../lib")
2
2
 
3
3
  require 'spec'
4
+ require 'interpreter/treetophelpers'
4
5
  require 'pp'
5
6
  require 'nudge'
6
7
  require 'erb'
7
8
 
9
+ include TreetopParserMatchers
10
+
8
11
  def fixture(name, data = binding)
9
12
  text = File.read(File.join(File.dirname(__FILE__), "/fixtures/#{name}.example"))
10
13
  ERB.new(text).result(data)
11
- end
14
+ end
15
+
@@ -0,0 +1,29 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
6
+ require 'fileutils'
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
10
+ PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
11
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
12
+ if defined?(APP_ROOT)
13
+ APP_ROOT.replace(app_root)
14
+ else
15
+ APP_ROOT = app_root
16
+ end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
22
+
23
+ begin
24
+ require 'rubigen'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'rubigen'
28
+ end
29
+ require 'rubigen/helpers/generator_test_helper'
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestNudgeGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup
7
+ bare_setup
8
+ end
9
+
10
+ def teardown
11
+ bare_teardown
12
+ end
13
+
14
+ # Some generator-related assertions:
15
+ # assert_generated_file(name, &block) # block passed the file contents
16
+ # assert_directory_exists(name)
17
+ # assert_generated_class(name, &block)
18
+ # assert_generated_module(name, &block)
19
+ # assert_generated_test_for(name, &block)
20
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
21
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
22
+ #
23
+ # Other helper methods are:
24
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
+
28
+ def test_generator_without_options
29
+ run_generator('nudge', [APP_ROOT], sources)
30
+ assert_directory_exists "path/to/included/folder"
31
+ assert_generated_file "path/to/included/folder/some_file"
32
+ end
33
+
34
+ private
35
+ def sources
36
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
37
+ ]
38
+ end
39
+
40
+ def generator_path
41
+ "app_generators"
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nudge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tozier
@@ -10,8 +10,8 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-29 00:00:00 -05:00
14
- default_executable:
13
+ date: 2010-02-01 00:00:00 -05:00
14
+ default_executable: nudge
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: couchrest
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: "0"
24
+ version: "0.33"
25
25
  version:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sinatra
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: "0"
34
+ version: 0.9.4
35
35
  version:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: treetop
@@ -41,7 +41,7 @@ dependencies:
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: "0"
44
+ version: 1.4.3
45
45
  version:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: polyglot
@@ -51,22 +51,22 @@ dependencies:
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: "0"
54
+ version: 0.2.9
55
55
  version:
56
56
  - !ruby/object:Gem::Dependency
57
- name: active_support
57
+ name: activesupport
58
58
  type: :runtime
59
59
  version_requirement:
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: "0"
64
+ version: 2.3.5
65
65
  version:
66
- description: It's way complicated
66
+ description: DOES NOT WORK YET. The nudge gem will provide a simple framework for building, running and managing genetic programming experiments which automatically discover algorithms and equations to solve well-defined target problems. It depends on CouchDB and Ruby 1.9+
67
67
  email: bill@vagueinnovation.com
68
- executables: []
69
-
68
+ executables:
69
+ - nudge
70
70
  extensions: []
71
71
 
72
72
  extra_rdoc_files:
@@ -79,6 +79,7 @@ files:
79
79
  - _spikes/couch_document_spike.rb
80
80
  - _spikes/nested_parsing/nested.rb
81
81
  - _spikes/nested_parsing/nested.treetop
82
+ - _spikes/nudge3_syntax_spike.txt
82
83
  - _spikes/nudgeview/init.rb
83
84
  - _spikes/nudgeview/public/javascripts/app.js
84
85
  - _spikes/nudgeview/public/javascripts/jquery.js
@@ -98,6 +99,10 @@ files:
98
99
  - _spikes/symbolic_regression/experiment/objectives/programLength.rb
99
100
  - _spikes/symbolic_regression/experiment/objectives/summedSquaredError.rb
100
101
  - _spikes/symbolic_regression/lib/tasks/run.rake
102
+ - app_generators/nudge/USAGE
103
+ - app_generators/nudge/nudge_generator.rb
104
+ - app_generators/nudge/templates/activate.rb
105
+ - bin/nudge
101
106
  - doc/classes/BlockNode.html
102
107
  - doc/classes/BlockNode.src/M000246.html
103
108
  - doc/classes/BoolAndInstruction.html
@@ -595,8 +600,12 @@ files:
595
600
  - lib/search/operators/evaluators.rb
596
601
  - lib/search/operators/samplers_and_selectors.rb
597
602
  - lib/search/stations/station.rb
603
+ - nudge.gemspec
598
604
  - push_language_coverage.md
599
605
  - readme.md
606
+ - script/console
607
+ - script/destroy
608
+ - script/generate
600
609
  - spec/data/couchdb_spec.rb
601
610
  - spec/fixtures/just_block.example
602
611
  - spec/fixtures/just_block_with_newline.example
@@ -632,6 +641,7 @@ files:
632
641
  - spec/interpreter/literal_spec.rb
633
642
  - spec/interpreter/parser_spec.rb
634
643
  - spec/interpreter/stack_spec.rb
644
+ - spec/interpreter/treetophelpers.rb
635
645
  - spec/interpreter/types_spec.rb
636
646
  - spec/search/batch_spec.rb
637
647
  - spec/search/experiments/experiment_spec.rb
@@ -655,6 +665,8 @@ files:
655
665
  - spec/search/operators/uniformBackboneCrossover_spec.rb
656
666
  - spec/search/stations/station_spec.rb
657
667
  - spec/spec_helper.rb
668
+ - test/test_generator_helper.rb
669
+ - test/test_nudge_generator.rb
658
670
  has_rdoc: true
659
671
  homepage: http://github.com/Vaguery/PragGP
660
672
  licenses: []
@@ -668,7 +680,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
668
680
  requirements:
669
681
  - - ">="
670
682
  - !ruby/object:Gem::Version
671
- version: "0"
683
+ version: 1.9.1
672
684
  version:
673
685
  required_rubygems_version: !ruby/object:Gem::Requirement
674
686
  requirements:
@@ -713,6 +725,7 @@ test_files:
713
725
  - spec/interpreter/literal_spec.rb
714
726
  - spec/interpreter/parser_spec.rb
715
727
  - spec/interpreter/stack_spec.rb
728
+ - spec/interpreter/treetophelpers.rb
716
729
  - spec/interpreter/types_spec.rb
717
730
  - spec/search/batch_spec.rb
718
731
  - spec/search/experiments/experiment_spec.rb
@@ -736,3 +749,5 @@ test_files:
736
749
  - spec/search/operators/uniformBackboneCrossover_spec.rb
737
750
  - spec/search/stations/station_spec.rb
738
751
  - spec/spec_helper.rb
752
+ - test/test_generator_helper.rb
753
+ - test/test_nudge_generator.rb