Class: Miron::Command::Server

Inherits:
Miron::Command show all
Defined in:
lib/miron/command/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Miron::Command

run

Constructor Details

#initialize(argv) ⇒ Server

Returns a new instance of Server


15
16
17
18
19
20
21
22
23
24
# File 'lib/miron/command/server.rb', line 15

def initialize(argv)
  @options = {}
  @options['port'] = argv.option('port') || 9290
  @options['handler'] = argv.option('handler')
  if argv.options.key?('mironfile')
    @options['mironfile'] = Pathname.pwd + argv.option('mironfile')
  end
  @mironfile = fetch_mironfile
  super
end

Class Method Details

.optionsObject


7
8
9
10
11
12
13
# File 'lib/miron/command/server.rb', line 7

def self.options
  [
    ['--port=PORT', 'Port to run the Mironfile on'],
    ['--handler=HANDLER', 'Handler to use for your Miron-backed server'],
    ['--mironfile=MIRONFILE', 'Path to Mironfile, if you are not planning on using a Mironfile.rb']
  ].concat(super)
end

Instance Method Details

#runObject


31
32
33
34
# File 'lib/miron/command/server.rb', line 31

def run
  server = Miron::Server.new(@mironfile, @options)
  server.start
end

#validate!Object


26
27
28
29
# File 'lib/miron/command/server.rb', line 26

def validate!
  super
  help! 'No Mironfile found in directory.' unless fetch_mironfile
end