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
196 197 198 199 200 |
# File 'lib/git_tools/branches/cleaner.rb', line 196 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.
194 195 196 |
# File 'lib/git_tools/branches/cleaner.rb', line 194 def age @age end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
194 195 196 |
# File 'lib/git_tools/branches/cleaner.rb', line 194 def name @name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
194 195 196 |
# File 'lib/git_tools/branches/cleaner.rb', line 194 def remote @remote end |
Class Method Details
.age(branch) ⇒ Object
179 180 181 182 183 184 185 186 |
# File 'lib/git_tools/branches/cleaner.rb', line 179 def self.age(branch) time = DATE_REGEXP.match(`git log --shortstat --date=iso -n 1 #{branch}`) if time.nil? raise "Error due to unexpected git output." else Time.parse(time[1]) end end |
.executor ⇒ Object
188 189 190 |
# File 'lib/git_tools/branches/cleaner.rb', line 188 def self.executor ActionExecutor.new end |
Instance Method Details
#confirm_remove(message, prompt) ⇒ Object
210 211 212 |
# File 'lib/git_tools/branches/cleaner.rb', line 210 def confirm_remove(, prompt) self.class.executor.execute(remove_branch_action, , prompt) end |
#normalized_name ⇒ Object
202 203 204 |
# File 'lib/git_tools/branches/cleaner.rb', line 202 def normalized_name local? ? name : "#{remote}/#{name}" end |
#remove!(message) ⇒ Object
206 207 208 |
# File 'lib/git_tools/branches/cleaner.rb', line 206 def remove!() self.class.executor.execute(remove_branch_action, ) end |
#to_s ⇒ Object
214 215 216 |
# File 'lib/git_tools/branches/cleaner.rb', line 214 def to_s name end |