class Mode
Public Class Methods
new(cli, version)
click to toggle source
# File lib/grundler/mode.rb, line 7 def initialize(cli, version) @cli = cli @version = version end
Private Instance Methods
file_path()
click to toggle source
# File lib/grundler/mode.rb, line 32 def file_path file_path = "#{@cli.nodule_path}/#{@version["name"]}.js" FileUtils.mkdir_p(File.dirname(file_path)) file_path end
index_file()
click to toggle source
# File lib/grundler/mode.rb, line 38 def index_file @index_file ||= Pathname.new(index_file_path).cleanpath.to_s end
index_file_path()
click to toggle source
# File lib/grundler/mode.rb, line 42 def index_file_path return "package/#{@version["module"]}" if @version["module"] return "package/#{@version["exports"]}" if @version["exports"] return "package/#{@version["main"]}" if @version["main"] "package/index.js" end
notify()
click to toggle source
# File lib/grundler/mode.rb, line 14 def notify puts "Installing #{@version["name"]} #{@version["version"]}" end
tempfile()
click to toggle source
# File lib/grundler/mode.rb, line 28 def tempfile Down::Http.download(@version.dig("dist", "tarball")) end
untar()
click to toggle source
# File lib/grundler/mode.rb, line 18 def untar tar = Gem::Package::TarReader.new(Zlib::GzipReader.open(tempfile.path)) file = tar.find { |f| f.full_name == index_file } tar.close raise NoEntryPointError if file.nil? file.read end