Class: MultiRepo::Helpers::UpdateMilestone
- Inherits:
-
Object
- Object
- MultiRepo::Helpers::UpdateMilestone
- Defined in:
- lib/multi_repo/helpers/update_milestone.rb
Instance Attribute Summary collapse
-
#close ⇒ Object
readonly
Returns the value of attribute close.
-
#due_on ⇒ Object
readonly
Returns the value of attribute due_on.
-
#github ⇒ Object
readonly
Returns the value of attribute github.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(repo_name, title:, due_on:, close:, dry_run: false) ⇒ UpdateMilestone
constructor
A new instance of UpdateMilestone.
- #run ⇒ Object
Constructor Details
#initialize(repo_name, title:, due_on:, close:, dry_run: false) ⇒ UpdateMilestone
Returns a new instance of UpdateMilestone.
7 8 9 10 11 12 13 14 15 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 7 def initialize(repo_name, title:, due_on:, close:, dry_run: false, **) raise ArgumentError, "due_on must be specified" if due_on.nil? && !close @repo_name = repo_name @title = title @due_on = MultiRepo::Service::Github.parse_milestone_date(due_on) if due_on @close = close @github = MultiRepo::Service::Github.new(dry_run: dry_run) end |
Instance Attribute Details
#close ⇒ Object (readonly)
Returns the value of attribute close.
5 6 7 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 5 def close @close end |
#due_on ⇒ Object (readonly)
Returns the value of attribute due_on.
5 6 7 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 5 def due_on @due_on end |
#github ⇒ Object (readonly)
Returns the value of attribute github.
5 6 7 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 5 def github @github end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
5 6 7 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 5 def repo_name @repo_name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 5 def title @title end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/multi_repo/helpers/update_milestone.rb', line 17 def run due_on_str = due_on.strftime("%Y-%m-%d").inspect existing = github.find_milestone_by_title(repo_name, title) if close if existing puts "Closing milestone #{title.inspect} (#{existing.number})" github.close_milestone(repo_name, title, existing.number) end elsif existing puts "Updating milestone #{title.inspect} (#{existing.number}) with due date #{due_on_str}" github.update_milestone(repo_name, existing.number, due_on) else puts "Creating milestone #{title.inspect} with due date #{due_on_str}" github.create_milestone(repo_name, title, due_on) end end |