Class: RubyInstaller::Build::Components::Base
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- RubyInstaller::Build::Components::Base
- Includes:
- RubyInstaller::Build::Colors
- Defined in:
- lib/ruby_installer/build/components/base.rb
Direct Known Subclasses
Constant Summary
Constants included from RubyInstaller::Build::Colors
RubyInstaller::Build::Colors::ColorMap, RubyInstaller::Build::Colors::ESC, RubyInstaller::Build::Colors::NND
Instance Attribute Summary collapse
- #msys ⇒ Object
-
#pacman_args ⇒ Object
Returns the value of attribute pacman_args.
-
#task_index ⇒ Object
Returns the value of attribute task_index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*_) ⇒ Base
constructor
A new instance of Base.
- #puts(*args) ⇒ Object
- #run_verbose(*args) ⇒ Object
-
#shell_escape(str) ⇒ Object
This is extracted from github.com/larskanis/shellwords.
- #shell_join(array) ⇒ Object
Methods included from RubyInstaller::Build::Colors
#colored, #disable_colors, #enable_colors
Constructor Details
#initialize(*_) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 |
# File 'lib/ruby_installer/build/components/base.rb', line 15 def initialize(*_) @msys = nil enable_colors super end |
Instance Attribute Details
#msys ⇒ Object
21 22 23 |
# File 'lib/ruby_installer/build/components/base.rb', line 21 def msys @msys ||= BuildOrRuntime.msys2_installation end |
#pacman_args ⇒ Object
Returns the value of attribute pacman_args.
9 10 11 |
# File 'lib/ruby_installer/build/components/base.rb', line 9 def pacman_args @pacman_args end |
#task_index ⇒ Object
Returns the value of attribute task_index.
7 8 9 |
# File 'lib/ruby_installer/build/components/base.rb', line 7 def task_index @task_index end |
Class Method Details
.depends ⇒ Object
11 12 13 |
# File 'lib/ruby_installer/build/components/base.rb', line 11 def self.depends [] end |
Instance Method Details
#puts(*args) ⇒ Object
52 53 54 |
# File 'lib/ruby_installer/build/components/base.rb', line 52 def puts(*args) $stderr.puts *args end |
#run_verbose(*args) ⇒ Object
47 48 49 50 |
# File 'lib/ruby_installer/build/components/base.rb', line 47 def run_verbose(*args) puts "> #{ cyan(shell_join(args)) }" system(*args) end |
#shell_escape(str) ⇒ Object
This is extracted from github.com/larskanis/shellwords
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_installer/build/components/base.rb', line 26 def shell_escape(str) str = str.to_s # An empty argument will be skipped, so return empty quotes. return '""' if str.empty? str = str.dup str.gsub!(/((?:\\)*)"/){ "\\" * ($1.length*2) + "\\\"" } if str =~ /\s/ str.gsub!(/(\\+)\z/){ "\\" * ($1.length*2) } str = "\"#{str}\"" end return str end |
#shell_join(array) ⇒ Object
43 44 45 |
# File 'lib/ruby_installer/build/components/base.rb', line 43 def shell_join(array) array.map { |arg| shell_escape(arg) }.join(' ') end |