Арутр Арутр - 6 months ago 24
Ruby Question

How to make a call rake console, these settings are set by default?

How to make a call rake console, these settings are set by default?

2.3.0: 001> (ENV [ 'BATTLE_NET_REGION'] = 'eu') and (ENV [ 'BATTLE_NET_LOCALE'] = 'ru_RU') and (ENV [ 'BATTLE_NET_KEY'] = 'my_battle_net_key')


rake task:

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task default: :spec

desc 'Open an irb session preloaded with this library'
task :console do
sh 'irb -rubygems -I lib -r wowrb.rb'
end

Answer

You could add tho variables to the shell command:

task :console do
  sh 'BATTLE_NET_REGION=eu BATTLE_NET_LOCALE=ru_RU BATTLE_NET_KEY=my_battle_net_key irb -rubygems -I lib -r wowrb.rb'
end

But why do you use a rake task to start a irb console? Would it be easier to start it directly or with a small shell script or alias that sets all variables?

Comments