Class: Semaph::Model::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/semaph/model/project.rb

Constant Summary collapse

GITHUB_REGGEXP =
%r{[email protected]:(.*)/(.*).git}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, raw) ⇒ Project

Returns a new instance of Project.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/semaph/model/project.rb', line 10

def initialize(client, raw)
  @client = client
  @raw = raw
  @id = raw["metadata"]["id"]
  @name = raw["metadata"]["name"]
  repo = raw["spec"]["repository"]["url"]
  match = GITHUB_REGGEXP.match(repo)
  return unless match

  @repo_owner = match[1]
  @repo_name = match[2]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/semaph/model/project.rb', line 8

def client
  @client
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/semaph/model/project.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/semaph/model/project.rb', line 8

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/semaph/model/project.rb', line 8

def raw
  @raw
end

Instance Method Details

#github_urlObject



23
24
25
26
27
# File 'lib/semaph/model/project.rb', line 23

def github_url
  return nil unless @repo_owner && @repo_name

  "https://github.com/#{@repo_owner}/#{@repo_name}"
end

#workflow_collectionObject



29
30
31
# File 'lib/semaph/model/project.rb', line 29

def workflow_collection
  @workflow_collection ||= WorkflowCollection.new(self)
end