Class: GithubPivotalFlow::Project
- Defined in:
- lib/github_pivotal_flow/project.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(args = {}) ⇒ Project
constructor
A new instance of Project.
- #method_missing(m, *args, &block) ⇒ Object
- #name_with_owner ⇒ Object
- #pivotal_project ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Project
Returns a new instance of Project.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/github_pivotal_flow/project.rb', line 10 def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end url = Git.get_config("remote.#{Git.get_remote}.url") if (matchdata = /^git@([a-z0-9\._-]+):([a-z0-9_-]+)\/([a-z0-9_-]+)(\.git)?$/i.match(url.strip)) self.host ||= matchdata[1] self.owner ||= matchdata[2] self.name ||= matchdata[3] else url = URI(url) if !url.is_a?(URI) path_components = url.path.split('/', 4) self.owner ||= path_components[1] self.name ||= path_components[2] self.host ||= url.host end self.name = self.name.tr(' ', '-').sub(/\.git$/, '') if self.name self.name ||= File.basename(Dir.getwd) self.host ||= 'github.com' self.host = host.sub(/^ssh\./i, '') if 'ssh.github.com' == host.downcase end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
44 45 46 |
# File 'lib/github_pivotal_flow/project.rb', line 44 def method_missing(m, *args, &block) return pivotal_project.send(m, *args, &block) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/github_pivotal_flow/project.rb', line 3 def config @config end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/github_pivotal_flow/project.rb', line 3 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/github_pivotal_flow/project.rb', line 3 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
3 4 5 |
# File 'lib/github_pivotal_flow/project.rb', line 3 def owner @owner end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/github_pivotal_flow/project.rb', line 36 def ==(other) name_with_owner == other.name_with_owner end |
#name_with_owner ⇒ Object
32 33 34 |
# File 'lib/github_pivotal_flow/project.rb', line 32 def name_with_owner "#{owner}/#{name}" end |
#pivotal_project ⇒ Object
40 41 42 |
# File 'lib/github_pivotal_flow/project.rb', line 40 def pivotal_project @pivotal_project ||= self.class.find(self.config.project_id) end |