Sha256: d9f1c7b1660b1566dd3df2da1f5fd98e94710a9c75571c562fc4eb001f435b99

Contents?: true

Size: 685 Bytes

Versions: 6

Compression:

Stored size: 685 Bytes

Contents

require 'optparse'

module RubyStation
  @port = nil
  @data_dir = nil

  def self.parse_argv
    OptionParser.new{|o|
      o.on("--port N"){|n| @port = n}
      o.on("--data-dir PATH"){|d| @data_dir = d}
    }.parse!(ARGV)

    unless @port
      @port = 40000 + rand(10000)
      warn "--port is not specified; assuming it is #{@port}"
    end
    unless @data_dir
      @data_dir = File.expand_path("./")
      warn "--data-dir is not specified; assuming it is #{@data_dir}" 
    end
  end

  def self.port; @port; end
  def self.data_dir; @data_dir; end
  def self.data_path(filename)
    File.expand_path(filename, @data_dir)
  end

  autoload :Helper, "ruby-station/helper"
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ruby-station-0.1.3 runtime/lib/ruby-station.rb
ruby-station-0.1.2 runtime/lib/ruby-station.rb
ruby-station-0.1.1 runtime/lib/ruby-station.rb
ruby-station-0.1.0 runtime/lib/ruby-station.rb
ruby-station-0.0.4 runtime/lib/ruby-station.rb
ruby-station-runtime-0.0.4 lib/ruby-station.rb