Class: Arli::Commands::Install
- Includes:
- Arduino::Library::InstanceMethods, Library
- Defined in:
- lib/arli/commands/install.rb
Constant Summary
Constants included from Library
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
- #search(**opts) ⇒ 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.
17 18 19 |
# File 'lib/arli/commands/install.rb', line 17 def arlifile @arlifile end |
#install_argument ⇒ Object
Returns the value of attribute install_argument.
17 18 19 |
# File 'lib/arli/commands/install.rb', line 17 def install_argument @install_argument end |
#install_method ⇒ Object
Returns the value of attribute install_method.
17 18 19 |
# File 'lib/arli/commands/install.rb', line 17 def install_method @install_method end |
#library ⇒ Object
Returns the value of attribute library.
17 18 19 |
# File 'lib/arli/commands/install.rb', line 17 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 72 73 |
# File 'lib/arli/commands/install.rb', line 48 def identify_library(arg) results = if arg =~ %r[https?://]i self.install_method = :url result = search url: /^#{arg}$/i if result.empty? self.install_method = :website result = search(website: /^#{arg}$/i) end if result.empty? self.install_method = :custom result = [Arduino::Library::Model.from_hash(url: arg, name: File.basename(arg))] end result 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
75 76 77 |
# File 'lib/arli/commands/install.rb', line 75 def params nil end |
#post_install ⇒ Object
79 80 81 |
# File 'lib/arli/commands/install.rb', line 79 def post_install # end |
#run ⇒ Object
43 44 45 |
# File 'lib/arli/commands/install.rb', line 43 def run arlifile.install end |
#search(**opts) ⇒ Object
83 84 85 86 |
# File 'lib/arli/commands/install.rb', line 83 def search(**opts) # noinspection RubyArgCount super(opts) end |
#setup ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/arli/commands/install.rb', line 24 def setup 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 |