Class: GitTools::Branches::Branch
- Inherits:
-
Object
- Object
- GitTools::Branches::Branch
- Defined in:
- lib/git_tools/branches/cleaner.rb
Constant Summary collapse
- DATE_REGEXP =
/^Date:\s+(.*)$/
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Class Method Summary collapse
Instance Method Summary collapse
- #confirm_remove(message, prompt) ⇒ Object
-
#initialize(name, remote) ⇒ Branch
constructor
A new instance of Branch.
- #normalized_name ⇒ Object
- #remove!(message) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, remote) ⇒ Branch
Returns a new instance of Branch.
205 206 207 208 209 |
# File 'lib/git_tools/branches/cleaner.rb', line 205 def initialize(name, remote) @name = name @remote = remote @age = self.class.age(normalized_name) end |
Instance Attribute Details
#age ⇒ Object (readonly)
Returns the value of attribute age.
203 204 205 |
# File 'lib/git_tools/branches/cleaner.rb', line 203 def age @age end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
203 204 205 |
# File 'lib/git_tools/branches/cleaner.rb', line 203 def name @name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
203 204 205 |
# File 'lib/git_tools/branches/cleaner.rb', line 203 def remote @remote end |
Class Method Details
.age(branch) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/git_tools/branches/cleaner.rb', line 187 def self.age(branch) cmd = "git log --shortstat --date=iso -n 1 #{branch}" time = DATE_REGEXP.match(`#{cmd}`) if time.nil? raise "Error due to unexpected git output on command: #{cmd}." else Time.parse(time[1]) end end |
.executor ⇒ Object
197 198 199 |
# File 'lib/git_tools/branches/cleaner.rb', line 197 def self.executor ActionExecutor.new end |
Instance Method Details
#confirm_remove(message, prompt) ⇒ Object
219 220 221 |
# File 'lib/git_tools/branches/cleaner.rb', line 219 def confirm_remove(, prompt) self.class.executor.execute(remove_branch_action, , prompt) end |
#normalized_name ⇒ Object
211 212 213 |
# File 'lib/git_tools/branches/cleaner.rb', line 211 def normalized_name local? ? name : "#{remote}/#{name}" end |
#remove!(message) ⇒ Object
215 216 217 |
# File 'lib/git_tools/branches/cleaner.rb', line 215 def remove!() self.class.executor.execute(remove_branch_action, ) end |
#to_s ⇒ Object
223 224 225 |
# File 'lib/git_tools/branches/cleaner.rb', line 223 def to_s name end |