Class: Buildmeister::Project

Inherits:
Object
  • Object
show all
Includes:
StringUtils
Defined in:
lib/buildmeister/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StringUtils

#divider

Constructor Details

#initialize(config, lighthouse_account, options = {}) ⇒ Project

Returns a new instance of Project.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/buildmeister/project.rb', line 7

def initialize(config, , options = {})
  self.name = config['name']
  self.bins = []
  
  bins.extend Finder
  
  self.project = .projects.named(name)

  project_bins = project.bins

  config['bins'].each do |bin_name|
    bin = project_bins.find { |b| b.name == bin_name }
    raise "No bin named #{bin_name}" unless bin 
    
    bins << Buildmeister::Bin.new(bin, options[:mode], :annotations => config['annotations'])
  end
  
  config['personal_bins'].each do |bin_name|
    bin = project_bins.find { |b| !b.shared && (b.name == bin_name) }
    raise "No bin named #{bin_name}" unless bin 
    
    bins << Buildmeister::Bin.new(bin, options[:mode], :annotations => config['annotations'])
  end if config['personal_bins']
end

Instance Attribute Details

#binsObject

Returns the value of attribute bins.



5
6
7
# File 'lib/buildmeister/project.rb', line 5

def bins
  @bins
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/buildmeister/project.rb', line 5

def name
  @name
end

#projectObject

Returns the value of attribute project.



5
6
7
# File 'lib/buildmeister/project.rb', line 5

def project
  @project
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/buildmeister/project.rb', line 56

def changed?
  bins.any? &:changed?
end

#displayObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/buildmeister/project.rb', line 40

def display
  out = ''
  out << name + "\n"
  out << "#{divider}\n"
  
  bins.each do |bin|
    out << bin.display + "\n"
  end
  
  out
end

#find_tickets(*ids) ⇒ Object

There’s no good way to do this in the Lighthouse API. This is slow, but at least it’s easy to write.



34
35
36
37
38
# File 'lib/buildmeister/project.rb', line 34

def find_tickets(*ids)
  ids.map do |id|
    project.tickets(id).first
  end.compact
end

#refresh!Object



52
53
54
# File 'lib/buildmeister/project.rb', line 52

def refresh!
  bins.each &:refresh!
end