Class: ExceptionHub::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/exception_hub/rake_task.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RakeTask

Returns a new instance of RakeTask.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/exception_hub/rake_task.rb', line 7

def initialize(*args)
  namespace :exception_hub do
    desc "Generate ExceptionHub initializer"
    task :generate_initializer do
      puts "Github username:"
      username = STDIN.gets.chomp
      puts "Github password:"
      system('stty -echo')
      password = STDIN.gets.chomp
      system('stty echo')
      puts "Repo name:"
      repo_name = STDIN.gets.chomp
      puts "Repo owner:"
      repo_owner = STDIN.gets.chomp


      puts "Getting authorization from Github"
      auth = ExceptionHub.get_api_token(username, password)

      puts "Generating initializer"
      File.write('./config/initializers/exception_hub.rb', ExceptionHub.generate_initializer(username, auth.token, auth.id, repo_name, repo_owner))
    end
  end
end