scicom 0.3.0-java → 0.4.0-java

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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +239 -55
  3. data/Rakefile +58 -5
  4. data/config.rb +34 -2
  5. data/doc/Array.html +153 -0
  6. data/doc/Java/OrgRenjinSexp/LogicalArrayVector.html +120 -0
  7. data/doc/Java/OrgRenjinSexp/StringArrayVector.html +133 -0
  8. data/doc/Java/RbScicom/MDDoubleVector.html +133 -0
  9. data/doc/MDArray.html +153 -0
  10. data/doc/MergeObservable.html +347 -0
  11. data/doc/NegRange.html +166 -0
  12. data/doc/PackageManager.html +823 -0
  13. data/doc/PackageManager/ParseXML.html +595 -0
  14. data/doc/Range.html +243 -0
  15. data/doc/Renjin.html +2210 -0
  16. data/doc/Renjin/Attributes.html +401 -0
  17. data/doc/Renjin/Closure.html +181 -0
  18. data/doc/Renjin/ComplexVector.html +557 -0
  19. data/doc/Renjin/DataFrame.html +258 -0
  20. data/doc/Renjin/Environment.html +279 -0
  21. data/doc/Renjin/Function.html +243 -0
  22. data/doc/Renjin/Index.html +628 -0
  23. data/doc/Renjin/List.html +398 -0
  24. data/doc/Renjin/Logical.html +352 -0
  25. data/doc/Renjin/Primitive.html +181 -0
  26. data/doc/Renjin/RBSexp.html +1151 -0
  27. data/doc/Renjin/RubySexp.html +498 -0
  28. data/doc/Renjin/Vector.html +3163 -0
  29. data/doc/RinRuby.html +2079 -0
  30. data/doc/_index.html +365 -0
  31. data/doc/class_list.html +58 -0
  32. data/doc/css/common.css +1 -0
  33. data/doc/css/full_list.css +57 -0
  34. data/doc/css/style.css +339 -0
  35. data/doc/file.README.html +159 -0
  36. data/doc/file_list.html +60 -0
  37. data/doc/frames.html +26 -0
  38. data/doc/index.html +159 -0
  39. data/doc/js/app.js +219 -0
  40. data/doc/js/full_list.js +181 -0
  41. data/doc/js/jquery.js +4 -0
  42. data/doc/method_list.html +939 -0
  43. data/doc/top-level-namespace.html +679 -0
  44. data/lib/JRubyR/attributes.rb +5 -2
  45. data/lib/JRubyR/callback.rb +115 -0
  46. data/lib/JRubyR/environment.rb +0 -1
  47. data/lib/JRubyR/indexed.rb +139 -0
  48. data/lib/JRubyR/list.rb +0 -16
  49. data/lib/JRubyR/logical_value.rb +0 -1
  50. data/lib/JRubyR/rbsexp.rb +20 -131
  51. data/lib/JRubyR/renjin.rb +201 -71
  52. data/lib/JRubyR/vector.rb +16 -15
  53. data/lib/scicom.rb +1 -3
  54. data/target/helper.jar +0 -0
  55. data/test/test_R_interface.rb +1 -1
  56. data/test/test_array.rb +1 -1
  57. data/test/test_assign_mdarray.rb +1 -1
  58. data/test/test_assign_mdarray_2d.rb +1 -1
  59. data/test/test_assign_mdarray_3d.rb +1 -1
  60. data/test/test_attributes.rb +1 -1
  61. data/test/test_basic.rb +7 -5
  62. data/test/test_callback.rb +176 -0
  63. data/test/test_complete.rb +1 -1
  64. data/test/test_creation.rb +29 -5
  65. data/test/test_dataframe.rb +1 -1
  66. data/test/test_factor.rb +1 -1
  67. data/test/test_functions.rb +13 -10
  68. data/test/test_linear_model.rb +1 -1
  69. data/test/test_list.rb +49 -10
  70. data/test/test_matrix.rb +6 -6
  71. data/test/test_operators.rb +1 -1
  72. data/test/test_package.rb +5 -5
  73. data/test/test_vector.rb +13 -7
  74. data/vendor/aether-api-1.0.2.v20150114.jar +0 -0
  75. data/vendor/aether-connector-basic-1.0.2.v20150114.jar +0 -0
  76. data/vendor/aether-impl-1.0.2.v20150114.jar +0 -0
  77. data/vendor/aether-spi-1.0.2.v20150114.jar +0 -0
  78. data/vendor/aether-transport-file-1.0.2.v20150114.jar +0 -0
  79. data/vendor/aether-transport-http-1.0.2.v20150114.jar +0 -0
  80. data/vendor/aether-util-1.0.2.v20150114.jar +0 -0
  81. data/vendor/aopalliance-1.0.jar +0 -0
  82. data/vendor/asm-3.3.1.jar +0 -0
  83. data/vendor/asm-5.0.4.jar +0 -0
  84. data/vendor/asm-commons-5.0.4.jar +0 -0
  85. data/vendor/asm-tree-5.0.4.jar +0 -0
  86. data/vendor/asm-util-5.0.4.jar +0 -0
  87. data/vendor/blas-0.8.jar +0 -0
  88. data/vendor/cdi-api-1.0.jar +0 -0
  89. data/vendor/codemodel-2.6.jar +0 -0
  90. data/vendor/collections-generic-4.01.jar +0 -0
  91. data/vendor/commons-codec-1.6.jar +0 -0
  92. data/vendor/commons-compress-1.4.1.jar +0 -0
  93. data/vendor/commons-logging-1.1.1.jar +0 -0
  94. data/vendor/commons-math-2.2.jar +0 -0
  95. data/vendor/commons-vfs2-2.0.jar +0 -0
  96. data/vendor/datasets-0.8.1891.jar +0 -0
  97. data/vendor/f2jutil-0.8.jar +0 -0
  98. data/vendor/gcc-runtime-0.8.1891.jar +0 -0
  99. data/vendor/grDevices-0.8.1891.jar +0 -0
  100. data/vendor/graphics-0.8.1891.jar +0 -0
  101. data/vendor/guava-17.0.jar +0 -0
  102. data/vendor/httpclient-4.2.6.jar +0 -0
  103. data/vendor/httpcore-4.2.5.jar +0 -0
  104. data/vendor/javax.inject-1.jar +0 -0
  105. data/vendor/jcl-over-slf4j-1.6.2.jar +0 -0
  106. data/vendor/joda-time-2.0.jar +0 -0
  107. data/vendor/jsr250-api-1.0.jar +0 -0
  108. data/vendor/jtransforms-2.4.jar +0 -0
  109. data/vendor/jung-api-2.0.1.jar +0 -0
  110. data/vendor/jung-graph-impl-2.0.1.jar +0 -0
  111. data/vendor/lapack-0.8.jar +0 -0
  112. data/vendor/maven-aether-provider-3.1.0.jar +0 -0
  113. data/vendor/maven-model-3.1.0.jar +0 -0
  114. data/vendor/maven-model-builder-3.1.0.jar +0 -0
  115. data/vendor/maven-repository-metadata-3.1.0.jar +0 -0
  116. data/vendor/maven-scm-api-1.4.jar +0 -0
  117. data/vendor/maven-scm-provider-svn-commons-1.4.jar +0 -0
  118. data/vendor/maven-scm-provider-svnexe-1.4.jar +0 -0
  119. data/vendor/maven-settings-3.1.0.jar +0 -0
  120. data/vendor/maven-settings-builder-3.1.0.jar +0 -0
  121. data/vendor/methods-0.8.1891.jar +0 -0
  122. data/vendor/netlib-java-0.9.3-renjin-patched-2.jar +0 -0
  123. data/vendor/org.eclipse.sisu.inject-0.0.0.M2a.jar +0 -0
  124. data/vendor/org.eclipse.sisu.plexus-0.0.0.M2a.jar +0 -0
  125. data/vendor/plexus-cipher-1.4.jar +0 -0
  126. data/vendor/plexus-classworlds-2.4.jar +0 -0
  127. data/vendor/plexus-component-annotations-1.5.5.jar +0 -0
  128. data/vendor/plexus-interpolation-1.16.jar +0 -0
  129. data/vendor/plexus-sec-dispatcher-1.3.jar +0 -0
  130. data/vendor/plexus-utils-1.5.6.jar +0 -0
  131. data/vendor/plexus-utils-3.0.10.jar +0 -0
  132. data/vendor/regexp-1.3.jar +0 -0
  133. data/vendor/renjin-aether-package-loader-0.8.1891.jar +0 -0
  134. data/vendor/renjin-appl-0.8.1891.jar +0 -0
  135. data/vendor/renjin-core-0.8.1891.jar +0 -0
  136. data/vendor/renjin-gnur-runtime-0.8.1891.jar +0 -0
  137. data/vendor/renjin-script-engine-0.8.1891.jar +0 -0
  138. data/vendor/sisu-guice-3.1.0-no_aop.jar +0 -0
  139. data/vendor/slf4j-api-1.6.2.jar +0 -0
  140. data/vendor/stats-0.8.1891.jar +0 -0
  141. data/vendor/utils-0.8.1891.jar +0 -0
  142. data/vendor/xerbla-0.8.jar +0 -0
  143. data/vendor/xz-1.0.jar +0 -0
  144. data/version.rb +1 -1
  145. metadata +229 -127
  146. data/cran/AppliedPredictiveModeling.jar +0 -0
  147. data/cran/AppliedPredictiveModeling.xml +0 -25
  148. data/cran/AssetPricing.jar +0 -0
  149. data/cran/AssetPricing.xml +0 -25
  150. data/lib/env.rb +0 -12
  151. data/lib/rinruby.rb +0 -795
  152. data/test/env.rb +0 -2
  153. data/test/test_tmp.rb +0 -67
  154. data/vendor/Renjin.pdf +0 -0
  155. data/vendor/renjin-script-engine-0.7.0-RC7-SNAPSHOT-jar-with-dependencies.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3591845889915f7a4faf6057a3cb94d2bc773ff2
4
- data.tar.gz: 25c6212971ec9b0a10a4397b99baa9cacc738a60
3
+ metadata.gz: 3ffc1bffa5d865e5df2c6843e4b016b34f283209
4
+ data.tar.gz: 362146cc4e463467e0d90c1758255c0bc97b9f9a
5
5
  SHA512:
6
- metadata.gz: 586f7a124a3fb21de912aa50a34e6a32cf3eaf041f4a38acca8eadf86f345aee216a0695832b2981fed8c57329498c1adca2f52d4f030c0e3dc4dd7a629a8c01
7
- data.tar.gz: cf0541cd4b4b02c3ffe4563547a82aac573943185668dbf7ffb29c7f1a52ddf5f2a7a3260a568a99e81a57bbf9c5a60bbe3485faa7a41fbb3a37d14e50e44e84
6
+ metadata.gz: f8d3a2b9b0d447b888b3cef294b21de6f085a5f199f38c7a295234b4eb02c8c32abcbb1ba6d42cbdac65f6b79e630ed7051836b64008f75779296378c3d63874
7
+ data.tar.gz: 1b7717cec680c29aa20579f7d4d62a37e3965272bcaadbf99d8c6563e833b873a6141b739283186c286e45127fcceb3c4a6ac98308f1063d7bccf111f7cdacde
data/README.md CHANGED
@@ -1,74 +1,258 @@
1
- Announcement
2
- ============
1
+ ## SciCom with Standard R Interface
3
2
 
4
- SciCom (Scientific Computing) for Ruby brings the power of R to the Ruby community. SciCom
5
- is based on Renjin, a JVM-based interpreter for the R language for statistical computing.
3
+ SciCom allows R programmers to use R commands inside a Ruby script in
4
+ a way similar to RinRuby by calling method eval and passing to it an R
5
+ script:
6
6
 
7
- R on the JVM
8
- ------------
7
+ # Basic integration with R can always be done by calling eval and passing it a valid
8
+ # R expression.
9
+ > R.eval("r.i = 10L")
10
+ > R.eval("print(r.i)")
9
11
 
10
- Over the past two decades, the R language for statistical computing has emerged as the de
11
- facto standard for analysts, statisticians, and scientists. Today, a wide range of
12
- enterprises – from pharmaceuticals to insurance – depend on R for key business uses. Renjin
13
- is a new implementation of the R language and environment for the Java Virtual Machine (JVM),
14
- whose goal is to enable transparent analysis of big data sets and seamless integration with
15
- other enterprise systems such as databases and application servers.
12
+ [1] 10
16
13
 
17
- Renjin is still under development, but it is already being used in production for a number
18
- of client projects, and supports most CRAN packages, including some with C/Fortran
19
- dependencies.
14
+ > R.eval("vec = c(10, 20, 30, 40, 50)")
15
+ > R.eval("print(vec)")
20
16
 
21
- SciCom and Renjin
22
- -----------------
17
+ [1] 10 20 30 40 50
23
18
 
24
- SciCom integrates with Renjin and allows the use of R inside a Ruby script. In a sense,
25
- SciCom is similar to other solutions such as RinRuby, Rpy2, PipeR, etc. However, since
26
- SciCom and Renjin both target the JVM there is no need to integrate both solutions and
27
- there is no need to send data between Ruby and R, as it all resides in the same JVM.
28
- Further, installation of SciCom does not require the installation of GNU R; Renjin is the
29
- interpreter and comes with SciCom. Finally, although SciCom provides a basic interface to
30
- Renjin similar to RinRuby, a much tighter integration is also possible.
19
+ > R.eval("print(vec[1])")
31
20
 
32
- SciCom and Renjin Limitations
33
- ------------------------------
21
+ [1] 10
34
22
 
35
- Renjin is in development and still has some limitations
23
+ Programmers can also use here docs to integrate an R script inside a
24
+ Ruby script. The next example show a model for predicting baseball
25
+ wins based on runs allowed and runs scored. The data comes from
26
+ Baseball-Reference.com.
36
27
 
37
- + Renjin does not allow dynamic loading of libaries. My understanding is that Renjin
38
- developers are actually working on a new version on which loading of libraries will be
39
- possible.
40
- + Renjin does not implement any of the graphical libaries such as plot or ggplot. We
41
- hope that this limitation will be solved not by implementing those libraries but by the
42
- use of Ruby libraries from SciRuby such as NyaPlot (https://github.com/domitry/nyaplot)
43
- or daru (https://github.com/v0dro/daru).
28
+ R.eval <<EOF
44
29
 
45
- What´s new:
46
- ===========
30
+ # This dataset comes from Baseball-Reference.com.
31
+ baseball = read.csv("baseball.csv")
32
+ # str has a bug in Renjin
33
+ # str(data)
47
34
 
48
- This version includes integration of MDArray and SciCom.
35
+ # Lets look at the data available for Momeyball.
36
+ moneyball = subset(baseball, Year < 2002)
49
37
 
38
+ # Let's see if we can predict the number of wins, by lookin at
39
+ # runs allowed (RA) and runs scored (RS). RD is the runs difference.
40
+ # We are making a linear model from predicting wins (W) based on RD
41
+ moneyball$RD = moneyball$RS - moneyball$RA
42
+ WinsReg = lm(W ~ RD, data=moneyball)
43
+ print(summary(WinsReg))
50
44
 
51
- SciCom installation and download:
52
- ==================================
45
+ EOF
53
46
 
54
- + Install Jruby
55
- + jruby –S gem install scicom
47
+ The output of the program above is:
56
48
 
57
- SciCom Homepages:
58
- ==================
49
+ Call:
50
+ lm(data = moneyball, formula = W ~ RD)
59
51
 
60
- + http://rubygems.org/gems/scicom
61
- + https://github.com/rbotafogo/scicom/wiki
52
+ Residuals:
53
+ Min 1Q Median 3Q Max
54
+ -14,266 -2,651 0,123 2,936 11,657
62
55
 
63
- Contributors:
64
- =============
65
- Contributors are welcome.
56
+ Coefficients:
57
+ Estimate Std. Error t value Pr(>|t|)
58
+ (Intercept) 80,881 0,131 616,675 <0 ***
59
+ RD 0,106 0,001 81,554 <0 ***
60
+ ---
61
+ Signif. codes: 0 '***' 0,001 '**' 0,01 '*' 0,05 '.' 0,1 ' ' 1
66
62
 
67
- SciCom History:
68
- ================
63
+ Residual standard error: 3,939 on 900 degrees of freedom
64
+ Multiple R-squared: 0,8808, Adjusted R-squared: 0,8807
65
+ F-statistic: 6.650,9926 on 1 and 900 DF, p-value: < 0
66
+
67
+ ## The SciCom “language”
68
+
69
+ SciCom also allows for implementing R scripts in a “language” that is
70
+ just like Ruby, so that the developer does not need to know that she
71
+ is actually writing an R script. All R methods are accessible through
72
+ an R namespace.
73
+
74
+ The next script is the same baseball model done in R above using
75
+ SciCom ‘language’:
76
+
77
+ require ‘scicom’
78
+ # This dataset comes from Baseball-Reference.com.
79
+ baseball = R.read__csv("baseball.csv")
80
+ # Lets look at the data available for Momeyball.
81
+ moneyball = baseball.subset(baseball.Year < 2002)
82
+
83
+ # Let's see if we can predict the number of wins, by looking at
84
+ # runs allowed (RA) and runs scored (RS). RD is the runs difference.
85
+ # We are making a linear model for predicting wins (W) based on RD
86
+ moneyball.RD = moneyball.RS - moneyball.RA
87
+ wins_reg = R.lm("W ~ RD", data: moneyball)
88
+ wins_reg.summary.pp
89
+
90
+ We show bellow an example of calculating the correlation matrix
91
+ without using the build-in functions. First this is done in an R
92
+ script and then using SciCom:
93
+
94
+ # Create a matrix and give it rownames and colnames
95
+ set.seed(42)
96
+ Xij <- matrix(sample(seq(0, 9), 40, replace = TRUE), ncol = 4)
97
+ rownames(Xij) <- paste("S", seq(1, dim(Xij)[1]), sep = "")
98
+ colnames(Xij) <- paste("V", seq(1, dim(Xij)[2]), sep = "")
99
+
100
+ # find the means of the columns
101
+ n <- dim(Xij)[1]
102
+ one <- rep(1, n)
103
+ X.means <- t(one) %*% Xij/n
104
+
105
+ # find the covariance of the matrix
106
+ X.diff <- Xij - one %*% X.means
107
+ X.cov <- t(X.diff) %*% X.diff/(n - 1)
108
+ round(X.cov, 2)
109
+
110
+ # find the correlation
111
+ sdi <- diag(1/sqrt(diag(X.cov)))
112
+ rownames(sdi) <- colnames(sdi) <- colnames(X.cov)
113
+ round(sdi, 2)
114
+ X.cor <- sdi %*% X.cov %*% sdi
115
+ rownames(X.cor) <- colnames(X.cor) <- colnames(X.cov)
116
+ round(X.cor, 2)
117
+
118
+ Now the same code using SciCom
119
+
120
+ require ‘scicom’
121
+ # Create a matrix and give it rownames and colnames
122
+ R.set__seed(42)
123
+ R.seq(0,9).sample(40, replace: TRUE).matrix(ncol: 4)
124
+ .fassign(:rownames, R.paste("S", R.seq(1, xij.attr.dim[1]), sep: ""))
125
+ .fassign(:colnames, R.paste("V", R.seq(1, xij.attr.dim[2]), sep: ""))
126
+
127
+ # find the means of the columns
128
+ n = xij.dim[1]
129
+ one = R.rep(1, n)
130
+ x_means = one.t._ :*, xij/n
131
+
132
+ # find the covariance of the matrix
133
+ x_diff = xij - (one._ :*, x_means)
134
+ x_cov = (x_diff.t._ :*, x_diff/(n - 1)).round(2)
135
+
136
+ # find the correlation
137
+ sdi = (1 / x_cov.diag.sqrt).diag.round(2)
138
+ sdi.fassign(:rownames, x_cov.rownames)
139
+ sdi.fassign(:colnames, x_cov.colnames)
140
+ x_cor = ((sdi._ :*, x_cov)._ :*, sdi)
141
+ .round(2)
142
+ .fassign(:rownames, x_cov.rownames)
143
+ .fassign(:colnames, x_cov.colnames)
144
+
145
+ As another example, here is a SciCom script to print the number of
146
+ days for every month is 2005:
147
+
148
+ require ‘scicom’
149
+ everyday = R.seq(from: R.as__Date('2005-1-1'), to: R.as__Date('2005-12-31'), by: 'day')
150
+ cmonth = everyday.format('%b')
151
+ cmonth
152
+ .factor(levels: cmonth.unique, ordered: TRUE)
153
+ .table
154
+ .pp
155
+
156
+ As can be seen from these examples, R methods can be accessed through
157
+ the R namespace in SciCom, so, R method ‘seq’ is called in SciCom as
158
+ ‘R.seq’. R methods that are applied on objects can be called in two
159
+ ways, either using the R namespace as in ‘R.factor’ or directly on the
160
+ object, as in this case we did ‘cmonth.factor’. This last example
161
+ shows how SciCom allows method chaining, which is not possible in an R
162
+ script.
163
+
164
+ ## R Functions
165
+
166
+ SciCom allows programmers to access any R function in the R namespace. For instance, as shown
167
+ above, function _c_ in R can be access in SciCom by a call to R.c. As another example,
168
+ method _seq_ in R is accessed in SciCom by a call to R.seq.
169
+
170
+ Parameters can be passed to R functions normaly. For example, the code bellow creates a vector
171
+ with with doubles:
172
+
173
+ > vec = R.c(2.4, 5.55, 10, 18.27, 34.45)
174
+ > vec.pp
175
+
176
+ [1] 2,4 5,55 10 18,27 34,45
177
+
178
+ Ruby variable can also be passed as arguments to R methods:
179
+
180
+ > vec2 = R.c(vec, 3.5)
181
+ > vec2.pp
182
+
183
+ [1] 2,4 5,55 10 18,27 34,45 3,5
184
+
185
+ > dbl = 3.5
186
+ > vec3 = R.c(vec2, dbl)
187
+ > vec3.pp
188
+
189
+ [1] 2,4 5,55 10 18,27 34,45 3,5 5,75
190
+
191
+ More complex Ruby classes, such ar Ruby hashes, of course, cannot be passed as argument to R
192
+ methods. SciCom, in principle, should support every Ruby method that is available in
193
+ Renjin. Note that Renjin is still under development and not all methods and libraries are
194
+ available.
195
+
196
+ Some methods and variables in R have a '.' in their names. This is standard R notation;
197
+ however, '.' in Ruby is interpreted as a method call and thus cannot be part of a
198
+ variable name or function. In order to access names in R that have a '.' on them
199
+ in SciCom, the '.' is substituted by '__':
200
+
201
+ > # variable defined in R with a '.' in the name
202
+ > R.eval("r.d = 10.35")
203
+ > # access the variable 'r.d' in Ruby by using '__' notation
204
+ > R.r__d.pp
205
+
206
+ [1] 10,35
207
+
208
+ Accessing method _as.complex_ in R is also done by using '__' notation:
209
+
210
+ # acess R method 'as.complex' using 'as__complex' notation
211
+ > comp = R.as__complex(-1)
212
+ > p R.Re(comp).gz
213
+
214
+ -1.0
215
+
216
+ > p R.Im(comp).gz
217
+
218
+ 0.0
219
+
220
+ > # now method 'is.complex'
221
+ > p R.is__complex(comp).gt
222
+
223
+ true
224
+
225
+ ### Method Chaining
226
+
227
+ SciCom allows methods to be chained. The code above can be written as:
228
+
229
+ # prints the real part of a complex number by using method chaining
230
+ > R.as__complex(-1)
231
+ .Re
232
+ .pp
233
+
234
+ [1] -1
235
+
236
+ We will see more examples of method chaining later in this documentation.
237
+ In principle, we will try to use method chaining whenever possible, but
238
+ in some situations normal use of R methods through the 'R.' notation will
239
+ be used to remind the reader that this notation is also possible.
240
+
241
+ ### Named Parameters
242
+
243
+ R allows the use of named parameters in function calls. SciCom also allows
244
+ for named parameters. Named parameters in SciCom require the use of
245
+ Ruby hashes in the normal Ruby way.
246
+
247
+ > # R code to create a complex number
248
+ > R.eval("comp = complex(real = 0, imaginary = 1)")
249
+ > R.eval("print(comp)")
250
+
251
+ [0.0+1.0i]
252
+
253
+ > # Same code as above in SciCom notation, with chaining
254
+ > R.complex(real: 0, imaginary: 1)
255
+ > .pp
256
+
257
+ [0.0+1.0i]
69
258
 
70
- + 30/Dec/2014: Version 0.2.3 - Integration with MDArray
71
- + 19/Nov/2014: Version 0.2.2 - Printing in Jirb
72
- + 17/Nov/2014: Version 0.2.1 - Added MDArray dependency
73
- + 17/Nov/2014: Version 0.2.0 - Most R functionality available to SciCom
74
- + 21/Jul/2014: Version 0.0.1 - Initial release
data/Rakefile CHANGED
@@ -1,14 +1,67 @@
1
+ require 'rbconfig'
1
2
  require 'rake/testtask'
2
- require_relative 'version'
3
+ require 'jars/installer'
4
+ require 'jars/classpath'
5
+ require 'rake/javaextensiontask'
6
+
7
+ require './version'
8
+
9
+ $env = `uname -o`.strip
10
+ $mdarray = `bundle show mdarray`.strip
11
+ # $mdarray_vendor = "#{$mdarray}/vendor/"
12
+
13
+ ##########################################################################################
14
+ # Prepare environment to work inside Cygwin
15
+ ##########################################################################################
16
+
17
+ if $env == 'Cygwin'
18
+
19
+ #---------------------------------------------------------------------------------------
20
+ # Return the cygpath (windows format) of a path in POSIX format, i.e., /home/...
21
+ #---------------------------------------------------------------------------------------
22
+
23
+ def set_path(path)
24
+ `cygpath -a -w #{path}`.tr("\n", "")
25
+ end
26
+
27
+ else
28
+
29
+ #---------------------------------------------------------------------------------------
30
+ # Return the given path. When not in cygwin then just use the given path
31
+ #---------------------------------------------------------------------------------------
32
+
33
+ def set_path(path)
34
+ path
35
+ end
36
+
37
+ end
38
+ ##########################################################################################
39
+
40
+ # $mdarray_path = set_path($mdarray_vendor)
41
+
42
+ # p "#{$mdarray_path}"
43
+ # p Dir.entries("#{$mdarray_path}")
44
+ # p FileList["#{$mdarray_path}/*.jar"]
3
45
 
4
46
  name = "#{$gem_name}-#{$version}.gem"
5
47
 
6
- rule '.class' => '.java' do |t|
7
- sh "javac #{t.source}"
48
+ task :install_jars do
49
+ Jars::JarInstaller.new.vendor_jars
50
+ end
51
+
52
+ Rake::JavaExtensionTask.new("scicom") do |ext|
53
+ jruby_home = RbConfig::CONFIG['prefix']
54
+ # ext.ext_dir = 'ext/java'
55
+ # ext.lib_dir = 'lib/nokogiri'
56
+ # jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
57
+ # jars = FileList["#{$mdarray_path}/*.jar"]
58
+ jars = FileList['vendor/*.jar']
59
+ ext.classpath = jars.map { |x| File.expand_path x }.join ':'
60
+ # ext.debug = true if ENV['JAVA_DEBUG']
8
61
  end
9
62
 
10
- desc 'default task'
11
- task :default => [:install_gem]
63
+ desc 'compile java files'
64
+ Rake::JavaExtensionTask.new("scicom")
12
65
 
13
66
  desc 'Makes a Gem'
14
67
  task :make_gem do
data/config.rb CHANGED
@@ -1,5 +1,19 @@
1
1
  require 'rbconfig'
2
+ require 'java'
3
+
4
+ #
5
+ # In principle should not be in this file. The right way of doing this is by executing
6
+ # bundler exec, but I don't know how to do this from inside emacs. So, should comment
7
+ # the next line before publishing the GEM. If not commented, this should be harmless
8
+ # anyway.
9
+ #
10
+
11
+ begin
12
+ require 'bundler/setup'
13
+ rescue LoadError
14
+ end
2
15
 
16
+ =begin
3
17
  ##########################################################################################
4
18
  # Configuration. Remove setting before publishing Gem.
5
19
  ##########################################################################################
@@ -8,14 +22,15 @@ require 'rbconfig'
8
22
  $DVLP = true
9
23
 
10
24
  # Set to 'cygwin' when in cygwin
11
- # $ENV = 'cygwin'
25
+ $ENV = 'cygwin'
12
26
 
13
27
  # Set development dependency: those are gems that are also in development and thus not
14
28
  # installed in the gem directory. Need a way of accessing them if we are in development
15
29
  # otherwise gem install will install the dependency
16
30
  if $DVLP
17
- $DEPEND=["MDArray"]
31
+ $DEPEND=["SciCom", "MDArray"]
18
32
  end
33
+ =end
19
34
 
20
35
  ##########################################################################################
21
36
 
@@ -36,6 +51,7 @@ end
36
51
  else 'default'
37
52
  end
38
53
 
54
+ =begin
39
55
  #---------------------------------------------------------------------------------------
40
56
  # Add path to load path
41
57
  #---------------------------------------------------------------------------------------
@@ -77,6 +93,7 @@ else
77
93
  end
78
94
 
79
95
  end
96
+ =end
80
97
 
81
98
  #---------------------------------------------------------------------------------------
82
99
  # Set the project directories
@@ -124,6 +141,7 @@ class SciCom
124
141
 
125
142
  end
126
143
 
144
+ =begin
127
145
  #---------------------------------------------------------------------------------------
128
146
  # Set dependencies
129
147
  #---------------------------------------------------------------------------------------
@@ -166,5 +184,19 @@ if ($DVLP == true)
166
184
 
167
185
  end
168
186
 
187
+
169
188
  # Add cran directory to the $LOAD_PATH search path
170
189
  mklib(SciCom.cran_dir, false)
190
+ =end
191
+
192
+ ##########################################################################################
193
+ # Load necessary jar files
194
+ ##########################################################################################
195
+
196
+ Dir["#{SciCom.vendor_dir}/*.jar"].each do |jar|
197
+ require jar
198
+ end
199
+
200
+ Dir["#{SciCom.target_dir}/*.jar"].each do |jar|
201
+ require jar
202
+ end
OSZAR »