Class: Arli::Commands::Install
- Includes:
- Library
- Defined in:
- lib/arli/commands/install.rb
Constant Summary
Constants included from Helpers::Output
Helpers::Output::CHAR_FAILURE, Helpers::Output::CHAR_SUCCESS
Instance Attribute Summary collapse
-
#arlifile ⇒ Object
Returns the value of attribute arlifile.
-
#install_argument ⇒ Object
Returns the value of attribute install_argument.
-
#install_method ⇒ Object
Returns the value of attribute install_method.
-
#library ⇒ Object
Returns the value of attribute library.
Attributes inherited from Base
Instance Method Summary collapse
- #additional_info ⇒ Object
-
#identify_library(arg) ⇒ Object
arg can be ‘Adafruit GFX Library’.
- #params ⇒ Object
- #post_install ⇒ Object
- #run ⇒ Object
- #setup ⇒ Object
Methods included from Library
Methods inherited from Base
#initialize, #library_path, #runtime, #temp_path
Methods included from Helpers::Output
#___, #__p, #__pf, #__pt, #abort?, #action_fail, #action_ok, #backup?, #cursor, #debug, #debug?, disable!, enable!, enabled?, #error, #fuck, #header, #hr, #indent_cursor, #info, #ok, #overwrite?, #print_action_failure, #print_action_starting, #print_action_success, #print_target_dir, #quiet?, #raise_invalid_arli_command!, #report_exception, #verbose?
Constructor Details
This class inherits a constructor from Arli::Commands::Base
Instance Attribute Details
#arlifile ⇒ Object
Returns the value of attribute arlifile.
16 17 18 |
# File 'lib/arli/commands/install.rb', line 16 def arlifile @arlifile end |
#install_argument ⇒ Object
Returns the value of attribute install_argument.
16 17 18 |
# File 'lib/arli/commands/install.rb', line 16 def install_argument @install_argument end |
#install_method ⇒ Object
Returns the value of attribute install_method.
16 17 18 |
# File 'lib/arli/commands/install.rb', line 16 def install_method @install_method end |
#library ⇒ Object
Returns the value of attribute library.
16 17 18 |
# File 'lib/arli/commands/install.rb', line 16 def library @library end |
Instance Method Details
#additional_info ⇒ Object
39 40 41 |
# File 'lib/arli/commands/install.rb', line 39 def additional_info "\nInstalling: #{runtime.argv.join(' ').bold.green}\n" end |
#identify_library(arg) ⇒ Object
arg can be ‘Adafruit GFX Library’
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/arli/commands/install.rb', line 48 def identify_library(arg) results = if arg =~ %r[https?://]i self.install_method = :url r = search(url: /^#{arg}$/i) if r.empty? self.install_method = :website r = search(website: /^#{arg}$/i) end if r.empty? self.install_method = :custom r = [Arduino::Library::Model.from_hash(url: arg, name: File.basename(arg))] end r elsif File.exist?(arg) || arg =~ /\.zip$/ self.install_method = :archiveFileName search(archiveFileName: "#{File.basename(arg)}") else self.install_method = :name search(name: /^#{arg}$/) end validate_search(arg, results) results.sort.last if results && !results.empty? end |
#params ⇒ Object
73 74 75 |
# File 'lib/arli/commands/install.rb', line 73 def params " • #{library.to_s}" end |
#post_install ⇒ Object
77 78 79 |
# File 'lib/arli/commands/install.rb', line 77 def post_install # end |
#run ⇒ Object
43 44 45 |
# File 'lib/arli/commands/install.rb', line 43 def run arlifile.install end |
#setup ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/arli/commands/install.rb', line 23 def setup super self.install_argument = runtime.argv.first raise InvalidInstallSyntaxError, 'Missing installation argument: a name, a file or a URL.' unless install_argument self.library = identify_library(install_argument) raise Arli::Errors::LibraryNotFound, "Library #{cfg.to_hash} was not found" unless library self.arlifile = Arli::ArliFile.new(config: config, libraries: [library]) if config.trace info("found library using #{install_method}:\n#{library.inspect}") end end |