Class: Epuber::Command::Server
- Inherits:
-
Epuber::Command
- Object
- CLAide::Command
- Epuber::Command
- Epuber::Command::Server
- Defined in:
- lib/epuber/command/server.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Epuber::Command
Constructor Details
#initialize(args) ⇒ Server
Returns a new instance of Server.
22 23 24 25 26 |
# File 'lib/epuber/command/server.rb', line 22 def initialize(args) super @selected_target_name = args.shift_argument @open_web_browser = args.flag?('open', false) end |
Class Method Details
.options ⇒ Object
14 15 16 17 18 |
# File 'lib/epuber/command/server.rb', line 14 def self. [ ['--open', 'Opens the web page in default web browser, working only on OS X'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/epuber/command/server.rb', line 35 def run super require_relative '../server' target = if @selected_target_name.nil? book.buildable_targets.first else book.target_named(@selected_target_name) end help!('Not existing target') if target.nil? begin Epuber::Server.run!(book, target, verbose: verbose?) do |uri| if OS.osx? if @open_web_browser system "open #{uri}" else UI.info 'Web browser can be automatically opened by adding --open flag, see --help' end end end rescue Interrupt write_lockfile raise end end |
#validate! ⇒ Object
28 29 30 31 32 33 |
# File 'lib/epuber/command/server.rb', line 28 def validate! super verify_one_bookspec_exists! pre_build_checks end |