Class: Space::Source::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/space/source/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, key, command) ⇒ Command

Returns a new instance of Command.



17
18
19
20
21
# File 'lib/space/source/command.rb', line 17

def initialize(source, key, command)
  @source = source
  @key = key
  @command = command
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



15
16
17
# File 'lib/space/source/command.rb', line 15

def command
  @command
end

#keyObject

Returns the value of attribute key.



15
16
17
# File 'lib/space/source/command.rb', line 15

def key
  @key
end

#sourceObject

Returns the value of attribute source.



15
16
17
# File 'lib/space/source/command.rb', line 15

def source
  @source
end

Class Method Details

.execute(dir, command) ⇒ Object



9
10
11
12
# File 'lib/space/source/command.rb', line 9

def execute(dir, command)
  log "#{File.basename(dir)} $ #{command}"
  Open3.capture2e("cd #{dir}; #{command}").first
end

Instance Method Details

#refreshObject



23
24
25
# File 'lib/space/source/command.rb', line 23

def refresh
  Thread.new(&method(:run))
end