Module: PlantWatchdog
- Defined in:
- lib/plantwatchdog/db.rb,
lib/plantwatchdog/data.rb,
lib/plantwatchdog/main.rb,
lib/plantwatchdog/model.rb,
lib/plantwatchdog/sinatra.rb,
lib/plantwatchdog/aggregation.rb,
lib/plantwatchdog/aggregation_methods.rb
Defined Under Namespace
Modules: ActiveRecordConnections, Aggregation, Datadetection, Model, Monthhelper, UI, Version Classes: ConnectionError, DayOfYearConverter
Class Method Summary collapse
-
.parse_command_line(args) ⇒ Object
Parses the command line arguments.
-
.start ⇒ Object
Starts App.
Class Method Details
.parse_command_line(args) ⇒ Object
Parses the command line arguments
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/plantwatchdog/main.rb', line 32 def self.parse_command_line args = OpenStruct.new .config_file = File.join(File.dirname(__FILE__),'..', '..', 'config', 'app_config.yaml') .aggregate = false args. do |opt| opt.on("Usage:") opt.on("plantwatchdog [options]") opt.on("Options:") opt.on("--debug", "-d","Turns on debug messages") { $DEBUG=true } opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 } opt.on("--config_file FILE", "-c FILE", "The config file") { |file| .config_file = file } opt.on("--aggregate", "-a", "Run daily data aggregation") { .aggregate = true } opt.on("--create_solar", nil, "Create database with sample data from a solar generator") { .createsolar = true } opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 } opt.parse! end end |
.start ⇒ Object
Starts App
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/plantwatchdog/main.rb', line 51 def self.start logger=Patir.setup_logger =parse_command_line(ARGV) if File.exists?(.config_file) config=YAML.load(File.read(.config_file)) config[:logger]=logger else logger.fatal("Cannot find #{.config_file}") exit 1 end extend PlantWatchdog::ActiveRecordConnections self.connect_to_active_record(config[:database_configuration],logger) if .createsolar then $:.unshift File.join(File.dirname(__FILE__),"..","..") require 'sample/solar/create_solar' PlantWatchdog::CreateSolar.create elsif .aggregate then require 'plantwatchdog/aggregation' Aggregation::Runner.new.run else PlantWatchdog::UI::SinatraApp.run! end end |