Class: Cloudpress::InitializerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/cloudpress/initializer/initializer_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/cloudpress/initializer/initializer_generator.rb', line 5

def create_initializer_file    
  if Cloudpress.unconfigured?
    say "Cloudpress is unconfigured, please enter the following:"
    app_key    = ask "Application Key:"
    app_secret = ask "Application Secret:"
  else
    app_key     = Cloudpress.config.app_key
    app_secret = Cloudpress.config.app_secret
  end

  connector  = Cloudpress::Dropbox::Connector.new(app_key, app_secret)

  say "Please visit the following URL: #{connector.authorize_url}"
  code  = ask("Enter the code:")
  token, _uid = connector.authorize!(code)

  initializer 'cloudpress.rb' do 
    <<-EOF
Cloudpress.configure do |config|
  config.app_key        = "#{app_key}"
  config.app_secret     = "#{app_secret}"
  config.app_token      = "#{token}"
  config.draft_user     = nil
  config.draft_password = nil
end
    EOF
  end
end