Class: SynchronizeUsers::App
- Inherits:
-
Object
- Object
- SynchronizeUsers::App
- Defined in:
- lib/synchronize-users/app.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#config_filename ⇒ Object
Returns the value of attribute config_filename.
-
#logfile ⇒ Object
Returns the value of attribute logfile.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/synchronize-users/app.rb', line 3 def config @config end |
#config_filename ⇒ Object
Returns the value of attribute config_filename.
3 4 5 |
# File 'lib/synchronize-users/app.rb', line 3 def config_filename @config_filename end |
#logfile ⇒ Object
Returns the value of attribute logfile.
3 4 5 |
# File 'lib/synchronize-users/app.rb', line 3 def logfile @logfile end |
Class Method Details
.run(argv) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/synchronize-users/app.rb', line 14 def self.run(argv) s = self.new OptionParser.new do |opts| opts. = "Usage: #{$0} [options]" opts.on("-f", "--logfile FILE", "Logfile", s.method(:logfile=)) opts.on("-v", "--verbose", "Verbose") do |x| s.logger.level = ::Logger::DEBUG end opts.on("-c", "--config FILE", "Config file", s.method(:config_filename=)) opts.parse!(argv) end LSpace[:logger] = s.logger if s.config_filename s.read_config s.run! end end |
Instance Method Details
#logger ⇒ Object
36 37 38 39 40 |
# File 'lib/synchronize-users/app.rb', line 36 def logger @logger ||= ::Logger.new(logfile || STDOUT).tap do |l| l.level = ::Logger::INFO end end |
#read_config ⇒ Object
10 11 12 |
# File 'lib/synchronize-users/app.rb', line 10 def read_config @config = SynchronizeUsers.load_config(config_filename) end |
#run! ⇒ Object
5 6 7 8 |
# File 'lib/synchronize-users/app.rb', line 5 def run! app = SynchronizeUsers::Sync.new(@config) app.run! end |