Class: GithubPivotalFlow::Project

Inherits:
Struct
  • Object
show all
Defined in:
lib/github_pivotal_flow/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Project

Returns a new instance of Project.



16
17
18
19
20
21
# File 'lib/github_pivotal_flow/project.rb', line 16

def initialize(*args)
  super
  self.name = self.name.tr(' ', '-')
  self.host ||= 'github.com'
  self.host = host.sub(/^ssh\./i, '') if 'ssh.github.com' == host.downcase
end

Instance Attribute Details

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



2
3
4
# File 'lib/github_pivotal_flow/project.rb', line 2

def host
  @host
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/github_pivotal_flow/project.rb', line 2

def name
  @name
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



2
3
4
# File 'lib/github_pivotal_flow/project.rb', line 2

def owner
  @owner
end

Class Method Details

.from_url(url) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/github_pivotal_flow/project.rb', line 3

def self.from_url(url)
  if (matchdata = /^git@([a-z0-9\._-]+):([a-z0-9_-]+)\/([a-z0-9_-]+)(\.git)?$/.match(url.strip))
    host = matchdata[1]
    owner = matchdata[2]
    name = matchdata[3]
  else
    url = URI(url) if !url.is_a?(URI)
    _, owner, name = url.path.split('/', 4)
    host = url.host
  end
  self.new(owner, name.sub(/\.git$/, ''), host)
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/github_pivotal_flow/project.rb', line 27

def ==(other)
  name_with_owner == other.name_with_owner
end

#name_with_ownerObject



23
24
25
# File 'lib/github_pivotal_flow/project.rb', line 23

def name_with_owner
  "#{owner}/#{name}"
end