Skip to content

Commit 5f68b34

Browse files
committed
added download script for prerequisits libraries and updated info how to do it.
1 parent 4d75b2d commit 5f68b34

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

RubyScript/lib/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ Prerequisits
44
1. Download jruby-complete-x.x.x.jar from http://www.jruby.org/download and
55
place it in this directory.
66

7-
2. Download RSyntaxTextArea from https://github.com/bobbylight/RSyntaxTextArea,
8-
build it and place rsyntaxtextarea.jar in this directory.
7+
2. Download RSyntaxTextArea from [Maven Central repository](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.fifesoft%22%20AND%20a%3A%22rsyntaxtextarea%22).
8+
Or download sources from https://github.com/bobbylight/RSyntaxTextArea,
9+
build it and place rsyntaxtextarea.jar in this directory.
10+
11+
12+
Or simply run ./download.rb

RubyScript/lib/download.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env ruby
2+
3+
# coding: utf-8
4+
5+
require 'net/http'
6+
require 'rexml/document'
7+
8+
def download(url, fn)
9+
puts 'Downloading: ' + url
10+
uri = URI.parse(url)
11+
Net::HTTP.start(uri.host, uri.port,
12+
use_ssl: uri.scheme == 'https') do |http|
13+
request = Net::HTTP::Get.new uri
14+
15+
http.request request do |response|
16+
open fn, 'wb' do |io|
17+
i = 0
18+
response.read_body do |chunk|
19+
print '.' if (i += 1) % 10 == 0
20+
io.write chunk
21+
end
22+
end
23+
end
24+
end
25+
puts
26+
end
27+
28+
RSYNTAX_SRC = 'https://repo1.maven.org/maven2/com/fifesoft/rsyntaxtextarea/'
29+
MVN_DESCR = 'maven-metadata.xml'
30+
31+
doc = Net::HTTP.get(URI.parse(RSYNTAX_SRC + MVN_DESCR))
32+
@data = (REXML::Document.new doc).root
33+
version = @data.elements['//versioning/latest'].first.to_s
34+
download(RSYNTAX_SRC + version + '/' + "rsyntaxtextarea-#{version}.jar",
35+
'rsyntaxtextarea.jar')
36+
37+
VERSION = '9.0.0.0'
38+
JRUBY_SRC = 'https://s3.amazonaws.com/jruby.org/downloads/' \
39+
"#{VERSION}/jruby-bin-#{VERSION}.zip"
40+
jruby_zip = 'jruby.zip'
41+
42+
# File.write(jruby_zip, Net::HTTP.get(URI.parse(JRUBY_SRC)))
43+
44+
download JRUBY_SRC, jruby_zip
45+
`unzip -j #{jruby_zip} jruby-9.0.0.0/lib/jruby.jar`
46+
`rm #{jruby_zip}`

0 commit comments

Comments
 (0)