gecoder-with-gecode 0.7.1-mswin32

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 (159) hide show
  1. data/CHANGES +81 -0
  2. data/COPYING +17 -0
  3. data/LGPL-LICENSE +458 -0
  4. data/README +45 -0
  5. data/Rakefile +13 -0
  6. data/example/example_helper.rb +1 -0
  7. data/example/magic_sequence.rb +43 -0
  8. data/example/queens.rb +43 -0
  9. data/example/raw_bindings.rb +42 -0
  10. data/example/send_more_money.rb +43 -0
  11. data/example/send_most_money.rb +58 -0
  12. data/example/square_tiling.rb +84 -0
  13. data/example/sudoku-set.rb +110 -0
  14. data/example/sudoku.rb +61 -0
  15. data/lib/gecode.dll +0 -0
  16. data/lib/gecoder.rb +5 -0
  17. data/lib/gecoder/bindings.rb +54 -0
  18. data/lib/gecoder/bindings/bindings.rb +2210 -0
  19. data/lib/gecoder/interface.rb +8 -0
  20. data/lib/gecoder/interface/binding_changes.rb +313 -0
  21. data/lib/gecoder/interface/branch.rb +152 -0
  22. data/lib/gecoder/interface/constraints.rb +397 -0
  23. data/lib/gecoder/interface/constraints/bool/boolean.rb +246 -0
  24. data/lib/gecoder/interface/constraints/bool/linear.rb +29 -0
  25. data/lib/gecoder/interface/constraints/bool_enum/boolean.rb +84 -0
  26. data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +8 -0
  27. data/lib/gecoder/interface/constraints/bool_var_constraints.rb +75 -0
  28. data/lib/gecoder/interface/constraints/int/arithmetic.rb +71 -0
  29. data/lib/gecoder/interface/constraints/int/domain.rb +78 -0
  30. data/lib/gecoder/interface/constraints/int/linear.rb +295 -0
  31. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +72 -0
  32. data/lib/gecoder/interface/constraints/int_enum/channel.rb +100 -0
  33. data/lib/gecoder/interface/constraints/int_enum/count.rb +92 -0
  34. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +69 -0
  35. data/lib/gecoder/interface/constraints/int_enum/element.rb +82 -0
  36. data/lib/gecoder/interface/constraints/int_enum/equality.rb +38 -0
  37. data/lib/gecoder/interface/constraints/int_enum/sort.rb +126 -0
  38. data/lib/gecoder/interface/constraints/int_enum_constraints.rb +37 -0
  39. data/lib/gecoder/interface/constraints/int_var_constraints.rb +58 -0
  40. data/lib/gecoder/interface/constraints/reifiable_constraints.rb +78 -0
  41. data/lib/gecoder/interface/constraints/set/cardinality.rb +75 -0
  42. data/lib/gecoder/interface/constraints/set/connection.rb +193 -0
  43. data/lib/gecoder/interface/constraints/set/domain.rb +109 -0
  44. data/lib/gecoder/interface/constraints/set/operation.rb +132 -0
  45. data/lib/gecoder/interface/constraints/set/relation.rb +178 -0
  46. data/lib/gecoder/interface/constraints/set_enum/channel.rb +18 -0
  47. data/lib/gecoder/interface/constraints/set_enum/distinct.rb +80 -0
  48. data/lib/gecoder/interface/constraints/set_enum/operation.rb +60 -0
  49. data/lib/gecoder/interface/constraints/set_enum/selection.rb +217 -0
  50. data/lib/gecoder/interface/constraints/set_enum_constraints.rb +34 -0
  51. data/lib/gecoder/interface/constraints/set_var_constraints.rb +72 -0
  52. data/lib/gecoder/interface/enum_matrix.rb +64 -0
  53. data/lib/gecoder/interface/enum_wrapper.rb +153 -0
  54. data/lib/gecoder/interface/model.rb +251 -0
  55. data/lib/gecoder/interface/search.rb +123 -0
  56. data/lib/gecoder/interface/variables.rb +254 -0
  57. data/lib/gecoder/version.rb +4 -0
  58. data/specs/binding_changes.rb +76 -0
  59. data/specs/bool_var.rb +74 -0
  60. data/specs/branch.rb +170 -0
  61. data/specs/constraints/arithmetic.rb +266 -0
  62. data/specs/constraints/bool_enum.rb +140 -0
  63. data/specs/constraints/boolean.rb +232 -0
  64. data/specs/constraints/cardinality.rb +154 -0
  65. data/specs/constraints/channel.rb +126 -0
  66. data/specs/constraints/connection.rb +373 -0
  67. data/specs/constraints/constraint_helper.rb +180 -0
  68. data/specs/constraints/constraints.rb +74 -0
  69. data/specs/constraints/count.rb +139 -0
  70. data/specs/constraints/distinct.rb +218 -0
  71. data/specs/constraints/element.rb +106 -0
  72. data/specs/constraints/equality.rb +31 -0
  73. data/specs/constraints/int_domain.rb +69 -0
  74. data/specs/constraints/int_relation.rb +78 -0
  75. data/specs/constraints/linear.rb +332 -0
  76. data/specs/constraints/reification_sugar.rb +96 -0
  77. data/specs/constraints/selection.rb +292 -0
  78. data/specs/constraints/set_domain.rb +181 -0
  79. data/specs/constraints/set_operation.rb +285 -0
  80. data/specs/constraints/set_relation.rb +201 -0
  81. data/specs/constraints/sort.rb +175 -0
  82. data/specs/distribution.rb +14 -0
  83. data/specs/enum_matrix.rb +43 -0
  84. data/specs/enum_wrapper.rb +122 -0
  85. data/specs/int_var.rb +144 -0
  86. data/specs/logging.rb +24 -0
  87. data/specs/model.rb +190 -0
  88. data/specs/search.rb +246 -0
  89. data/specs/set_var.rb +68 -0
  90. data/specs/spec_helper.rb +93 -0
  91. data/tasks/all_tasks.rb +1 -0
  92. data/tasks/building.howto +65 -0
  93. data/tasks/distribution.rake +156 -0
  94. data/tasks/rcov.rake +17 -0
  95. data/tasks/specs.rake +15 -0
  96. data/tasks/svn.rake +11 -0
  97. data/tasks/website.rake +51 -0
  98. data/vendor/gecode/win32/lib/libgecodeint.dll +0 -0
  99. data/vendor/gecode/win32/lib/libgecodekernel.dll +0 -0
  100. data/vendor/gecode/win32/lib/libgecodeminimodel.dll +0 -0
  101. data/vendor/gecode/win32/lib/libgecodesearch.dll +0 -0
  102. data/vendor/gecode/win32/lib/libgecodeset.dll +0 -0
  103. data/vendor/rust/README +28 -0
  104. data/vendor/rust/bin/cxxgenerator.rb +93 -0
  105. data/vendor/rust/include/rust_checks.hh +115 -0
  106. data/vendor/rust/include/rust_conversions.hh +102 -0
  107. data/vendor/rust/rust.rb +67 -0
  108. data/vendor/rust/rust/attribute.rb +51 -0
  109. data/vendor/rust/rust/bindings.rb +172 -0
  110. data/vendor/rust/rust/class.rb +339 -0
  111. data/vendor/rust/rust/constants.rb +48 -0
  112. data/vendor/rust/rust/container.rb +110 -0
  113. data/vendor/rust/rust/cppifaceparser.rb +129 -0
  114. data/vendor/rust/rust/cwrapper.rb +72 -0
  115. data/vendor/rust/rust/cxxclass.rb +98 -0
  116. data/vendor/rust/rust/element.rb +81 -0
  117. data/vendor/rust/rust/enum.rb +63 -0
  118. data/vendor/rust/rust/function.rb +407 -0
  119. data/vendor/rust/rust/namespace.rb +61 -0
  120. data/vendor/rust/rust/templates/AttributeDefinition.rusttpl +17 -0
  121. data/vendor/rust/rust/templates/AttributeInitBinding.rusttpl +9 -0
  122. data/vendor/rust/rust/templates/BindingsHeader.rusttpl +24 -0
  123. data/vendor/rust/rust/templates/BindingsUnit.rusttpl +46 -0
  124. data/vendor/rust/rust/templates/CWrapperClassDefinitions.rusttpl +64 -0
  125. data/vendor/rust/rust/templates/ClassDeclarations.rusttpl +7 -0
  126. data/vendor/rust/rust/templates/ClassInitialize.rusttpl +6 -0
  127. data/vendor/rust/rust/templates/ConstructorStub.rusttpl +21 -0
  128. data/vendor/rust/rust/templates/CxxClassDefinitions.rusttpl +91 -0
  129. data/vendor/rust/rust/templates/CxxMethodStub.rusttpl +12 -0
  130. data/vendor/rust/rust/templates/CxxStandaloneClassDefinitions.rusttpl +26 -0
  131. data/vendor/rust/rust/templates/EnumDeclarations.rusttpl +3 -0
  132. data/vendor/rust/rust/templates/EnumDefinitions.rusttpl +29 -0
  133. data/vendor/rust/rust/templates/FunctionDefinition.rusttpl +9 -0
  134. data/vendor/rust/rust/templates/FunctionInitAlias.rusttpl +5 -0
  135. data/vendor/rust/rust/templates/FunctionInitBinding.rusttpl +9 -0
  136. data/vendor/rust/rust/templates/MethodInitBinding.rusttpl +9 -0
  137. data/vendor/rust/rust/templates/ModuleDeclarations.rusttpl +3 -0
  138. data/vendor/rust/rust/templates/ModuleDefinitions.rusttpl +3 -0
  139. data/vendor/rust/rust/templates/StandaloneClassDeclarations.rusttpl +7 -0
  140. data/vendor/rust/rust/templates/VariableFunctionCall.rusttpl +14 -0
  141. data/vendor/rust/rust/type.rb +98 -0
  142. data/vendor/rust/test/Makefile +4 -0
  143. data/vendor/rust/test/constants.rb +36 -0
  144. data/vendor/rust/test/cppclass.cc +45 -0
  145. data/vendor/rust/test/cppclass.hh +67 -0
  146. data/vendor/rust/test/cppclass.rb +59 -0
  147. data/vendor/rust/test/cwrapper.c +74 -0
  148. data/vendor/rust/test/cwrapper.h +41 -0
  149. data/vendor/rust/test/cwrapper.rb +56 -0
  150. data/vendor/rust/test/dummyclass.hh +31 -0
  151. data/vendor/rust/test/lib/extension-test.rb +98 -0
  152. data/vendor/rust/test/operators.cc +41 -0
  153. data/vendor/rust/test/operators.hh +39 -0
  154. data/vendor/rust/test/operators.rb +39 -0
  155. data/vendor/rust/test/test-constants.rb +43 -0
  156. data/vendor/rust/test/test-cppclass.rb +82 -0
  157. data/vendor/rust/test/test-cwrapper.rb +80 -0
  158. data/vendor/rust/test/test-operators.rb +42 -0
  159. metadata +293 -0
data/specs/set_var.rb ADDED
@@ -0,0 +1,68 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Gecode::FreeSetVar, '(not assigned)' do
4
+ before do
5
+ model = Gecode::Model.new
6
+ @var = model.set_var(1..3, 0..4)
7
+ end
8
+
9
+ it 'should not be assigned' do
10
+ @var.should_not be_assigned
11
+ end
12
+
13
+ it 'should give glb and lub ranges when inspecting' do
14
+ @var.inspect.should include('lub-range')
15
+ @var.inspect.should include('glb-range')
16
+ end
17
+
18
+ it 'should report the correct bounds' do
19
+ @var.lower_bound.sort.to_a.should == (1..3).to_a
20
+ @var.upper_bound.sort.to_a.should == (0..4).to_a
21
+ end
22
+
23
+ it 'should report correct bounds on upper bound' do
24
+ @var.upper_bound.min.should == 0
25
+ @var.upper_bound.max.should == 4
26
+ end
27
+
28
+ it 'should report correct bounds on lower bound' do
29
+ @var.lower_bound.min.should == 1
30
+ @var.lower_bound.max.should == 3
31
+ end
32
+
33
+ it 'should raise error when trying to access assigned value' do
34
+ lambda{ @var.value }.should raise_error(RuntimeError)
35
+ end
36
+
37
+ it 'should not raise error when enumerating over bound multiple times' do
38
+ # For C0 coverage.
39
+ lower_bound = @var.lower_bound
40
+ lambda do
41
+ lower_bound.each{}
42
+ lower_bound.each{}
43
+ end.should_not raise_error
44
+ end
45
+ end
46
+
47
+ describe Gecode::FreeSetVar, '(assigned)' do
48
+ before do
49
+ model = Gecode::Model.new
50
+ @var = model.set_var([1], [1])
51
+ model.solve!
52
+ end
53
+
54
+ it 'should be assigned' do
55
+ @var.should be_assigned
56
+ end
57
+
58
+ it "should give it's value when inspecting" do
59
+ @var.inspect.should include('[1]')
60
+ @var.inspect.should_not include('lub-range')
61
+ end
62
+
63
+ it 'should report the correct bounds' do
64
+ @var.upper_bound.to_a.should == [1]
65
+ @var.lower_bound.to_a.should == [1]
66
+ @var.value.to_a.should == [1]
67
+ end
68
+ end
@@ -0,0 +1,93 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require File.dirname(__FILE__) + '/../lib/gecoder'
4
+
5
+ module CustomVarMatchers
6
+ class HaveDomain
7
+ def initialize(expected)
8
+ @expected = expected.to_a
9
+ end
10
+
11
+ def matches?(target)
12
+ @target = target
13
+ return false unless @target.size == @expected.size
14
+ @expected.each do |element|
15
+ return false unless @target.include? element
16
+ end
17
+ return true
18
+ end
19
+
20
+ def failure_message
21
+ "expected #{@target.inspect} to have domain #{@expected.inspect}"
22
+ end
23
+
24
+ def negative_failure_message
25
+ "expected #{@target.inspect} not to have domain #{@expected.inspect}"
26
+ end
27
+ end
28
+
29
+ # Tests whether a variable has the expected domain.
30
+ def have_domain(expected)
31
+ HaveDomain.new(expected)
32
+ end
33
+
34
+ class HaveBounds
35
+ def initialize(expected_glb, expected_lub)
36
+ @expected_glb = expected_glb.to_a
37
+ @expected_lub = expected_lub.to_a
38
+ end
39
+
40
+ def matches?(target)
41
+ @target = target
42
+ return @target.lower_bound.to_a == @expected_glb &&
43
+ @target.upper_bound.to_a == @expected_lub
44
+ end
45
+
46
+ def failure_message
47
+ "expected #{@target.inspect} to have greatest lower bound " +
48
+ "#{@expected_glb.inspect} and least upper bound #{@expected_lub.inspect}"
49
+ end
50
+
51
+ def negative_failure_message
52
+ "expected #{@target.inspect} to not have greatest lower bound " +
53
+ "#{@expected_glb.inspect} and least upper bound #{@expected_lub.inspect}"
54
+ end
55
+ end
56
+
57
+ # Tests whether a set variable has the expected bounds.
58
+ def have_bounds(expected_glb, expected_lub)
59
+ HaveBounds.new(expected_glb, expected_lub)
60
+ end
61
+
62
+ class IsAlias
63
+ def initialize(expected)
64
+ @expected = expected.to_a
65
+ end
66
+
67
+ def matches?(target)
68
+ @target = target
69
+ return false unless @target.size == @expected.size
70
+ @expected.each do |element|
71
+ return false unless @target.in(element)
72
+ end
73
+ return true
74
+ end
75
+
76
+ def failure_message
77
+ "expected #{@target.inspect} to be an alias of #{@expected.inspect}"
78
+ end
79
+
80
+ def negative_failure_message
81
+ "expected #{@target.inspect} not to be an alias of #{@expected.inspect}"
82
+ end
83
+ end
84
+
85
+ # Tests whether a method with a specified name is the alias of another.
86
+ def is_alias_of(expected)
87
+ HaveDomain.new(expected)
88
+ end
89
+ end
90
+
91
+ Spec::Runner.configure do |config|
92
+ config.include(CustomVarMatchers)
93
+ end
@@ -0,0 +1 @@
1
+ Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
@@ -0,0 +1,65 @@
1
+ Doing the full "release" task requires a number of gems:
2
+
3
+ # To run the Rake scripts.
4
+ rake
5
+
6
+ # To generate the website.
7
+ webgen
8
+ coderay
9
+
10
+ # To run the specs and produce a report for the website.
11
+ rspec
12
+
13
+ # To release files to RubyForge.
14
+ meta_project
15
+ rubyforge
16
+
17
+ Crosscompiling the win32 binaries under Linux requires the following.
18
+
19
+ http://www.libsdl.org/extras/win32/cross/README.txt
20
+ http://www.mingw.org/
21
+ http://www.profv.de/mingw_cross_env/
22
+ http://www.mingw.org/MinGWiki/index.php/build%20a%20Win32%20x-compiler%20for%20Linux
23
+ http://www.mingw.org/MinGWiki/index.php/BuildMingwCross
24
+
25
+ Used the patch in the end of
26
+ http://www.mingw.org/MinGWiki/index.php/build%20a%20Win32%20x-compiler%20for%20Linux
27
+ but with
28
+ BINUTILS_ARCHIVE="binutils-2.18.50-20071123-src.tar.gz"
29
+
30
+ Generate rbconfig.rb by following:
31
+ http://eigenclass.org/hiki.rb?cross+compiling+rcovrt
32
+
33
+ In ext do:
34
+ ruby -I win32 extconf.rb
35
+ make
36
+
37
+ # ruby -Iwin32 -Iwin32/gecode-1.3.1/include/ -Iwin32/gecode-1.3.1/lib/ -I~/cross-compile/ruby-mingw32/lib/ruby/1.8/i386-mingw32/ extconf-win32.rb
38
+
39
+
40
+ get mingw32 via modified install script (need at least gcc4.2 due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27650)
41
+ add bin to bath, make i386-* symbolic links: ruby -e "Dir['*'].each{ |x| %x{ln -s -T #{x} i386-#{x}} }"
42
+ compile Ruby with cross-compile script
43
+ comment out the read, write and select macros in ruby-mingw32/lib/ruby/1.8/i386-mingw32/win32/win32.h
44
+ edit rbconfig.rb to use mingw32-g++ instead of mingw32-gcc in "LDSHARED".
45
+ copy the produced rbconfig.rb file to ext/win32
46
+ compile Gecode with the cross-compile script
47
+ move dlls to ext/, move includes to ext/win32
48
+ install pexports (included in mingw-utils)
49
+ create definitions from MSVC dlls: ruby -e "Dir['*.dll'].each{ |x| %x{pexports #{x} > #{x.sub('dll', 'def')}} }"
50
+ ruby -e "Dir['*.def'].each{ |x| %x{mingw32-dlltool -U -d #{x} > lib#{x.downcase.chomp('def')}a} }"
51
+ ruby -Iwin32 extconf-win32.rb
52
+ make
53
+
54
+ # Building Gecode and Gecode/R dlls using mingw:
55
+ get mingw32 via modified install script (need at least gcc4.2 due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27650)
56
+ add bin to bath, make i386-* symbolic links: ruby -e "Dir['*'].each{ |x| %x{ln -s -T #{x} i386-#{x}} }"
57
+ compile Ruby with cross-compile script
58
+ comment out the read, write and select macros in ruby-mingw32/lib/ruby/1.8/i386-mingw32/win32/win32.h
59
+ edit rbconfig.rb to use mingw32-g++ instead of mingw32-gcc in "LDSHARED".
60
+ copy the produced rbconfig.rb file to ext/win32
61
+ compile Gecode with the cross-compile script
62
+ move dlls to ext/, move includes to ext/win32
63
+ ruby -Iwin32 extconf-win32.rb
64
+ make
65
+ move gecode.dll to lib/, put the Gecode dlls somewhere in the path
@@ -0,0 +1,156 @@
1
+ require 'lib/gecoder/version'
2
+
3
+ PROJECT_NAME = PKG_NAME = 'gecoder'
4
+ PKG_NAME_WITH_GECODE = 'gecoder-with-gecode'
5
+ PKG_VERSION = GecodeR::VERSION
6
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
7
+ PKG_FILE_NAME_WITH_GECODE = "#{PKG_NAME_WITH_GECODE}-#{PKG_VERSION}"
8
+
9
+ desc 'Generate RDoc'
10
+ rd = Rake::RDocTask.new do |rdoc|
11
+ rdoc.rdoc_dir = 'doc/output/rdoc'
12
+ rdoc.options << '--title' << 'Gecode/R' << '--line-numbers' <<
13
+ '--inline-source' << '--accessor' << 'delegate' << '--main' << 'README'
14
+ rdoc.rdoc_files.include('README', 'CHANGES', 'LGPL-LICENSE', 'lib/**/*.rb')
15
+ end
16
+
17
+ desc 'Generate RDoc, ignoring nodoc'
18
+ Rake::RDocTask.new(:rdoc_dev) do |rdoc|
19
+ rdoc.rdoc_dir = 'doc/output/rdoc_dev'
20
+ rdoc.options << '--title' << 'Gecode/R Developers RDoc' << '--line-numbers' <<
21
+ '--inline-source' << '--accessor' << 'delegate'
22
+
23
+ # Copy the rdoc and remove all #:nodoc: .
24
+ TMP_DIR = 'doc/tmp/rdoc_dev'
25
+ Dir['lib/**/*.rb'].each do |source_name|
26
+ destination_name = source_name.sub('lib', TMP_DIR)
27
+ File.makedirs File.dirname(destination_name)
28
+ destination = File.open(destination_name, 'w')
29
+ File.open(source_name) do |source|
30
+ source.each{ |line| destination << line.gsub('#:nodoc:', '' ) }
31
+ end
32
+ destination.close
33
+ end
34
+
35
+ rdoc.rdoc_files.include("#{TMP_DIR}/**/*.rb")
36
+ end
37
+
38
+ spec = Gem::Specification.new do |s|
39
+ s.name = PKG_NAME
40
+ s.version = GecodeR::VERSION
41
+ s.summary = 'Ruby interface to Gecode, an environment for constraint programming.'
42
+ s.description = <<-end_description
43
+ Gecode/R is a Ruby interface to the Gecode constraint programming library.
44
+ Gecode/R is intended for people with no previous experience of constraint
45
+ programming, aiming to be easy to pick up and use.
46
+ end_description
47
+
48
+ s.files = FileList[
49
+ '[A-Z]*',
50
+ 'lib/**/*.rb',
51
+ 'example/**/*',
52
+ 'src/**/*',
53
+ 'vendor/rust/**/*',
54
+ 'tasks/**/*',
55
+ 'specs/**/*',
56
+ 'ext/*.cpp',
57
+ 'ext/*.h',
58
+ 'ext/extconf.rb'
59
+ ].to_a
60
+ s.require_path = 'lib'
61
+ s.extensions << 'ext/extconf.rb'
62
+ s.requirements << 'Gecode 1.3.1'
63
+
64
+ s.has_rdoc = true
65
+ s.rdoc_options = rd.options
66
+ s.extra_rdoc_files = rd.rdoc_files
67
+ s.test_files = FileList['specs/**/*.rb']
68
+
69
+ s.autorequire = 'gecoder'
70
+ s.author = ["Gecode/R Development Team"]
71
+ s.email = "gecoder-users@rubyforge.org"
72
+ s.homepage = "http://gecoder.rubyforge.org"
73
+ s.rubyforge_project = "gecoder"
74
+ end
75
+
76
+ # Create a clone of the gem spec with the precompiled binaries for Windows.
77
+ spec_windows_binary_with_gecode = spec.dup
78
+ spec_windows_binary_with_gecode.name = PKG_NAME_WITH_GECODE
79
+ spec_windows_binary_with_gecode.extensions = []
80
+ spec_windows_binary_with_gecode.requirements = []
81
+ # Add the precompiled Gecode DLLs and precompiled bindings.
82
+ spec_windows_binary_with_gecode.files = spec.files.dup -
83
+ FileList['ext/**/*'].to_a +
84
+ FileList['vendor/gecode/win32/lib/*'].to_a << 'lib/gecode.dll'
85
+ spec_windows_binary_with_gecode.platform = Gem::Platform::WIN32
86
+
87
+ # Create a clone of the gem spec that includes Gecode.
88
+ spec_with_gecode = spec.dup
89
+ spec_with_gecode.name = PKG_NAME_WITH_GECODE
90
+ spec_with_gecode.extensions = spec.extensions.dup << 'ext/gecode-1.3.1/extconf.rb'
91
+ spec_with_gecode.requirements = []
92
+ spec_with_gecode.files = spec.files.dup + FileList['ext/gecode-*/**/*'].to_a
93
+
94
+ desc 'Generate Gecode/R Gem'
95
+ Rake::GemPackageTask.new(spec) do |pkg|
96
+ pkg.need_zip = true
97
+ pkg.need_tar = true
98
+ end
99
+
100
+ desc 'Generate Gecode/R + Gecode Gem'
101
+ Rake::GemPackageTask.new(spec_with_gecode) do |pkg|
102
+ pkg.need_zip = true
103
+ pkg.need_tar = true
104
+ end
105
+
106
+ desc 'Generate Gecode/R + Gecode Gem (windows binary)'
107
+ Rake::GemPackageTask.new(spec_windows_binary_with_gecode) do |pkg|
108
+ end
109
+
110
+ desc 'Precompiles the Gecode/R bindings for Windows platforms'
111
+ file 'lib/gecode.dll' do
112
+ cd 'ext' do
113
+ sh 'ruby -Iwin32 extconf-win32.rb'
114
+ sh 'make'
115
+ mv 'gecode.so', '../lib/gecode.dll'
116
+ end
117
+ end
118
+
119
+ desc 'Publish packages on RubyForge'
120
+ task :publish_packages => [:publist_gecoder_packages,
121
+ :publish_gecoder_with_gecode_packages]
122
+
123
+ desc 'Publish Gecode/R packages on RubyForge'
124
+ task :publish_gecoder_packages => [:verify_user, :package] do
125
+ release_files = FileList[
126
+ "pkg/#{PKG_FILE_NAME}.gem",
127
+ "pkg/#{PKG_FILE_NAME}.tgz",
128
+ "pkg/#{PKG_FILE_NAME}.zip"
129
+ ]
130
+ require 'meta_project'
131
+ require 'rake/contrib/xforge'
132
+
133
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PROJECT_NAME)) do |xf|
134
+ xf.user_name = ENV['RUBYFORGE_USER']
135
+ xf.files = release_files.to_a
136
+ xf.release_name = "Gecode/R #{PKG_VERSION}"
137
+ end
138
+ end
139
+
140
+ desc 'Publish Gecode/R with Gecode packages on RubyForge'
141
+ task :publish_gecoder_with_gecode_packages => [:verify_user, :package] do
142
+ release_files = FileList[
143
+ "pkg/#{PKG_FILE_NAME_WITH_GECODE}*.gem",
144
+ "pkg/#{PKG_FILE_NAME_WITH_GECODE}*.tgz",
145
+ "pkg/#{PKG_FILE_NAME_WITH_GECODE}*.zip"
146
+ ]
147
+
148
+ require 'meta_project'
149
+ require 'rake/contrib/xforge'
150
+
151
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PROJECT_NAME)) do |xf|
152
+ xf.user_name = ENV['RUBYFORGE_USER']
153
+ xf.files = release_files.to_a
154
+ xf.release_name = "Gecode/R with Gecode #{PKG_VERSION}"
155
+ end
156
+ end
data/tasks/rcov.rake ADDED
@@ -0,0 +1,17 @@
1
+ require 'spec/rake/spectask'
2
+ require 'spec/rake/verify_rcov'
3
+
4
+ RCOV_DIR = "#{File.dirname(__FILE__)}/../doc/output/coverage"
5
+
6
+ desc "Run all specs with rcov"
7
+ Spec::Rake::SpecTask.new(:rcov) do |t|
8
+ t.spec_files = FileList['specs/**/*.rb']
9
+ t.rcov = true
10
+ t.rcov_opts = ['--exclude examples', '--exclude specs']
11
+ t.rcov_dir = RCOV_DIR
12
+ end
13
+
14
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
15
+ t.threshold = 100.0
16
+ t.index_html = "#{RCOV_DIR}/index.html"
17
+ end
data/tasks/specs.rake ADDED
@@ -0,0 +1,15 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ spec_files = FileList['specs/**/*.rb']
4
+
5
+ desc 'Run all specs'
6
+ Spec::Rake::SpecTask.new('specs') do |t|
7
+ t.libs = ['lib']
8
+ t.spec_files = spec_files
9
+ end
10
+
11
+ desc 'Generate an rspec html report'
12
+ Spec::Rake::SpecTask.new('spec_html') do |t|
13
+ t.spec_files = spec_files
14
+ t.spec_opts = ['--format html:doc/output/rspec.html','--backtrace']
15
+ end
data/tasks/svn.rake ADDED
@@ -0,0 +1,11 @@
1
+ require 'lib/gecoder/version'
2
+
3
+ desc "Tag the release in svn"
4
+ task :tag do
5
+ from = `svn info`.match(/Repository Root: (.*)/n)[1] + '/trunk'
6
+ to = from.gsub(/trunk/, "tags/gecoder-#{GecodeR::VERSION}")
7
+
8
+ puts "Creating tag in SVN"
9
+ tag_cmd = "svn cp #{from} #{to} -m \"Tag release Gecode/R #{GecodeR::VERSION}\""
10
+ `#{tag_cmd}` ; raise "ERROR: #{tag_cmd}" unless $? == 0
11
+ end
@@ -0,0 +1,51 @@
1
+ require 'rake/contrib/rubyforgepublisher'
2
+
3
+ desc 'Regenerates the contents of the website'
4
+ task :website do
5
+ mkpath 'doc/output'
6
+ Rake::Task[:spec_html].invoke
7
+ Rake::Task[:rdoc].invoke
8
+ Rake::Task[:rdoc_dev].invoke
9
+ Rake::Task[:rcov].invoke
10
+ WebsiteRakeHelpers.webgen
11
+ end
12
+
13
+ desc 'Removes generated documentation'
14
+ task :clobber do
15
+ WebsiteRakeHelpers.clobber
16
+ end
17
+
18
+ task :verify_user do
19
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
20
+ end
21
+
22
+ desc "Uploads the website to RubyForge"
23
+ task :publish_website => [:verify_user, :website] do
24
+ publisher = Rake::SshDirPublisher.new(
25
+ "#{ENV['RUBYFORGE_USER']}@rubyforge.org",
26
+ "/var/www/gforge-projects/gecoder",
27
+ "doc/output"
28
+ )
29
+ publisher.upload
30
+ end
31
+
32
+ module WebsiteRakeHelpers
33
+ module_function
34
+
35
+ # Remove generated documentation.
36
+ def clobber
37
+ rm_rf 'doc/output'
38
+ rm_rf 'doc/tmp'
39
+ end
40
+
41
+ # Generates the website with webgen.
42
+ def webgen
43
+ Dir.chdir 'doc' do
44
+ output = nil
45
+ IO.popen('webgen 2>&1') do |io|
46
+ output = io.read
47
+ end
48
+ raise "ERROR while running webgen: #{output}" if output =~ /ERROR/n || $? != 0
49
+ end
50
+ end
51
+ end