Sha256: f30022e42fd098e6975af5056efa3c91725461daedb50608f0ebab164e4b507a

Contents?: true

Size: 1.19 KB

Versions: 13

Compression:

Stored size: 1.19 KB

Contents

require 'yaml'
$environment = "development"
$config = YAML::load(File.open("#{ADAPTOR_ROOT}/config/settings.yml"))[$environment]
Adaptation::Base.new
# connect to test database
require 'active_record'

if File.exists?("#{ADAPTOR_ROOT}/config/database.yml") 
  configurations = YAML::load(File.open("#{ADAPTOR_ROOT}/config/database.yml"))[$environment]
  ActiveRecord::Base.configurations.update($environment => configurations)
  ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[$environment])
end

if File.exists?("log")
  ActiveRecord::Base.logger = Logger.new("#{ADAPTOR_ROOT}/log/"+$environment+".log")
end

def get_xml_from_file xml_file
    contents = new Array
    File.open(xml_file).each { |line|
      unless line =~ /^ {0,}#/
        contents << line.strip.chomp
      end
    }
    "#{contents.chomp}"
end

def xml_to_object xml_message
  class_name = xml_message[1..(xml_message.index(/(>| )/) - 1)]
  message_class = Object.const_get(class_name.capitalize)
  message_object = message_class.to_object(xml_message)
  message_object
end

def xmlfile_to_object xml_file
  xml_message = get_xml_from_file(xml_file.to_s)
  message_object = xml_to_object xml_message
  message_object
end



Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
adaptation-0.0.6 lib/adaptation/console/environment.rb
adaptation-0.0.7 lib/adaptation/console/environment.rb
adaptation-0.0.9 lib/adaptation/console/environment.rb
adaptation-0.0.4 lib/adaptation/console/environment.rb
adaptation-0.0.5 lib/adaptation/console/environment.rb
adaptation-0.0.8 lib/adaptation/console/environment.rb
adaptation-0.1.0 lib/adaptation/console/environment.rb
adaptation-0.1.1 lib/adaptation/console/environment.rb
adaptation-0.1.2 lib/adaptation/console/environment.rb
adaptation-0.1.3 lib/adaptation/console/environment.rb
adaptation-0.1.4 lib/adaptation/console/environment.rb
adaptation-0.1.6 lib/adaptation/console/environment.rb
adaptation-0.1.5 lib/adaptation/console/environment.rb