New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Adapter with Repository #117

Merged
merged 11 commits into from Jan 15, 2015
View
@@ -4,8 +4,15 @@ require "rake/testtask"
RSpec::Core::RakeTask.new(:spec)
task default: [:ci]
desc 'Run specs in isolation'
task :"spec:isolation" do
FileList["spec/**/*_spec.rb"].each do |spec|
sh "rspec", spec
end
end
desc "Run CI tasks"
task ci: [:spec, :lint]
task ci: [:spec, :lint, :"spec:isolation"]
Rake::TestTask.new(:lint) do |test|
test.description = "Run adapter lint tests against memory adapter"
View
@@ -16,7 +16,6 @@
require 'rom/commands'
require 'rom/adapter'
require 'rom/repository'
require 'rom/config'
View

This file was deleted.

Oops, something went wrong.
@@ -1,61 +1,61 @@
module ROM
class Adapter
module Adapter
module Lint
# This is a simple lint-test for an adapter class to ensure the basic
# interfaces are in place
# This is a simple lint-test for adapter's repository class to ensure the
# basic interfaces are in place
#
# @example
#
# class MyAdapterTest < Minitest::Test
# include ROM::Adapter::Lint::TestAdapter
# include ROM::Adapter::Lint::TestRepository
#
# def setup
# @adapter = MyAdapter
# @repository = MyRepository
# @uri = "super_db://something"
# end
# end
#
# @public
module TestAdapter
attr_reader :adapter, :uri
module TestRepository
attr_reader :repository, :uri
def test_schemes
assert_respond_to adapter, :schemes,
"#{adapter}.schemes must be implemented"
assert_respond_to repository, :schemes,
"#{repository}.schemes must be implemented"
assert_instance_of Array, adapter.schemes,
"#{adapter}.schemes must return an array with supported URI schemes"
assert_instance_of Array, repository.schemes,
"#{repository}.schemes must return an array with supported URI schemes"
assert adapter.schemes.any?,
"#{adapter}.schemes must return at least one supported URI scheme"
assert repository.schemes.any?,
"#{repository}.schemes must return at least one supported URI scheme"
end
def test_setup
assert_instance_of adapter, adapter_instance
assert_instance_of repository, repository_instance
end
def test_dataset_reader
assert_respond_to adapter_instance, :[]
assert_respond_to repository_instance, :[]
end
def test_dataset_predicate
assert_respond_to adapter_instance, :dataset?
assert_respond_to repository_instance, :dataset?
end
private
def adapter_instance
Adapter.setup(uri)
def repository_instance
Repository.setup(uri)
end
end
# This is a simple lint-test for an adapter dataset class to ensure the
# This is a simple lint-test for an repository dataset class to ensure the
# basic behavior is correct
#
# @example
#
# class MyDatasetLintTest < Minitest::Test
# include ROM::Adapter::Lint::TestEnumerableDataset
# include ROM::Repository::Lint::TestEnumerableDataset
#
# def setup
# @data = [{ name: 'Jane', age: 24 }, { name: 'Joe', age: 25 }]
View
@@ -1,33 +1 @@
require 'rom/adapter'
require 'rom/adapter/memory/storage'
require 'rom/adapter/memory/dataset'
require 'rom/adapter/memory/commands'
module ROM
class Adapter
class Memory < Adapter
attr_accessor :logger
def self.schemes
[:memory]
end
def setup
@connection = Storage.new
end
def dataset(name)
self[name] || connection.create_dataset(name)
end
def dataset?(name)
connection.key?(name)
end
def [](name)
connection[name]
end
end
end
end
require 'rom/adapter/memory/repository'
@@ -1,8 +1,8 @@
require 'rom/commands'
module ROM
class Adapter
class Memory < Adapter
module Adapter
module Memory
module Commands
class Create < ROM::Commands::Create
def execute(tuple)
@@ -1,8 +1,8 @@
require 'rom/array_dataset'
module ROM
class Adapter
class Memory < Adapter
module Adapter
module Memory
class Dataset
include ArrayDataset
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.