Sha256: 3b78f9e78164b909978bbfa0417186055cd388c82d05e52266867af2c5de4623

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

require 'highrise'
require 'erb'
require 'logger'
require 'tempfile'
require 'pathname'
require 'yaml'

Encoding.default_internal = "utf-8"
Encoding.default_external = "utf-8"

#Adds a way to retrieve Submodules of a Module, used for CustomContentParsers
class Module
  def submodules
    constants.collect {|const_name| const_get(const_name)}.select {|const| const.class == Module}
  end
end

module HighriseMapper

  load 'highrise_mapper/context.rb'
  load 'highrise_mapper/person.rb'

  def self.config(root_dir=nil)
    @config ||= load_config(root_dir)
  end

  def self.load_config(root_dir=nil)
    root_dir ||= Pathname.new(Dir.pwd)
    
    path = "#{root_dir}/config/highrise_mapper.yml"

    raise "Couldn't find config yml at #{path}." unless File.file?(path)
    content = File.read(path)
    erb = ERB.new(content).result
    YAML.load(erb).with_indifferent_access
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
highrise_mapper-0.0.3 lib/highrise_mapper.rb
highrise_mapper-0.0.2 lib/highrise_mapper.rb