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/spec_helper.rb
CHANGED
@@ -20,14 +20,16 @@ if ENV['COVERAGE'] == 'true'
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
require 'devtools/spec_helper'
|
24
23
|
require 'axiom'
|
24
|
+
require 'devtools/spec_helper'
|
25
25
|
|
26
26
|
include Axiom
|
27
27
|
|
28
28
|
RSpec.configure do |config|
|
29
|
+
EMPTY_PROC = proc {}.freeze
|
30
|
+
|
29
31
|
config.expect_with :rspec do |expect_with|
|
30
|
-
expect_with.syntax =
|
32
|
+
expect_with.syntax = :expect
|
31
33
|
end
|
32
34
|
|
33
35
|
# Record the original Attribute descendants
|
@@ -42,13 +44,13 @@ RSpec.configure do |config|
|
|
42
44
|
|
43
45
|
# Record the original Type descendants
|
44
46
|
config.before do
|
45
|
-
|
46
|
-
@original_type_descendants =
|
47
|
+
Types.finalize
|
48
|
+
@original_type_descendants = Types::Type.descendants.dup
|
47
49
|
end
|
48
50
|
|
49
51
|
# Reset the Type descendants
|
50
52
|
config.after do
|
51
|
-
|
52
|
-
|
53
|
+
Types::Type.descendants.replace(@original_type_descendants)
|
54
|
+
Types.instance_variable_get(:@inference_cache).clear
|
53
55
|
end
|
54
56
|
end
|
@@ -3,21 +3,19 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Aggregate, '#call' do
|
6
|
-
subject { object.call(
|
6
|
+
subject { object.call(accumulator, tuple) }
|
7
7
|
|
8
|
-
let(:described_class) { Class.new(Aggregate) }
|
9
8
|
let(:object) { described_class.new(attribute) }
|
9
|
+
let(:described_class) { Class.new(Aggregate) }
|
10
|
+
let(:accumulator) { double('accumulator') }
|
10
11
|
let(:attribute) { Attribute::Integer.new(:id) }
|
11
12
|
let(:header) { Relation::Header.new([attribute]) }
|
12
13
|
let(:tuple) { Tuple.new(header, [1]) }
|
13
14
|
|
14
15
|
context 'when operand is an attribute' do
|
15
16
|
before do
|
16
|
-
described_class.
|
17
|
-
|
18
|
-
value
|
19
|
-
end
|
20
|
-
end
|
17
|
+
expect(described_class).to receive(:call).with(accumulator, 1)
|
18
|
+
.and_return(1)
|
21
19
|
end
|
22
20
|
|
23
21
|
it { should eql(1) }
|
@@ -27,11 +25,8 @@ describe Aggregate, '#call' do
|
|
27
25
|
let(:object) { described_class.new(2) }
|
28
26
|
|
29
27
|
before do
|
30
|
-
described_class.
|
31
|
-
|
32
|
-
value
|
33
|
-
end
|
34
|
-
end
|
28
|
+
expect(described_class).to receive(:call).with(accumulator, 2)
|
29
|
+
.and_return(2)
|
35
30
|
end
|
36
31
|
|
37
32
|
it { should eql(2) }
|
@@ -5,7 +5,12 @@ require 'spec_helper'
|
|
5
5
|
describe Aggregate, '.default' do
|
6
6
|
subject { object.default }
|
7
7
|
|
8
|
-
let(:object)
|
8
|
+
let(:object) { Class.new(described_class) }
|
9
|
+
let(:default) { double('default') }
|
9
10
|
|
10
|
-
|
11
|
+
before do
|
12
|
+
object.const_set(:DEFAULT, default)
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should be(default) }
|
11
16
|
end
|
@@ -11,7 +11,7 @@ describe Aggregate, '#default' do
|
|
11
11
|
|
12
12
|
it 'delegates to self.class.default' do
|
13
13
|
return_value = double('Return Value')
|
14
|
-
described_class.
|
14
|
+
expect(described_class).to receive(:default).with(no_args).and_return(return_value)
|
15
15
|
should be(return_value)
|
16
16
|
end
|
17
17
|
end
|
@@ -12,7 +12,7 @@ describe Aggregate, '#finalize' do
|
|
12
12
|
|
13
13
|
it 'delegates to self.class.finalize' do
|
14
14
|
return_value = double('Return Value')
|
15
|
-
described_class.
|
15
|
+
expect(described_class).to receive(:finalize).with(accumulator).and_return(return_value)
|
16
16
|
should be(return_value)
|
17
17
|
end
|
18
18
|
end
|
@@ -6,15 +6,11 @@ describe Aggregate::Maximum, '#type' do
|
|
6
6
|
subject { object.type }
|
7
7
|
|
8
8
|
let(:object) { described_class.new(operand) }
|
9
|
-
let(:operand) {
|
10
|
-
|
11
|
-
before do
|
12
|
-
operand.stub(freeze: operand, :frozen? => true)
|
13
|
-
end
|
9
|
+
let(:operand) { Object.new.freeze }
|
14
10
|
|
15
11
|
it 'delegates to Attribute.infer_type' do
|
16
12
|
return_value = double('Return Value')
|
17
|
-
Attribute.
|
13
|
+
expect(Attribute).to receive(:infer_type).with(operand).and_return(return_value)
|
18
14
|
should be(return_value)
|
19
15
|
end
|
20
16
|
end
|
@@ -16,7 +16,7 @@ describe Aggregate::Mean, '.call' do
|
|
16
16
|
let(:values) { [0] }
|
17
17
|
|
18
18
|
it 'returns the expected count and mean of the values' do
|
19
|
-
should
|
19
|
+
should eql([1, 0.to_r])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -24,7 +24,7 @@ describe Aggregate::Mean, '.call' do
|
|
24
24
|
let(:values) { [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6] }
|
25
25
|
|
26
26
|
it 'returns the expected count and mean of the values' do
|
27
|
-
should
|
27
|
+
should eql([13, 0.to_r])
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -8,9 +8,16 @@ describe Aggregate::Mean, '.finalize' do
|
|
8
8
|
let(:object) { described_class }
|
9
9
|
let(:accumulator) { [count, mean] }
|
10
10
|
let(:count) { double('Count') }
|
11
|
-
let(:mean) { double('Mean') }
|
12
11
|
|
13
|
-
|
12
|
+
context 'when the accumulator mean is nil' do
|
13
|
+
let(:mean) { nil }
|
14
14
|
|
15
|
-
|
15
|
+
it { should be_nil }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the accumulator mean is not nil' do
|
19
|
+
let(:mean) { 1.to_r }
|
20
|
+
|
21
|
+
it { should eql(1.0) }
|
22
|
+
end
|
16
23
|
end
|
@@ -6,15 +6,11 @@ describe Aggregate::Minimum, '#type' do
|
|
6
6
|
subject { object.type }
|
7
7
|
|
8
8
|
let(:object) { described_class.new(operand) }
|
9
|
-
let(:operand) {
|
10
|
-
|
11
|
-
before do
|
12
|
-
operand.stub(freeze: operand, :frozen? => true)
|
13
|
-
end
|
9
|
+
let(:operand) { Object.new.freeze }
|
14
10
|
|
15
11
|
it 'delegates to Attribute.infer_type' do
|
16
12
|
return_value = double('Return Value')
|
17
|
-
Attribute.
|
13
|
+
expect(Attribute).to receive(:infer_type).with(operand).and_return(return_value)
|
18
14
|
should be(return_value)
|
19
15
|
end
|
20
16
|
end
|
@@ -7,27 +7,53 @@ describe Aggregate::Sum, '#default' do
|
|
7
7
|
|
8
8
|
let(:object) { described_class.new(attribute) }
|
9
9
|
|
10
|
+
# This is needed to test the contract that the DEFAULT constant is
|
11
|
+
# used for the identity. Subclasses of this function may rely on this.
|
12
|
+
def self.default_value(value)
|
13
|
+
before do
|
14
|
+
stub_const("#{described_class}::DEFAULT", value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
context 'when the attribute is an Integer' do
|
11
19
|
let(:attribute) { Attribute::Integer.new(:integer) }
|
12
20
|
|
13
|
-
|
21
|
+
context 'with the default value of 0' do
|
22
|
+
it { should be(0) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with a default value other than 0' do
|
26
|
+
default_value(1)
|
14
27
|
|
15
|
-
|
28
|
+
it { should be(1) }
|
29
|
+
end
|
16
30
|
end
|
17
31
|
|
18
32
|
context 'when the attribute is a Float' do
|
19
33
|
let(:attribute) { Attribute::Float.new(:float) }
|
20
34
|
|
21
|
-
|
35
|
+
context 'with the default value of 0' do
|
36
|
+
it { should eql(0.0) }
|
37
|
+
end
|
22
38
|
|
23
|
-
|
39
|
+
context 'with the default value other than 0' do
|
40
|
+
default_value(1)
|
41
|
+
|
42
|
+
it { should eql(1.0) }
|
43
|
+
end
|
24
44
|
end
|
25
45
|
|
26
46
|
context 'when the attribute is a Decimal' do
|
27
47
|
let(:attribute) { Attribute::Decimal.new(:decimal) }
|
28
48
|
|
29
|
-
|
49
|
+
context 'with the default value of 0' do
|
50
|
+
it { should eql(BigDecimal('0')) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with the default value other than 0' do
|
54
|
+
default_value(1)
|
30
55
|
|
31
|
-
|
56
|
+
it { should eql(BigDecimal('1')) }
|
57
|
+
end
|
32
58
|
end
|
33
59
|
end
|
@@ -6,15 +6,11 @@ describe Aggregate::Sum, '#type' do
|
|
6
6
|
subject { object.type }
|
7
7
|
|
8
8
|
let(:object) { described_class.new(operand) }
|
9
|
-
let(:operand) {
|
10
|
-
|
11
|
-
before do
|
12
|
-
operand.stub(freeze: operand, :frozen? => true)
|
13
|
-
end
|
9
|
+
let(:operand) { Object.new.freeze }
|
14
10
|
|
15
11
|
it 'delegates to Attribute.infer_type' do
|
16
12
|
return_value = double('Return Value')
|
17
|
-
Attribute.
|
13
|
+
expect(Attribute).to receive(:infer_type).with(operand).and_return(return_value)
|
18
14
|
should be(return_value)
|
19
15
|
end
|
20
16
|
end
|
@@ -19,15 +19,15 @@ describe Aggregate::Variance, '.call' do
|
|
19
19
|
let(:sum_of_squares) { values.map { |value| value**2.0 }.reduce(:+) }
|
20
20
|
|
21
21
|
it 'returns the expected count' do
|
22
|
-
subject.fetch(0).
|
22
|
+
expect(subject.fetch(0)).to be(count)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the expected mean' do
|
26
|
-
subject.fetch(1).
|
26
|
+
expect(subject.fetch(1)).to eq(mean)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns the expected sum of squares' do
|
30
|
-
subject.fetch(2).
|
30
|
+
expect(subject.fetch(2)).to eq(sum_of_squares)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -38,15 +38,15 @@ describe Aggregate::Variance, '.call' do
|
|
38
38
|
let(:sum_of_squares) { default.fetch(2) }
|
39
39
|
|
40
40
|
it 'returns the default count' do
|
41
|
-
subject.fetch(0).
|
41
|
+
expect(subject.fetch(0)).to be(count)
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'returns the default mean' do
|
45
|
-
subject.fetch(1).
|
45
|
+
expect(subject.fetch(1)).to eq(mean)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'returns the default sum of squares' do
|
49
|
-
subject.fetch(2).
|
49
|
+
expect(subject.fetch(2)).to eq(sum_of_squares)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -17,7 +17,7 @@ describe Algebra::Difference, '#each' do
|
|
17
17
|
|
18
18
|
it 'yields no tuples' do
|
19
19
|
subject
|
20
|
-
yields.
|
20
|
+
expect(yields).to be_empty
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -28,12 +28,12 @@ describe Algebra::Difference, '#each' do
|
|
28
28
|
|
29
29
|
it 'yields only tuples' do
|
30
30
|
subject
|
31
|
-
yields.each { |tuple| tuple.
|
31
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'yields only tuples with the expected header' do
|
35
35
|
subject
|
36
|
-
yields.each { |tuple| tuple.header.
|
36
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'yields only tuples with the expected data' do
|
@@ -15,7 +15,7 @@ describe Algebra::Extension, '.new' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'with a duplicate attribute name provided' do
|
18
|
-
let(:extensions) { { id:
|
18
|
+
let(:extensions) { { id: EMPTY_PROC, name: EMPTY_PROC } }
|
19
19
|
|
20
20
|
specify { expect { subject }.to raise_error(DuplicateNameError, 'duplicate names: [:id, :name]') }
|
21
21
|
end
|
@@ -14,12 +14,12 @@ describe Algebra::Extension, '#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' do
|
@@ -17,12 +17,12 @@ describe Algebra::Intersection, '#each' do
|
|
17
17
|
|
18
18
|
it 'yields only tuples' do
|
19
19
|
subject
|
20
|
-
yields.each { |tuple| tuple.
|
20
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'yields only tuples with the expected header' do
|
24
24
|
subject
|
25
|
-
yields.each { |tuple| tuple.header.
|
25
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'yields only tuples with the expected data' do
|
@@ -39,7 +39,7 @@ describe Algebra::Intersection, '#each' do
|
|
39
39
|
|
40
40
|
it 'yields no tuples' do
|
41
41
|
subject
|
42
|
-
yields.
|
42
|
+
expect(yields).to be_empty
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -16,12 +16,12 @@ describe Algebra::Join, '#each' do
|
|
16
16
|
|
17
17
|
it 'yields only tuples' do
|
18
18
|
subject
|
19
|
-
yields.each { |tuple| tuple.
|
19
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'yields only tuples with the expected header' do
|
23
23
|
subject
|
24
|
-
yields.each { |tuple| tuple.header.
|
24
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'yields only tuples with the expected data' do
|
@@ -38,12 +38,12 @@ describe Algebra::Join, '#each' do
|
|
38
38
|
|
39
39
|
it 'yields only tuples' do
|
40
40
|
subject
|
41
|
-
yields.each { |tuple| tuple.
|
41
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'yields only tuples with the expected header' do
|
45
45
|
subject
|
46
|
-
yields.each { |tuple| tuple.header.
|
46
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'yields only tuples with the expected data' do
|
@@ -60,12 +60,12 @@ describe Algebra::Join, '#each' do
|
|
60
60
|
|
61
61
|
it 'yields only tuples' do
|
62
62
|
subject
|
63
|
-
yields.each { |tuple| tuple.
|
63
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'yields only tuples with the expected header' do
|
67
67
|
subject
|
68
|
-
yields.each { |tuple| tuple.header.
|
68
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'yields only tuples with the expected data' do
|
@@ -15,12 +15,12 @@ describe Algebra::Product, '#each' do
|
|
15
15
|
|
16
16
|
it 'yields only tuples' do
|
17
17
|
subject
|
18
|
-
yields.each { |tuple| tuple.
|
18
|
+
yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'yields only tuples with the expected header' do
|
22
22
|
subject
|
23
|
-
yields.each { |tuple| tuple.header.
|
23
|
+
yields.each { |tuple| expect(tuple.header).to be(object.header) }
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'yields only tuples with the expected data' do
|