Class: ItunesController::Application
- Inherits:
-
Object
- Object
- ItunesController::Application
- Defined in:
- lib/itunesController/application.rb
Instance Method Summary collapse
- #checkAppOptions ⇒ Object
-
#checkOptions ⇒ Object
Used to check the command line options are valid.
-
#displayUsage ⇒ Object
Used to display the command line useage.
- #exec ⇒ Object
- #execApp(controllerCreator) ⇒ Object
- #genericOptionDescription ⇒ Object
- #getOptions ⇒ Object
-
#initialize(appName) ⇒ Application
constructor
A new instance of Application.
- #parseAppOptions(opts) ⇒ Object
- #parseOptions ⇒ Object
-
#usageError(message) ⇒ Object
Used to display a error message and the command line usesage.
Constructor Details
#initialize(appName) ⇒ Application
Returns a new instance of Application.
34 35 36 37 38 |
# File 'lib/itunesController/application.rb', line 34 def initialize(appName) @appName = appName @options = {} @options[:logFile] = nil end |
Instance Method Details
#checkAppOptions ⇒ Object
119 120 |
# File 'lib/itunesController/application.rb', line 119 def checkAppOptions() end |
#checkOptions ⇒ Object
Used to check the command line options are valid
66 67 68 |
# File 'lib/itunesController/application.rb', line 66 def checkOptions checkAppOptions end |
#displayUsage ⇒ Object
Used to display the command line useage
51 52 53 54 55 |
# File 'lib/itunesController/application.rb', line 51 def displayUsage() puts("Usage: "+@appName+" [options]") puts("") puts(genericOptionDescription()) end |
#exec ⇒ Object
105 106 107 108 109 110 |
# File 'lib/itunesController/application.rb', line 105 def exec() parseOptions controllerCreator = createController() execApp(controllerCreator) #controller.close() end |
#execApp(controllerCreator) ⇒ Object
122 123 124 |
# File 'lib/itunesController/application.rb', line 122 def execApp(controllerCreator) raise "ERROR: Your trying to instantiate an abstract class" end |
#genericOptionDescription ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/itunesController/application.rb', line 40 def genericOptionDescription() result=[] result.push("Specific options:") result.push(" -f, --log_file FILE Optional paramter used to log messages to") result.push(" -l, --log_config LEVEL Optional paramter used to log level [DEBUG|INFO|WARN|ERROR]") result.push(" -v, --version Display version of the application") result.push(" -h, --help Display this screen") return result.join("\n") end |
#getOptions ⇒ Object
112 113 114 |
# File 'lib/itunesController/application.rb', line 112 def getOptions() return @options end |
#parseAppOptions(opts) ⇒ Object
116 117 |
# File 'lib/itunesController/application.rb', line 116 def parseAppOptions(opts) end |
#parseOptions ⇒ Object
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 |
# File 'lib/itunesController/application.rb', line 70 def parseOptions optparse = OptionParser.new do|opts| opts. = "Usage: "+@appName+" [options]" opts.separator "" opts.separator "Specific options:" opts.on('-f','--log_file FILE','Optional paramter used to log messages to') do |value| @options[:logFile] = value ItunesController::ItunesControllerLogging::setLogFile(@options[:logFile]) end opts.on('-l','--log_config LEVEL','Optional paramter used to log level [DEBUG|INFO|WARN|ERROR]') do |value| @options[:logConfig] = value ItunesController::ItunesControllerLogging::setLogLevelFromString(@options[:logConfig]) end parseAppOptions(opts) opts.on_tail( '-v', '--version', 'Display version of the application' ) do puts "itunes-remote-control-server "+ItunesController::VERSION puts "Copyright (C) 2012 John-Paul Stanford" puts "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>." puts "This is free software: you are free to change and redistribute it." puts "There is NO WARRANTY, to the extent permitted by law." puts "" puts "Authors: John-Paul Stanford <[email protected]>" puts "Website: http://code.google.com/p/itunes-remote-control-server/" end opts.on_tail( '-h', '--help', 'Display this screen' ) do puts opts exit end end optparse.parse! checkOptions() end |
#usageError(message) ⇒ Object
Used to display a error message and the command line usesage
59 60 61 62 63 |
# File 'lib/itunesController/application.rb', line 59 def usageError() $stderr.puts "ERROR: "+ displayUsage() exit(1) end |