Class: UpdateDraftRelease::Runner
- Inherits:
-
Object
- Object
- UpdateDraftRelease::Runner
- Defined in:
- lib/update_draft_release.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ skip_confirmation: false, open_url_after_update: false }
Instance Method Summary collapse
-
#initialize(repo, opts = {}) ⇒ Runner
constructor
A new instance of Runner.
- #update_draft_release ⇒ Object
Constructor Details
#initialize(repo, opts = {}) ⇒ Runner
Returns a new instance of Runner.
17 18 19 20 21 22 23 |
# File 'lib/update_draft_release.rb', line 17 def initialize(repo, opts = {}) @github = Github.open(repo) @opts = DEFAULT_OPTIONS.merge(opts) LOGGER.info "Logged in as: #{@github.user.login}" LOGGER.info "Repository used: #{repo}" end |
Instance Method Details
#update_draft_release ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/update_draft_release.rb', line 25 def update_draft_release draft_release = get_draft_release lines = get_user_commit_lines.reverse body = Content.new(draft_release.body) if body.headings.empty? body.append(lines) else line_num = ask_where_to_insert_line(body) body.insert(line_num, lines) end unless ask_confirmation(draft_release.name, body) LOGGER.warn('Update cancelled') exit end LOGGER.info("Updating to URL: #{draft_release.html_url}") @github.update_release(draft_release, body) LOGGER.info("Release '#{draft_release.name}' updated!") `open #{draft_release.html_url}` if @opts[:open_url_after_update] end |