Class: Sensible::Requirement
- Inherits:
-
Object
- Object
- Sensible::Requirement
- Defined in:
- lib/sensible/requirement.rb
Instance Attribute Summary collapse
-
#check ⇒ Object
readonly
Returns the value of attribute check.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#install ⇒ Object
readonly
Returns the value of attribute install.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#sensible ⇒ Object
readonly
Returns the value of attribute sensible.
Instance Method Summary collapse
- #do_check ⇒ Object
- #do_install ⇒ Object
-
#initialize(requirement_file_name, sensible) ⇒ Requirement
constructor
Pretty much the same as package right now.
Constructor Details
#initialize(requirement_file_name, sensible) ⇒ Requirement
Pretty much the same as package right now
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sensible/requirement.rb', line 15 def initialize(requirement_file_name, sensible) requirement_file_path = "#{sensible.sensible_folder}/#{sensible.requirements_folder}/#{requirement_file_name}.yml" # If requirement is not found, exit! if not File.exist?(requirement_file_path) pastel = Pastel.new Logger.error("Requirement: #{pastel.bold(requirement_file_name)} does not exist!") exit(1) end # Load the data requirement_data = YAML.load_file(requirement_file_path) @sensible = sensible @name = requirement_data["name"] @check = requirement_data["check"] @install = requirement_data["install"] @env = requirement_data["env"] @description = requirement_data["description"] # Parse packages @packages = Parse::parse_sensible_packages(requirement_data['packages'], sensible) end |
Instance Attribute Details
#check ⇒ Object (readonly)
Returns the value of attribute check.
8 9 10 |
# File 'lib/sensible/requirement.rb', line 8 def check @check end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
11 12 13 |
# File 'lib/sensible/requirement.rb', line 11 def description @description end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
10 11 12 |
# File 'lib/sensible/requirement.rb', line 10 def env @env end |
#install ⇒ Object (readonly)
Returns the value of attribute install.
9 10 11 |
# File 'lib/sensible/requirement.rb', line 9 def install @install end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/sensible/requirement.rb', line 7 def name @name end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
12 13 14 |
# File 'lib/sensible/requirement.rb', line 12 def packages @packages end |
#sensible ⇒ Object (readonly)
Returns the value of attribute sensible.
6 7 8 |
# File 'lib/sensible/requirement.rb', line 6 def sensible @sensible end |
Instance Method Details
#do_check ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sensible/requirement.rb', line 39 def do_check # If check is not set, always run the task if @check == nil return false end # If there is no check, default to false, to force task to install every time system(@check, out: File::NULL) return $?.success? end |
#do_install ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/sensible/requirement.rb', line 50 def do_install # TODO: Handle the show output property! if @install.include?("\n") temp_path = "/tmp/sensible" temp_file_name = "install.sh" temp_file_path = "#{temp_path}/#{temp_file_name}" # Make sure we have the tmp folder created FileUtils.mkdir_p(temp_path) File.open(temp_file_path, "w") do |f| f.puts "#!/usr/bin/env bash\n\n" f.write(@install) end # Make it executable File.chmod(0700, temp_file_path) system("#{temp_file_path}", out: File::NULL, err: File::NULL) return $?.success? else system(@install, out: File::NULL, err: File::NULL) return $?.success? end end |