11require '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
1514HOME_DIR = ENV [ 'HOME' ]
1615MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig ::CONFIG [ 'host_os' ]
1716
@@ -26,51 +25,51 @@ file "jruby-complete-#{JRUBYC_VERSION}.jar.sha256" do
2625 end
2726end
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
3837file "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 )
4645end
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"
5352end
5453
5554def 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 } )"
6665end
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
7170desc 'download and copy examples to user home'
7271task :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"
7473file file_name do
7574 begin
7675 if MAC_OR_LINUX . nil?
@@ -83,8 +82,8 @@ file file_name do
8382 end
8483end
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