Module: Space::Source

Includes:
Events
Included in:
Model::Project::Bundler, Model::Repo::Bundle, Model::Repo::Git
Defined in:
lib/space/source.rb,
lib/space/source/watch.rb,
lib/space/source/command.rb

Defined Under Namespace

Modules: ClassMethods Classes: Command, Watch

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Events

events, notify, #notify, sources, subscribe, subscriptions

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#commandsObject



32
33
34
35
36
# File 'lib/space/source.rb', line 32

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

#initialize(path) ⇒ Object



26
27
28
29
30
# File 'lib/space/source.rb', line 26

def initialize(path)
  @path = path
  @results = {}
  watch
end

#refreshObject



38
39
40
# File 'lib/space/source.rb', line 38

def refresh
  commands.each { |key, command| command.refresh }
end

#update(key, result) ⇒ Object



42
43
44
45
# File 'lib/space/source.rb', line 42

def update(key, result)
  results[key] = result
  notify(:update)
end