Class: Space::Models::Project

Inherits:
Object
  • Object
show all
Includes:
Events
Defined in:
lib/space/models/project.rb,
lib/space/models/project/bundler.rb

Defined Under Namespace

Classes: Bundler

Instance Attribute Summary collapse

Attributes included from Events

#buffer

Instance Method Summary collapse

Methods included from Events

#buffering, #buffering?, #notify, #observers

Constructor Details

#initialize(name) ⇒ Project

Returns a new instance of Project.



10
11
12
13
14
15
# File 'lib/space/models/project.rb', line 10

def initialize(name)
  @name    = name
  @config  = Config.load(name)
  @repos   = Repos.new(self, config.paths)
  @bundler = Bundler.new(self)
end

Instance Attribute Details

#bundlerObject (readonly)

Returns the value of attribute bundler.



8
9
10
# File 'lib/space/models/project.rb', line 8

def bundler
  @bundler
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/space/models/project.rb', line 8

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/space/models/project.rb', line 8

def name
  @name
end

#reposObject (readonly)

Returns the value of attribute repos.



8
9
10
# File 'lib/space/models/project.rb', line 8

def repos
  @repos
end

Instance Method Details

#local_reposObject



17
18
19
20
21
22
# File 'lib/space/models/project.rb', line 17

def local_repos
  bundler.config.keys.map do |key|
    key =~ /^local\.(.+)$/
    $1 if repos.names.include?($1)
  end.compact
end

#namesObject



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

def names
  @names ||= Tmux.windows || repos.names
end

#number(name) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/space/models/project.rb', line 28

def number(name)
  if number = names.index(name)
    number + 1
  else
    names << name
    number(name)
  end
end

#refreshObject



37
38
39
40
# File 'lib/space/models/project.rb', line 37

def refresh
  bundler.refresh
  repos.all.each(&:refresh)
end

#subscribe(*args) ⇒ Object



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

def subscribe(*args)
  super
  [bundler, repos].each { |object| object.subscribe(self) }
end