axiom-memory-adapter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -8
- data/Gemfile +7 -2
- data/Gemfile.devtools +24 -29
- data/Guardfile +7 -0
- data/README.md +39 -17
- data/axiom-memory-adapter.gemspec +2 -1
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/mutant.yml +2 -2
- data/config/reek.yml +3 -6
- data/config/rubocop.yml +33 -0
- data/lib/axiom/adapter/memory.rb +58 -53
- data/lib/axiom/adapter/memory/version.rb +4 -4
- data/spec/integration/axiom/adapter/memory_spec.rb +52 -0
- data/spec/shared/base_relation_context.rb +8 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/axiom/adapter/memory/class_methods/new_spec.rb +33 -0
- data/spec/unit/axiom/adapter/memory/element_reader_spec.rb +27 -0
- data/spec/unit/axiom/adapter/memory/element_writer_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/materialized/update_spec.rb +17 -0
- data/spec/unit/axiom/relation/variable/update_spec.rb +17 -0
- metadata +39 -9
- checksums.yaml +0 -7
data/.travis.yml
CHANGED
@@ -7,8 +7,15 @@ rvm:
|
|
7
7
|
- 2.0.0
|
8
8
|
- ruby-head
|
9
9
|
- rbx-19mode
|
10
|
-
|
11
|
-
|
10
|
+
matrix:
|
11
|
+
include:
|
12
|
+
- rvm: jruby-19mode
|
13
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
14
|
+
- rvm: jruby-head
|
15
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
16
|
+
allow_failures:
|
17
|
+
# broken on travis
|
18
|
+
- rvm: ruby-head
|
12
19
|
notifications:
|
13
20
|
irc:
|
14
21
|
channels:
|
@@ -20,9 +27,3 @@ notifications:
|
|
20
27
|
- dan.kubb@gmail.com
|
21
28
|
on_success: never
|
22
29
|
on_failure: change
|
23
|
-
matrix:
|
24
|
-
include:
|
25
|
-
- rvm: jruby-19mode
|
26
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
27
|
-
- rvm: jruby-head
|
28
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
data/Gemfile
CHANGED
@@ -4,5 +4,10 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem '
|
8
|
-
|
7
|
+
gem 'axiom', '~> 0.1.1', git: 'https://github.com/dkubb/axiom.git'
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
|
11
|
+
end
|
12
|
+
|
13
|
+
eval_gemfile 'Gemfile.devtools'
|
data/Gemfile.devtools
CHANGED
@@ -1,52 +1,47 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'rake', '~> 10.0
|
5
|
-
gem 'rspec', '~> 2.
|
6
|
-
gem 'yard', '~> 0.8.
|
4
|
+
gem 'rake', '~> 10.1.0'
|
5
|
+
gem 'rspec', '~> 2.14.1'
|
6
|
+
gem 'yard', '~> 0.8.7'
|
7
7
|
end
|
8
8
|
|
9
9
|
group :yard do
|
10
|
-
gem 'kramdown', '~> 1.0
|
10
|
+
gem 'kramdown', '~> 1.1.0'
|
11
11
|
end
|
12
12
|
|
13
13
|
group :guard do
|
14
|
-
gem 'guard', '~> 1.8.
|
14
|
+
gem 'guard', '~> 1.8.1'
|
15
15
|
gem 'guard-bundler', '~> 1.0.0'
|
16
16
|
gem 'guard-rspec', '~> 3.0.2'
|
17
|
+
gem 'guard-rubocop', '~> 0.2.0'
|
18
|
+
gem 'guard-mutant', '~> 0.0.1'
|
17
19
|
|
18
20
|
# file system change event handling
|
19
|
-
gem 'listen', '~> 1.
|
20
|
-
gem 'rb-fchange', '~> 0.0.6', :
|
21
|
-
gem 'rb-fsevent', '~> 0.9.3', :
|
22
|
-
gem 'rb-inotify', '~> 0.9.0', :
|
21
|
+
gem 'listen', '~> 1.3.0'
|
22
|
+
gem 'rb-fchange', '~> 0.0.6', require: false
|
23
|
+
gem 'rb-fsevent', '~> 0.9.3', require: false
|
24
|
+
gem 'rb-inotify', '~> 0.9.0', require: false
|
23
25
|
|
24
26
|
# notification handling
|
25
|
-
gem 'libnotify', '~> 0.8.0', :
|
26
|
-
gem 'rb-notifu', '~> 0.0.4', :
|
27
|
-
gem 'terminal-notifier-guard', '~> 1.5.3', :
|
27
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
28
|
+
gem 'rb-notifu', '~> 0.0.4', require: false
|
29
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
28
30
|
end
|
29
31
|
|
30
32
|
group :metrics do
|
31
|
-
gem '
|
32
|
-
gem '
|
33
|
-
gem '
|
34
|
-
gem '
|
35
|
-
gem '
|
36
|
-
gem 'simplecov',
|
37
|
-
gem 'yardstick',
|
38
|
-
|
39
|
-
platforms :ruby_19 do
|
33
|
+
gem 'coveralls', '~> 0.6.7'
|
34
|
+
gem 'flay', '~> 2.4.0'
|
35
|
+
gem 'flog', '~> 4.1.1'
|
36
|
+
gem 'reek', '~> 1.3.2'
|
37
|
+
gem 'rubocop', '~> 0.11.0'
|
38
|
+
gem 'simplecov', '~> 0.7.1'
|
39
|
+
gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
|
40
|
+
|
41
|
+
platforms :ruby_19, :ruby_20 do
|
42
|
+
gem 'mutant', git: 'https://github.com/mbj/mutant.git'
|
40
43
|
gem 'yard-spellcheck', '~> 0.1.5'
|
41
44
|
end
|
42
|
-
|
43
|
-
platforms :mri_19, :rbx do
|
44
|
-
gem 'mutant', '~> 0.2.20'
|
45
|
-
end
|
46
|
-
|
47
|
-
platforms :rbx do
|
48
|
-
gem 'pelusa', '~> 0.2.2'
|
49
|
-
end
|
50
45
|
end
|
51
46
|
|
52
47
|
group :benchmarks do
|
data/Guardfile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
guard :bundler do
|
4
4
|
watch('Gemfile')
|
5
|
+
watch('Gemfile.lock')
|
5
6
|
watch('axiom-memory-adapter.gemspec')
|
6
7
|
end
|
7
8
|
|
@@ -22,3 +23,9 @@ guard :rspec, :keep_failed => false do
|
|
22
23
|
# run a spec if it is modified
|
23
24
|
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
24
25
|
end
|
26
|
+
|
27
|
+
guard :rubocop, cli: %w[--config config/rubocop.yml] do
|
28
|
+
watch(%r{.+\.(?:rb|rake)\z})
|
29
|
+
watch(%r{\Aconfig/rubocop\.yml\z}) { |m| File.dirname(m[0]) }
|
30
|
+
watch(%r{(?:.+/)?\.rubocop\.yml\z}) { |m| File.dirname(m[0]) }
|
31
|
+
end
|
data/README.md
CHANGED
@@ -15,27 +15,49 @@ axiom-memory-adapter
|
|
15
15
|
|
16
16
|
Use Axiom relations with an in-memory datastore
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
Examples
|
19
|
+
--------
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
require 'axiom-memory-adapter'
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
adapter = Axiom::Adapter::Memory.new(
|
25
|
+
customers: Axiom::Relation.new([[:id, Integer], [:name, String]]),
|
26
|
+
orders: Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]])
|
27
|
+
)
|
28
|
+
|
29
|
+
# Insert customer data
|
30
|
+
customers = adapter[:customers]
|
31
|
+
customers.insert([[1, 'Dan Kubb']])
|
32
|
+
customers.insert([[2, 'John Doe']])
|
33
|
+
|
34
|
+
# Insert order data
|
35
|
+
orders = adapter[:orders]
|
36
|
+
orders.insert([[1, 1]])
|
37
|
+
orders.insert([[2, 1]])
|
38
|
+
orders.insert([[3, 1]])
|
39
|
+
orders.insert([[4, 2]])
|
40
|
+
|
41
|
+
# Join customers and orders
|
42
|
+
customer_orders = customers.
|
43
|
+
rename(id: :customer_id).
|
44
|
+
join(orders.rename(id: :order_id))
|
45
|
+
|
46
|
+
# Demonstrate writable view-like behaviour
|
47
|
+
|
48
|
+
# Insert into the join
|
49
|
+
customer_orders.insert([[3, 'Jane Doe', 5]])
|
50
|
+
|
51
|
+
# Inserts are propagated to the base relations
|
52
|
+
customers.count # => 3
|
53
|
+
orders.count # => 5
|
29
54
|
|
30
|
-
|
55
|
+
# Delete from a join
|
56
|
+
customer_orders.delete([[3, 'Jane Doe', 5]])
|
31
57
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
$ rake install
|
36
|
-
$ irb -rubygems
|
37
|
-
>> require 'axiom-memory-adapter'
|
38
|
-
=> true
|
58
|
+
# Deletes are propagated to the base relations
|
59
|
+
customers.count # => 2
|
60
|
+
orders.count # => 4
|
39
61
|
```
|
40
62
|
|
41
63
|
Contributing
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
|
18
18
|
gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
|
19
19
|
|
20
|
-
gem.add_runtime_dependency('axiom',
|
20
|
+
gem.add_runtime_dependency('axiom', '~> 0.1.1')
|
21
|
+
gem.add_runtime_dependency('thread_safe', '~> 0.1.0')
|
21
22
|
|
22
23
|
gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
|
23
24
|
end
|
data/config/flay.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
3
|
-
total_score:
|
2
|
+
threshold: 3
|
3
|
+
total_score: 7
|
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 4.2
|
data/config/mutant.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
name:
|
3
|
-
namespace:
|
2
|
+
name: axiom-memory-adapter
|
3
|
+
namespace: Axiom::Adapter::Memory
|
data/config/reek.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
---
|
2
2
|
Attribute:
|
3
3
|
enabled: true
|
4
|
-
exclude:
|
4
|
+
exclude:
|
5
|
+
- Axiom::Adapter::Memory
|
5
6
|
BooleanParameter:
|
6
7
|
enabled: true
|
7
8
|
exclude: []
|
@@ -96,11 +97,7 @@ UncommunicativeVariableName:
|
|
96
97
|
accept: []
|
97
98
|
UnusedParameters:
|
98
99
|
enabled: true
|
99
|
-
exclude:
|
100
|
-
- Axiom::Adapter::Memory#delete
|
101
|
-
- Axiom::Adapter::Memory#insert
|
102
|
-
- Axiom::Adapter::Memory#read
|
103
|
-
- Axiom::Adapter::Memory#update
|
100
|
+
exclude: []
|
104
101
|
UtilityFunction:
|
105
102
|
enabled: true
|
106
103
|
exclude: []
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- '**/*.rake'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.devtools'
|
6
|
+
Excludes:
|
7
|
+
- '**/vendor/**'
|
8
|
+
|
9
|
+
# Avoid parameter lists longer than five parameters.
|
10
|
+
ParameterLists:
|
11
|
+
Max: 3
|
12
|
+
CountKeywordArgs: true
|
13
|
+
|
14
|
+
# Avoid more than `Max` levels of nesting.
|
15
|
+
BlockNesting:
|
16
|
+
Max: 3
|
17
|
+
|
18
|
+
# Align with the style guide.
|
19
|
+
CollectionMethods:
|
20
|
+
PreferredMethods:
|
21
|
+
collect: 'map'
|
22
|
+
inject: 'reduce'
|
23
|
+
find: 'detect'
|
24
|
+
find_all: 'select'
|
25
|
+
|
26
|
+
# Do not force public/protected/private keyword to be indented at the same
|
27
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
28
|
+
# because I think when scanning code it makes it easier to identify the
|
29
|
+
# sections of code and visually separate them. When the keyword is at the same
|
30
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
31
|
+
# to scan the code and see where the sections are.
|
32
|
+
AccessControl:
|
33
|
+
Enabled: false
|
data/lib/axiom/adapter/memory.rb
CHANGED
@@ -1,98 +1,103 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'axiom'
|
4
|
+
require 'thread_safe'
|
4
5
|
|
5
6
|
module Axiom
|
6
7
|
module Adapter
|
7
8
|
|
8
9
|
# A reference adapter for in-memory information
|
9
10
|
class Memory
|
10
|
-
include Adamantium
|
11
|
+
include Adamantium::Flat
|
11
12
|
|
12
|
-
#
|
13
|
+
# Raised when the relation name is unknown
|
14
|
+
UnknownRelationError = Class.new(IndexError)
|
15
|
+
|
16
|
+
# The schema
|
13
17
|
#
|
14
|
-
# @return [
|
18
|
+
# @return [Hash{Symbol => Axiom::Relation::Variable}]
|
15
19
|
#
|
16
20
|
# @api private
|
17
|
-
|
18
|
-
|
19
|
-
end
|
21
|
+
attr_reader :schema
|
22
|
+
private :schema
|
20
23
|
|
21
|
-
#
|
24
|
+
# Initialize a Memory adapter
|
25
|
+
#
|
26
|
+
# @example with a schema
|
27
|
+
# adapter = Axiom::Adapter::Memory.new(
|
28
|
+
# users: Axiom::Relation.new(
|
29
|
+
# [[:id, Integer], [:name, String]],
|
30
|
+
# [[1, 'Dan Kubb'], [2, 'John Doe']]
|
31
|
+
# )
|
32
|
+
# )
|
22
33
|
#
|
23
|
-
# @example
|
24
|
-
#
|
25
|
-
# tuple = Axiom::Tuple.new(header, [ 'Dan Kubb' ])
|
26
|
-
# adapter.insert(users, [ tuple ])
|
34
|
+
# @example without a schema
|
35
|
+
# adapter = Axiom::Adapter::Memory.new
|
27
36
|
#
|
28
|
-
# @param [Axiom::Relation]
|
29
|
-
# @param [Enumerable<Axiom::Tuple>] tuples
|
30
|
-
# a set of tuples to insert into the relation
|
37
|
+
# @param [Hash{Symbol => Axiom::Relation::Variable}] schema
|
31
38
|
#
|
32
|
-
# @return [
|
39
|
+
# @return [undefined]
|
33
40
|
#
|
34
41
|
# @api public
|
35
|
-
def
|
36
|
-
|
42
|
+
def initialize(schema = {})
|
43
|
+
@schema = ThreadSafe::Hash.new
|
44
|
+
schema.each { |name, relation| self[name] = relation }
|
37
45
|
end
|
38
46
|
|
39
|
-
#
|
47
|
+
# Get relation variable in the schema
|
40
48
|
#
|
41
49
|
# @example
|
42
|
-
# adapter
|
43
|
-
#
|
44
|
-
# @param [Axiom::Relation] relation
|
50
|
+
# adapter[:users] # => users relation
|
45
51
|
#
|
46
|
-
# @
|
52
|
+
# @param [Symbol] name
|
47
53
|
#
|
48
|
-
# @
|
49
|
-
# each row in the results
|
50
|
-
#
|
51
|
-
# @return [self]
|
54
|
+
# @return [Axiom::Relation::Variable]
|
52
55
|
#
|
53
56
|
# @api public
|
54
|
-
def
|
55
|
-
|
57
|
+
def [](name)
|
58
|
+
schema.fetch(name) do
|
59
|
+
raise UnknownRelationError, "the relation named #{name} is unknown"
|
60
|
+
end
|
56
61
|
end
|
57
62
|
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# @example update all users to be active
|
61
|
-
# header = Axiom::Header.coerce([ [ :active, TrueClass ] ])
|
62
|
-
# tuple = Axiom::Tuple.new(header, [ true ])
|
63
|
-
# adapter.update(inactive_users, tuple)
|
63
|
+
# Set the relation variable in the schema
|
64
64
|
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
# to match the tuple. The tuple header must not be a superset of any
|
68
|
-
# keys and cause a uniqueness constraint violation.
|
65
|
+
# @example
|
66
|
+
# adapter[:users] = users_relation
|
69
67
|
#
|
70
|
-
# @param [
|
71
|
-
# @param [Axiom::
|
68
|
+
# @param [Symbol] name
|
69
|
+
# @param [Axiom::Relation::Materialized] relation
|
72
70
|
#
|
73
|
-
# @return [
|
71
|
+
# @return [undefined]
|
74
72
|
#
|
75
73
|
# @api public
|
76
|
-
def
|
77
|
-
|
74
|
+
def []=(name, relation)
|
75
|
+
schema[name] = Relation::Variable.new(relation)
|
78
76
|
end
|
79
77
|
|
80
|
-
|
78
|
+
end # Memory
|
79
|
+
end # Adapter
|
80
|
+
|
81
|
+
# XXX: patch Axiom:Relation
|
82
|
+
class Relation
|
83
|
+
|
84
|
+
# XXX: patch #update into Variable
|
85
|
+
class Variable
|
86
|
+
|
87
|
+
# Update a relation variable
|
81
88
|
#
|
82
89
|
# @example
|
83
|
-
#
|
84
|
-
#
|
85
|
-
# @param [Axiom::Relation] relation
|
90
|
+
# relvar.update { |tuple| ... }
|
86
91
|
#
|
87
|
-
# @return [
|
92
|
+
# @return [Axiom::Relation::Variable]
|
88
93
|
#
|
89
94
|
# @api public
|
90
|
-
def
|
91
|
-
|
95
|
+
def update(&block)
|
96
|
+
replace(map(&block))
|
92
97
|
end
|
93
98
|
|
94
|
-
end #
|
95
|
-
end #
|
96
|
-
end #
|
99
|
+
end # Variable
|
100
|
+
end # Relation
|
101
|
+
end # Axiom
|
97
102
|
|
98
103
|
require 'axiom/adapter/memory/version'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Adapter::Memory do
|
6
|
+
subject { described_class.new(schema) }
|
7
|
+
|
8
|
+
include_context 'relation'
|
9
|
+
|
10
|
+
before do
|
11
|
+
subject[name] = relation
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#insert' do
|
15
|
+
it 'inserts a new tuple' do
|
16
|
+
subject[name].insert([[3], [4]])
|
17
|
+
expect(subject[name].to_a).to eq([[1], [2], [3], [4]])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#replace' do
|
22
|
+
it 'replaces with new tuples' do
|
23
|
+
subject[name].replace([[2]])
|
24
|
+
expect(subject[name].to_a).to eq([[2]])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#delete' do
|
29
|
+
it 'deletes matching tuples' do
|
30
|
+
subject[name].delete([[3], [4]])
|
31
|
+
expect(subject[name].to_a).to eq([[1], [2]])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#update' do
|
36
|
+
pending 'Design interface' do
|
37
|
+
context 'with a Hash argument' do
|
38
|
+
it 'updates matching tuples' do
|
39
|
+
subject[name].update(id: 2)
|
40
|
+
expect(subject[name].to_a).to eq([[2]])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with a block' do
|
46
|
+
it 'updates matching tuples' do
|
47
|
+
subject[name].update { |tuple| [2] }
|
48
|
+
expect(subject[name].to_a).to eq([[2]])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Adapter::Memory, '.new' do
|
6
|
+
context 'with a schema' do
|
7
|
+
subject { described_class.new(schema) }
|
8
|
+
|
9
|
+
let(:schema) { {} }
|
10
|
+
|
11
|
+
it { should be_instance_of(described_class) }
|
12
|
+
|
13
|
+
it 'creates a new thread safe hash for the schema' do
|
14
|
+
klass = double('ThreadSafe::Hash')
|
15
|
+
expect(klass).to receive(:new).and_return({})
|
16
|
+
stub_const('ThreadSafe::Hash', klass)
|
17
|
+
subject
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'without a schema' do
|
22
|
+
subject { described_class.new }
|
23
|
+
|
24
|
+
it { should be_instance_of(described_class) }
|
25
|
+
|
26
|
+
it 'creates a new thread safe hash for the schema' do
|
27
|
+
klass = double('ThreadSafe::Hash')
|
28
|
+
expect(klass).to receive(:new).and_return({})
|
29
|
+
stub_const('ThreadSafe::Hash', klass)
|
30
|
+
subject
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Adapter::Memory, '#[]' do
|
6
|
+
subject { object[name] }
|
7
|
+
|
8
|
+
let!(:object) { described_class.new(users: relation) }
|
9
|
+
let(:relation) { double('relation', :materialized? => false) }
|
10
|
+
|
11
|
+
context 'with a known name' do
|
12
|
+
let(:name) { :users }
|
13
|
+
|
14
|
+
it { should eql(Relation::Variable.new(relation)) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with an unknown name' do
|
18
|
+
let(:name) { :unknown }
|
19
|
+
|
20
|
+
specify do
|
21
|
+
expect { subject }.to raise_error(
|
22
|
+
Adapter::Memory::UnknownRelationError,
|
23
|
+
'the relation named unknown is unknown'
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Adapter::Memory, '#[]=' do
|
6
|
+
subject { object[name] = relation }
|
7
|
+
|
8
|
+
include_context 'relation'
|
9
|
+
|
10
|
+
let!(:object) { described_class.new }
|
11
|
+
|
12
|
+
it { should be(relation) }
|
13
|
+
|
14
|
+
it 'wraps the relation in in a relation variable' do
|
15
|
+
subject
|
16
|
+
expect(object[name]).to eql(Relation::Variable.new(relation))
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Variable::Materialized, '#update' do
|
6
|
+
subject { object.update { [2] } }
|
7
|
+
|
8
|
+
let(:object) { described_class.new(relation) }
|
9
|
+
let(:relation) { Relation.new(header, [[1]]) }
|
10
|
+
let(:header) { [[:id, Integer]] }
|
11
|
+
|
12
|
+
it { should be_instance_of(described_class) }
|
13
|
+
|
14
|
+
it { should be_materialized }
|
15
|
+
|
16
|
+
it { should == [[2]] }
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Variable, '#update' do
|
6
|
+
subject { object.update { [2] } }
|
7
|
+
|
8
|
+
let(:object) { described_class.new(relation) }
|
9
|
+
let(:relation) { Relation::Base.new(:users, header, [[1]]) }
|
10
|
+
let(:header) { [[:id, Integer]] }
|
11
|
+
|
12
|
+
it { should be_instance_of(described_class) }
|
13
|
+
|
14
|
+
it { should_not be_materialized }
|
15
|
+
|
16
|
+
it { should == [[2]] }
|
17
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axiom-memory-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Dan Kubb
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: axiom
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thread_safe
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
16
34
|
requirements:
|
17
35
|
- - ~>
|
18
36
|
- !ruby/object:Gem::Version
|
@@ -20,6 +38,7 @@ dependencies:
|
|
20
38
|
type: :runtime
|
21
39
|
prerelease: false
|
22
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
23
42
|
requirements:
|
24
43
|
- - ~>
|
25
44
|
- !ruby/object:Gem::Version
|
@@ -27,21 +46,23 @@ dependencies:
|
|
27
46
|
- !ruby/object:Gem::Dependency
|
28
47
|
name: bundler
|
29
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
30
50
|
requirements:
|
31
51
|
- - ~>
|
32
52
|
- !ruby/object:Gem::Version
|
33
53
|
version: '1.3'
|
34
|
-
- - '>='
|
54
|
+
- - ! '>='
|
35
55
|
- !ruby/object:Gem::Version
|
36
56
|
version: 1.3.5
|
37
57
|
type: :development
|
38
58
|
prerelease: false
|
39
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
40
61
|
requirements:
|
41
62
|
- - ~>
|
42
63
|
- !ruby/object:Gem::Version
|
43
64
|
version: '1.3'
|
44
|
-
- - '>='
|
65
|
+
- - ! '>='
|
45
66
|
- !ruby/object:Gem::Version
|
46
67
|
version: 1.3.5
|
47
68
|
description: Use Axiom relations with an in-memory datastore
|
@@ -73,34 +94,43 @@ files:
|
|
73
94
|
- config/flog.yml
|
74
95
|
- config/mutant.yml
|
75
96
|
- config/reek.yml
|
97
|
+
- config/rubocop.yml
|
76
98
|
- config/yardstick.yml
|
77
99
|
- lib/axiom-memory-adapter.rb
|
78
100
|
- lib/axiom/adapter/memory.rb
|
79
101
|
- lib/axiom/adapter/memory/version.rb
|
102
|
+
- spec/integration/axiom/adapter/memory_spec.rb
|
103
|
+
- spec/shared/base_relation_context.rb
|
80
104
|
- spec/spec_helper.rb
|
105
|
+
- spec/unit/axiom/adapter/memory/class_methods/new_spec.rb
|
106
|
+
- spec/unit/axiom/adapter/memory/element_reader_spec.rb
|
107
|
+
- spec/unit/axiom/adapter/memory/element_writer_spec.rb
|
108
|
+
- spec/unit/axiom/relation/variable/materialized/update_spec.rb
|
109
|
+
- spec/unit/axiom/relation/variable/update_spec.rb
|
81
110
|
homepage: https://github.com/dkubb/axiom-memory-adapter
|
82
111
|
licenses:
|
83
112
|
- MIT
|
84
|
-
metadata: {}
|
85
113
|
post_install_message:
|
86
114
|
rdoc_options: []
|
87
115
|
require_paths:
|
88
116
|
- lib
|
89
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
90
119
|
requirements:
|
91
|
-
- - '>='
|
120
|
+
- - ! '>='
|
92
121
|
- !ruby/object:Gem::Version
|
93
122
|
version: '0'
|
94
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
95
125
|
requirements:
|
96
|
-
- - '>='
|
126
|
+
- - ! '>='
|
97
127
|
- !ruby/object:Gem::Version
|
98
128
|
version: '0'
|
99
129
|
requirements: []
|
100
130
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
131
|
+
rubygems_version: 1.8.23
|
102
132
|
signing_key:
|
103
|
-
specification_version:
|
133
|
+
specification_version: 3
|
104
134
|
summary: Axiom Memory adapter
|
105
135
|
test_files: []
|
106
136
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 94c19af0600da7b06aefddead4f489e717f8ea41
|
4
|
-
data.tar.gz: 33cd3eb27a5a3bbafc7e7b534b64f333633b7565
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 503db171d87002481874517f3eedb4dfce7d3bdb2358873e2e7fb9c3befb44a9468abceef5b4cab96f1c1647b9273eb5b0dae9a228075dc6a685c55dd4b37986
|
7
|
-
data.tar.gz: cacf03827d491e6940e84958e83b5d1d6a9f38849357b0c07cb49649d2d787777546454d58cc879a4676eef33825ff8193181f3aaba7d1c7585baff41a2f7ee3
|