Class: Hookers::Changelog::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/hookers/changelog/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, uri) ⇒ Project

Returns a new instance of Project.



8
9
10
11
# File 'lib/hookers/changelog/project.rb', line 8

def initialize(name, uri)
  self.name = name
  self.uri = uri
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/hookers/changelog/project.rb', line 6

def name
  @name
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/hookers/changelog/project.rb', line 6

def uri
  @uri
end

Class Method Details

.discoverObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/hookers/changelog/project.rb', line 17

def self.discover
  remote_uri = %x[git remote -v].split(/\n/).first.split(/\s+/).at(1)

  return nil if remote_uri.nil?
  remote_uri.gsub!(/(git@|git:\/\/)/, "https://")
  remote_uri.gsub!(/:(?!\/\/)/, "/")
  remote_uri.gsub!(/\.git$/, "")
  name = remote_uri.split(/\//).at(-1)
  new(name, remote_uri)
end

Instance Method Details

#commit_uri(id) ⇒ Object



13
14
15
# File 'lib/hookers/changelog/project.rb', line 13

def commit_uri(id)
  "#{self.uri}/commit/#{id}"
end