Class: DynportTools::Jenkins::RemoteProject

Inherits:
Object
  • Object
show all
Defined in:
lib/dynport_tools/jenkins/remote_project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RemoteProject

Returns a new instance of RemoteProject.



8
9
10
11
12
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 8

def initialize(options = {})
  options.each do |key, value|
    self.send(:"#{key}=", value)
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 2

def name
  @name
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 2

def url
  @url
end

#xmlObject

Returns the value of attribute xml.



2
3
4
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 2

def xml
  @xml
end

Class Method Details

.from_details_hash(project_hash) ⇒ Object



4
5
6
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 4

def self.from_details_hash(project_hash)
  new(:url => project_hash[:url], :name => project_hash[:name], :xml => project_hash[:body])
end

Instance Method Details

#child_projectsObject



48
49
50
51
52
53
54
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 48

def child_projects
  if projects = doc.xpath("/project/publishers/hudson.tasks.BuildTrigger/childProjects").first
    projects.inner_text.split(/\s*,\s*/)
  else
    []
  end
end

#commandsObject



36
37
38
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 36

def commands
  doc.xpath("/project/builders/hudson.tasks.Shell/command").map(&:inner_text)
end

#crontab_patternsObject



40
41
42
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 40

def crontab_patterns
  doc.xpath("/project/triggers/hudson.triggers.TimerTrigger/spec").map(&:inner_text)
end

#days_to_keepObject



22
23
24
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 22

def days_to_keep
  logrotate_value_when_set("daysToKeep")
end

#disabled?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 44

def disabled?
  doc.at("/project/disabled/text()").to_s == "true"
end

#docObject



14
15
16
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 14

def doc
  @doc ||= Nokogiri::XML(xml) if xml
end

#email_addressesObject



56
57
58
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 56

def email_addresses
  doc.xpath("/project/publishers/hudson.tasks.Mailer/recipients").map { |rec| rec.inner_text.split(",") }.flatten
end

#locksObject



64
65
66
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 64

def locks
doc.xpath("/project/buildWrappers/hudson.plugins.locksandlatches.LockWrapper/locks/hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig/name").map(&:inner_text)
end

#logrotate_value_when_set(key) ⇒ Object



30
31
32
33
34
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 30

def logrotate_value_when_set(key)
  if node = doc.at("/project/logRotator/#{key}")
    node.inner_text.to_i if node.inner_text.to_i != -1
  end
end

#md5Object



18
19
20
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 18

def md5
  Digest::MD5.hexdigest(xml) if xml
end

#nodeObject



60
61
62
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 60

def node
  doc.xpath("/project/assignedNode").map { |n| n.inner_text }.first
end

#num_to_keepObject



26
27
28
# File 'lib/dynport_tools/jenkins/remote_project.rb', line 26

def num_to_keep
  logrotate_value_when_set("numToKeep")
end