Class: Databasion::CronSystem
- Inherits:
-
Object
- Object
- Databasion::CronSystem
- Defined in:
- lib/databasion/cron_system.rb
Constant Summary collapse
- @@config =
nil
Class Method Summary collapse
- .config ⇒ Object
- .config=(data) ⇒ Object
- .config? ⇒ Boolean
- .run(opts) ⇒ Object
- .write_version(version, version_file) ⇒ Object
Class Method Details
.config ⇒ Object
19 20 21 22 |
# File 'lib/databasion/cron_system.rb', line 19 def self.config config? @@config end |
.config=(data) ⇒ Object
15 16 17 |
# File 'lib/databasion/cron_system.rb', line 15 def self.config=(data) @@config = data end |
.config? ⇒ Boolean
9 10 11 12 13 |
# File 'lib/databasion/cron_system.rb', line 9 def self.config? raise CronSystemError, 'CronSystem cannot load without a config.' unless defined?(@@config) raise CronSystemError, 'CronSystem now requires an environments config section.' unless defined?(@@config['environments']) true end |
.run(opts) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/databasion/cron_system.rb', line 24 def self.run(opts) Databasion::GoogleLoader.config = @@config version = Databasion::GoogleLoader.run_version(opts) version_file = "%s/config/version_%s" % [@@config['project_base'], opts[:env]] if File.exist?(version_file) old_version = File.open(version_file).readline.strip if version > old_version Databasion::LOGGER.info "Version changed, running databasion." system "cd %s && %s %s" % [@@config['project_base'], File.dirname(__FILE__) + '/../../bin/databasion', @@config['environments'][opts[:env]]['cron_options']] write_version(version) elsif version < old_version Databasion::LOGGER.info "Version rollback is currently not implemented." else Databasion::LOGGER.info "Version has not changed." end else Databasion::LOGGER.info "CronSystem running for the first time." system "cd %s && %s %s" % [@@config['project_base'], File.dirname(__FILE__) + '/../../bin/databasion', @@config['environments'][opts[:env]]['cron_options']] write_version(version, version_file) end end |
.write_version(version, version_file) ⇒ Object
48 49 50 51 52 |
# File 'lib/databasion/cron_system.rb', line 48 def self.write_version(version, version_file) File.open(version_file, 'w') do |file| file.write version end end |