class Surbase::InstallGenerator
Public Instance Methods
generate()
click to toggle source
# File lib/generators/surbase/install/install_generator.rb, line 6 def generate file_path = "app/controllers/accounts_controller.rb" if ! File.exists?( file_path ) Command.execute( "rails generate controller accounts" ).output open( file_path, "wb" ){|f| f.puts <<EOS class AccountsController < ApplicationController include Surbase::AccountsController protected def result_api( status ) cookie( :account_info, status.values, 30.days.from_now ) if status.values.key?( :account_id ) redirect_to "/" end end EOS } end file_path = "app/models/account.rb" Command.execute( "rails generate model account provider_id:string login_key:string" ).output if ! File.exists?( file_path ) file_path = "app/models/provider_account.rb" Command.execute( "rails generate model provider_account account_id:integer name:string icon:string encrypted_access_token:string" ).output if ! File.exists?( file_path ) file_path = "config/initializers/surbase.rb" if ! File.exists?( file_path ) open( file_path, "wb" ){|f| f.puts <<EOS Surbase::Config.setup do prefix "" # provider :twitter # provider :facebook # provider :github end EOS } end file_path = "config/surbase_secrets.rb" if ! File.exists?( file_path ) open( file_path, "wb" ){|f| f.puts <<EOS Surbase::Secrets.setup do set( :CIPHER_NAME, "AES-256-CBC" ) # set( :TWITTER_KEY, "" ) # set( :TWITTER_SECRET, "" ) # set( :FACEBOOK_KEY, "" ) # set( :FACEBOOK_SECRET, "" ) # set( :GITHUB_KEY, "" ) # set( :GITHUB_SECRET, "" ) end EOS } Command.execute( %Q(echo "\n#{file_path}" >> .gitignore) ) end end