Class: Jets::Gems::Extract::Ruby
- Defined in:
- lib/jets/gems/extract/ruby.rb
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #download_path(filename) ⇒ Object
- #download_ruby ⇒ Object
-
#full_ruby_name ⇒ Object
If only the ruby version is given, then append ruby- in front.
- #ruby_url ⇒ Object
- #run ⇒ Object
- #unzip(path) ⇒ Object
Methods inherited from Base
#clean_downloads, #download_file, #initialize, #log_level=, #project_root, #say, #sh, #url_exists?
Constructor Details
This class inherits a constructor from Jets::Gems::Extract::Base
Instance Method Details
#download_path(filename) ⇒ Object
45 46 47 |
# File 'lib/jets/gems/extract/ruby.rb', line 45 def download_path(filename) "#{@downloads_root}/downloads/rubies/#{filename}" end |
#download_ruby ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jets/gems/extract/ruby.rb', line 28 def download_ruby url = ruby_url puts "download ruby url #{url}" tarball_dest = download_file(url, download_path(File.basename(url))) unless tarball_dest = "Url: #{url} not found" if @options[:exit_on_error] say exit else raise NotFound.new() end end say "Downloaded to: #{tarball_dest}" tarball_dest end |
#full_ruby_name ⇒ Object
If only the ruby version is given, then append ruby- in front. Otherwise leave alone.
Example:
2.5.3 -> ruby-2.5.3.zip
ruby-2.5.3 -> ruby-2.5.3.zip
test-ruby-2.5.3 -> test-ruby-2.5.3.zip
57 58 59 60 61 62 63 64 65 |
# File 'lib/jets/gems/extract/ruby.rb', line 57 def full_ruby_name md = @name.match(/^(\d+\.\d+\.\d+)$/) if md ruby_version = md[1] "ruby-#{ruby_version}.zip" else "#{@name}.zip" end end |
#ruby_url ⇒ Object
67 68 69 |
# File 'lib/jets/gems/extract/ruby.rb', line 67 def ruby_url "#{source_url}/rubies/#{full_ruby_name}" end |
#run ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jets/gems/extract/ruby.rb', line 12 def run say "Looking for #{full_ruby_name}" clean_downloads(:rubies) if @options[:clean] zip_path = download_ruby unzip(zip_path) end |
#unzip(path) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/jets/gems/extract/ruby.rb', line 19 def unzip(path) dest = "#{Jets.build_root}/stage/code/opt" say "Unpacking into #{dest}" FileUtils.mkdir_p(dest) # cd-ing dest unzips the files into that folder sh("cd #{dest} && unzip -qo #{path}") say("Ruby #{full_ruby_name} unziped at #{dest}", :debug) end |