Skip to content

Commit 3cf1a51

Browse files
committed
2 parents f6c8400 + 03966b5 commit 3cf1a51

File tree

8 files changed

+83
-11
lines changed

8 files changed

+83
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![Travis CI](https://travis-ci.org/ruby-processing/JRubyArt.svg)
55
Versions before JRubyArt-1.2.0, are unsupported, please update, preferably to latest version...
66

7-
_Note the only reason the current build is failing on travis is that the current version of [processing is not available from maven central][testing], it has only ever been available by third parties (I am eternally hopeful that one day processing.org will see the light)._
7+
_Note the main reason for the current build to fail on travis is when the current version of [processing is not available from maven central][testing], it has only ever been available by third parties (I am eternally hopeful that one day processing.org will see the light)._
88

99
## Requirements
1010
A clean start for `jruby_art` that works best with the latest version of [processing-3.2.1](https://github.com/processing/processing/releases) and [jruby-9.1.5.0](http://jruby.org/download) see [wiki](https://github.com/ruby-processing/JRubyArt/wiki/Building-latest-gem) for building gem from this repo. Changes from processing- 2.0 to [processing-3.0 here](https://github.com/processing/processing/wiki/Changes-in-3.0). Should work on same platforms as vanilla processing (windows, mac, linux) for Android see Yuki Morohoshi [rubuto-processing3][].

lib/jruby_art/command.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require_relative '../jruby_art/jruby_complete'
2+
require_relative '../jruby_art/java_opts'
3+
module Processing
4+
class Command
5+
attr_reader :executable, :runner, :args, :filename
6+
def initialize(executable:, runner:, args:, filename:)
7+
@executable = executable
8+
@runner = runner
9+
@args = args
10+
@filename = filename
11+
end
12+
13+
def cmd(root)
14+
return [executable, JRubyOpts.new(root).opts, runner, filename, args].flatten if executable =~ /jruby/
15+
[executable, JavaOpts.new(root).opts, '-cp', JRubyComplete.complete, 'org.jruby.Main', runner, filename, args].flatten
16+
end
17+
end
18+
end

lib/jruby_art/jruby_complete.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class JRubyComplete
2+
def self.complete
3+
rcomplete = File.join('/home/tux/JRubyArt', 'lib/ruby/jruby-complete.jar')
4+
return [rcomplete] if FileTest.exist?(rcomplete)
5+
warn "#{rcomplete} does not exist\nTry running `k9 --install`"
6+
exit
7+
end
8+
end

test/data/java_args.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xms512M -Xmx1G

test/deglut_spec_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def test_cos_sin
2020
(-720..720).step(1) do |deg|
2121
sine = DegLut.sin(deg)
2222
deg_sin = Math.sin(deg * to_radian)
23-
assert_in_delta(sine, deg_sin)
23+
assert_in_delta(sine, deg_sin, delta = 0.000001)
2424
cosine = DegLut.cos(deg)
2525
deg_cos = Math.cos(deg * to_radian)
26-
assert_in_delta(cosine, deg_cos)
26+
assert_in_delta(cosine, deg_cos, delta = 0.000001)
2727
end
2828
end
2929
end

test/helper_methods_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ def test_hex_color
3131

3232
def test_dist
3333
ax, ay, bx, by = 0, 0, 1.0, 1.0
34-
assert dist(ax, ay, bx, by) == Math.sqrt(2), '2D distance'
34+
assert_in_epsilon(dist(ax, ay, bx, by), Math.sqrt(2), epsilon = 0.0001, msg = '2D distance')
3535
by = 0.0
36-
assert dist(ax, ay, bx, by) == 1.0, 'when y dimension is zero'
36+
assert_in_epsilon(dist(ax, ay, bx, by), 1.0, epsilon = 0.0001, msg = 'when y dimension is zero')
3737
ax, ay, bx, by = 0, 0, 0.0, 0.0
38-
assert dist(ax, ay, bx, by) == 0.0, 'when x and y dimension are zero'
38+
assert_in_epsilon(dist(ax, ay, bx, by), 0.0, epsilon = 0.0001, msg = 'when x and y dimension are zero')
3939
ax, ay, bx, by = 1, 1, -2.0, -3.0
40-
assert dist(ax, ay, bx, by) == 5, 'classic triangle dimensions'
40+
assert_in_epsilon(dist(ax, ay, bx, by), 5.0, epsilon = 0.0001, msg = 'classic triangle dimensions')
4141
ax, ay, bx, by, cx, cy = -1, -1, 100, 2.0, 3.0, 100
42-
assert dist(ax, ay, bx, by, cx, cy) == 5, 'classic triangle dimensions'
42+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 5.0, epsilon = 0.0001, msg = 'classic triangle dimensions')
4343
ax, ay, bx, by, cx, cy = 0, 0, -1.0, -1.0, 0, 0
44-
assert dist(ax, ay, bx, by, cx, cy) == Math.sqrt(2)
44+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), Math.sqrt(2), epsilon = 0.0001, msg = '2D distance')
4545
ax, ay, bx, by, cx, cy = 0, 0, 0.0, 0.0, 0, 0
46-
assert dist(ax, ay, bx, by, cx, cy) == 0.0
46+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 0.0)
4747
ax, ay, bx, by, cx, cy = 0, 0, 1.0, 0.0, 0, 0
48-
assert dist(ax, ay, bx, by, cx, cy) == 1.0, 'when x and z dimension are zero'
48+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 1.0, epsilon = 0.0001, msg = 'when x and z dimension are zero')
4949
end
5050
end

test/test_command.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
gem 'minitest' # don't use bundled minitest
2+
require 'minitest/autorun'
3+
require 'minitest/pride'
4+
5+
require_relative '../lib/jruby_art/command'
6+
7+
JAVA = %w(java -Xmx512 -Xms1G -cp /home/tux/JRubyArt/lib/ruby/jruby-complete.jar org.jruby.Main watch)
8+
JRUBY = %w(jruby -J-Xmx512 -J-Xms1G watch)
9+
10+
class JavaArgsTest < Minitest::Test
11+
attr_reader :root
12+
def setup
13+
end
14+
15+
def test_java
16+
assert_equal JAVA.flatten, Processing::Command.new(executable: 'java', runner: 'watch', args: []).cmd('./')
17+
end
18+
19+
def test_jruby
20+
assert_equal JRUBY.flatten, Processing::Command.new(executable: 'jruby', runner: 'watch', args: []).cmd('./')
21+
end
22+
end

test/test_java_args.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
gem 'minitest' # don't use bundled minitest
2+
require 'minitest/autorun'
3+
require 'minitest/pride'
4+
5+
require_relative '../lib/jruby_art/java_opts'
6+
7+
JAVA = %w(-Xmx512 -Xms1G)
8+
JRUBY = %w(-J-Xmx512 -J-Xms1G)
9+
10+
class JavaArgsTest < Minitest::Test
11+
attr_reader :root
12+
def setup
13+
@root = './'
14+
end
15+
16+
def test_java
17+
assert_equal JAVA, JavaOpts.new(root).opts
18+
end
19+
20+
def test_jruby
21+
assert_equal JRUBY, JRubyOpts.new(root).opts
22+
end
23+
end

0 commit comments

Comments
 (0)