class MineShipper::App
Public Class Methods
new()
click to toggle source
# File lib/mine-shipper/app.rb, line 24 def initialize @config = Config::new @issue_key = @config[:github][:issue] @logger = Logger.new(STDOUT) @logger.level = @config[:log_level] end
Public Instance Methods
run()
click to toggle source
# File lib/mine-shipper/app.rb, line 31 def run begin do_run rescue Exception => e @logger.error(e) end end
Private Instance Methods
do_run()
click to toggle source
# File lib/mine-shipper/app.rb, line 41 def do_run @logger.info("Fetching #{@issue_key} comments on Redmine...") redmine_issue = get_redmine_issue if redmine_issue @logger.info("Fetching #{@issue_key} comments on GitHub...") github_issue = get_github_issue dump_issue(github_issue) dump_issue(redmine_issue) redmine_issue.sync_comments(github_issue.comments) @logger.info("Done synchronizing issue comments of #{@issue_key}") else @logger.info("Cannot find Redmine issue for #{@issue_key}") end end
dump_comment(comment)
click to toggle source
# File lib/mine-shipper/app.rb, line 76 def dump_comment(comment) time = comment.created_at.getlocal @logger.debug("#{comment.tracker} Comment #{time}\n#{comment.body}") end
dump_issue(issue)
click to toggle source
# File lib/mine-shipper/app.rb, line 69 def dump_issue(issue) @logger.debug("#{issue.tracker} Issue \##{issue.identifier}: #{issue.title}") issue.comments.each do |comment| dump_comment(comment) end end
get_github_issue()
click to toggle source
# File lib/mine-shipper/app.rb, line 56 def get_github_issue project_name, issue_id = @issue_key.split('#', 2) github = GitHub::new(@config[:github][:access_token]) github.issue(project_name, issue_id) end
get_redmine_issue()
click to toggle source
# File lib/mine-shipper/app.rb, line 62 def get_redmine_issue redmine = Redmine.new(@config[:redmine][:base_url], @config[:redmine][:api_key]) redmine.issue_by_custom_field(@config[:redmine][:custom_field_id], @issue_key) end