Class: Germinate::ShellProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/germinate/shell_process.rb

Overview

A ShellProcess represents an external command which can be used to process a Hunk of text.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, command, variables = {}) ⇒ ShellProcess

Returns a new instance of ShellProcess.



15
16
17
18
19
# File 'lib/germinate/shell_process.rb', line 15

def initialize(name, command, variables={})
  @name      = name
  @command   = command
  @variables = variables
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/germinate/shell_process.rb', line 10

def command
  @command
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/germinate/shell_process.rb', line 9

def name
  @name
end

#variablesObject (readonly)

Returns the value of attribute variables.



11
12
13
# File 'lib/germinate/shell_process.rb', line 11

def variables
  @variables
end

Instance Method Details

#call(input) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/germinate/shell_process.rb', line 21

def call(input)
  if pipe?
    call_command_in_pipe(input)
  elsif input.whole_file?
    call_command_on_source_file(input)
  else
    call_command_on_temp_file(input)
  end
end