Sha256: c267aef7673228c321a3b2ef2aebe488a89f143ff8ed85130f57a177c55ece6e
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
require 'rails/generators' class EotbGenerator < Rails::Generators::Base desc "Creates eotb initializer in confing/initializers/eotb.rb, setting your app to work with Beholder." source_root File.expand_path('../../../../generators/eotb/templates', __FILE__) class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Beholder API key" class_option :login, :aliases => "-l", :type => :string, :desc => "Your Beholder app login" class_option :password, :aliases => "-d", :type => :string, :desc => "Your Beholder app password" def generator ensure_parameters_was_set generate_initializer unless api_key_configured? puts "Eotb is configured!" puts "File 'config/initializers/eotb.rb' was created!" puts "Start using eotb now!" end private def ensure_parameters_was_set if api_key_configured? puts "Configuration file already exists: config/initializers/eotb.rb" exit end end def api_key_exp "#{options[:api_key]}" end def login_exp "#{options[:login]}" end def password_exp "#{options[:password]}" end def generate_initializer template 'initializer.rb', 'config/initializers/eotb.rb' end def api_key_configured? if !options[:api_key] puts "Must pass --api-key='your_api_key' or -k 'your_api_key'" exit elsif !options[:email] puts "Must pass --email='app_email' or -l 'app_email'" exit elsif !options[:password] puts "Must pass --password='app_password' or -d 'app_password'" exit end File.exists?('config/initializers/eotb.rb') && options[:api_key].empty? && options[:login].empty? && options[:password].empty? end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eotb-0.5.16 | lib/generators/eotb/eotb_generator.rb |
eotb-0.5.15 | lib/generators/eotb/eotb_generator.rb |
eotb-0.5.14 | lib/generators/eotb/eotb_generator.rb |