module GithubIssueMaker
Public Instance Methods
create_github_issue!()
click to toggle source
# File lib/github_issue_maker.rb, line 6 def create_github_issue! set_config_variables file_name = "#{SecureRandom.hex}/issue.png" create_s3_object(file_name) github = Github.new oauth_token: @github_details[:access_token] issue_body = github_issue_body(file_name) issue = github.issues.create(user: @github_details[:user], repo: @github_details[:repo], body: issue_body, title: @github_details[:issue_title], labels: @github_details[:labels]) issue[:html_url] end
create_s3_object(file_name)
click to toggle source
# File lib/github_issue_maker.rb, line 18 def create_s3_object(file_name) s3 = Aws::S3::Client.new s3_body = decoded_issue_screenshot s3.put_object(bucket: @s3_details[:bucket], acl: 'public-read', key: file_name, body: s3_body, content_type: 'image/png') end
decoded_issue_screenshot()
click to toggle source
# File lib/github_issue_maker.rb, line 24 def decoded_issue_screenshot screenshot = self.send(@instance_details[:screenshot_column]) base_64_data_regex = /^data:image\/\w+;base64,/ screenshot.gsub!(base_64_data_regex, '') Base64.decode64(screenshot) end
description_section()
click to toggle source
# File lib/github_issue_maker.rb, line 41 def description_section self.send(@instance_details[:description_column]) end
git_head_section()
click to toggle source
# File lib/github_issue_maker.rb, line 58 def git_head_section self.send(@instance_details[:git_hash_column]) end
github_issue_body(screenshot_url)
click to toggle source
# File lib/github_issue_maker.rb, line 31 def github_issue_body(screenshot_url) body = [] body << "# Description \n #{description_section}" body << "# User \n #{user_section}" body << "# URL \n #{url_section}" body << "# Screenshot \n #{screenshot_section(screenshot_url)}" body << "# HEAD \n #{git_head_section}" body.join("\n \n") end
screenshot_section(screenshot_url)
click to toggle source
# File lib/github_issue_maker.rb, line 54 def screenshot_section(screenshot_url) "" end
url_section()
click to toggle source
# File lib/github_issue_maker.rb, line 50 def url_section self.send(@instance_details[:url_column]) end
user_section()
click to toggle source
# File lib/github_issue_maker.rb, line 45 def user_section user = self.send(@instance_details[:user_method]) "#{user.try(:email) || user.try(:login)} - (#{user.try(:id)})" end
Private Instance Methods
set_config_variables()
click to toggle source
# File lib/github_issue_maker.rb, line 64 def set_config_variables @instance_details = GITHUB_ISSUE_MAKER_CONFIG[:instance_details] @github_details = GITHUB_ISSUE_MAKER_CONFIG[:github_details] @s3_details = GITHUB_ISSUE_MAKER_CONFIG[:s3_details] end