Module: Daengine

Defined in:
lib/daengine.rb,
lib/daengine/engine.rb,
lib/daengine/railtie.rb,
lib/daengine/version.rb,
lib/daengine/taxonomy_processor.rb,
lib/daengine/digital_asset_processor.rb,
lib/daengine/content_service_processor.rb

Defined Under Namespace

Modules: TaxonomyParser, TeamsiteMetadataParser Classes: ContentServiceProcessor, DigitalAssetProcessor, Engine, Railtie, TaxonomyProcessor

Constant Summary collapse

VERSION =
"0.4.7.8"

Class Method Summary collapse

Class Method Details

.configObject



60
61
62
# File 'lib/daengine.rb', line 60

def self.config
  @config
end

.configure(config_options) ⇒ Object

yaml file config



49
50
51
52
53
54
55
56
57
58
# File 'lib/daengine.rb', line 49

def self.configure(config_options)
  config_options.each {|k,v| @config[k.to_sym] = v}
  config_options.each {|k,v| 
    @mongoid_config[k] = v if @valid_mongoid_keys.include? k
  }
  @mongoid_config.delete_if { |k,v| ! v }
  Mongoid.configure do |config|
    config.from_hash(@mongoid_config)
  end
end

.execute(config_options) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/daengine.rb', line 64

def self.execute(config_options)
  self.configure(config_options)
  self.set_logger(config[:logfile_location])
  self.log("Daengine: ### Loading application config ###", "info")
  config_options.each { |key, value| self.log("CONFIG #{key}\t#{value}", "info")}
  begin
    DigitalAssetProcessor.process_tuple_directory  # start the thread daemon
  rescue Exception => e
    self.log(e.message, "error")
  end
end

.execute_content_service(config_options) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/daengine.rb', line 88

def self.execute_content_service(config_options)
  self.configure(config_options)
  self.set_logger(config[:content_service_logfile_location])
  self.log("Daengine: ### Loading application config ###", "info")
  config_options.each { |key, value| self.log("CONFIG #{key}\t#{value}", "info")}
  begin
    ContentServiceProcessor.process_orderable
  rescue Exception => e
    self.log(e.message, "error")
  end
end

.execute_taxonomy(config_options) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/daengine.rb', line 76

def self.execute_taxonomy(config_options)
  self.configure(config_options)
  self.set_logger(config[:taxonomyengine_logfile_location])
  self.log("Daengine: ### Loading application config ###", "info")
  config_options.each { |key, value| self.log("CONFIG #{key}\t#{value}", "info")}
  # begin
    TaxonomyProcessor.process_taxonomy_file
  # rescue Exception => e
  #   self.log(e.message, "error")
  # end
end

.log(message, level) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/daengine.rb', line 35

def self.log(message, level)
  message = "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}"
  puts "#{message}"
  case level
    when "warn"
       @logger.warn "#{message}"
    when "error"
      @logger.error "#{message}"
    else
      @logger.info "#{message}"
  end
end

.loggerObject



104
105
106
# File 'lib/daengine.rb', line 104

def self.logger
  @logger
end

.set_logger(logfile) ⇒ Object



100
101
102
# File 'lib/daengine.rb', line 100

def self.set_logger(logfile)
  @logger = Logger.new(logfile, 'daily')
end