axiom 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -1
- data/.rubocop.yml +7 -0
- data/.travis.yml +10 -7
- data/Gemfile +4 -0
- data/Gemfile.devtools +27 -13
- data/Guardfile +2 -2
- data/README.md +36 -30
- data/TODO +22 -24
- data/axiom.gemspec +9 -9
- data/benchmarks/memory.rb +1 -2
- data/benchmarks/speed.rb +7 -8
- data/config/flay.yml +1 -1
- data/config/reek.yml +19 -7
- data/config/rubocop.yml +6 -9
- data/lib/axiom.rb +28 -13
- data/lib/axiom/aggregate/mean.rb +4 -3
- data/lib/axiom/aggregate/sum.rb +1 -1
- data/lib/axiom/algebra/extension.rb +1 -1
- data/lib/axiom/algebra/join.rb +4 -27
- data/lib/axiom/algebra/product.rb +3 -3
- data/lib/axiom/algebra/projection.rb +2 -2
- data/lib/axiom/algebra/rename.rb +2 -2
- data/lib/axiom/algebra/rename/aliases.rb +3 -3
- data/lib/axiom/algebra/summarization.rb +3 -3
- data/lib/axiom/attribute.rb +5 -4
- data/lib/axiom/attribute/comparable.rb +15 -11
- data/lib/axiom/attribute/date.rb +1 -1
- data/lib/axiom/attribute/date_time.rb +1 -1
- data/lib/axiom/attribute/length_comparable.rb +39 -0
- data/lib/axiom/attribute/numeric.rb +1 -26
- data/lib/axiom/attribute/relation.rb +64 -0
- data/lib/axiom/attribute/string.rb +1 -28
- data/lib/axiom/attribute/time.rb +1 -1
- data/lib/axiom/attribute/tuple.rb +50 -0
- data/lib/axiom/attribute/value_comparable.rb +42 -0
- data/lib/axiom/function.rb +1 -1
- data/lib/axiom/function/binary.rb +4 -16
- data/lib/axiom/function/comparable.rb +1 -1
- data/lib/axiom/function/connective/conjunction.rb +1 -1
- data/lib/axiom/function/connective/disjunction.rb +1 -1
- data/lib/axiom/function/connective/negation.rb +1 -1
- data/lib/axiom/function/numeric/exponentiation.rb +1 -1
- data/lib/axiom/function/numeric/square_root.rb +1 -1
- data/lib/axiom/function/predicate/enumerable.rb +0 -14
- data/lib/axiom/function/predicate/exclusion.rb +1 -1
- data/lib/axiom/function/predicate/inclusion.rb +1 -1
- data/lib/axiom/function/proposition.rb +12 -25
- data/lib/axiom/function/unary.rb +92 -106
- data/lib/axiom/relation.rb +3 -3
- data/lib/axiom/relation/base.rb +15 -0
- data/lib/axiom/relation/header.rb +25 -22
- data/lib/axiom/relation/index.rb +91 -0
- data/lib/axiom/relation/keys.rb +3 -3
- data/lib/axiom/relation/materialized.rb +48 -4
- data/lib/axiom/relation/operation/binary.rb +5 -5
- data/lib/axiom/relation/operation/group.rb +95 -0
- data/lib/axiom/relation/operation/limit.rb +15 -15
- data/lib/axiom/relation/operation/offset.rb +12 -12
- data/lib/axiom/relation/operation/reverse.rb +9 -9
- data/lib/axiom/relation/operation/set.rb +1 -1
- data/lib/axiom/relation/operation/{order.rb → sorted.rb} +29 -28
- data/lib/axiom/relation/operation/{order → sorted}/direction.rb +4 -4
- data/lib/axiom/relation/operation/{order → sorted}/direction_set.rb +3 -3
- data/lib/axiom/relation/operation/ungroup.rb +82 -0
- data/lib/axiom/relation/operation/unwrap.rb +80 -0
- data/lib/axiom/relation/operation/wrap.rb +85 -0
- data/lib/axiom/relation/proxy.rb +5 -6
- data/lib/axiom/relation/variable.rb +1 -2
- data/lib/axiom/support/aliasable.rb +3 -5
- data/lib/axiom/support/equalizer.rb +10 -12
- data/lib/axiom/support/operation/binary.rb +3 -2
- data/lib/axiom/support/operation/unary.rb +1 -1
- data/lib/axiom/tuple.rb +76 -26
- data/lib/axiom/types/relation.rb +13 -0
- data/lib/axiom/types/tuple.rb +13 -0
- data/lib/axiom/version.rb +1 -1
- data/spec/integration/axiom/relation/efficient_enumerable_spec.rb +9 -9
- data/spec/integration/axiom/relation/writable_relations_spec.rb +12 -12
- data/spec/shared/invertible_method_behaviour.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/unit/axiom/aggregate/call_spec.rb +7 -12
- data/spec/unit/axiom/aggregate/class_methods/default_spec.rb +7 -2
- data/spec/unit/axiom/aggregate/default_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/finalize_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/maximum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/mean/class_methods/call_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/mean/class_methods/finalize_spec.rb +10 -3
- data/spec/unit/axiom/aggregate/minimum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/sum/default_spec.rb +32 -6
- data/spec/unit/axiom/aggregate/sum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/variance/class_methods/call_spec.rb +6 -6
- data/spec/unit/axiom/algebra/difference/each_spec.rb +3 -3
- data/spec/unit/axiom/algebra/extension/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/algebra/extension/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/intersection/each_spec.rb +3 -3
- data/spec/unit/axiom/algebra/join/each_spec.rb +6 -6
- data/spec/unit/axiom/algebra/product/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/projection/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/directions_spec.rb +3 -3
- data/spec/unit/axiom/algebra/rename/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/restriction/delete_spec.rb +3 -3
- data/spec/unit/axiom/algebra/restriction/each_spec.rb +12 -11
- data/spec/unit/axiom/algebra/restriction/insert_spec.rb +3 -3
- data/spec/unit/axiom/algebra/restriction/methods/restrict_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/eql_spec.rb +1 -1
- data/spec/unit/axiom/algebra/summarization/summaries/summarize_by_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/summaries/to_hash_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/summary/summarize_by_spec.rb +1 -1
- data/spec/unit/axiom/algebra/union/each_spec.rb +4 -4
- data/spec/unit/axiom/aliasable/fixtures/classes.rb +3 -1
- data/spec/unit/axiom/aliasable/inheritable_alias_spec.rb +18 -27
- data/spec/unit/axiom/attribute/call_spec.rb +1 -1
- data/spec/unit/axiom/attribute/class_methods/coerce_spec.rb +57 -51
- data/spec/unit/axiom/attribute/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/attribute/comparable/asc_spec.rb +4 -2
- data/spec/unit/axiom/attribute/comparable/desc_spec.rb +4 -2
- data/spec/unit/axiom/attribute/comparable/range_spec.rb +20 -0
- data/spec/unit/axiom/attribute/eql_spec.rb +1 -1
- data/spec/unit/axiom/attribute/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/attribute/include_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/name_spec.rb +1 -1
- data/spec/unit/axiom/attribute/optional_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/relation/class_methods/new_spec.rb +56 -0
- data/spec/unit/axiom/attribute/relation/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/relation/header_spec.rb +13 -0
- data/spec/unit/axiom/attribute/relation/new_relation_spec.rb +15 -0
- data/spec/unit/axiom/attribute/rename_spec.rb +1 -1
- data/spec/unit/axiom/attribute/required_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/tuple/class_methods/new_spec.rb +56 -0
- data/spec/unit/axiom/attribute/tuple/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/tuple/header_spec.rb +13 -0
- data/spec/unit/axiom/equalizer/class_method/new_spec.rb +24 -54
- data/spec/unit/axiom/evaluator/context/add_spec.rb +7 -7
- data/spec/unit/axiom/evaluator/context/element_reader_spec.rb +4 -4
- data/spec/unit/axiom/evaluator/context/functions_spec.rb +1 -1
- data/spec/unit/axiom/evaluator/context/method_missing_spec.rb +3 -3
- data/spec/unit/axiom/evaluator/context/respond_to_predicate_spec.rb +3 -3
- data/spec/unit/axiom/evaluator/context/send_spec.rb +8 -8
- data/spec/unit/axiom/function/binary/call_spec.rb +1 -1
- data/spec/unit/axiom/function/binary/type_spec.rb +12 -10
- data/spec/unit/axiom/function/comparable/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/function/connective/negation/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/call_spec.rb +5 -4
- data/spec/unit/axiom/function/predicate/enumerable/call_spec.rb +12 -2
- data/spec/unit/axiom/function/predicate/eql_spec.rb +4 -3
- data/spec/unit/axiom/function/predicate/equality/methods/eq_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/exclusion/class_methods/call_spec.rb +37 -8
- data/spec/unit/axiom/function/predicate/exclusion/methods/exclude_spec.rb +6 -2
- data/spec/unit/axiom/function/predicate/greater_than/methods/gt_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/methods/gte_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/inclusion/class_methods/call_spec.rb +37 -8
- data/spec/unit/axiom/function/predicate/inclusion/methods/include_spec.rb +6 -2
- data/spec/unit/axiom/function/predicate/inequality/methods/ne_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/less_than/methods/lt_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/less_than_or_equal_to/methods/lte_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/match/methods/match_spec.rb +7 -3
- data/spec/unit/axiom/function/predicate/no_match/methods/no_match_spec.rb +6 -2
- data/spec/unit/axiom/function/proposition/call_spec.rb +6 -4
- data/spec/unit/axiom/function/proposition/class_methods/{new_spec.rb → coerce_spec.rb} +17 -17
- data/spec/unit/axiom/function/proposition/eql_spec.rb +4 -4
- data/spec/unit/axiom/function/proposition/equality_operator_spec.rb +3 -3
- data/spec/unit/axiom/function/proposition/inverse_spec.rb +4 -4
- data/spec/unit/axiom/function/proposition/rename_spec.rb +1 -1
- data/spec/unit/axiom/function/type_spec.rb +1 -1
- data/spec/unit/axiom/function/unary/call_spec.rb +1 -1
- data/spec/unit/axiom/function/unary/callable/call_spec.rb +3 -13
- data/spec/unit/axiom/function/unary/callable/included_spec.rb +2 -2
- data/spec/unit/axiom/function/unary/type_spec.rb +11 -1
- data/spec/unit/axiom/relation/base/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/base/equality_operator_spec.rb +138 -0
- data/spec/unit/axiom/relation/class_methods/new_spec.rb +7 -7
- data/spec/unit/axiom/relation/directions_spec.rb +2 -2
- data/spec/unit/axiom/relation/each_spec.rb +5 -5
- data/spec/unit/axiom/relation/element_reader_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty/each_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/class_methods/coerce_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/class_methods/new_spec.rb +3 -3
- data/spec/unit/axiom/relation/header/context_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/extend_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/{call_spec.rb → fetch_spec.rb} +1 -1
- data/spec/unit/axiom/relation/header/project_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/rename_spec.rb +19 -5
- data/spec/unit/axiom/relation/header/size_spec.rb +14 -0
- data/spec/unit/axiom/relation/header_spec.rb +1 -1
- data/spec/unit/axiom/relation/index/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/index/element_reader_spec.rb +17 -0
- data/spec/unit/axiom/relation/index/left_shift_operator_spec.rb +23 -0
- data/spec/unit/axiom/relation/index/merge_spec.rb +19 -0
- data/spec/unit/axiom/relation/keys/class_methods/coerce_spec.rb +19 -2
- data/spec/unit/axiom/relation/keys/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/relation/keys/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/materialize_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized/class_methods/new_spec.rb +30 -4
- data/spec/unit/axiom/relation/materialized/directions_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized/materialized_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/binary/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/combination/class_methods/combine_tuples_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/group/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/group/header_spec.rb +22 -0
- data/spec/unit/axiom/relation/operation/group/methods/group_spec.rb +25 -0
- data/spec/unit/axiom/relation/operation/limit/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/limit/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/limit_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/offset/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/offset/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/offset_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/reverse/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/reverse/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/reverse/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/set/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/ascending/class_methods/call_spec.rb +22 -1
- data/spec/unit/axiom/relation/operation/sorted/ascending/class_methods/reverse_spec.rb +11 -0
- data/spec/unit/axiom/relation/operation/{order/descending → sorted/ascending}/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/delete_spec.rb +12 -6
- data/spec/unit/axiom/relation/operation/{order → sorted}/descending/class_methods/call_spec.rb +22 -1
- data/spec/unit/axiom/relation/operation/sorted/descending/class_methods/reverse_spec.rb +11 -0
- data/spec/unit/axiom/relation/operation/{order/ascending → sorted/descending}/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/attribute_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/call_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/class_methods/coerce_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/eql_predicate_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/name_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/rename_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/reverse_spec.rb +9 -9
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/attributes_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/coerce_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/project_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/rename_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/sort_tuples_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/to_ary_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/directions_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/each_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/{order → sorted}/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/header_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/insert_spec.rb +12 -6
- data/spec/unit/axiom/relation/operation/{order → sorted}/methods/sort_by_spec.rb +24 -24
- data/spec/unit/axiom/relation/operation/sorted/methods/sort_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/ungroup/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/ungroup/header_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/ungroup/methods/ungroup_spec.rb +21 -0
- data/spec/unit/axiom/relation/operation/unwrap/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/unwrap/header_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/unwrap/methods/unwrap_spec.rb +21 -0
- data/spec/unit/axiom/relation/operation/wrap/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/wrap/header_spec.rb +22 -0
- data/spec/unit/axiom/relation/operation/wrap/methods/wrap_spec.rb +25 -0
- data/spec/unit/axiom/relation/proxy/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/proxy/respond_to_predicate_spec.rb +48 -12
- data/spec/unit/axiom/relation/replace_spec.rb +8 -8
- data/spec/unit/axiom/tuple/class_methods/coerce_spec.rb +7 -1
- data/spec/unit/axiom/tuple/{call_spec.rb → fetch_spec.rb} +1 -1
- data/spec/unit/axiom/tuple/inspect_spec.rb +14 -0
- data/spec/unit/axiom/tuple/rename_spec.rb +17 -0
- data/spec/unit/axiom/tuple/size_spec.rb +14 -0
- data/spec/unit/axiom/tuple/to_ary_spec.rb +22 -5
- data/spec/unit/axiom/tuple/to_hash_spec.rb +14 -0
- data/spec/unit/axiom/types/relation/class_methods/primitive_spec.rb +13 -0
- data/spec/unit/axiom/types/tuple/class_methods/primitive_spec.rb +13 -0
- data/spec/unit/axiom/visitable/accept_spec.rb +1 -1
- data/spec/unit/date/pred_spec.rb +1 -1
- data/spec/unit/time/pred_spec.rb +1 -1
- metadata +631 -107
- data/spec/unit/axiom/aggregate/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/extension/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/projection/hash_spec.rb +0 -16
- data/spec/unit/axiom/algebra/rename/aliases/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/rename/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/restriction/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/summarization/hash_spec.rb +0 -16
- data/spec/unit/axiom/attribute/hash_spec.rb +0 -21
- data/spec/unit/axiom/attribute/numeric/hash_spec.rb +0 -17
- data/spec/unit/axiom/attribute/string/hash_spec.rb +0 -25
- data/spec/unit/axiom/equalizer/methods/eql_spec.rb +0 -49
- data/spec/unit/axiom/equalizer/methods/equality_operator_spec.rb +0 -85
- data/spec/unit/axiom/function/binary/invertible/class_methods/included_spec.rb +0 -29
- data/spec/unit/axiom/function/predicate/hash_spec.rb +0 -16
- data/spec/unit/axiom/function/predicate/inverse_spec.rb +0 -17
- data/spec/unit/axiom/function/proposition/hash_spec.rb +0 -14
- data/spec/unit/axiom/function/unary/hash_spec.rb +0 -18
- data/spec/unit/axiom/function/unary/invertible/class_methods/included_spec.rb +0 -29
- data/spec/unit/axiom/operation/binary/hash_spec.rb +0 -16
- data/spec/unit/axiom/operation/unary/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/base/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/hash_spec.rb +0 -19
- data/spec/unit/axiom/relation/header/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/limit/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/operation/offset/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/operation/order/ascending/class_methods/reverse_spec.rb +0 -11
- data/spec/unit/axiom/relation/operation/order/descending/class_methods/reverse_spec.rb +0 -11
- data/spec/unit/axiom/relation/operation/order/direction/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/direction_set/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/methods/sort_spec.rb +0 -19
- data/spec/unit/axiom/relation/proxy/hash_spec.rb +0 -26
- data/spec/unit/axiom/relation/proxy/method_missing_spec.rb +0 -24
- data/spec/unit/axiom/tuple/hash_spec.rb +0 -15
data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/coerce_spec.rb
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted::DirectionSet, '.coerce' do
|
6
6
|
subject { object.coerce(argument) }
|
7
7
|
|
8
8
|
let(:object) { described_class }
|
@@ -14,8 +14,8 @@ describe Relation::Operation::Order::DirectionSet, '.coerce' do
|
|
14
14
|
subject { object.coerce(argument, &block) }
|
15
15
|
|
16
16
|
context 'when the argument is a DirectionSet' do
|
17
|
-
let(:argument) { direction_set
|
18
|
-
let(:block) { proc {
|
17
|
+
let(:argument) { direction_set }
|
18
|
+
let(:block) { proc { fail 'should not fail' } }
|
19
19
|
|
20
20
|
it { should be(direction_set) }
|
21
21
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted::DirectionSet, '#project' do
|
6
6
|
subject { object.project(attributes) }
|
7
7
|
|
8
8
|
let(:header) { Relation::Header.coerce([[:id, Integer], [:name, String]]) }
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted::DirectionSet, '#reverse' do
|
6
6
|
subject { object.reverse }
|
7
7
|
|
8
8
|
let(:attribute1) { Attribute::Integer.new(:id) }
|
@@ -18,6 +18,6 @@ describe Relation::Operation::Order::DirectionSet, '#reverse' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'does not reverse the attribute order' do
|
21
|
-
subject.attributes.
|
21
|
+
expect(subject.attributes).to eql([attribute1, attribute2])
|
22
22
|
end
|
23
23
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted::DirectionSet, '#sort_tuples' do
|
6
6
|
subject { object.sort_tuples(relation) }
|
7
7
|
|
8
8
|
let(:header) { [[:id, Integer], [:name, String]] }
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted, '#each' do
|
6
6
|
subject { object.each { |tuple| yields << tuple } }
|
7
7
|
|
8
8
|
let(:object) { described_class.new(relation, directions) }
|
@@ -14,12 +14,12 @@ describe Relation::Operation::Order, '#each' do
|
|
14
14
|
|
15
15
|
it 'yields only tuples' do
|
16
16
|
subject
|
17
|
-
yields.each { |tuple| tuple.
|
17
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'yields only tuples with the expected header' do
|
21
21
|
subject
|
22
|
-
yields.each { |tuple| tuple.header.
|
22
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'yields only tuples with the expected data in order' do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted, '#insert' do
|
6
6
|
subject { object.insert(other) }
|
7
7
|
|
8
8
|
let(:object) { described_class.new(relation, directions) }
|
@@ -20,8 +20,8 @@ describe Relation::Operation::Order, '#insert' do
|
|
20
20
|
|
21
21
|
it 'passes expected relations into the insertion' do
|
22
22
|
subject = self.subject.operand
|
23
|
-
subject.left.
|
24
|
-
subject.right.
|
23
|
+
expect(subject.left).to be(relation)
|
24
|
+
expect(subject.right).to be(other_base)
|
25
25
|
end
|
26
26
|
|
27
27
|
its(:directions) { should == directions }
|
@@ -34,12 +34,18 @@ describe Relation::Operation::Order, '#insert' do
|
|
34
34
|
context 'when other relation does not have the same directions' do
|
35
35
|
let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])).sort_by([attribute]) }
|
36
36
|
|
37
|
-
specify { expect { subject }.to raise_error(
|
37
|
+
specify { expect { subject }.to raise_error(SortedMismatchError, 'other relation must have matching directions to be inserted') }
|
38
38
|
end
|
39
39
|
|
40
|
-
context 'when other relation is not
|
40
|
+
context 'when other relation is not sorted' do
|
41
41
|
let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])) }
|
42
42
|
|
43
|
-
specify { expect { subject }.to raise_error(
|
43
|
+
specify { expect { subject }.to raise_error(SortedMismatchError, 'other relation must have matching directions to be inserted') }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when other object is not a relation' do
|
47
|
+
let(:other) { LazyEnumerable.new([[2]]) }
|
48
|
+
|
49
|
+
specify { expect { subject }.to raise_error(SortedMismatchError, 'other relation must have matching directions to be inserted') }
|
44
50
|
end
|
45
51
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
6
|
-
let(:object) { Relation.new(header, LazyEnumerable.new([[1], [2]]))
|
7
|
-
let(:header) { Relation::Header.coerce([[:id, Integer]])
|
8
|
-
let(:directions) { Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted::Methods, '#sort_by' do
|
6
|
+
let(:object) { Relation.new(header, LazyEnumerable.new([[1], [2]])) }
|
7
|
+
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
8
|
+
let(:directions) { Relation::Operation::Sorted::DirectionSet.coerce(header) }
|
9
9
|
|
10
10
|
context 'with a block' do
|
11
11
|
context 'returning an array of attribute names' do
|
@@ -13,12 +13,12 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
13
13
|
|
14
14
|
let(:block) { ->(relation) { [relation[:id].name] } }
|
15
15
|
|
16
|
-
it { should be_instance_of(Relation::Operation::
|
16
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
17
17
|
|
18
18
|
its(:directions) { should eql(directions) }
|
19
19
|
|
20
20
|
it 'behaves the same as Array#sort_by' do
|
21
|
-
subject.to_a.
|
21
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,12 +27,12 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
27
27
|
|
28
28
|
let(:block) { ->(relation) { [relation[:id]] } }
|
29
29
|
|
30
|
-
it { should be_instance_of(Relation::Operation::
|
30
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
31
31
|
|
32
32
|
its(:directions) { should eql(directions) }
|
33
33
|
|
34
34
|
it 'behaves the same as Array#sort_by' do
|
35
|
-
subject.to_a.
|
35
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -41,12 +41,12 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
41
41
|
|
42
42
|
let(:block) { ->(relation) { [relation[:id].desc] } }
|
43
43
|
|
44
|
-
it { should be_instance_of(Relation::Operation::
|
44
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
45
45
|
|
46
46
|
its(:directions) { should eql(directions.reverse) }
|
47
47
|
|
48
48
|
it 'behaves the same as Array#sort_by' do
|
49
|
-
subject.to_a.
|
49
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -55,12 +55,12 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
55
55
|
|
56
56
|
let(:block) { ->(relation) { header } }
|
57
57
|
|
58
|
-
it { should be_instance_of(Relation::Operation::
|
58
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
59
59
|
|
60
60
|
its(:directions) { should eql(directions) }
|
61
61
|
|
62
62
|
it 'behaves the same as Array#sort_by' do
|
63
|
-
subject.to_a.
|
63
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -69,12 +69,12 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
69
69
|
|
70
70
|
let(:block) { ->(relation) { directions } }
|
71
71
|
|
72
|
-
it { should be_instance_of(Relation::Operation::
|
72
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
73
73
|
|
74
74
|
its(:directions) { should eql(directions) }
|
75
75
|
|
76
76
|
it 'behaves the same as Array#sort_by' do
|
77
|
-
subject.to_a.
|
77
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -83,60 +83,60 @@ describe Relation::Operation::Order::Methods, '#sort_by' do
|
|
83
83
|
context 'with an array of attribute names' do
|
84
84
|
subject { object.sort_by([header[:id].name]) }
|
85
85
|
|
86
|
-
it { should be_instance_of(Relation::Operation::
|
86
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
87
87
|
|
88
88
|
its(:directions) { should eql(directions) }
|
89
89
|
|
90
90
|
it 'behaves the same as Array#sort_by' do
|
91
|
-
subject.to_a.
|
91
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'with an array of attributes' do
|
96
96
|
subject { object.sort_by([header[:id]]) }
|
97
97
|
|
98
|
-
it { should be_instance_of(Relation::Operation::
|
98
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
99
99
|
|
100
100
|
its(:directions) { should eql(directions) }
|
101
101
|
|
102
102
|
it 'behaves the same as Array#sort_by' do
|
103
|
-
subject.to_a.
|
103
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
context 'with an array of directions' do
|
108
108
|
subject { object.sort_by([header[:id].desc]) }
|
109
109
|
|
110
|
-
it { should be_instance_of(Relation::Operation::
|
110
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
111
111
|
|
112
112
|
its(:directions) { should eql(directions.reverse) }
|
113
113
|
|
114
114
|
it 'behaves the same as Array#sort_by' do
|
115
|
-
subject.to_a.
|
115
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
context 'with a header' do
|
120
120
|
subject { object.sort_by(header) }
|
121
121
|
|
122
|
-
it { should be_instance_of(Relation::Operation::
|
122
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
123
123
|
|
124
124
|
its(:directions) { should eql(directions) }
|
125
125
|
|
126
126
|
it 'behaves the same as Array#sort_by' do
|
127
|
-
subject.to_a.
|
127
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
131
|
context 'with a direction set' do
|
132
132
|
subject { object.sort_by(directions) }
|
133
133
|
|
134
|
-
it { should be_instance_of(Relation::Operation::
|
134
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
135
135
|
|
136
136
|
its(:directions) { should eql(directions) }
|
137
137
|
|
138
138
|
it 'behaves the same as Array#sort_by' do
|
139
|
-
subject.to_a.
|
139
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Operation::Sorted::Methods, '#sort' do
|
6
|
+
subject { object.sort }
|
7
|
+
|
8
|
+
let(:object) { Relation.new(header, LazyEnumerable.new([[1], [2]])) }
|
9
|
+
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
10
|
+
let(:directions) { Relation::Operation::Sorted::DirectionSet.coerce(header) }
|
11
|
+
|
12
|
+
it { should be_instance_of(Relation::Operation::Sorted) }
|
13
|
+
|
14
|
+
its(:directions) { should eql(directions) }
|
15
|
+
|
16
|
+
it 'behaves the same as Array#sort_by' do
|
17
|
+
expect(subject.to_a).to eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Operation::Ungroup, '#each' do
|
6
|
+
subject { object }
|
7
|
+
|
8
|
+
let(:object) { described_class.new(relation, :names) }
|
9
|
+
let(:relation) { Relation.new(header, body).group(names: [:name]) }
|
10
|
+
let(:header) { [[:id, Integer], [:name, String]] }
|
11
|
+
let(:body) { [[1, 'John Doe']] }
|
12
|
+
|
13
|
+
it_should_behave_like 'an #each method'
|
14
|
+
|
15
|
+
it 'is a command method' do
|
16
|
+
expect(subject.each(&EMPTY_PROC)).to be(object)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'yields only tuples' do
|
20
|
+
expect { |block| subject.each(&block) }.to yield_with_args(Tuple)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'yields only tuples with the expected header' do
|
24
|
+
tuples = []
|
25
|
+
subject.each(&tuples.method(:<<))
|
26
|
+
expect(tuples.first.header).to eq(header)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'yields only tuples with the expected data' do
|
30
|
+
expect { |block| subject.each(&block) }
|
31
|
+
.to yield_with_args([1, 'John Doe'])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Operation::Ungroup, '#header' do
|
6
|
+
subject { object.header }
|
7
|
+
|
8
|
+
let(:object) { described_class.new(relation, :names) }
|
9
|
+
let(:relation) { Relation.new(header, []).group(names: [:name]) }
|
10
|
+
let(:header) { [[:id, Integer], [:name, String]] }
|
11
|
+
|
12
|
+
it_should_behave_like 'an idempotent method'
|
13
|
+
|
14
|
+
it { should be_instance_of(Relation::Header) }
|
15
|
+
|
16
|
+
it 'returns the expected attributes' do
|
17
|
+
should == header
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Operation::Ungroup::Methods, '#ungroup' do
|
6
|
+
subject { object.ungroup(name) }
|
7
|
+
|
8
|
+
let(:object) { relation.group(name => attributes) }
|
9
|
+
let(:described_class) { Relation }
|
10
|
+
let(:relation) { described_class.new(header, body) }
|
11
|
+
let(:header) { [[:id, Integer], [:name, String]] }
|
12
|
+
let(:body) { [[1, 'John Doe']] }
|
13
|
+
let(:name) { :names }
|
14
|
+
let(:attributes) { [:name] }
|
15
|
+
|
16
|
+
it { should be_instance_of(Relation::Operation::Ungroup) }
|
17
|
+
|
18
|
+
its(:header) { should == header }
|
19
|
+
|
20
|
+
its(:to_a) { should eq([[1, 'John Doe']]) }
|
21
|
+
end
|