Class: Space::Models::Repo

Inherits:
Object
  • Object
show all
Includes:
Events
Defined in:
lib/space/models/repo.rb,
lib/space/models/repo/git.rb,
lib/space/models/repo/bundle.rb,
lib/space/models/repo/dependency.rb

Defined Under Namespace

Classes: Bundle, Dependency, Git

Instance Attribute Summary collapse

Attributes included from Events

#buffer

Instance Method Summary collapse

Methods included from Events

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

Constructor Details

#initialize(project, path) ⇒ Repo

Returns a new instance of Repo.



12
13
14
15
16
17
# File 'lib/space/models/repo.rb', line 12

def initialize(project, path)
  @project = project
  @path    = File.expand_path(path)
  @git     = Git.new(self)
  @bundle  = Bundle.new(self, project.repos)
end

Instance Attribute Details

#bundleObject (readonly)

Returns the value of attribute bundle.



10
11
12
# File 'lib/space/models/repo.rb', line 10

def bundle
  @bundle
end

#gitObject (readonly)

Returns the value of attribute git.



10
11
12
# File 'lib/space/models/repo.rb', line 10

def git
  @git
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/space/models/repo.rb', line 10

def path
  @path
end

#projectObject (readonly)

Returns the value of attribute project.



10
11
12
# File 'lib/space/models/repo.rb', line 10

def project
  @project
end

Instance Method Details

#chdir(&block) ⇒ Object



47
48
49
# File 'lib/space/models/repo.rb', line 47

def chdir(&block)
  Dir.chdir(path, &block)
end

#depsObject



31
32
33
# File 'lib/space/models/repo.rb', line 31

def deps
  bundle.deps
end

#execute(cmd) ⇒ Object



40
41
42
43
44
45
# File 'lib/space/models/repo.rb', line 40

def execute(cmd)
  chdir do
    puts "in #{path}".ansi(:bold, :yellow)
    system(cmd)
  end
end

#nameObject



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

def name
  @name ||= File.basename(path)
end

#numberObject



23
24
25
# File 'lib/space/models/repo.rb', line 23

def number
  @number ||= project.number(name)
end

#refObject



27
28
29
# File 'lib/space/models/repo.rb', line 27

def ref
  git.commit
end

#refreshObject



35
36
37
38
# File 'lib/space/models/repo.rb', line 35

def refresh
  git.refresh
  bundle.refresh
end

#subscribe(*args) ⇒ Object



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

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