Class: EotbConfigurator
- Inherits:
-
Object
- Object
- EotbConfigurator
- Defined in:
- bin/eotb
Instance Method Summary collapse
- #configure(args) ⇒ Object
- #ensure_parameter_was_set ⇒ Object
- #parse_options ⇒ Object
- #prepare_command ⇒ Object
- #recognize_rails_version ⇒ Object
Instance Method Details
#configure(args) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'bin/eotb', line 46 def configure args @args = args ensure_parameter_was_set recognize_rails_version command = prepare_command system( command ) end |
#ensure_parameter_was_set ⇒ Object
27 28 29 30 31 32 |
# File 'bin/eotb', line 27 def ensure_parameter_was_set if !@app[:apikey] puts "Must pass --api-key or file config/initializers/eotb.rb already exists" exit end end |
#parse_options ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'bin/eotb', line 7 def @app = Hash.new = OptionParser.new do |opts| opts.on("init") do @action = :init end opts.on("-a", "--api-key=[ARG]", "Your API Key") do |opt| @app[:apikey] = opt end opts.on("-d", "--dir=[ARG]", "Directory of app") do |opt| @app[:dir] = opt end end .parse!(ARGV) end |
#prepare_command ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'bin/eotb', line 34 def prepare_command if @version >= "3" command = "rails generate eotb --api-key=#{@app[:apikey]}" else command = "script/generate eotb --api-key=#{@app[:apikey]}" end if @app[:dir] command = "cd "+@app[:dir]+";"+command end command end |
#recognize_rails_version ⇒ Object
23 24 25 |
# File 'bin/eotb', line 23 def recognize_rails_version @version = %x( rails -v ).split[1] end |