Class: Conv::ConvItem
- Inherits:
-
Object
- Object
- Conv::ConvItem
- Defined in:
- lib/ffc.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#input ⇒ Object
Returns the value of attribute input.
-
#input_path ⇒ Object
Returns the value of attribute input_path.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#last_access ⇒ Object
Returns the value of attribute last_access.
-
#output ⇒ Object
Returns the value of attribute output.
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#package ⇒ Object
Returns the value of attribute package.
-
#pacman ⇒ Object
Returns the value of attribute pacman.
-
#substitute ⇒ Object
Returns the value of attribute substitute.
-
#type ⇒ Object
Returns the value of attribute type.
-
#warning ⇒ Object
Returns the value of attribute warning.
Instance Method Summary collapse
- #brew! ⇒ Object
- #brew_command ⇒ Object
- #cmd(inputs, output) ⇒ Object
- #generate_command(options, input, output) ⇒ Object
- #generate_output_filename(input, option = :exchange) ⇒ Object
-
#initialize(**params) ⇒ ConvItem
constructor
A new instance of ConvItem.
- #run!(inputs, output, arguments = "") ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(**params) ⇒ ConvItem
Returns a new instance of ConvItem.
132 133 134 135 136 137 |
# File 'lib/ffc.rb', line 132 def initialize **params Config.load_and_set_settings(Dir.home + ".conv") @type |= :convert @package_manager = Settings.package_manager params.each{|k,v| self.send("#{k}=", v) if self.methods.include?(k)} end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
130 131 132 |
# File 'lib/ffc.rb', line 130 def command @command end |
#input ⇒ Object
Returns the value of attribute input.
130 131 132 |
# File 'lib/ffc.rb', line 130 def input @input end |
#input_path ⇒ Object
Returns the value of attribute input_path.
130 131 132 |
# File 'lib/ffc.rb', line 130 def input_path @input_path end |
#lang ⇒ Object
Returns the value of attribute lang.
130 131 132 |
# File 'lib/ffc.rb', line 130 def lang @lang end |
#last_access ⇒ Object
Returns the value of attribute last_access.
130 131 132 |
# File 'lib/ffc.rb', line 130 def last_access @last_access end |
#output ⇒ Object
Returns the value of attribute output.
130 131 132 |
# File 'lib/ffc.rb', line 130 def output @output end |
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
130 131 132 |
# File 'lib/ffc.rb', line 130 def output_buffer @output_buffer end |
#output_path ⇒ Object
Returns the value of attribute output_path.
130 131 132 |
# File 'lib/ffc.rb', line 130 def output_path @output_path end |
#package ⇒ Object
Returns the value of attribute package.
130 131 132 |
# File 'lib/ffc.rb', line 130 def package @package end |
#pacman ⇒ Object
Returns the value of attribute pacman.
130 131 132 |
# File 'lib/ffc.rb', line 130 def pacman @pacman end |
#substitute ⇒ Object
Returns the value of attribute substitute.
130 131 132 |
# File 'lib/ffc.rb', line 130 def substitute @substitute end |
#type ⇒ Object
Returns the value of attribute type.
130 131 132 |
# File 'lib/ffc.rb', line 130 def type @type end |
#warning ⇒ Object
Returns the value of attribute warning.
130 131 132 |
# File 'lib/ffc.rb', line 130 def warning @warning end |
Instance Method Details
#brew! ⇒ Object
175 176 177 178 179 |
# File 'lib/ffc.rb', line 175 def brew! status, stdout, stderr= systemu self.brew_command #status, stdout = Open3.capture2(self.brew_command) return status, stdout, stderr end |
#brew_command ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ffc.rb', line 181 def brew_command if self.pacman return pacman + " " + package else if !@package_manager return "brew install " + package else return @package_manager + package end end end |
#cmd(inputs, output) ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/ffc.rb', line 156 def cmd(inputs, output) cmd = self.command inputs.each{ |input| cmd.sub!("{input}", input)} cmd.sub!("{output}", output) return cmd end |
#generate_command(options, input, output) ⇒ Object
139 140 141 |
# File 'lib/ffc.rb', line 139 def generate_command(, input, output) return [self.cmd, self.brew] end |
#generate_output_filename(input, option = :exchange) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ffc.rb', line 143 def generate_output_filename(input, option=:exchange) extensions = self.output case option when :exchange extensions = extensions.map{ |ext| Pathname(input).sub_ext("."+ext).to_s } when :prefix extensions = extensions.map{ |ext| input + "." + ext } #when :withtime # extensions = extensions.map{ |ext| Pathname(input + "." + ext) } end extensions[0] end |
#run!(inputs, output, arguments = "") ⇒ Object
168 169 170 171 172 173 |
# File 'lib/ffc.rb', line 168 def run!(inputs, output, arguments="") raise "Error -- no input file" unless inputs.all?{ |t| Pathname(t).exist?} status, stdout, stderr = systemu self.cmd(inputs, output) return status, stdout, stderr end |
#to_s ⇒ Object
164 165 166 |
# File 'lib/ffc.rb', line 164 def to_s return self.output.to_s + " " + self.cmd(@input_path, @output_path) + " (" + self.package + ")" end |