Module: Daengine

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

Defined Under Namespace

Modules: HTTP, TaxonomyParser, TeamsiteMetadataParser, TeamsiteMetadataProcessor Classes: ContentServiceProcessor, DigitalAssetProcessor, Document, Engine, Railtie, TaxonomyProcessor

Constant Summary collapse

VERSION =
"0.6.8"

Class Method Summary collapse

Class Method Details

.configObject



62
63
64
# File 'lib/daengine.rb', line 62

def self.config
  @config
end

.configure(config_options) ⇒ Object

yaml file config



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

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



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

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



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

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



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

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



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

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



106
107
108
# File 'lib/daengine.rb', line 106

def self.logger
  @logger
end

.set_logger(logfile) ⇒ Object



102
103
104
# File 'lib/daengine.rb', line 102

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