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.
79 80 81 82 83 |
# File 'lib/needy.rb', line 79 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.
77 78 79 |
# File 'lib/needy.rb', line 77 def branch @branch end |
#dir ⇒ Object
Returns the value of attribute dir.
77 78 79 |
# File 'lib/needy.rb', line 77 def dir @dir end |
#log_opt ⇒ Object
Returns the value of attribute log_opt.
77 78 79 |
# File 'lib/needy.rb', line 77 def log_opt @log_opt end |
Instance Method Details
#author(name) ⇒ Object
99 100 101 |
# File 'lib/needy.rb', line 99 def name self.log_opt += " --author=#{name}" end |
#exec(*args) ⇒ Object
89 90 91 |
# File 'lib/needy.rb', line 89 def exec *args system("#{git_cmd} #{args.map(&:to_s).join(' ')}") end |
#git_cmd ⇒ Object
85 86 87 |
# File 'lib/needy.rb', line 85 def git_cmd "git --git-dir=#{dir}" end |
#when ⇒ Object
93 94 95 96 97 |
# File 'lib/needy.rb', line 93 def when open "|#{git_cmd} log #{branch} #{log_opt} --pretty=%ct -n1" do |f| Time.at(f.gets.chomp.to_i) end end |