class Adhearsion::CLI::PluginCommand
Public Instance Methods
create_ahnhub_hooks()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 28 def create_ahnhub_hooks create_github_hook create_rubygem_hook end
create_github_hook()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 12 def create_github_hook get_github_vals generate_github_webhook end
create_rubygem_hook()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 18 def create_rubygem_hook get_rubygem_vals puts `curl -H 'Authorization:#{ENV['RUBYGEM_AUTH']}' \ -F 'gem_name=#{ENV['RUBYGEM_NAME']}' \ -F 'url=http://www.ahnhub.com/gem' \ https://rubygems.org/api/v1/web_hooks/fire` end
Protected Instance Methods
generate_github_webhook()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 54 def generate_github_webhook require 'net/http' uri = URI("https://api.github.com/repos/#{github_repo_owner}/#{github_repo_name}/hooks") req = Net::HTTP::Post.new(uri.to_s) req.basic_auth ENV['GITHUB_USERNAME'], ENV['GITHUB_PASSWORD'] req.body = { name: "web", active: true, events: ["push", "pull_request"], config: {url: "http://ahnhub.com/github"} }.to_json req["content-type"] = "application/json" Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| response = http.request(req) puts response.body end end
get_github_vals()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 40 def get_github_vals ENV['GITHUB_USERNAME'] ||= ask "What's your github username?" ENV['GITHUB_PASSWORD'] ||= ask "What's your github password?" ENV['GITHUB_REPO'] ||= ask "Please enter the owner and repo (for example, 'adhearsion/new-plugin'): " end
get_rubygem_vals()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 35 def get_rubygem_vals ENV['RUBYGEM_NAME'] ||= ask "What's the rubygem name?" ENV['RUBYGEM_AUTH'] ||= ask "What's your authorization key for Rubygems?" end
github_repo_name()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 50 def github_repo_name ENV['GITHUB_REPO'].split('/')[1] end
github_repo_owner()
click to toggle source
# File lib/adhearsion/cli_commands/plugin_command.rb, line 46 def github_repo_owner ENV['GITHUB_REPO'].split('/')[0] end