Class: GameMachine::Console::Server
- Inherits:
-
Object
- Object
- GameMachine::Console::Server
- Defined in:
- lib/game_machine/console/server.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #check_start_dir ⇒ Object
-
#initialize(argv) ⇒ Server
constructor
A new instance of Server.
- #parse_arguments(arguments) ⇒ Object
- #run! ⇒ Object
- #set_environment ⇒ Object
Constructor Details
#initialize(argv) ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/game_machine/console/server.rb', line 7 def initialize(argv) @options = parse_arguments(argv) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/game_machine/console/server.rb', line 6 def @options end |
Instance Method Details
#check_start_dir ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/game_machine/console/server.rb', line 11 def check_start_dir java_dir = File.join(File.(Dir.pwd),'java') unless File.directory?(java_dir) puts "Please run game_machine from your game directory" exit 1 end end |
#parse_arguments(arguments) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/game_machine/console/server.rb', line 31 def parse_arguments(arguments) = {} OptionParser.new do |opt| opt. = "Usage: game_machine server [options]" opt.on('-c', '--config=name', String, 'Configuration file') { |v| [:config] = v.strip } opt.on("-e", "--environment=name", String, "Specifies the environment to run under (development/production).", "Default: development") { |v| [:environment] = v.strip } opt.parse!(arguments) end unless .has_key?(:environment) [:environment] = 'development' end end |
#run! ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/game_machine/console/server.rb', line 23 def run! check_start_dir GameMachine.logger.info "Starting with options = #{.inspect}" GameMachine::Application.initialize! GameMachine::Application.start end |
#set_environment ⇒ Object
19 20 21 |
# File 'lib/game_machine/console/server.rb', line 19 def set_environment ENV['GAME_ENV'] = [:environment] end |