rri 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.document +3 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +1 -0
  5. data/ChangeLog.md +4 -0
  6. data/Gemfile +16 -0
  7. data/Guardfile +6 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.md +131 -0
  10. data/Rakefile +66 -0
  11. data/examples/create_pdf.rb +18 -0
  12. data/examples/ggplot.rb +42 -0
  13. data/examples/simple.rb +19 -0
  14. data/gemspec.yml +11 -0
  15. data/lib/rri.rb +11 -0
  16. data/lib/rri/callback_objects.rb +1 -0
  17. data/lib/rri/callback_objects/r_engine_std_output.rb +6 -0
  18. data/lib/rri/engine.rb +390 -0
  19. data/lib/rri/java_gd.rb +23 -0
  20. data/lib/rri/jri.rb +24 -0
  21. data/lib/rri/r_converters.rb +4 -0
  22. data/lib/rri/r_converters/array_converter.rb +59 -0
  23. data/lib/rri/r_converters/float_converter.rb +28 -0
  24. data/lib/rri/r_converters/integer_converter.rb +28 -0
  25. data/lib/rri/r_converters/string_converter.rb +28 -0
  26. data/lib/rri/rexp.rb +8 -0
  27. data/lib/rri/rri_exception.rb +5 -0
  28. data/lib/rri/ruby_converters.rb +2 -0
  29. data/lib/rri/ruby_converters/double_converter.rb +28 -0
  30. data/lib/rri/ruby_converters/integer_converter.rb +28 -0
  31. data/lib/rri/version.rb +5 -0
  32. data/rri.gemspec +15 -0
  33. data/spec/rri/engine_spec.rb +203 -0
  34. data/spec/rri/r_converters/array_converter_spec.rb +56 -0
  35. data/spec/rri/r_converters/float_converter_spec.rb +19 -0
  36. data/spec/rri/r_converters/integer_converter_spec.rb +19 -0
  37. data/spec/rri/r_converters/string_converter_spec.rb +19 -0
  38. data/spec/rri/ruby_converters/double_converter.rb +20 -0
  39. data/spec/rri/ruby_converters/integer_converter_spec.rb +20 -0
  40. data/spec/rri_spec.rb +8 -0
  41. data/spec/spec_helper.rb +4 -0
  42. metadata +126 -0
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/r_converters/array_converter'
4
+
5
+ describe Rri::RConverters::ArrayConverter do
6
+ it "should correctly convert an Array of all Floats" do
7
+ ruby_value = [1.2, 3.4, -5.6]
8
+ success, value = subject.convert(ruby_value)
9
+ success.should be_true
10
+ value.class.should == Java::OrgRosudaREngine::REXPDouble
11
+ value.length.should == ruby_value.size
12
+ value.asDoubles.to_a.should == ruby_value
13
+ end
14
+
15
+ it "should correctly convert an Array of all Integers" do
16
+ ruby_value = [1, 2, -4, 5]
17
+ success, value = subject.convert(ruby_value)
18
+ success.should be_true
19
+ value.class.should == Java::OrgRosudaREngine::REXPInteger
20
+ value.length.should == ruby_value.size
21
+ value.asIntegers.to_a.should == ruby_value
22
+ end
23
+
24
+ it "should correctly convert an Array of all Strings" do
25
+ ruby_value = ["foo", "bar", "baz"]
26
+ success, value = subject.convert(ruby_value)
27
+ success.should be_true
28
+ value.class.should == Java::OrgRosudaREngine::REXPString
29
+ value.length.should == ruby_value.size
30
+ value.asStrings.to_a.should == ruby_value
31
+ end
32
+
33
+ it "should fail to convert a non Array" do
34
+ success, value = subject.convert({:a =>1})
35
+ success.should be_false
36
+ success, value = subject.convert(1)
37
+ success.should be_false
38
+ success, value = subject.convert(1.2)
39
+ success.should be_false
40
+ end
41
+
42
+ it "should fail to convert an Array with elements of mixed types" do
43
+ success, value = subject.convert([1, 1.2, "foo"])
44
+ success.should be_false
45
+ success, value = subject.convert([1, 1.2])
46
+ success.should be_false
47
+ end
48
+
49
+ it "should fail to convert an Array with elements of same but unsupported types" do
50
+ class Foo
51
+ end
52
+ success, value = subject.convert([Foo.new, Foo.new])
53
+ success.should be_false
54
+ end
55
+
56
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/r_converters/float_converter'
4
+
5
+ describe Rri::RConverters::FloatConverter do
6
+ it "should correctly convert a Float" do
7
+ ruby_input = 1.2
8
+ success, value = subject.convert(ruby_input)
9
+ success.should be_true
10
+ value.class.should == Java::OrgRosudaREngine::REXPDouble
11
+ value.asDouble.should == ruby_input
12
+ end
13
+
14
+ it "should correctly fail for non Floats" do
15
+ ruby_input = 1
16
+ success, value = subject.convert(ruby_input)
17
+ success.should be_false
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/r_converters/integer_converter'
4
+
5
+ describe Rri::RConverters::IntegerConverter do
6
+ it "should correctly convert an Integer" do
7
+ ruby_input = 1234
8
+ success, value = subject.convert(ruby_input)
9
+ success.should be_true
10
+ value.class.should == Java::OrgRosudaREngine::REXPInteger
11
+ value.asDouble.should == ruby_input
12
+ end
13
+
14
+ it "should correctly fail for non Integers" do
15
+ ruby_input = 1.23
16
+ success, value = subject.convert(ruby_input)
17
+ success.should be_false
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/r_converters/string_converter'
4
+
5
+ describe Rri::RConverters::StringConverter do
6
+ it "should correctly convert a String" do
7
+ ruby_input = "foobar"
8
+ success, value = subject.convert(ruby_input)
9
+ success.should be_true
10
+ value.class.should == Java::OrgRosudaREngine::REXPString
11
+ value.asString.should == ruby_input
12
+ end
13
+
14
+ it "should correctly fail for non Strings" do
15
+ ruby_input = 1.23
16
+ success, value = subject.convert(ruby_input)
17
+ success.should be_false
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/ruby_converters/double_converter'
4
+
5
+ describe Rri::RubyConverters::DoubleConverter do
6
+ it "should correctly convert a double" do
7
+ value = 1.234
8
+ rexp = REXPDouble.new(value)
9
+ success, obj = subject.convert(rexp)
10
+ success.should be_true
11
+ obj.should == value
12
+ end
13
+
14
+ it "should correctly fail for non-doubles" do
15
+ value = 123
16
+ rexp = REXPInteger.new(value)
17
+ success, obj = subject.convert(rexp)
18
+ success.should be_false
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+ require 'rri/ruby_converters/integer_converter'
4
+
5
+ describe Rri::RubyConverters::IntegerConverter do
6
+ it "should correctly convert an integer" do
7
+ value = 1234
8
+ rexp = REXPInteger.new(value)
9
+ success, obj = subject.convert(rexp)
10
+ success.should be_true
11
+ obj.should == value
12
+ end
13
+
14
+ it "should correctly fail for non integers" do
15
+ value = 1.23
16
+ rexp = REXPDouble.new(value)
17
+ success, obj = subject.convert(rexp)
18
+ success.should be_false
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'rri'
3
+
4
+ describe Rri do
5
+ it "should have a VERSION constant" do
6
+ subject.const_get('VERSION').should_not be_empty
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'rri/version'
3
+
4
+ include Rri
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rri
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Patrik Sundberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-31 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ version_requirements: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ requirement: *id001
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: yard
29
+ version_requirements: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.6.0
35
+ requirement: *id002
36
+ prerelease: false
37
+ type: :development
38
+ description: Ruby/R Interface - A wrapper of jri (Java/R Interface) for JRuby
39
+ email: []
40
+
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - README.md
47
+ - ChangeLog.md
48
+ - LICENSE.txt
49
+ files:
50
+ - .document
51
+ - .gemtest
52
+ - .rspec
53
+ - .yardopts
54
+ - ChangeLog.md
55
+ - Gemfile
56
+ - Guardfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - examples/create_pdf.rb
61
+ - examples/ggplot.rb
62
+ - examples/simple.rb
63
+ - gemspec.yml
64
+ - lib/rri.rb
65
+ - lib/rri/callback_objects.rb
66
+ - lib/rri/callback_objects/r_engine_std_output.rb
67
+ - lib/rri/engine.rb
68
+ - lib/rri/java_gd.rb
69
+ - lib/rri/jri.rb
70
+ - lib/rri/r_converters.rb
71
+ - lib/rri/r_converters/array_converter.rb
72
+ - lib/rri/r_converters/float_converter.rb
73
+ - lib/rri/r_converters/integer_converter.rb
74
+ - lib/rri/r_converters/string_converter.rb
75
+ - lib/rri/rexp.rb
76
+ - lib/rri/rri_exception.rb
77
+ - lib/rri/ruby_converters.rb
78
+ - lib/rri/ruby_converters/double_converter.rb
79
+ - lib/rri/ruby_converters/integer_converter.rb
80
+ - lib/rri/version.rb
81
+ - rri.gemspec
82
+ - spec/rri/engine_spec.rb
83
+ - spec/rri/r_converters/array_converter_spec.rb
84
+ - spec/rri/r_converters/float_converter_spec.rb
85
+ - spec/rri/r_converters/integer_converter_spec.rb
86
+ - spec/rri/r_converters/string_converter_spec.rb
87
+ - spec/rri/ruby_converters/double_converter.rb
88
+ - spec/rri/ruby_converters/integer_converter_spec.rb
89
+ - spec/rri_spec.rb
90
+ - spec/spec_helper.rb
91
+ has_rdoc: yard
92
+ homepage: http://rubygems.org/gems/rri
93
+ licenses:
94
+ - MIT
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 1.3.6
112
+ requirements: []
113
+
114
+ rubyforge_project: rri
115
+ rubygems_version: 1.6.2
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Ruby/R Interface for JRuby
119
+ test_files:
120
+ - spec/rri_spec.rb
121
+ - spec/rri/engine_spec.rb
122
+ - spec/rri/ruby_converters/integer_converter_spec.rb
123
+ - spec/rri/r_converters/array_converter_spec.rb
124
+ - spec/rri/r_converters/float_converter_spec.rb
125
+ - spec/rri/r_converters/integer_converter_spec.rb
126
+ - spec/rri/r_converters/string_converter_spec.rb