Class: Monorail::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/monorail/app.rb

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



48
49
# File 'lib/monorail/app.rb', line 48

def initialize
end

Instance Method Details

#parse_argumentsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/monorail/app.rb', line 58

def parse_arguments
  @options = OpenStruct.new
  @options.host = "127.0.0.1"
  @options.port = 8090
  @options.ssl = false
  @options.daemon = false
  @options.rails = nil
  @options.monorail = nil

  opts = OptionParser.new {|opts|

    opts.separator ""
    opts.separator "Options summary:"

    opts.on("-a", "--addr IP-address",
      "Requires the host IP address to listen on",
      "    default: 127.0.0.1") {|addr|
        @options.host = addr
    }

    opts.on("-p", "--port TCP port",
      "Requires the TCP port to listen on",
      "    default: 8090") {|port|
        @options.port = port.to_i
    }

    opts.on("-s", "--[no-]ssl", "Require SSL (HTTPS)",
      "    default: false") {|ssl|
        @options.ssl = ssl
    }

    opts.on("-d", "--[no-]daemon", "Run in the background",
      "    default: false") {|d|
        @options.daemon = d
    }

    # TODO, wrong, we need one parameter to select the environment, not several.
    opts.on("--rails [DIR]", "run a rails app in the specified directory",
      "    default: the current directory") {|d|
        @options.rails = d || "."
    }

    opts.on("--monorail [DIR]", "run a monorails app in the specified directory",
      "    default: the current directory") {|d|
        @options.monorail = d || "."
    }

    # Options summary
    opts.on_tail("-h", "--help", "Show this message") {
      puts opts
      exit
    }
    # Version
    opts.on_tail("--version", "Show version") {
      puts Monorail::Version
      exit
    }


  }

  opts.parse!(ARGV)

end

#runObject



52
53
54
55
# File 'lib/monorail/app.rb', line 52

def run
  parse_arguments
  Monorail.new( @options ).run
end