Class: PartyFoul::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/party_foul/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/party_foul/install_generator.rb', line 8

def create_initializer_file
           = ask 'GitHub login:'
  password      = ask 'GitHub password:'
  @owner        = ask_with_default "\nRepository owner:", 
  @repo         = ask 'Repository name:'
  @api_endpoint = ask_with_default 'Api Endpoint:', 'https://api.github.com'
  @web_url      = ask_with_default 'Web URL:', 'https://github.com'

  begin
    octokit      = Octokit::Client.new :login => , :password => password, :api_endpoint => @api_endpoint
    @oauth_token = octokit.create_authorization(scopes: ['repo'], note: "PartyFoul #{@owner}/#{@repo}", note_url: "#{@web_url}/#{@owner}/#{@repo}").token
    template 'party_foul.rb', 'config/initializers/party_foul.rb'
  rescue Octokit::Unauthorized
    say 'There was an error retrieving your GitHub OAuth token'
  end
end