Sha256: 4712e42c8aec0e6a99a0d22c049613ebab32ae13dc9e025d152a42e609ba30dd

Contents?: true

Size: 1.12 KB

Versions: 71

Compression:

Stored size: 1.12 KB

Contents

require "extface/engine"
require "extface/routes"
require "extface/mapping"
require "extface/extfaceable"
require "redis-namespace"
module Extface
  RAW_DRIVER = "Raw Communication Devices"
  PRINT_DRIVER = "Print Devices"
  FISCAL_DRIVER = "Fiscal Printers & Cash Registers"
  REPORT_DRIVER = "CDR Loggers, Report Devices"
    
  mattr_accessor :redis_connection_string
  
  mattr_reader :mappings
  @@mappings = ActiveSupport::OrderedHash.new
  
  mattr_reader :device_timeout
  @@device_timeout = 10
  
  class << self
    def setup
      yield self
    end

    def add_mapping(resource, options)
      mapping = Extface::Mapping.new(resource, options)
      @@mappings[mapping.name] = mapping
    end
    
    def redis_block
      r = redis_instance
      begin
        yield Redis::Namespace.new(:extface, :redis => r)
      ensure
        r.quit
      end
    end
    
    private
      def redis_instance
        if @@redis_connection_string
          uri = URI.parse(@@redis_connection_string)
          Redis.new(host: uri.host, port: uri.port, password: uri.password)
        else
          Redis.new
        end
      end
  end 
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
extface-0.7.3 lib/extface.rb
extface-0.7.2 lib/extface.rb
extface-0.7.1 lib/extface.rb
extface-0.7.0 lib/extface.rb
extface-0.6.9 lib/extface.rb
extface-0.6.8 lib/extface.rb
extface-0.6.7 lib/extface.rb
extface-0.6.6 lib/extface.rb
extface-0.6.5 lib/extface.rb
extface-0.6.4 lib/extface.rb
extface-0.6.3 lib/extface.rb
extface-0.6.2 lib/extface.rb
extface-0.6.1 lib/extface.rb
extface-0.6.0 lib/extface.rb
extface-0.5.9 lib/extface.rb
extface-0.5.8 lib/extface.rb
extface-0.5.7 lib/extface.rb
extface-0.5.6 lib/extface.rb
extface-0.5.5 lib/extface.rb
extface-0.5.4b lib/extface.rb