Skip to content

Commit f8eac62

Browse files
committed
download script: small refactoring
1 parent 5f68b34 commit f8eac62

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

RubyScript/lib/download.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
def download(url, fn)
99
puts 'Downloading: ' + url
1010
uri = URI.parse(url)
11+
1112
Net::HTTP.start(uri.host, uri.port,
1213
use_ssl: uri.scheme == 'https') do |http|
1314
request = Net::HTTP::Get.new uri
1415

1516
http.request request do |response|
1617
open fn, 'wb' do |io|
17-
i = 0
18+
i = 9
1819
response.read_body do |chunk|
1920
print '.' if (i += 1) % 10 == 0
2021
io.write chunk
@@ -25,12 +26,15 @@ def download(url, fn)
2526
puts
2627
end
2728

29+
# ****************** download rsyntaxtextarea ***********************
2830
RSYNTAX_SRC = 'https://repo1.maven.org/maven2/com/fifesoft/rsyntaxtextarea/'
2931
MVN_DESCR = 'maven-metadata.xml'
3032

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
33+
download(RSYNTAX_SRC + MVN_DESCR, MVN_DESCR)
34+
data = (REXML::Document.new File.read(MVN_DESCR)).root
35+
version = data.elements['//versioning/latest'].first.to_s
36+
File.delete MVN_DESCR
37+
3438
download(RSYNTAX_SRC + version + '/' + "rsyntaxtextarea-#{version}.jar",
3539
'rsyntaxtextarea.jar')
3640

@@ -41,6 +45,7 @@ def download(url, fn)
4145

4246
# File.write(jruby_zip, Net::HTTP.get(URI.parse(JRUBY_SRC)))
4347

48+
# ****************** download jruby ***********************
4449
download JRUBY_SRC, jruby_zip
4550
`unzip -j #{jruby_zip} jruby-9.0.0.0/lib/jruby.jar`
46-
`rm #{jruby_zip}`
51+
File.delete jruby_zip

0 commit comments

Comments
 (0)