Skip to content

Commit eebb012

Browse files
committed
Reafactor vendors rakefile
1 parent bd356de commit eebb012

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<extension>
44
<groupId>io.takari.polyglot</groupId>
55
<artifactId>polyglot-ruby</artifactId>
6-
<version>0.3.1.1</version>
6+
<version>0.3.2</version>
77
</extension>
88
</extensions>

vendors/Rakefile

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
require 'rake/clean'
22

3-
WARNING = <<-EOS.freeze
3+
WARNING = <<-WARN.freeze
44
WARNING: you may not have wget installed, you could just download
55
the correct version of jruby-complete to the vendors folder, and
66
re-run k9 setup install instead of installing wget. Some systems
77
may also require 'sudo' access to install, NB: this is untested....
88
9-
EOS
9+
WARN
1010

11+
JRUBYC_VERSION = '9.2.4.1'.freeze
1112

12-
JRUBYC_VERSION = '9.2.4.1'
13-
14-
EXAMPLES = '3.2'
13+
EXAMPLES = '3.2'.freeze
1514
HOME_DIR = ENV['HOME']
1615
MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
1716

@@ -26,51 +25,51 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar.sha256" do
2625
end
2726
end
2827

29-
desc "get sha256"
30-
task :get_sha256 => ["jruby-complete-#{JRUBYC_VERSION}.jar.sha256"]
28+
desc 'get sha256'
29+
task get_sha256: ["jruby-complete-#{JRUBYC_VERSION}.jar.sha256"]
3130

32-
desc "download, and copy to jruby_art"
33-
task :default => [:get_sha256, :download, :copy_ruby]
31+
desc 'download, and copy to jruby_art'
32+
task default: %i[get_sha256 download copy_ruby]
3433

35-
desc "download JRuby upstream sources"
36-
task :download => ["jruby-complete-#{JRUBYC_VERSION}.jar"]
34+
desc 'download JRuby upstream sources'
35+
task download: ["jruby-complete-#{JRUBYC_VERSION}.jar"]
3736

3837
file "jruby-complete-#{JRUBYC_VERSION}.jar" do
3938
begin
4039
sh "wget https://repo1.maven.org/maven2/org/jruby/jruby-complete/#{JRUBYC_VERSION}/jruby-complete-#{JRUBYC_VERSION}.jar"
4140
rescue
4241
warn(WARNING)
4342
end
44-
value=File.read("jruby-complete-#{JRUBYC_VERSION}.jar.sha256")
43+
value = File.read("jruby-complete-#{JRUBYC_VERSION}.jar.sha256")
4544
check_sha256("jruby-complete-#{JRUBYC_VERSION}.jar", value)
4645
end
4746

48-
directory "../lib/ruby"
47+
directory '../lib/ruby'
4948

50-
desc "copy jruby-complete"
51-
task :copy_ruby => ["../lib/ruby"] do
49+
desc 'copy jruby-complete'
50+
task copy_ruby: ['../lib/ruby'] do
5251
sh "cp -v jruby-complete-#{JRUBYC_VERSION}.jar ../lib/ruby/jruby-complete.jar"
5352
end
5453

5554
def check_sha256(filename, expected_hash)
56-
require "digest"
55+
require 'digest'
5756
sha256 = Digest::SHA256.new
58-
File.open(filename, "r") do |f|
59-
while buf = f.read(4096)
57+
File.open(filename, 'r') do |f|
58+
while (buf = f.read(4096))
6059
sha256.update(buf)
6160
end
6261
end
63-
if sha256.hexdigest != expected_hash
64-
raise "bad sha256 checksum for #{filename} (expected #{expected_hash} got #{sha256.hexdigest})"
65-
end
62+
return if sha256.hexdigest == expected_hash
63+
64+
raise "bad sha256 checksum for #{filename} (expected #{expected_hash} got #{sha256.hexdigest})"
6665
end
6766

68-
desc "download, and copy to jruby_art"
69-
task :unpack_samples => [:download_examples, :copy_examples]
67+
desc 'download, and copy to jruby_art'
68+
task unpack_samples: %i[download_examples copy_examples]
7069

7170
desc 'download and copy examples to user home'
7271
task :download_examples
73-
file_name = (MAC_OR_LINUX.nil?) ? "#{EXAMPLES}.zip" : "#{EXAMPLES}.tar.gz"
72+
file_name = MAC_OR_LINUX.nil? ? "#{EXAMPLES}.zip" : "#{EXAMPLES}.tar.gz"
7473
file file_name do
7574
begin
7675
if MAC_OR_LINUX.nil?
@@ -83,8 +82,8 @@ file file_name do
8382
end
8483
end
8584

86-
desc "copy examples"
87-
task :copy_examples => file_name do
85+
desc 'copy examples'
86+
task copy_examples: file_name do
8887
if MAC_OR_LINUX.nil?
8988
sh "unzip #{EXAMPLES}.zip"
9089
else

0 commit comments

Comments
 (0)