Module: Space::Shell

Includes:
Watcher
Included in:
Models::Project::Bundler, Models::Repo::Bundle, Models::Repo::Git
Defined in:
lib/space/shell.rb,
lib/space/shell/watch.rb,
lib/space/shell/command.rb,
lib/space/shell/watcher.rb

Defined Under Namespace

Modules: ClassMethods, Watcher Classes: Command, Watch

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Watcher

suspend, suspended?

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



33
34
35
# File 'lib/space/shell.rb', line 33

def path
  @path
end

Class Method Details

.allObject



24
25
26
# File 'lib/space/shell.rb', line 24

def all
  @all ||= []
end

.included(base) ⇒ Object



20
21
22
# File 'lib/space/shell.rb', line 20

def included(base)
  base.extend(ClassMethods)
end

.refreshObject



28
29
30
# File 'lib/space/shell.rb', line 28

def refresh
  all.map(&:refresh)
end

Instance Method Details

#commandsObject



45
46
47
48
49
# File 'lib/space/shell.rb', line 45

def commands
  @commands ||= self.class.commands.inject({}) do |commands, (key, command)|
    commands.merge(key => Command.new(self, command))
  end
end

#initialize(path = '.') ⇒ Object



35
36
37
38
39
# File 'lib/space/shell.rb', line 35

def initialize(path = '.')
  @path = File.expand_path(path)
  Shell.all << self
  super
end

#refreshObject



51
52
53
54
# File 'lib/space/shell.rb', line 51

def refresh
  commands.each { |key, command| command.run }
  # notify(:refresh, self.class.name)
end

#result(command) ⇒ Object



41
42
43
# File 'lib/space/shell.rb', line 41

def result(command)
  commands[command].result
end