Sha256: f705eecb43d84ed77ee0f368c00ccdb201211cd1b0656ae14cd926b584f98c6c

Contents?: true

Size: 1.02 KB

Versions: 17

Compression:

Stored size: 1.02 KB

Contents

module Khronos
  class Storage
    module Adapter
      @frameworks = {
        'mongodb' => 'mongoid',
        'postgresql' => 'activerecord',
        'mysql2' => 'activerecord',
        'sqlite3' => 'activerecord'
      }
      @classes = {
        'activerecord' => 'ActiveRecord',
        'mongoid' => 'Mongoid'
      }
      @adapters = {
        'mongodb' => 'mongoid'
      }

      def self.parse_uri(uri)
        data = URI.parse(uri)
        {
          :scheme     => data.scheme,
          :host       => data.host,
          :user       => data.user,
          :password   => data.password,
          :path       => data.path
        }
      end

      def self.get(url)
        uri = parse_uri(url)
        framework = @frameworks[uri[:scheme]]

        require "khronos/storage/adapter/#{framework}"

        # Get and connect with the adapter class.
        adapter = const_get(@classes[framework])

        # uri.merge(:adapter => @adapters[uri[:scheme]] || uri[:scheme])
        adapter.connect!(url)
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
khronos-0.1.3 lib/khronos/storage/adapter.rb
khronos-0.1.2 lib/khronos/storage/adapter.rb
khronos-0.1.1 lib/khronos/storage/adapter.rb
khronos-0.1.0 lib/khronos/storage/adapter.rb
khronos-0.0.3.pre4 lib/khronos/storage/adapter.rb
khronos-0.0.3.pre3 lib/khronos/storage/adapter.rb
khronos-0.0.3.pre2 lib/khronos/storage/adapter.rb
khronos-0.0.3.pre1 lib/khronos/storage/adapter.rb
khronos-0.0.2 lib/khronos/storage/adapter.rb
khronos-0.0.2.pre1 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre6 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre5 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre4 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre3 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre2 lib/khronos/storage/adapter.rb
khronos-0.0.1.pre1 lib/khronos/storage/adapter.rb
khronos-0.0.1 lib/khronos/storage/adapter.rb