Sha256: ddb3a2f9f4be6d2df4463b01aca6683f9dac41bbcecfd29ff5d3ce12d67ec5b8

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

module NudgeGP
  class Factory
    require 'open-uri'
    require 'configatron'
    
    attr_reader :name
    attr_reader :instruction_library, :type_library
    attr_accessor :workstation_names
    attr_reader :original_options_hash
    
    
    def initialize(name = "my_factory", options = {})
      @name = name
      @original_options_hash = options
      @instruction_library = options[:instruction_library] || Instruction.all_instructions
      @type_library = options[:type_library] || NudgeType.all_types
      @workstation_names = Array.new
      
      self.configure!
    end
    
    
    def couch_available?
      open(self.configatron.couchdb_uri).status
      true
    rescue StandardError
      false 
    end
    
    
    def configure!
      self.configure_constants!
      self.configure_paths!
      self.configure_databases!
    end
    
    
    def configure_constants!
      self.configatron.factory_name = self.name
    end
    
    
    def configure_paths!
      self.configatron.factory_root = File.expand_path("#{File.dirname(__FILE__)}/../..")
    end
    
    
    def configure_databases!
      self.configatron.configure_from_yaml("#{self.configatron.factory_root}/config/database.yml")
      self.configatron.couchdb_uri = "#{self.configatron.main_database.db_root}/#{self.name}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
answer-factory-0.0.3 lib/factories/factory.rb
answer-factory-0.0.2 lib/factories/factory.rb
answer-factory-0.0.1 lib/factories/factory.rb