Sha256: 13b446859f48e06d4719b538c3cc73191890187a6a0a13e19c97cce042ce26e7

Contents?: true

Size: 971 Bytes

Versions: 5

Compression:

Stored size: 971 Bytes

Contents

module ChronoTrigger
  
  class Process

    def run(options={})
      @t = Thread.new do
        setup(options)
        
        shell = ChronoTrigger::Shell.new
        options[:trigger_files] ? shell.load_triggers(options[:trigger_files].split(":")) : shell.load_triggers 
        loop do
          shell.execute_triggers
          sleep 1.minute.to_i
        end
      end
      
      @t.join
    end
    
    def stop
      @t.exit
    end
    
    private
    def setup(options={})
      if application_context = options[:application_context]
        ENV['RAILS_ENV'] = options[:env] || "development"
        
        application_path = File.join(application_context, 'config', 'environment')
        STDOUT.puts "Loading application environment at #{File.join(application_context, 'config', 'environment')} for '#{ENV['RAILS_ENV']}' enviroment."
        require(application_path)              
      end
      
      require "chrono_trigger"
    end
  end    
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
gregfitz23-chrono_trigger-0.1.3 lib/chrono_trigger/process.rb
gregfitz23-chrono_trigger-0.1.4 lib/chrono_trigger/process.rb
gregfitz23-chrono_trigger-0.1.5 lib/chrono_trigger/process.rb
chrono_trigger-0.2.0 lib/chrono_trigger/process.rb
chrono_trigger-0.1.7 lib/chrono_trigger/process.rb