Class: Needy::Git
- Inherits:
-
Object
- Object
- Needy::Git
- Defined in:
- lib/needy.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#log_opt ⇒ Object
Returns the value of attribute log_opt.
Instance Method Summary collapse
- #author(name) ⇒ Object
- #exec(*args) ⇒ Object
- #git_cmd ⇒ Object
-
#initialize(dir, branch) ⇒ Git
constructor
A new instance of Git.
- #when ⇒ Object
Constructor Details
#initialize(dir, branch) ⇒ Git
Returns a new instance of Git.
70 71 72 73 74 |
# File 'lib/needy.rb', line 70 def initialize dir, branch self.dir = File.join File.(dir), '.git' self.branch = branch self.log_opt = '' end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
68 69 70 |
# File 'lib/needy.rb', line 68 def branch @branch end |
#dir ⇒ Object
Returns the value of attribute dir.
68 69 70 |
# File 'lib/needy.rb', line 68 def dir @dir end |
#log_opt ⇒ Object
Returns the value of attribute log_opt.
68 69 70 |
# File 'lib/needy.rb', line 68 def log_opt @log_opt end |
Instance Method Details
#author(name) ⇒ Object
90 91 92 |
# File 'lib/needy.rb', line 90 def name self.log_opt += " --author=#{name}" end |
#exec(*args) ⇒ Object
80 81 82 |
# File 'lib/needy.rb', line 80 def exec *args system("#{git_cmd} #{args.map(&:to_s).join(' ')}") end |
#git_cmd ⇒ Object
76 77 78 |
# File 'lib/needy.rb', line 76 def git_cmd "git --git-dir=#{dir}" end |
#when ⇒ Object
84 85 86 87 88 |
# File 'lib/needy.rb', line 84 def when open "|#{git_cmd} log #{branch} #{log_opt} --pretty=%ct -n1" do |f| Time.at(f.gets.chomp.to_i) end end |