veritas 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.travis.yml +5 -4
  2. data/Gemfile +16 -14
  3. data/Guardfile +0 -4
  4. data/README.md +188 -0
  5. data/Rakefile +2 -2
  6. data/TODO +0 -16
  7. data/config/flay.yml +1 -1
  8. data/config/flog.yml +1 -1
  9. data/config/roodi.yml +4 -4
  10. data/config/site.reek +7 -3
  11. data/lib/veritas/aggregate.rb +18 -0
  12. data/lib/veritas/algebra/extension.rb +2 -29
  13. data/lib/veritas/algebra/projection.rb +2 -29
  14. data/lib/veritas/algebra/rename/aliases.rb +4 -32
  15. data/lib/veritas/algebra/rename.rb +2 -29
  16. data/lib/veritas/algebra/restriction.rb +2 -29
  17. data/lib/veritas/algebra/summarization.rb +2 -31
  18. data/lib/veritas/attribute/time.rb +1 -1
  19. data/lib/veritas/attribute.rb +20 -40
  20. data/lib/veritas/function/binary.rb +2 -3
  21. data/lib/veritas/function/connective/negation.rb +1 -1
  22. data/lib/veritas/function/predicate/enumerable.rb +19 -0
  23. data/lib/veritas/function/predicate/exclusion.rb +1 -1
  24. data/lib/veritas/function/predicate/match.rb +1 -1
  25. data/lib/veritas/function/unary.rb +5 -3
  26. data/lib/veritas/function.rb +1 -41
  27. data/lib/veritas/relation/base.rb +2 -29
  28. data/lib/veritas/relation/empty.rb +30 -2
  29. data/lib/veritas/relation/header.rb +17 -31
  30. data/lib/veritas/relation/materialized.rb +0 -12
  31. data/lib/veritas/relation/operation/limit.rb +2 -29
  32. data/lib/veritas/relation/operation/offset.rb +2 -29
  33. data/lib/veritas/relation/operation/order/direction.rb +3 -29
  34. data/lib/veritas/relation/operation/order/direction_set.rb +18 -34
  35. data/lib/veritas/relation/operation/order.rb +4 -56
  36. data/lib/veritas/relation.rb +8 -36
  37. data/lib/veritas/support/aliasable.rb +20 -7
  38. data/lib/veritas/support/comparator.rb +81 -0
  39. data/lib/veritas/support/evaluator.rb +1 -1
  40. data/lib/veritas/support/immutable.rb +22 -49
  41. data/lib/veritas/support/operation/binary.rb +3 -30
  42. data/lib/veritas/support/operation/unary.rb +3 -29
  43. data/lib/veritas/tuple.rb +19 -29
  44. data/lib/veritas/version.rb +1 -1
  45. data/lib/veritas.rb +1 -0
  46. data/spec/integration/veritas/relation/efficient_enumerable_spec.rb +3 -3
  47. data/spec/shared/hash_method_behavior.rb +7 -2
  48. data/spec/unit/date/pred_spec.rb +1 -1
  49. data/spec/unit/veritas/aggregate/equal_value_spec.rb +52 -0
  50. data/spec/unit/veritas/aggregate/hash_spec.rb +15 -0
  51. data/spec/unit/veritas/aliasable/inheritable_alias_spec.rb +1 -1
  52. data/spec/unit/veritas/comparator/compare_spec.rb +40 -0
  53. data/spec/unit/veritas/comparator/methods/eql_spec.rb +48 -0
  54. data/spec/unit/veritas/evaluator/context/respond_to_spec.rb +1 -1
  55. data/spec/unit/veritas/function/predicate/enumerable/call_spec.rb +36 -0
  56. data/spec/unit/veritas/function/unary/hash_spec.rb +18 -0
  57. data/spec/unit/veritas/immutable/freeze_spec.rb +2 -2
  58. data/spec/unit/veritas/immutable/memoize_spec.rb +13 -0
  59. data/spec/unit/veritas/immutable/module_methods/memoize_spec.rb +1 -1
  60. data/spec/unit/veritas/relation/empty/class_methods/new_spec.rb +30 -0
  61. data/spec/unit/veritas/relation/empty/each_spec.rb +20 -5
  62. data/spec/unit/veritas/relation/empty/size_spec.rb +11 -0
  63. data/spec/unit/veritas/relation/header/hash_spec.rb +1 -1
  64. data/spec/unit/veritas/relation/materialized/empty_spec.rb +0 -10
  65. data/spec/unit/veritas/relation/operation/order/direction_set/class_methods/coerce_spec.rb +12 -3
  66. data/tasks/metrics/heckle.rake +2 -3
  67. data/veritas.gemspec +21 -18
  68. metadata +36 -33
  69. data/README.rdoc +0 -143
  70. data/spec/unit/veritas/function/eql_spec.rb +0 -14
  71. data/spec/unit/veritas/function/equal_value_spec.rb +0 -14
  72. data/spec/unit/veritas/function/hash_spec.rb +0 -13
  73. data/spec/unit/veritas/immutable/memory/element_reference_spec.rb +0 -26
  74. data/spec/unit/veritas/immutable/memory/element_set_spec.rb +0 -19
  75. data/spec/unit/veritas/relation/operation/order/methods/order_spec.rb +0 -54
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veritas
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Kubb
@@ -15,10 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-29 00:00:00 Z
18
+ date: 2011-10-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
21
+ type: :development
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
22
24
  none: false
23
25
  requirements:
24
26
  - - ~>
@@ -29,12 +31,12 @@ dependencies:
29
31
  - 3
30
32
  - 0
31
33
  version: 2.3.0
32
- type: :development
33
- requirement: *id001
34
- prerelease: false
34
+ version_requirements: *id001
35
35
  name: backports
36
36
  - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ type: :development
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
40
42
  - - ~>
@@ -45,12 +47,12 @@ dependencies:
45
47
  - 6
46
48
  - 4
47
49
  version: 1.6.4
48
- type: :development
49
- requirement: *id002
50
- prerelease: false
50
+ version_requirements: *id002
51
51
  name: jeweler
52
52
  - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ type: :development
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
54
56
  none: false
55
57
  requirements:
56
58
  - - ~>
@@ -61,12 +63,12 @@ dependencies:
61
63
  - 9
62
64
  - 2
63
65
  version: 0.9.2
64
- type: :development
65
- requirement: *id003
66
- prerelease: false
66
+ version_requirements: *id003
67
67
  name: rake
68
68
  - !ruby/object:Gem::Dependency
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ type: :development
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
70
72
  none: false
71
73
  requirements:
72
74
  - - ~>
@@ -77,12 +79,12 @@ dependencies:
77
79
  - 3
78
80
  - 2
79
81
  version: 1.3.2
80
- type: :development
81
- requirement: *id004
82
- prerelease: false
82
+ version_requirements: *id004
83
83
  name: rspec
84
84
  - !ruby/object:Gem::Dependency
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ type: :development
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
86
88
  none: false
87
89
  requirements:
88
90
  - - ~>
@@ -93,9 +95,7 @@ dependencies:
93
95
  - 7
94
96
  - 2
95
97
  version: 0.7.2
96
- type: :development
97
- requirement: *id005
98
- prerelease: false
98
+ version_requirements: *id005
99
99
  name: yard
100
100
  description: Simplifies querying of structured data using relational algebra
101
101
  email: dan.kubb@gmail.com
@@ -105,7 +105,7 @@ extensions: []
105
105
 
106
106
  extra_rdoc_files:
107
107
  - LICENSE
108
- - README.rdoc
108
+ - README.md
109
109
  - TODO
110
110
  files:
111
111
  - .document
@@ -115,7 +115,7 @@ files:
115
115
  - Gemfile
116
116
  - Guardfile
117
117
  - LICENSE
118
- - README.rdoc
118
+ - README.md
119
119
  - Rakefile
120
120
  - TODO
121
121
  - benchmarks/memory.rb
@@ -218,6 +218,7 @@ files:
218
218
  - lib/veritas/relation/operation/unary.rb
219
219
  - lib/veritas/support/abstract_class.rb
220
220
  - lib/veritas/support/aliasable.rb
221
+ - lib/veritas/support/comparator.rb
221
222
  - lib/veritas/support/evaluator.rb
222
223
  - lib/veritas/support/immutable.rb
223
224
  - lib/veritas/support/operation/binary.rb
@@ -251,7 +252,9 @@ files:
251
252
  - spec/unit/veritas/aggregate/count/methods/count_spec.rb
252
253
  - spec/unit/veritas/aggregate/count/type_spec.rb
253
254
  - spec/unit/veritas/aggregate/default_spec.rb
255
+ - spec/unit/veritas/aggregate/equal_value_spec.rb
254
256
  - spec/unit/veritas/aggregate/finalize_spec.rb
257
+ - spec/unit/veritas/aggregate/hash_spec.rb
255
258
  - spec/unit/veritas/aggregate/maximum/class_methods/call_spec.rb
256
259
  - spec/unit/veritas/aggregate/maximum/class_methods/default_spec.rb
257
260
  - spec/unit/veritas/aggregate/maximum/methods/maximum_spec.rb
@@ -389,6 +392,8 @@ files:
389
392
  - spec/unit/veritas/attribute/type_spec.rb
390
393
  - spec/unit/veritas/attribute/valid_primitive_spec.rb
391
394
  - spec/unit/veritas/attribute/valid_value_spec.rb
395
+ - spec/unit/veritas/comparator/compare_spec.rb
396
+ - spec/unit/veritas/comparator/methods/eql_spec.rb
392
397
  - spec/unit/veritas/evaluator/context/add_spec.rb
393
398
  - spec/unit/veritas/evaluator/context/element_reference_spec.rb
394
399
  - spec/unit/veritas/evaluator/context/functions_spec.rb
@@ -424,10 +429,7 @@ files:
424
429
  - spec/unit/veritas/function/connective/negation/methods/fixtures/classes.rb
425
430
  - spec/unit/veritas/function/connective/negation/methods/not_spec.rb
426
431
  - spec/unit/veritas/function/connective/type_spec.rb
427
- - spec/unit/veritas/function/eql_spec.rb
428
- - spec/unit/veritas/function/equal_value_spec.rb
429
432
  - spec/unit/veritas/function/fixtures/classes.rb
430
- - spec/unit/veritas/function/hash_spec.rb
431
433
  - spec/unit/veritas/function/inspect_spec.rb
432
434
  - spec/unit/veritas/function/numeric/absolute/class_methods/call_spec.rb
433
435
  - spec/unit/veritas/function/numeric/absolute/inspect_spec.rb
@@ -479,6 +481,7 @@ files:
479
481
  - spec/unit/veritas/function/numeric/unary_plus/methods/unary_plus_spec.rb
480
482
  - spec/unit/veritas/function/predicate/call_spec.rb
481
483
  - spec/unit/veritas/function/predicate/class_methods/call_spec.rb
484
+ - spec/unit/veritas/function/predicate/enumerable/call_spec.rb
482
485
  - spec/unit/veritas/function/predicate/enumerable/class_methods/compare_method_spec.rb
483
486
  - spec/unit/veritas/function/predicate/eql_spec.rb
484
487
  - spec/unit/veritas/function/predicate/equality/class_methods/call_spec.rb
@@ -591,6 +594,7 @@ files:
591
594
  - spec/unit/veritas/function/unary/call_spec.rb
592
595
  - spec/unit/veritas/function/unary/equal_value_spec.rb
593
596
  - spec/unit/veritas/function/unary/fixtures/classes.rb
597
+ - spec/unit/veritas/function/unary/hash_spec.rb
594
598
  - spec/unit/veritas/function/unary/invertible/inverse_spec.rb
595
599
  - spec/unit/veritas/function/unary/rename_spec.rb
596
600
  - spec/unit/veritas/immutable/class_methods/freeze_object_spec.rb
@@ -600,8 +604,6 @@ files:
600
604
  - spec/unit/veritas/immutable/freeze_spec.rb
601
605
  - spec/unit/veritas/immutable/memoize_spec.rb
602
606
  - spec/unit/veritas/immutable/memoized_spec.rb
603
- - spec/unit/veritas/immutable/memory/element_reference_spec.rb
604
- - spec/unit/veritas/immutable/memory/element_set_spec.rb
605
607
  - spec/unit/veritas/immutable/module_methods/included_spec.rb
606
608
  - spec/unit/veritas/immutable/module_methods/memoize_spec.rb
607
609
  - spec/unit/veritas/operation/binary/eql_spec.rb
@@ -619,9 +621,11 @@ files:
619
621
  - spec/unit/veritas/relation/directions_spec.rb
620
622
  - spec/unit/veritas/relation/each_spec.rb
621
623
  - spec/unit/veritas/relation/element_reference_spec.rb
624
+ - spec/unit/veritas/relation/empty/class_methods/new_spec.rb
622
625
  - spec/unit/veritas/relation/empty/each_spec.rb
623
626
  - spec/unit/veritas/relation/empty/empty_spec.rb
624
627
  - spec/unit/veritas/relation/empty/header_spec.rb
628
+ - spec/unit/veritas/relation/empty/size_spec.rb
625
629
  - spec/unit/veritas/relation/empty_spec.rb
626
630
  - spec/unit/veritas/relation/eql_spec.rb
627
631
  - spec/unit/veritas/relation/equal_value_spec.rb
@@ -705,7 +709,6 @@ files:
705
709
  - spec/unit/veritas/relation/operation/order/eql_spec.rb
706
710
  - spec/unit/veritas/relation/operation/order/hash_spec.rb
707
711
  - spec/unit/veritas/relation/operation/order/header_spec.rb
708
- - spec/unit/veritas/relation/operation/order/methods/order_spec.rb
709
712
  - spec/unit/veritas/relation/operation/order/methods/sort_by_spec.rb
710
713
  - spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb
711
714
  - spec/unit/veritas/relation/operation/reverse/directions_spec.rb
@@ -770,7 +773,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
770
773
  requirements: []
771
774
 
772
775
  rubyforge_project:
773
- rubygems_version: 1.8.5
776
+ rubygems_version: 1.8.10
774
777
  signing_key:
775
778
  specification_version: 3
776
779
  summary: Ruby Relational Algebra
data/README.rdoc DELETED
@@ -1,143 +0,0 @@
1
- = Veritas
2
-
3
- Simplifies querying of structured data using relational algebra
4
-
5
- http://travis-ci.org/dkubb/veritas.png
6
-
7
- == Usage
8
-
9
- relation = Veritas::Relation.new([ [ :id, Integer ] ], [ [ 1 ] ])
10
-
11
- # Relational Operators
12
- # --------------------
13
-
14
- # projection
15
- new_relation = relation.project([ :a, :b, :c ])
16
-
17
- # removal
18
- new_relation = relation.remove([ :a, :b, :c ])
19
-
20
- # rename
21
- new_relation = relation.rename(a: :b, c: :d)
22
-
23
- # natural join
24
- new_relation = relation.join(other) # OR relation + other
25
-
26
- # product
27
- new_relation = relation.product(other) # OR relation * other
28
-
29
- # intersection
30
- new_relation = relation.intersect(other) # OR relation & other
31
-
32
- # union
33
- new_relation = relation.union(other) # OR relation | other
34
-
35
- # difference
36
- new_relation = relation.difference(other) # OR relation - other
37
-
38
- # restriction
39
- new_relation = relation.restrict { |r| r.a.eq('other').and(r.b.gte(42)) }
40
-
41
- # theta-join
42
- new_relation = relation.join(other) { |r| r.a.gte(r.b) }
43
-
44
- # NOTE: theta-join is effectively restricting a product of the relations
45
-
46
- # extend
47
- new_relation = relation.extend { |r| r.add(:total, r.unit_price * r.quantity) }
48
- new_relation = relation.extend { |r| r.add(:total) { |t| t[:unit_price] * t[:quantity] } }
49
-
50
- # summarize
51
- new_relation = relation.summarize(relation.project([ :name ])) { |r| r.add(:count, r.name.count) }
52
- new_relation = relation.summarize(relation.project([ :name ])) { |r| r.add(:count) { |acc, t| acc.to_i + 1 } }
53
-
54
- # Non-Relational Operators
55
- # ------------------------
56
-
57
- # returns a set that represents the relation header
58
- header = relation.header
59
-
60
- # a relation is Enumerable
61
- relation = relation.each { |tuple| ... }
62
-
63
- # order by attribute and direction
64
- new_relation = relation.sort_by { |r| [ r.a.desc, r.b ] }
65
-
66
- # reverse the relation (only allowed if ordered)
67
- new_relation = relation.reverse
68
-
69
- # offset (only allowed if ordered)
70
- new_relation = relation.drop(5)
71
-
72
- # limiting (only allowed if ordered)
73
- new_relation = relation.take(10)
74
-
75
- # get the first n tuples (only allowed if ordered)
76
- new_relation = relation.first # default is 1
77
- new_relation = relation.first(5)
78
-
79
- # get the last n tuples (only allowed if ordered)
80
- new_relation = relation.last # default is 1
81
- new_relation = relation.last(5)
82
-
83
- == Goals
84
-
85
- The purpose of this project is to expand my knowledge of relational algebra by attempting to implement a simple query system using the primitive operations defined in relational algebra.
86
-
87
- Most of the design is heavily inspired from koios[https://github.com/carllerche/koios] and arel[https://github.com/rails/arel]. The reason I decided to write my own and not just build on top of those systems was not so much because I don't like the code/API in those projects, it's more because I wanted to gain a depth of understanding that can only be earned by trying to solve the problem myself.
88
-
89
- I should note though that I don't plan to just re-implement those systems with a different API, or different internals, I plan to make something that surpasses them in several areas. For example, I want to be able to join information from multiple datastores and represent it as a single relation. I want to be able to insert, update or delete from that relation and have those changes propagated back to the right datastore. This is not an easy feat, since it is basically the writable view problem that RDBMS' struggle with. While I do think there are some cases where relations will become read-only, I think it will be possible to propagate writes properly in this manner. I certainly think for the current use cases in DataMapper this should work quite well.
90
-
91
- The ability to join data from multiple datastores and have it presented in a consistent manner will solve one of the longest standing problems in DataMapper, namely how do we do cross repository joins. It should be possible to construct one query for one datastore, and then another query for another datastore and then join them. Since they are using different engines veritas will know to perform each query *natively* and then join the results in-memory seamlessly. It should also be possible to reorganize the queries so that as much work as possible is done natively as opposed to in-memory, which is considered the last resort.
92
-
93
- Not only does this work nicely with associations, but it will allow DataMapper to perform mapping in a more powerful way. You'll be able to construct a join from multiple datastores, and set that as the base for your model. Each DM Resource would work as normal, but again writes could be propagated back to the appropriate datastore. You'd be able to split your data up between different datastores, but assemble it into one coherent view.
94
-
95
- === Phase 1: In-Memory Operations
96
-
97
- The first phase of this project will be to implement all the operations listed below using in-memory data structures. I'm focusing on the API, and making sure the specs ensure the desired results are obtained from each operation.
98
-
99
- This is 100% complete.
100
-
101
- === Phase 2: RDBMS Engines
102
-
103
- The second phase of this project will be to add a RDBMS based engine, and move the in-memory matching to it's own engine. I'll also be working on a system where if the primary engine cannot carry out some operation, that it first look at alternate forms (eg. using a join instead of an intersection), and then fall-back to in-memory matching. I also want to look at re-arranging queries so that all the operations that can be performed natively are "pushed down" the hierarchy and then the in-memory matching is performed last.
104
-
105
- This is 95% complete. I have completed a first pass on veritas-sql-generator[https://github.com/dkubb/veritas-sql-generator] which is a visitor that walks the AST and produces SQL for every operatione. More work is needed to write adapters that use the veritas-sql-generator and manage database connections/execution.
106
-
107
- === Phase 3: DataMapper Integration
108
-
109
- The third phase of this project will be to add a few NoSQL engines (like MongoDB[http://www.mongodb.org/] and CouchDB[http://couchdb.org/]) and then look at writing a DataMapper adapter that translates Query objects into Veritas relations. I want to make sure all the DM specs pass with this adapter and each engine, and if everything goes well I will look at updating DM to work directly on top of Veritas.
110
-
111
- == Related Projects
112
-
113
- * veritas-optimizer[https://github.com/dkubb/veritas-optimizer]
114
-
115
- This is an optimizer that takes a veritas relation, scalar or aggregate function and will transform it into something equivalent but simpler in structure to the original.
116
-
117
- * veritas-sql-generator[https://github.com/dkubb/veritas-sql-generator]
118
-
119
- This is a visitor class that takes a veritas relation and generates valid SQL from it.
120
-
121
- == Note on Patches/Pull Requests
122
-
123
- * If you want your code merged into the mainline, please discuss
124
- the proposed changes with me before doing any work on it. This
125
- library is still in early development, and it may not always be
126
- clear the direction it is going. Some features may not be appropriate
127
- yet, may need to be deferred until later when the foundation for
128
- them is laid, or may be more applicable in a plugin.
129
- * Fork the project.
130
- * Make your feature addition or bug fix.
131
- * Follow this {style guide}[https://github.com/dkubb/styleguide].
132
- * Add specs for it. This is important so I don't break it in a
133
- future version unintentionally. Tests must cover all branches
134
- within the code, and code must be fully covered.
135
- * Commit, do not mess with Rakefile, version, or history.
136
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
137
- * Run "rake ci". This must pass and not show any regressions in the
138
- metrics for the code to be merged.
139
- * Send me a pull request. Bonus points for topic branches.
140
-
141
- == Copyright
142
-
143
- Copyright (c) 2009-2011 Dan Kubb. See LICENSE for details.
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require File.expand_path('../fixtures/classes', __FILE__)
5
-
6
- describe Function, '#eql?' do
7
- subject { object.eql?(other) }
8
-
9
- let(:described_class) { FunctionSpecs::Object }
10
- let(:other) { described_class.new }
11
- let(:object) { described_class.new }
12
-
13
- specify { expect { subject }.to raise_error(NotImplementedError, 'FunctionSpecs::Object#eql? must be implemented') }
14
- end
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require File.expand_path('../fixtures/classes', __FILE__)
5
-
6
- describe Function, '#==' do
7
- subject { object == other }
8
-
9
- let(:described_class) { FunctionSpecs::Object }
10
- let(:other) { described_class.new }
11
- let(:object) { described_class.new }
12
-
13
- specify { expect { subject }.to raise_error(NotImplementedError, 'FunctionSpecs::Object#== must be implemented') }
14
- end
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require File.expand_path('../fixtures/classes', __FILE__)
5
-
6
- describe Function, '#hash' do
7
- subject { object.hash }
8
-
9
- let(:described_class) { FunctionSpecs::Object }
10
- let(:object) { described_class.new }
11
-
12
- specify { expect { subject }.to raise_error(NotImplementedError, "#{described_class}#hash must be implemented") }
13
- end
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Immutable::Memory, '#[]' do
6
- subject { object[key] }
7
-
8
- let(:object) { described_class.new }
9
-
10
- context 'with known key' do
11
- let(:key) { '@key' }
12
- let(:value) { mock('Value') }
13
-
14
- before do
15
- object.instance_variable_set(key, value)
16
- end
17
-
18
- it { should equal(value) }
19
- end
20
-
21
- context 'with unknown key' do
22
- let(:key) { '@key' }
23
-
24
- it { should be_nil }
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Immutable::Memory, '#[]=' do
6
- subject { object[key] = value }
7
-
8
- let(:object) { described_class.new }
9
- let(:key) { '@key' }
10
- let(:value) { mock('Value') }
11
-
12
- it { should equal(value) }
13
-
14
- it 'sets the instance variable' do
15
- object.should_not be_instance_variable_defined(key)
16
- subject
17
- object.instance_variable_get(key).should equal(value)
18
- end
19
- end
@@ -1,54 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Relation::Operation::Order::Methods, '#order' do
6
- let(:described_class) { Relation }
7
- let(:object) { described_class.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ] ].each) }
8
-
9
- before do
10
- @original, $stderr = $stderr, StringIO.new
11
- end
12
-
13
- after do
14
- $stderr = @original
15
- end
16
-
17
- context 'with no arguments' do
18
- subject { object.order }
19
-
20
- it { should be_instance_of(Relation::Operation::Order) }
21
-
22
- its(:directions) { should == object.header }
23
-
24
- it 'behaves the same as Array#sort_by' do
25
- subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
26
- end
27
-
28
- it 'warns with a deprecation message' do
29
- expect { subject }.to change { $stderr.string.chomp }.
30
- from(nil).
31
- to('Veritas::Relation#order is deprecated and will be removed from Veritas 0.0.6')
32
- end
33
- end
34
-
35
- context 'with a block' do
36
- subject { object.order(&block) }
37
-
38
- let(:block) { lambda { |relation| [ relation[:id].desc ] } }
39
-
40
- it { should be_instance_of(Relation::Operation::Order) }
41
-
42
- its(:directions) { should == block.call(object) }
43
-
44
- it 'behaves the same as Array#sort_by' do
45
- subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
46
- end
47
-
48
- it 'warns with a deprecation message' do
49
- expect { subject }.to change { $stderr.string.chomp }.
50
- from(nil).
51
- to('Veritas::Relation#order is deprecated and will be removed from Veritas 0.0.6')
52
- end
53
- end
54
- end