scicom 0.2.3.1-java → 0.3.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.
- checksums.yaml +4 -4
- data/config.rb +12 -5
- data/cran/AppliedPredictiveModeling.jar +0 -0
- data/cran/AppliedPredictiveModeling.xml +25 -0
- data/cran/AssetPricing.jar +0 -0
- data/cran/AssetPricing.xml +25 -0
- data/doc/SciCom.tex +4 -0
- data/doc/SciCom.tex~ +14 -0
- data/doc/hearder.aux +10 -0
- data/doc/hearder.log +655 -0
- data/doc/hearder.pdf +0 -0
- data/doc/hearder.synctex.gz +0 -0
- data/doc/hearder.tex +87 -0
- data/doc/hearder.tex~ +78 -0
- data/lib/JRubyR/download_url_to_file.rb +132 -0
- data/lib/JRubyR/package.rb +286 -0
- data/lib/JRubyR/renjin.rb +28 -1
- data/test/test_dataframe.rb +1 -2
- data/test/test_linear_model.rb +3 -0
- data/test/test_list.rb +1 -1
- data/test/test_package.rb +66 -0
- data/test/test_tmp.rb +5 -5
- data/test/test_vector.rb +3 -0
- data/version.rb +1 -1
- metadata +67 -8
- data/README.md~ +0 -290
data/doc/hearder.pdf
ADDED
Binary file
|
Binary file
|
data/doc/hearder.tex
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
% !TEX TS-program = pdflatex
|
2
|
+
% !TEX encoding = UTF-8 Unicode
|
3
|
+
|
4
|
+
% This is a simple template for a LaTeX document using the "article" class.
|
5
|
+
% See "book", "report", "letter" for other types of document.
|
6
|
+
|
7
|
+
\documentclass[11pt]{report} % use larger type; default would be 10pt
|
8
|
+
|
9
|
+
\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)
|
10
|
+
|
11
|
+
%%% Examples of Article customizations
|
12
|
+
% These packages are optional, depending whether you want the features they provide.
|
13
|
+
% See the LaTeX Companion or other references for full information.
|
14
|
+
|
15
|
+
%%% PAGE DIMENSIONS
|
16
|
+
\usepackage{geometry} % to change the page dimensions
|
17
|
+
\geometry{a4paper} % or letterpaper (US) or a5paper or....
|
18
|
+
% \geometry{margin=2in} % for example, change the margins to 2 inches all round
|
19
|
+
% \geometry{landscape} % set up the page for landscape
|
20
|
+
% read geometry.pdf for detailed page layout information
|
21
|
+
|
22
|
+
\usepackage{graphicx} % support the \includegraphics command and options
|
23
|
+
|
24
|
+
% \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
|
25
|
+
|
26
|
+
%%% PACKAGES
|
27
|
+
\usepackage{booktabs} % for much better looking tables
|
28
|
+
\usepackage{array} % for better arrays (eg matrices) in maths
|
29
|
+
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
|
30
|
+
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
|
31
|
+
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
|
32
|
+
% These packages are all incorporated in the memoir class to one degree or another...
|
33
|
+
|
34
|
+
\usepackage{color}
|
35
|
+
\usepackage{xcolor}
|
36
|
+
\usepackage{listings}
|
37
|
+
|
38
|
+
\usepackage{caption}
|
39
|
+
\DeclareCaptionFont{white}{\color{white}}
|
40
|
+
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
|
41
|
+
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
|
42
|
+
|
43
|
+
\lstset{
|
44
|
+
language=Ruby,
|
45
|
+
basicstyle=\small\sffamily,
|
46
|
+
numbers=left,
|
47
|
+
numberstyle=\tiny,
|
48
|
+
frame=tb,
|
49
|
+
columns=fullflexible,
|
50
|
+
showstringspaces=false
|
51
|
+
}
|
52
|
+
|
53
|
+
%%% HEADERS & FOOTERS
|
54
|
+
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
|
55
|
+
\pagestyle{fancy} % options: empty , plain , fancy
|
56
|
+
\renewcommand{\headrulewidth}{0pt} % customise the layout...
|
57
|
+
\lhead{}\chead{}\rhead{}
|
58
|
+
\lfoot{}\cfoot{\thepage}\rfoot{}
|
59
|
+
|
60
|
+
%%% SECTION TITLE APPEARANCE
|
61
|
+
\usepackage{sectsty}
|
62
|
+
\allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
|
63
|
+
% (This matches ConTeXt defaults)
|
64
|
+
|
65
|
+
%%% ToC (table of contents) APPEARANCE
|
66
|
+
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
|
67
|
+
\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
|
68
|
+
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
|
69
|
+
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!
|
70
|
+
|
71
|
+
\newcommand{\del}[1]{}
|
72
|
+
|
73
|
+
%%% END Article customizations
|
74
|
+
|
75
|
+
%%% The "real" document content comes below...
|
76
|
+
|
77
|
+
\title{SciCom Manual}
|
78
|
+
\author{Rodrigo Botafogo}
|
79
|
+
%\date{} % Activate to display a given date or no date (if empty),
|
80
|
+
% otherwise the current date is printed
|
81
|
+
|
82
|
+
\begin{document}
|
83
|
+
\maketitle
|
84
|
+
|
85
|
+
\input{SciCom.tex}
|
86
|
+
|
87
|
+
\end{document}
|
data/doc/hearder.tex~
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
% !TEX TS-program = pdflatex
|
2
|
+
% !TEX encoding = UTF-8 Unicode
|
3
|
+
|
4
|
+
% This is a simple template for a LaTeX document using the "article" class.
|
5
|
+
% See "book", "report", "letter" for other types of document.
|
6
|
+
|
7
|
+
\documentclass[11pt]{report} % use larger type; default would be 10pt
|
8
|
+
|
9
|
+
\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)
|
10
|
+
|
11
|
+
%%% Examples of Article customizations
|
12
|
+
% These packages are optional, depending whether you want the features they provide.
|
13
|
+
% See the LaTeX Companion or other references for full information.
|
14
|
+
|
15
|
+
%%% PAGE DIMENSIONS
|
16
|
+
\usepackage{geometry} % to change the page dimensions
|
17
|
+
\geometry{a4paper} % or letterpaper (US) or a5paper or....
|
18
|
+
% \geometry{margin=2in} % for example, change the margins to 2 inches all round
|
19
|
+
% \geometry{landscape} % set up the page for landscape
|
20
|
+
% read geometry.pdf for detailed page layout information
|
21
|
+
|
22
|
+
\usepackage{graphicx} % support the \includegraphics command and options
|
23
|
+
|
24
|
+
% \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
|
25
|
+
|
26
|
+
%%% PACKAGES
|
27
|
+
\usepackage{booktabs} % for much better looking tables
|
28
|
+
\usepackage{array} % for better arrays (eg matrices) in maths
|
29
|
+
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
|
30
|
+
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
|
31
|
+
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
|
32
|
+
% These packages are all incorporated in the memoir class to one degree or another...
|
33
|
+
|
34
|
+
\usepackage{color}
|
35
|
+
\usepackage{xcolor}
|
36
|
+
\usepackage{listings}
|
37
|
+
|
38
|
+
\usepackage{caption}
|
39
|
+
\DeclareCaptionFont{white}{\color{white}}
|
40
|
+
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
|
41
|
+
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
|
42
|
+
|
43
|
+
\lstset{
|
44
|
+
language=Ruby,
|
45
|
+
basicstyle=\small\sffamily,
|
46
|
+
numbers=left,
|
47
|
+
numberstyle=\tiny,
|
48
|
+
frame=tb,
|
49
|
+
columns=fullflexible,
|
50
|
+
showstringspaces=false
|
51
|
+
}
|
52
|
+
|
53
|
+
%%% HEADERS & FOOTERS
|
54
|
+
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
|
55
|
+
\pagestyle{fancy} % options: empty , plain , fancy
|
56
|
+
\renewcommand{\headrulewidth}{0pt} % customise the layout...
|
57
|
+
\lhead{}\chead{}\rhead{}
|
58
|
+
\lfoot{}\cfoot{\thepage}\rfoot{}
|
59
|
+
|
60
|
+
%%% SECTION TITLE APPEARANCE
|
61
|
+
\usepackage{sectsty}
|
62
|
+
\allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
|
63
|
+
% (This matches ConTeXt defaults)
|
64
|
+
|
65
|
+
%%% ToC (table of contents) APPEARANCE
|
66
|
+
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
|
67
|
+
\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
|
68
|
+
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
|
69
|
+
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!
|
70
|
+
|
71
|
+
%%% END Article customizations
|
72
|
+
|
73
|
+
%%% The "real" document content comes below...
|
74
|
+
|
75
|
+
\title{Brief Article}
|
76
|
+
\author{The Author}
|
77
|
+
%\date{} % Activate to display a given date or no date (if empty),
|
78
|
+
% otherwise the current date is printed
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Ruby script to download a number of files
|
4
|
+
# from individual URLs via HTTP/HTTPS/FTP
|
5
|
+
# specified in an external file.
|
6
|
+
#
|
7
|
+
# Author: Tobias Preuss
|
8
|
+
# Revision: 2013-04-18 16:26 +0100 UTC
|
9
|
+
# License: Creative Commons Attribution-ShareAlike 3.0 Unported
|
10
|
+
|
11
|
+
require 'net/http'
|
12
|
+
require 'net/ftp'
|
13
|
+
require 'uri'
|
14
|
+
require 'date'
|
15
|
+
|
16
|
+
|
17
|
+
def create_directory(dirname)
|
18
|
+
unless Dir.exists?(dirname)
|
19
|
+
Dir.mkdir(dirname)
|
20
|
+
else
|
21
|
+
puts "Skipping creating directory " + dirname + ". It already exists."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_uris_from_file(file)
|
26
|
+
uris = Array.new
|
27
|
+
File.open(file).each do |line|
|
28
|
+
line = line.strip
|
29
|
+
next if line == nil || line.length == 0
|
30
|
+
parts = line.split(' ')
|
31
|
+
pair = Hash[ [:resource, :filename].zip(parts) ]
|
32
|
+
uris.push(pair)
|
33
|
+
end
|
34
|
+
uris
|
35
|
+
end
|
36
|
+
|
37
|
+
def download_resource(resource, filename)
|
38
|
+
uri = URI.parse(resource)
|
39
|
+
case uri.scheme.downcase
|
40
|
+
when /http|https/
|
41
|
+
http_download_uri(uri, filename)
|
42
|
+
when /ftp/
|
43
|
+
ftp_download_uri(uri, filename)
|
44
|
+
else
|
45
|
+
puts "Unsupported URI scheme for resource " + resource + "."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def http_download_uri(uri, filename)
|
50
|
+
puts "Starting HTTP download for: " + uri.to_s
|
51
|
+
http_object = Net::HTTP.new(uri.host, uri.port)
|
52
|
+
http_object.use_ssl = true if uri.scheme == 'https'
|
53
|
+
begin
|
54
|
+
http_object.start do |http|
|
55
|
+
request = Net::HTTP::Get.new uri.request_uri
|
56
|
+
http.read_timeout = 500
|
57
|
+
http.request request do |response|
|
58
|
+
open filename, 'w' do |io|
|
59
|
+
response.read_body do |chunk|
|
60
|
+
io.write chunk
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue Exception => e
|
66
|
+
puts "=> Exception: '#{e}'. Skipping download."
|
67
|
+
return
|
68
|
+
end
|
69
|
+
puts "Stored download as " + filename + "."
|
70
|
+
end
|
71
|
+
|
72
|
+
def ftp_download_uri(uri, filename)
|
73
|
+
puts "Starting FTP download for: " + uri.to_s + "."
|
74
|
+
dirname = File.dirname(uri.path)
|
75
|
+
basename = File.basename(uri.path)
|
76
|
+
begin
|
77
|
+
Net::FTP.open(uri.host) do |ftp|
|
78
|
+
ftp.login
|
79
|
+
ftp.chdir(dirname)
|
80
|
+
ftp.getbinaryfile(basename)
|
81
|
+
end
|
82
|
+
rescue Exception => e
|
83
|
+
puts "=> Exception: '#{e}'. Skipping download."
|
84
|
+
return
|
85
|
+
end
|
86
|
+
puts "Stored download as " + filename + "."
|
87
|
+
end
|
88
|
+
|
89
|
+
def download_resources(pairs)
|
90
|
+
pairs.each do |pair|
|
91
|
+
filename = pair[:filename].to_s
|
92
|
+
resource = pair[:resource].to_s
|
93
|
+
unless File.exists?(filename)
|
94
|
+
download_resource(resource, filename)
|
95
|
+
else
|
96
|
+
puts "Skipping download for " + filename + ". It already exists."
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
def main
|
103
|
+
sources_file = ARGV.first
|
104
|
+
uris = read_uris_from_file(sources_file)
|
105
|
+
|
106
|
+
target_dir_name = Date.today.strftime('%y%m%d')
|
107
|
+
create_directory(target_dir_name)
|
108
|
+
Dir.chdir(target_dir_name)
|
109
|
+
puts "Changed directory: " + Dir.pwd
|
110
|
+
|
111
|
+
download_resources(uris)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
if __FILE__ == $0
|
116
|
+
usage = <<-EOU
|
117
|
+
|
118
|
+
usage: ruby #{File.basename($0)} sources.txt
|
119
|
+
|
120
|
+
The file sources.txt should contain an URL and the target file name.
|
121
|
+
The expected file format is:
|
122
|
+
|
123
|
+
http://www.domain.com/file target_file_name
|
124
|
+
ftp://www.domain.com/file target_file_name
|
125
|
+
|
126
|
+
EOU
|
127
|
+
|
128
|
+
abort usage if ARGV.length != 1
|
129
|
+
|
130
|
+
main
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# @author Rodrigo Botafogo
|
5
|
+
#
|
6
|
+
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
7
|
+
# and distribute this software and its documentation, without fee and without a signed
|
8
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
9
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
10
|
+
# distributions.
|
11
|
+
#
|
12
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
13
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
14
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
15
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
16
|
+
#
|
17
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
19
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
20
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
21
|
+
# OR MODIFICATIONS.
|
22
|
+
##########################################################################################
|
23
|
+
|
24
|
+
require 'net/http'
|
25
|
+
require 'state_machine'
|
26
|
+
require 'rexml/document'
|
27
|
+
require 'observer'
|
28
|
+
|
29
|
+
##########################################################################################
|
30
|
+
#
|
31
|
+
##########################################################################################
|
32
|
+
|
33
|
+
module MergeObservable
|
34
|
+
include Observable
|
35
|
+
|
36
|
+
alias_method :old_notify, :notify_observers
|
37
|
+
|
38
|
+
def add_new_observer(observer)
|
39
|
+
@new_observers ||= Array.new
|
40
|
+
@new_observers << observer
|
41
|
+
end
|
42
|
+
|
43
|
+
def merge_observers
|
44
|
+
@new_observers ||= Array.new
|
45
|
+
@new_observers.each do |obs|
|
46
|
+
self.add_observer(obs)
|
47
|
+
end
|
48
|
+
@new_observers = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def notify_observers(*args)
|
52
|
+
merge_observers
|
53
|
+
old_notify(*args)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
##########################################################################################
|
59
|
+
#
|
60
|
+
##########################################################################################
|
61
|
+
|
62
|
+
class PackageManager
|
63
|
+
|
64
|
+
##########################################################################################
|
65
|
+
# Class to parse the maven-metadata.xml file for package management
|
66
|
+
##########################################################################################
|
67
|
+
|
68
|
+
class ParseXML
|
69
|
+
include MergeObservable
|
70
|
+
|
71
|
+
#----------------------------------------------------------------------------------------
|
72
|
+
# Parse the input_file and send parsed events to the given state machine. Results should
|
73
|
+
# be stored in the output_dir
|
74
|
+
#----------------------------------------------------------------------------------------
|
75
|
+
|
76
|
+
def initialize(source)
|
77
|
+
@source = source
|
78
|
+
end
|
79
|
+
|
80
|
+
#----------------------------------------------------------------------------------------
|
81
|
+
# start parsing the file. This class will receive the events and redirect them to
|
82
|
+
# listeners
|
83
|
+
#----------------------------------------------------------------------------------------
|
84
|
+
|
85
|
+
def start
|
86
|
+
REXML::Document.parse_stream(@source, self)
|
87
|
+
end
|
88
|
+
|
89
|
+
#----------------------------------------------------------------------------------------
|
90
|
+
# This method is necessary do ignore parsing events that are of no interest to our
|
91
|
+
# parsing.
|
92
|
+
#----------------------------------------------------------------------------------------
|
93
|
+
|
94
|
+
def method_missing(*args)
|
95
|
+
# p args
|
96
|
+
end
|
97
|
+
|
98
|
+
#----------------------------------------------------------------------------------------
|
99
|
+
# Called when receiving a tag_start event
|
100
|
+
#----------------------------------------------------------------------------------------
|
101
|
+
|
102
|
+
def tag_start(name, attrs)
|
103
|
+
changed
|
104
|
+
notify_observers(:tag_start, name, attrs)
|
105
|
+
end
|
106
|
+
|
107
|
+
#----------------------------------------------------------------------------------------
|
108
|
+
# Called when receiving a tag_end event
|
109
|
+
#----------------------------------------------------------------------------------------
|
110
|
+
|
111
|
+
def tag_end(name)
|
112
|
+
changed
|
113
|
+
notify_observers(:tag_end, name, nil)
|
114
|
+
end
|
115
|
+
|
116
|
+
#----------------------------------------------------------------------------------------
|
117
|
+
#
|
118
|
+
#----------------------------------------------------------------------------------------
|
119
|
+
|
120
|
+
def text(text)
|
121
|
+
changed
|
122
|
+
notify_observers(:new_text, text, nil)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
##########################################################################################
|
128
|
+
#
|
129
|
+
##########################################################################################
|
130
|
+
|
131
|
+
#----------------------------------------------------------------------------------------
|
132
|
+
#
|
133
|
+
#----------------------------------------------------------------------------------------
|
134
|
+
|
135
|
+
def initialize
|
136
|
+
@properties = Hash.new
|
137
|
+
super
|
138
|
+
end
|
139
|
+
|
140
|
+
#----------------------------------------------------------------------------------------
|
141
|
+
# Machine starts in the metadata state.
|
142
|
+
#----------------------------------------------------------------------------------------
|
143
|
+
|
144
|
+
state_machine :state, initial: :metadata do
|
145
|
+
|
146
|
+
event :read_value do
|
147
|
+
transition :metadata => :reading
|
148
|
+
end
|
149
|
+
|
150
|
+
event :value_read do
|
151
|
+
transition :reading => :metadata
|
152
|
+
end
|
153
|
+
|
154
|
+
before_transition :on => :value_read, :do => :set_value
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
#----------------------------------------------------------------------------------------
|
159
|
+
#
|
160
|
+
#----------------------------------------------------------------------------------------
|
161
|
+
|
162
|
+
def set_value
|
163
|
+
@properties[@name] = @text
|
164
|
+
end
|
165
|
+
|
166
|
+
#----------------------------------------------------------------------------------------
|
167
|
+
#
|
168
|
+
#----------------------------------------------------------------------------------------
|
169
|
+
|
170
|
+
def tag_start(name, value)
|
171
|
+
@name = name
|
172
|
+
read_value
|
173
|
+
end
|
174
|
+
|
175
|
+
#----------------------------------------------------------------------------------------
|
176
|
+
#
|
177
|
+
#----------------------------------------------------------------------------------------
|
178
|
+
|
179
|
+
def tag_end(name)
|
180
|
+
value_read
|
181
|
+
end
|
182
|
+
|
183
|
+
#----------------------------------------------------------------------------------------
|
184
|
+
#
|
185
|
+
#----------------------------------------------------------------------------------------
|
186
|
+
|
187
|
+
def new_text(text)
|
188
|
+
@text = text
|
189
|
+
end
|
190
|
+
|
191
|
+
#----------------------------------------------------------------------------------------
|
192
|
+
#
|
193
|
+
#----------------------------------------------------------------------------------------
|
194
|
+
|
195
|
+
def update(type, name, attrs)
|
196
|
+
|
197
|
+
case type
|
198
|
+
when :tag_start
|
199
|
+
tag_start(name, attrs)
|
200
|
+
when :tag_end
|
201
|
+
tag_end(name)
|
202
|
+
when :new_text
|
203
|
+
new_text(name)
|
204
|
+
else
|
205
|
+
raise "Unknown type #{type}"
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
#----------------------------------------------------------------------------------------
|
211
|
+
#
|
212
|
+
#----------------------------------------------------------------------------------------
|
213
|
+
|
214
|
+
def http_download_uri(uri, filename)
|
215
|
+
puts "Starting HTTP download for: " + uri.to_s
|
216
|
+
http_object = Net::HTTP.new(uri.host, uri.port)
|
217
|
+
http_object.use_ssl = true if uri.scheme == 'https'
|
218
|
+
begin
|
219
|
+
http_object.start do |http|
|
220
|
+
request = Net::HTTP::Get.new uri.request_uri
|
221
|
+
http.read_timeout = 500
|
222
|
+
http.request request do |response|
|
223
|
+
open filename, 'wb' do |io|
|
224
|
+
response.read_body do |chunk|
|
225
|
+
io.write chunk
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
rescue Exception => e
|
231
|
+
puts "=> Exception: '#{e}'. Skipping download."
|
232
|
+
return
|
233
|
+
end
|
234
|
+
puts "Stored download as " + filename + "."
|
235
|
+
end
|
236
|
+
|
237
|
+
#----------------------------------------------------------------------------------------
|
238
|
+
# Installs a new package
|
239
|
+
#----------------------------------------------------------------------------------------
|
240
|
+
|
241
|
+
def load_package(name)
|
242
|
+
|
243
|
+
# create the cran_dir if it does not already exists
|
244
|
+
Dir.mkdir(SciCom.cran_dir) if !Dir.exists?(SciCom.cran_dir)
|
245
|
+
|
246
|
+
# download address for Renjin packages
|
247
|
+
renjin_cran = 'http://nexus.bedatadriven.com/content/groups/public/org/renjin/cran/'
|
248
|
+
|
249
|
+
package = renjin_cran + name
|
250
|
+
spec = package + "/" + "maven-metadata.xml"
|
251
|
+
# read the maven-metadata specification
|
252
|
+
uri = URI(spec)
|
253
|
+
|
254
|
+
# parse the maven-metadata file
|
255
|
+
parse = ParseXML.new(Net::HTTP.get(uri))
|
256
|
+
parse.add_observer(self)
|
257
|
+
parse.start
|
258
|
+
|
259
|
+
download_dir = package + '/' + @properties['latest']
|
260
|
+
spec2 = download_dir + '/' + "maven-metadata.xml"
|
261
|
+
|
262
|
+
# parse the second maven-metadata file
|
263
|
+
uri = URI(spec2)
|
264
|
+
# download the spec file, so we know what version is actually installed
|
265
|
+
http_download_uri(uri, SciCom.cran_dir + "/#{name}.xml")
|
266
|
+
|
267
|
+
# need to clear the properties. If the file has multiple properties with the same
|
268
|
+
# name, then only the last one will be kept. This might be a problem, but for
|
269
|
+
# now this does not seem to matter... We are only interested in the 'value'
|
270
|
+
# property that seems to always be the same for the 'pom' and 'jar' files.
|
271
|
+
@properties.clear
|
272
|
+
parse = ParseXML.new(Net::HTTP.get(uri))
|
273
|
+
parse.add_observer(self)
|
274
|
+
parse.start
|
275
|
+
|
276
|
+
filename = '/' + name + '-' + @properties['value'] + ".jar"
|
277
|
+
|
278
|
+
download_file = download_dir + filename
|
279
|
+
target_file = SciCom.cran_dir + '/' + name + ".jar"
|
280
|
+
|
281
|
+
uri = URI.parse(download_file)
|
282
|
+
http_download_uri(uri, target_file)
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|