Class: Flunkey::Application
- Inherits:
-
Object
- Object
- Flunkey::Application
- Defined in:
- lib/flunkey/application.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #default_options ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #parse(args) ⇒ Object
- #run(args = ARGV) ⇒ Object
- #run_server ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
44 45 46 |
# File 'lib/flunkey/application.rb', line 44 def initialize self. = {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/flunkey/application.rb', line 7 def @options end |
Class Method Details
.run(args = ARGV) ⇒ Object
40 41 42 |
# File 'lib/flunkey/application.rb', line 40 def self.run(args = ARGV) new.run(args) end |
Instance Method Details
#default_options ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/flunkey/application.rb', line 14 def root = File.('../../', File.dirname(__FILE__)) { root: root, port: 8080, address: '127.0.0.1', paths: [root] } end |
#parse(args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/flunkey/application.rb', line 24 def parse(args) optparse = OptionParser.new do|opts| opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts Flunkey::VERSION exit end end optparse.parse(args) .merge end |
#run(args = ARGV) ⇒ Object
9 10 11 12 |
# File 'lib/flunkey/application.rb', line 9 def run(args = ARGV) @options = parse(args) run_server end |