axiom 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +11 -20
- data/Gemfile +5 -2
- data/Gemfile.devtools +26 -28
- data/Guardfile +18 -9
- data/README.md +20 -39
- data/axiom.gemspec +17 -18
- data/benchmarks/memory.rb +14 -14
- data/benchmarks/speed.rb +14 -14
- data/config/devtools.yml +2 -0
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/reek.yml +3 -3
- data/config/rubocop.yml +62 -0
- data/lib/axiom.rb +17 -20
- data/lib/axiom/aggregate.rb +2 -5
- data/lib/axiom/aggregate/count.rb +4 -4
- data/lib/axiom/aggregate/maximum.rb +3 -3
- data/lib/axiom/aggregate/mean.rb +9 -9
- data/lib/axiom/aggregate/minimum.rb +3 -3
- data/lib/axiom/aggregate/standard_deviation.rb +5 -4
- data/lib/axiom/aggregate/sum.rb +4 -4
- data/lib/axiom/aggregate/variance.rb +15 -12
- data/lib/axiom/algebra/extension.rb +2 -2
- data/lib/axiom/algebra/projection.rb +3 -3
- data/lib/axiom/algebra/rename/aliases.rb +6 -6
- data/lib/axiom/algebra/restriction.rb +1 -1
- data/lib/axiom/algebra/summarization.rb +5 -7
- data/lib/axiom/algebra/summarization/summaries.rb +2 -2
- data/lib/axiom/algebra/union.rb +1 -1
- data/lib/axiom/attribute.rb +24 -33
- data/lib/axiom/attribute/boolean.rb +10 -20
- data/lib/axiom/attribute/class.rb +5 -5
- data/lib/axiom/attribute/date.rb +5 -19
- data/lib/axiom/attribute/date_time.rb +5 -19
- data/lib/axiom/attribute/decimal.rb +5 -5
- data/lib/axiom/attribute/float.rb +5 -7
- data/lib/axiom/attribute/integer.rb +5 -5
- data/lib/axiom/attribute/numeric.rb +15 -39
- data/lib/axiom/attribute/object.rb +5 -5
- data/lib/axiom/attribute/string.rb +16 -63
- data/lib/axiom/attribute/time.rb +5 -19
- data/lib/axiom/function.rb +14 -2
- data/lib/axiom/function/binary.rb +17 -0
- data/lib/axiom/function/connective.rb +6 -3
- data/lib/axiom/function/connective/conjunction.rb +2 -2
- data/lib/axiom/function/connective/disjunction.rb +2 -2
- data/lib/axiom/function/numeric.rb +13 -0
- data/lib/axiom/function/numeric/absolute.rb +1 -1
- data/lib/axiom/function/numeric/division.rb +18 -2
- data/lib/axiom/function/numeric/exponentiation.rb +1 -1
- data/lib/axiom/function/numeric/modulo.rb +1 -1
- data/lib/axiom/function/numeric/square_root.rb +19 -3
- data/lib/axiom/function/predicate.rb +6 -3
- data/lib/axiom/function/predicate/exclusion.rb +2 -2
- data/lib/axiom/function/predicate/inclusion.rb +2 -2
- data/lib/axiom/function/proposition.rb +12 -9
- data/lib/axiom/function/string/length.rb +6 -3
- data/lib/axiom/function/unary.rb +12 -0
- data/lib/axiom/relation.rb +31 -50
- data/lib/axiom/relation/base.rb +3 -3
- data/lib/axiom/relation/empty.rb +3 -32
- data/lib/axiom/relation/header.rb +31 -15
- data/lib/axiom/relation/keys.rb +4 -4
- data/lib/axiom/relation/materialized.rb +2 -1
- data/lib/axiom/relation/operation/limit.rb +51 -0
- data/lib/axiom/relation/operation/order.rb +21 -28
- data/lib/axiom/relation/operation/order/direction_set.rb +1 -1
- data/lib/axiom/relation/proxy.rb +2 -2
- data/lib/axiom/relation/variable.rb +117 -0
- data/lib/axiom/support/equalizer.rb +9 -2
- data/lib/axiom/support/evaluator.rb +4 -1
- data/lib/axiom/tuple.rb +2 -2
- data/lib/axiom/version.rb +1 -1
- data/spec/integration/axiom/algebra/join_spec.rb +2 -2
- data/spec/integration/axiom/algebra/product_spec.rb +2 -2
- data/spec/integration/axiom/algebra/projection_spec.rb +6 -6
- data/spec/integration/axiom/algebra/summarization_spec.rb +9 -9
- data/spec/integration/axiom/relation/efficient_enumerable_spec.rb +18 -18
- data/spec/integration/axiom/relation/mutable_enumerator_spec.rb +51 -0
- data/spec/integration/axiom/relation/variable/thread_safe_spec.rb +45 -0
- data/spec/integration/axiom/relation/writable_relations_spec.rb +14 -14
- data/spec/shared/invertible_method_behaviour.rb +1 -1
- data/spec/spec_helper.rb +23 -15
- data/spec/support/config_alias.rb +2 -0
- data/spec/unit/axiom/aggregate/call_spec.rb +5 -5
- data/spec/unit/axiom/aggregate/class_methods/finalize_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/count/class_methods/call_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/count/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/aggregate/count/methods/count_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/default_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/finalize_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/maximum/class_methods/call_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/maximum/methods/maximum_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/maximum/type_spec.rb +4 -4
- data/spec/unit/axiom/aggregate/mean/class_methods/call_spec.rb +6 -6
- data/spec/unit/axiom/aggregate/mean/class_methods/default_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/mean/class_methods/finalize_spec.rb +4 -4
- data/spec/unit/axiom/aggregate/mean/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/aggregate/mean/methods/mean_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/minimum/class_methods/call_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/minimum/methods/minimum_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/minimum/type_spec.rb +4 -4
- data/spec/unit/axiom/aggregate/standard_deviation/class_methods/finalize_spec.rb +4 -4
- data/spec/unit/axiom/aggregate/standard_deviation/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/aggregate/standard_deviation/methods/standard_deviation_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/sum/class_methods/call_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/sum/default_spec.rb +3 -3
- data/spec/unit/axiom/aggregate/sum/methods/sum_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/sum/type_spec.rb +4 -4
- data/spec/unit/axiom/aggregate/variance/class_methods/call_spec.rb +9 -9
- data/spec/unit/axiom/aggregate/variance/class_methods/default_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/variance/class_methods/finalize_spec.rb +11 -3
- data/spec/unit/axiom/aggregate/variance/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/aggregate/variance/methods/variance_spec.rb +2 -2
- data/spec/unit/axiom/algebra/difference/delete_spec.rb +6 -6
- data/spec/unit/axiom/algebra/difference/each_spec.rb +6 -6
- data/spec/unit/axiom/algebra/difference/insert_spec.rb +5 -5
- data/spec/unit/axiom/algebra/difference/methods/difference_spec.rb +5 -5
- data/spec/unit/axiom/algebra/extension/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/algebra/extension/delete_spec.rb +11 -11
- data/spec/unit/axiom/algebra/extension/each_spec.rb +7 -7
- data/spec/unit/axiom/algebra/extension/eql_spec.rb +5 -5
- data/spec/unit/axiom/algebra/extension/extensions_spec.rb +3 -3
- data/spec/unit/axiom/algebra/extension/hash_spec.rb +3 -3
- data/spec/unit/axiom/algebra/extension/header_spec.rb +4 -4
- data/spec/unit/axiom/algebra/extension/insert_spec.rb +11 -11
- data/spec/unit/axiom/algebra/extension/methods/extend_spec.rb +6 -6
- data/spec/unit/axiom/algebra/extension/operand_spec.rb +4 -4
- data/spec/unit/axiom/algebra/intersection/delete_spec.rb +6 -6
- data/spec/unit/axiom/algebra/intersection/each_spec.rb +6 -6
- data/spec/unit/axiom/algebra/intersection/insert_spec.rb +5 -5
- data/spec/unit/axiom/algebra/intersection/methods/intersect_spec.rb +5 -5
- data/spec/unit/axiom/algebra/join/class_methods/new_spec.rb +5 -5
- data/spec/unit/axiom/algebra/join/delete_spec.rb +8 -8
- data/spec/unit/axiom/algebra/join/each_spec.rb +15 -15
- data/spec/unit/axiom/algebra/join/insert_spec.rb +8 -8
- data/spec/unit/axiom/algebra/join/join_header_spec.rb +4 -4
- data/spec/unit/axiom/algebra/join/methods/join_spec.rb +6 -6
- data/spec/unit/axiom/algebra/product/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/algebra/product/delete_spec.rb +4 -4
- data/spec/unit/axiom/algebra/product/each_spec.rb +8 -8
- data/spec/unit/axiom/algebra/product/insert_spec.rb +4 -4
- data/spec/unit/axiom/algebra/product/methods/product_spec.rb +4 -4
- data/spec/unit/axiom/algebra/projection/delete_spec.rb +11 -11
- data/spec/unit/axiom/algebra/projection/each_spec.rb +7 -7
- data/spec/unit/axiom/algebra/projection/eql_spec.rb +5 -5
- data/spec/unit/axiom/algebra/projection/hash_spec.rb +4 -4
- data/spec/unit/axiom/algebra/projection/header_spec.rb +3 -3
- data/spec/unit/axiom/algebra/projection/insert_spec.rb +14 -14
- data/spec/unit/axiom/algebra/projection/methods/project_spec.rb +5 -5
- data/spec/unit/axiom/algebra/projection/methods/remove_spec.rb +5 -5
- data/spec/unit/axiom/algebra/rename/aliases/class_methods/coerce_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/aliases/each_spec.rb +4 -4
- data/spec/unit/axiom/algebra/rename/aliases/element_reader_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/aliases/to_hash_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/aliases/union_spec.rb +1 -1
- data/spec/unit/axiom/algebra/rename/aliases_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/delete_spec.rb +6 -6
- data/spec/unit/axiom/algebra/rename/directions_spec.rb +4 -4
- data/spec/unit/axiom/algebra/rename/each_spec.rb +6 -6
- data/spec/unit/axiom/algebra/rename/eql_spec.rb +5 -5
- data/spec/unit/axiom/algebra/rename/hash_spec.rb +3 -3
- data/spec/unit/axiom/algebra/rename/header_spec.rb +3 -3
- data/spec/unit/axiom/algebra/rename/insert_spec.rb +6 -6
- data/spec/unit/axiom/algebra/rename/methods/rename_spec.rb +4 -4
- data/spec/unit/axiom/algebra/restriction/delete_spec.rb +9 -9
- data/spec/unit/axiom/algebra/restriction/each_spec.rb +12 -12
- data/spec/unit/axiom/algebra/restriction/eql_spec.rb +4 -4
- data/spec/unit/axiom/algebra/restriction/hash_spec.rb +3 -3
- data/spec/unit/axiom/algebra/restriction/insert_spec.rb +9 -9
- data/spec/unit/axiom/algebra/restriction/methods/restrict_spec.rb +12 -15
- data/spec/unit/axiom/algebra/restriction/predicate_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/algebra/summarization/delete_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/each_spec.rb +5 -5
- data/spec/unit/axiom/algebra/summarization/eql_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/hash_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/header_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/insert_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/methods/summarize_spec.rb +15 -15
- data/spec/unit/axiom/algebra/summarization/summaries/summarize_by_spec.rb +6 -6
- data/spec/unit/axiom/algebra/summarization/summaries/to_hash_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/summarize_per_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/summarizers_spec.rb +3 -3
- data/spec/unit/axiom/algebra/summarization/summary/call_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/summary/summarize_by_spec.rb +9 -6
- data/spec/unit/axiom/algebra/union/delete_spec.rb +6 -6
- data/spec/unit/axiom/algebra/union/each_spec.rb +9 -9
- data/spec/unit/axiom/algebra/union/insert_spec.rb +5 -5
- data/spec/unit/axiom/algebra/union/methods/union_spec.rb +5 -5
- data/spec/unit/axiom/aliasable/inheritable_alias_spec.rb +6 -6
- data/spec/unit/axiom/attribute/{date/class_methods/primitive_spec.rb → boolean/class_methods/type_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/boolean/{valid_value_predicate_spec.rb → include_predicate_spec.rb} +2 -2
- data/spec/unit/axiom/attribute/call_spec.rb +8 -4
- data/spec/unit/axiom/attribute/{time/class_methods/primitive_spec.rb → class/class_methods/type_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/class_methods/coerce_spec.rb +6 -6
- data/spec/unit/axiom/attribute/class_methods/infer_type_spec.rb +15 -15
- data/spec/unit/axiom/attribute/class_methods/name_from_spec.rb +4 -4
- data/spec/unit/axiom/attribute/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/attribute/{float/class_methods/primitive_spec.rb → date/class_methods/type_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/{class/class_methods/primitive_spec.rb → date_time/class_methods/type_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/decimal/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/eql_spec.rb +5 -1
- data/spec/unit/axiom/attribute/equality_operator_spec.rb +5 -1
- data/spec/unit/axiom/attribute/float/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/hash_spec.rb +6 -2
- data/spec/unit/axiom/attribute/{valid_value_predicate_spec.rb → include_predicate_spec.rb} +4 -8
- data/spec/unit/axiom/attribute/integer/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/name_spec.rb +5 -1
- data/spec/unit/axiom/attribute/numeric/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/numeric/eql_spec.rb +2 -2
- data/spec/unit/axiom/attribute/numeric/equality_operator_spec.rb +2 -2
- data/spec/unit/axiom/attribute/numeric/hash_spec.rb +6 -6
- data/spec/unit/axiom/attribute/numeric/{valid_value_predicate_spec.rb → include_predicate_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/object/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/optional_predicate_spec.rb +31 -0
- data/spec/unit/axiom/attribute/rename_spec.rb +9 -5
- data/spec/unit/axiom/attribute/required_predicate_spec.rb +8 -4
- data/spec/unit/axiom/attribute/string/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/string/eql_spec.rb +5 -5
- data/spec/unit/axiom/attribute/string/equality_operator_spec.rb +5 -5
- data/spec/unit/axiom/attribute/string/hash_spec.rb +9 -9
- data/spec/unit/axiom/attribute/string/{valid_value_predicate_spec.rb → include_predicate_spec.rb} +3 -3
- data/spec/unit/axiom/attribute/time/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/type_spec.rb +4 -4
- data/spec/unit/axiom/equalizer/class_method/new_spec.rb +11 -11
- data/spec/unit/axiom/equalizer/methods/eql_spec.rb +1 -1
- data/spec/unit/axiom/evaluator/context/add_spec.rb +5 -5
- data/spec/unit/axiom/evaluator/context/element_reader_spec.rb +5 -5
- data/spec/unit/axiom/evaluator/context/functions_spec.rb +1 -1
- data/spec/unit/axiom/evaluator/context/method_missing_spec.rb +5 -5
- data/spec/unit/axiom/evaluator/context/respond_to_predicate_spec.rb +3 -3
- data/spec/unit/axiom/evaluator/context/send_spec.rb +9 -9
- data/spec/unit/axiom/evaluator/context/yield_spec.rb +3 -3
- data/spec/unit/axiom/function/binary/call_spec.rb +4 -4
- data/spec/unit/axiom/function/binary/equality_operator_spec.rb +6 -6
- data/spec/unit/axiom/function/binary/invertible/class_methods/included_spec.rb +5 -5
- data/spec/unit/axiom/function/binary/invertible/inverse_spec.rb +5 -5
- data/spec/unit/axiom/function/binary/rename_spec.rb +9 -9
- data/spec/unit/axiom/function/binary/type_spec.rb +53 -0
- data/spec/unit/axiom/function/class_methods/extract_value_spec.rb +5 -5
- data/spec/unit/axiom/function/class_methods/rename_attributes_spec.rb +3 -3
- data/spec/unit/axiom/function/class_methods/type_spec.rb +12 -0
- data/spec/unit/axiom/function/comparable/class_methods/included_spec.rb +5 -5
- data/spec/unit/axiom/function/connective/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/connective/conjunction/methods/and_spec.rb +5 -5
- data/spec/unit/axiom/function/connective/disjunction/methods/or_spec.rb +5 -5
- data/spec/unit/axiom/function/connective/negation/class_methods/operation_spec.rb +1 -1
- data/spec/unit/axiom/function/connective/negation/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/connective/negation/methods/not_spec.rb +6 -6
- data/spec/unit/axiom/function/numeric/absolute/class_methods/operation_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/absolute/methods/absolute_spec.rb +2 -2
- data/spec/unit/axiom/function/numeric/addition/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/addition/methods/add_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/numeric/division/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/division/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/numeric/division/methods/divide_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/division/type_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/exponentiation/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/exponentiation/methods/exponent_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/modulo/methods/modulo_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/multiplication/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/multiplication/methods/multiply_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/square_root/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/numeric/square_root/methods/square_root_spec.rb +2 -2
- data/spec/unit/axiom/function/numeric/square_root/type_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/subtraction/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/subtraction/methods/subtract_spec.rb +4 -4
- data/spec/unit/axiom/function/numeric/unary_minus/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/unary_minus/class_methods/operation_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/unary_minus/methods/unary_minus_spec.rb +2 -2
- data/spec/unit/axiom/function/numeric/unary_plus/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/unary_plus/class_methods/operation_spec.rb +1 -1
- data/spec/unit/axiom/function/numeric/unary_plus/methods/unary_plus_spec.rb +2 -2
- data/spec/unit/axiom/function/predicate/call_spec.rb +5 -5
- data/spec/unit/axiom/function/predicate/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/predicate/enumerable/call_spec.rb +11 -11
- data/spec/unit/axiom/function/predicate/enumerable/class_methods/compare_method_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/equality/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/equality/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/equality/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/exclusion/class_methods/call_spec.rb +4 -4
- data/spec/unit/axiom/function/predicate/exclusion/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/exclusion/inverse_spec.rb +3 -3
- data/spec/unit/axiom/function/predicate/exclusion/methods/exclude_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/inclusion/class_methods/call_spec.rb +4 -4
- data/spec/unit/axiom/function/predicate/inclusion/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/inclusion/inverse_spec.rb +3 -3
- data/spec/unit/axiom/function/predicate/inclusion/methods/include_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/inequality/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/inequality/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/inequality/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than_or_equal_to/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than_or_equal_to/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/less_than_or_equal_to/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/match/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/match/inverse_spec.rb +2 -2
- data/spec/unit/axiom/function/predicate/no_match/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/no_match/inverse_spec.rb +2 -2
- data/spec/unit/axiom/function/proposition/call_spec.rb +2 -2
- data/spec/unit/axiom/function/proposition/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/function/proposition/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/proposition/contradiction/and_spec.rb +2 -2
- data/spec/unit/axiom/function/proposition/contradiction/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/proposition/contradiction/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/proposition/contradiction/or_spec.rb +2 -2
- data/spec/unit/axiom/function/proposition/inverse_spec.rb +6 -6
- data/spec/unit/axiom/function/proposition/rename_spec.rb +1 -1
- data/spec/unit/axiom/function/proposition/tautology/and_spec.rb +2 -2
- data/spec/unit/axiom/function/proposition/tautology/class_methods/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/proposition/tautology/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/proposition/tautology/or_spec.rb +2 -2
- data/spec/unit/axiom/function/rename_spec.rb +1 -1
- data/spec/unit/axiom/function/string/length/class_methods/type_spec.rb +11 -0
- data/spec/unit/axiom/function/string/length/methods/length_spec.rb +1 -1
- data/spec/unit/axiom/function/type_spec.rb +8 -1
- data/spec/unit/axiom/function/unary/call_spec.rb +7 -7
- data/spec/unit/axiom/function/unary/callable/call_spec.rb +4 -4
- data/spec/unit/axiom/function/unary/callable/included_spec.rb +1 -1
- data/spec/unit/axiom/function/unary/equality_operator_spec.rb +5 -5
- data/spec/unit/axiom/function/unary/hash_spec.rb +5 -5
- data/spec/unit/axiom/function/unary/invertible/class_methods/included_spec.rb +5 -5
- data/spec/unit/axiom/function/unary/invertible/inverse_spec.rb +2 -2
- data/spec/unit/axiom/function/unary/rename_spec.rb +7 -7
- data/spec/unit/axiom/function/unary/type_spec.rb +26 -0
- data/spec/unit/axiom/operation/binary/eql_spec.rb +4 -4
- data/spec/unit/axiom/operation/binary/hash_spec.rb +2 -2
- data/spec/unit/axiom/operation/binary/left_spec.rb +2 -2
- data/spec/unit/axiom/operation/binary/right_spec.rb +2 -2
- data/spec/unit/axiom/operation/unary/eql_spec.rb +2 -2
- data/spec/unit/axiom/operation/unary/hash_spec.rb +1 -1
- data/spec/unit/axiom/operation/unary/operand_spec.rb +2 -2
- data/spec/unit/axiom/relation/base/class_methods/new_spec.rb +20 -8
- data/spec/unit/axiom/relation/base/eql_spec.rb +12 -12
- data/spec/unit/axiom/relation/base/hash_spec.rb +4 -4
- data/spec/unit/axiom/relation/base/name_spec.rb +5 -34
- data/spec/unit/axiom/relation/class_methods/coerce_spec.rb +11 -5
- data/spec/unit/axiom/relation/class_methods/new_spec.rb +15 -7
- data/spec/unit/axiom/relation/directions_spec.rb +2 -2
- data/spec/unit/axiom/relation/each_spec.rb +10 -10
- data/spec/unit/axiom/relation/element_reader_spec.rb +4 -4
- data/spec/unit/axiom/relation/empty/class_methods/new_spec.rb +6 -20
- data/spec/unit/axiom/relation/empty/each_spec.rb +7 -22
- data/spec/unit/axiom/relation/empty/empty_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty/header_spec.rb +3 -3
- data/spec/unit/axiom/relation/empty/size_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty_predicate_spec.rb +2 -2
- data/spec/unit/axiom/relation/eql_spec.rb +10 -10
- data/spec/unit/axiom/relation/equality_operator_spec.rb +24 -14
- data/spec/unit/axiom/relation/hash_spec.rb +3 -3
- data/spec/unit/axiom/relation/header/call_spec.rb +5 -5
- data/spec/unit/axiom/relation/header/class_methods/coerce_spec.rb +13 -13
- data/spec/unit/axiom/relation/header/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/header/context_spec.rb +27 -0
- data/spec/unit/axiom/relation/header/difference_spec.rb +19 -19
- data/spec/unit/axiom/relation/header/each_spec.rb +6 -6
- data/spec/unit/axiom/relation/header/empty_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/eql_spec.rb +6 -6
- data/spec/unit/axiom/relation/header/equality_operator_spec.rb +8 -8
- data/spec/unit/axiom/relation/header/extend_spec.rb +9 -9
- data/spec/unit/axiom/relation/header/hash_spec.rb +3 -3
- data/spec/unit/axiom/relation/header/intersect_spec.rb +19 -19
- data/spec/unit/axiom/relation/header/keys_spec.rb +5 -5
- data/spec/unit/axiom/relation/header/project_spec.rb +11 -11
- data/spec/unit/axiom/relation/header/rename_spec.rb +6 -6
- data/spec/unit/axiom/relation/header/to_ary_spec.rb +3 -3
- data/spec/unit/axiom/relation/header/union_spec.rb +20 -20
- data/spec/unit/axiom/relation/header_spec.rb +2 -2
- data/spec/unit/axiom/relation/include_predicate_spec.rb +4 -4
- data/spec/unit/axiom/relation/keys/class_methods/coerce_spec.rb +4 -4
- data/spec/unit/axiom/relation/keys/class_methods/new_spec.rb +5 -5
- data/spec/unit/axiom/relation/keys/difference_spec.rb +7 -7
- data/spec/unit/axiom/relation/keys/each_spec.rb +6 -6
- data/spec/unit/axiom/relation/keys/empty_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/keys/extend_spec.rb +7 -7
- data/spec/unit/axiom/relation/keys/intersect_spec.rb +6 -6
- data/spec/unit/axiom/relation/keys/project_spec.rb +8 -8
- data/spec/unit/axiom/relation/keys/rename_spec.rb +5 -5
- data/spec/unit/axiom/relation/keys/to_ary_spec.rb +3 -3
- data/spec/unit/axiom/relation/keys/union_spec.rb +8 -8
- data/spec/unit/axiom/relation/materialize_spec.rb +3 -3
- data/spec/unit/axiom/relation/materialized/class_methods/new_spec.rb +19 -7
- data/spec/unit/axiom/relation/materialized/directions_spec.rb +4 -4
- data/spec/unit/axiom/relation/materialized/empty_predicate_spec.rb +2 -2
- data/spec/unit/axiom/relation/materialized/materialize_spec.rb +2 -2
- data/spec/unit/axiom/relation/materialized/materialized_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized/size_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 +5 -5
- data/spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/binary/header_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/combination/class_methods/combine_tuples_spec.rb +18 -11
- data/spec/unit/axiom/relation/operation/combination/header_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/deletion/initialize_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/deletion/methods/delete_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/insertion/initialize_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/insertion/methods/insert_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/limit/class_methods/new_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/limit/delete_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/directions_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/each_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/limit/eql_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/limit/hash_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/insert_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/limit_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/methods/first_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/limit/methods/last_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/limit/methods/one_spec.rb +63 -0
- data/spec/unit/axiom/relation/operation/limit/methods/take_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/class_methods/new_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/offset/delete_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/directions_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/each_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/offset/eql_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/offset/hash_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/insert_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/methods/drop_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/offset_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/order/ascending/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/ascending/reverse_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/class_methods/new_spec.rb +117 -15
- data/spec/unit/axiom/relation/operation/order/delete_spec.rb +11 -11
- data/spec/unit/axiom/relation/operation/order/descending/class_methods/reverse_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/descending/reverse_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/direction/attribute_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/direction/call_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/order/direction/class_methods/coerce_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/order/direction/eql_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/direction/name_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/direction/rename_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/order/direction/reverse_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/order/direction_set/attributes_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/order/direction_set/class_methods/coerce_spec.rb +11 -11
- data/spec/unit/axiom/relation/operation/order/direction_set/class_methods/new_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/order/direction_set/eql_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/order/direction_set/equality_operator_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/order/direction_set/hash_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/direction_set/project_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/order/direction_set/rename_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/order/direction_set/reverse_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/order/direction_set/sort_tuples_spec.rb +12 -12
- data/spec/unit/axiom/relation/operation/order/direction_set/to_ary_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/order/directions_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/order/each_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/order/eql_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/order/hash_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/order/header_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/order/insert_spec.rb +11 -11
- data/spec/unit/axiom/relation/operation/order/methods/sort_by_spec.rb +127 -20
- data/spec/unit/axiom/relation/operation/order/methods/sort_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/reverse/class_methods/new_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/reverse/directions_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/reverse/each_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/reverse/methods/reverse_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/set/class_methods/included_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/set/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/set/header_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/unary/header_spec.rb +5 -5
- data/spec/unit/axiom/relation/proxy/each_spec.rb +8 -8
- data/spec/unit/axiom/relation/proxy/hash_spec.rb +4 -4
- data/spec/unit/axiom/relation/proxy/method_missing_spec.rb +4 -4
- data/spec/unit/axiom/relation/proxy/respond_to_predicate_spec.rb +4 -4
- data/spec/unit/axiom/relation/replace_spec.rb +6 -6
- data/spec/unit/axiom/relation/variable/class_methods/new_spec.rb +35 -0
- data/spec/unit/axiom/relation/variable/delete_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/insert_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/materialized/delete_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/materialized/insert_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/materialized/replace_spec.rb +18 -0
- data/spec/unit/axiom/relation/variable/replace_spec.rb +18 -0
- data/spec/unit/axiom/tuple/call_spec.rb +3 -4
- data/spec/unit/axiom/tuple/class_methods/coerce_spec.rb +6 -6
- data/spec/unit/axiom/tuple/data_spec.rb +2 -2
- data/spec/unit/axiom/tuple/eql_spec.rb +5 -5
- data/spec/unit/axiom/tuple/equality_operator_spec.rb +6 -6
- data/spec/unit/axiom/tuple/extend_spec.rb +12 -12
- data/spec/unit/axiom/tuple/hash_spec.rb +3 -3
- data/spec/unit/axiom/tuple/header_spec.rb +3 -3
- data/spec/unit/axiom/tuple/join_spec.rb +6 -6
- data/spec/unit/axiom/tuple/predicate_spec.rb +5 -5
- data/spec/unit/axiom/tuple/project_spec.rb +5 -5
- data/spec/unit/axiom/tuple/to_ary_spec.rb +3 -3
- data/spec/unit/axiom/visitable/accept_spec.rb +1 -1
- data/spec/unit/range/to_inclusive_spec.rb +1 -1
- data/spec/unit/time/pred_spec.rb +1 -1
- metadata +92 -614
- checksums.yaml +0 -7
- data/.rvmrc +0 -1
- data/lib/axiom/function/numeric/binary.rb +0 -26
- data/lib/axiom/function/numeric/unary.rb +0 -26
- data/spec/support/ice_nine_config.rb +0 -6
- data/spec/unit/axiom/aggregate/count/type_spec.rb +0 -12
- data/spec/unit/axiom/aggregate/mean/type_spec.rb +0 -12
- data/spec/unit/axiom/aggregate/standard_deviation/type_spec.rb +0 -12
- data/spec/unit/axiom/aggregate/type_spec.rb +0 -13
- data/spec/unit/axiom/aggregate/variance/type_spec.rb +0 -12
- data/spec/unit/axiom/attribute/boolean/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/date/range_spec.rb +0 -11
- data/spec/unit/axiom/attribute/date_time/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/date_time/range_spec.rb +0 -11
- data/spec/unit/axiom/attribute/decimal/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/float/size_spec.rb +0 -21
- data/spec/unit/axiom/attribute/integer/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/numeric/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/numeric/size_spec.rb +0 -33
- data/spec/unit/axiom/attribute/object/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/string/class_methods/primitive_spec.rb +0 -13
- data/spec/unit/axiom/attribute/string/max_length_spec.rb +0 -20
- data/spec/unit/axiom/attribute/string/min_length_spec.rb +0 -20
- data/spec/unit/axiom/attribute/time/range_spec.rb +0 -11
- data/spec/unit/axiom/attribute/valid_primitive_predicate_spec.rb +0 -30
- data/spec/unit/axiom/function/connective/type_spec.rb +0 -12
- data/spec/unit/axiom/function/numeric/binary/type_spec.rb +0 -33
- data/spec/unit/axiom/function/numeric/unary/type_spec.rb +0 -21
- data/spec/unit/axiom/function/predicate/type_spec.rb +0 -14
- data/spec/unit/axiom/function/proposition/type_spec.rb +0 -12
- data/spec/unit/axiom/function/string/length/type_spec.rb +0 -11
- data/spec/unit/axiom/relation/one_spec.rb +0 -36
@@ -5,10 +5,10 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Order, '#each' do
|
6
6
|
subject { object.each { |tuple| yields << tuple } }
|
7
7
|
|
8
|
-
let(:object) { described_class.new(relation, directions)
|
9
|
-
let(:relation) { Relation.new([
|
10
|
-
let(:directions) { [
|
11
|
-
let(:yields) { []
|
8
|
+
let(:object) { described_class.new(relation, directions) }
|
9
|
+
let(:relation) { Relation.new([[:id, Integer]], [[1], [2], [3]]) }
|
10
|
+
let(:directions) { [relation[:id].desc] }
|
11
|
+
let(:yields) { [] }
|
12
12
|
|
13
13
|
it_should_behave_like 'an #each method'
|
14
14
|
|
@@ -23,8 +23,8 @@ describe Relation::Operation::Order, '#each' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'yields only tuples with the expected data in order' do
|
26
|
-
expect { subject }.to change { yields.dup }
|
27
|
-
from([])
|
28
|
-
to([
|
26
|
+
expect { subject }.to change { yields.dup }
|
27
|
+
.from([])
|
28
|
+
.to([[3], [2], [1]])
|
29
29
|
end
|
30
30
|
end
|
@@ -5,9 +5,9 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Order, '#eql?' do
|
6
6
|
subject { object.eql?(other) }
|
7
7
|
|
8
|
-
let(:operand) { Relation.new([
|
9
|
-
let(:directions) { operand.header
|
10
|
-
let(:object) { described_class.new(operand, directions)
|
8
|
+
let(:operand) { Relation.new([[:id, Integer]], [[1], [2]]) }
|
9
|
+
let(:directions) { operand.header }
|
10
|
+
let(:object) { described_class.new(operand, directions) }
|
11
11
|
|
12
12
|
context 'with the same object' do
|
13
13
|
let(:other) { object }
|
@@ -40,7 +40,7 @@ describe Relation::Operation::Order, '#eql?' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with an object having a different operand' do
|
43
|
-
let(:other_operand) { Relation.new([
|
43
|
+
let(:other_operand) { Relation.new([[:id, Integer]], [[1]]) }
|
44
44
|
let(:other_directions) { directions }
|
45
45
|
let(:other) { described_class.new(other_operand, other_directions) }
|
46
46
|
|
@@ -53,7 +53,7 @@ describe Relation::Operation::Order, '#eql?' do
|
|
53
53
|
|
54
54
|
context 'with an object having different directions' do
|
55
55
|
let(:other_operand) { operand }
|
56
|
-
let(:other_directions) { [
|
56
|
+
let(:other_directions) { [operand[:id].desc] }
|
57
57
|
let(:other) { described_class.new(other_operand, other_directions) }
|
58
58
|
|
59
59
|
it { should be(false) }
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Order, '#hash' do
|
6
6
|
subject { object.hash }
|
7
7
|
|
8
|
-
let(:operand) { Relation.new([
|
8
|
+
let(:operand) { Relation.new([[:id, Integer]], [[1], [2]]) }
|
9
9
|
let(:directions) { described_class::DirectionSet.coerce(operand.header) }
|
10
10
|
let(:object) { described_class.new(operand, directions) }
|
11
11
|
|
@@ -5,11 +5,11 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Order, '#header' do
|
6
6
|
subject { object.header }
|
7
7
|
|
8
|
-
let(:header) { Relation::Header.coerce([
|
9
|
-
let(:relation) { Relation.new(header, [
|
10
|
-
let(:object) { described_class.new(relation, header)
|
8
|
+
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
9
|
+
let(:relation) { Relation.new(header, [[1], [2]]) }
|
10
|
+
let(:object) { described_class.new(relation, header) }
|
11
11
|
|
12
12
|
it_should_behave_like 'an idempotent method'
|
13
13
|
|
14
|
-
it { should
|
14
|
+
it { should be(header) }
|
15
15
|
end
|
@@ -5,14 +5,14 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Order, '#insert' do
|
6
6
|
subject { object.insert(other) }
|
7
7
|
|
8
|
-
let(:object) { described_class.new(relation, directions)
|
9
|
-
let(:relation) { Relation.new([
|
10
|
-
let(:attribute) { Attribute::Integer.new(:id)
|
11
|
-
let(:directions) { [
|
8
|
+
let(:object) { described_class.new(relation, directions) }
|
9
|
+
let(:relation) { Relation.new([attribute], LazyEnumerable.new([[1]])) }
|
10
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
11
|
+
let(:directions) { [attribute.desc] }
|
12
12
|
|
13
13
|
context 'when other relation has matching directions' do
|
14
|
-
let(:other) { other_base.sort_by(directions)
|
15
|
-
let(:other_base) { Relation.new([
|
14
|
+
let(:other) { other_base.sort_by(directions) }
|
15
|
+
let(:other_base) { Relation.new([attribute], LazyEnumerable.new([[2]])) }
|
16
16
|
|
17
17
|
it { should be_instance_of(described_class) }
|
18
18
|
|
@@ -20,25 +20,25 @@ 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.should
|
24
|
-
subject.right.should
|
23
|
+
subject.left.should be(relation)
|
24
|
+
subject.right.should be(other_base)
|
25
25
|
end
|
26
26
|
|
27
27
|
its(:directions) { should == directions }
|
28
28
|
|
29
29
|
it 'inserts the tuples' do
|
30
|
-
should == [
|
30
|
+
should == [[2], [1]]
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when other relation does not have the same directions' do
|
35
|
-
let(:other) { Relation.new([
|
35
|
+
let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])).sort_by([attribute]) }
|
36
36
|
|
37
37
|
specify { expect { subject }.to raise_error(OrderMismatchError, 'other relation must have matching directions to be inserted') }
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when other relation is not an order' do
|
41
|
-
let(:other) { Relation.new([
|
41
|
+
let(:other) { Relation.new([attribute], LazyEnumerable.new([[2]])) }
|
42
42
|
|
43
43
|
specify { expect { subject }.to raise_error(OrderMismatchError, 'other relation must have matching directions to be inserted') }
|
44
44
|
end
|
@@ -3,40 +3,147 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Relation::Operation::Order::Methods, '#sort_by' do
|
6
|
-
let(:
|
7
|
-
let(:
|
6
|
+
let(:object) { Relation.new(header, LazyEnumerable.new([[1], [2]])) }
|
7
|
+
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
8
|
+
let(:directions) { Relation::Operation::Order::DirectionSet.coerce(header) }
|
8
9
|
|
9
|
-
context 'with
|
10
|
-
|
10
|
+
context 'with a block' do
|
11
|
+
context 'returning an array of attribute names' do
|
12
|
+
subject { object.sort_by(&block) }
|
11
13
|
|
12
|
-
|
13
|
-
end
|
14
|
+
let(:block) { ->(relation) { [relation[:id].name] } }
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
17
|
+
|
18
|
+
its(:directions) { should eql(directions) }
|
19
|
+
|
20
|
+
it 'behaves the same as Array#sort_by' do
|
21
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'returning an array of attributes' do
|
26
|
+
subject { object.sort_by(&block) }
|
27
|
+
|
28
|
+
let(:block) { ->(relation) { [relation[:id]] } }
|
29
|
+
|
30
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
31
|
+
|
32
|
+
its(:directions) { should eql(directions) }
|
33
|
+
|
34
|
+
it 'behaves the same as Array#sort_by' do
|
35
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
36
|
+
end
|
37
|
+
end
|
17
38
|
|
18
|
-
|
39
|
+
context 'returning an array of directions' do
|
40
|
+
subject { object.sort_by(&block) }
|
19
41
|
|
20
|
-
|
42
|
+
let(:block) { ->(relation) { [relation[:id].desc] } }
|
21
43
|
|
22
|
-
|
44
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
23
45
|
|
24
|
-
|
25
|
-
|
46
|
+
its(:directions) { should eql(directions.reverse) }
|
47
|
+
|
48
|
+
it 'behaves the same as Array#sort_by' do
|
49
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'returning a header' do
|
54
|
+
subject { object.sort_by(&block) }
|
55
|
+
|
56
|
+
let(:block) { ->(relation) { header } }
|
57
|
+
|
58
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
59
|
+
|
60
|
+
its(:directions) { should eql(directions) }
|
61
|
+
|
62
|
+
it 'behaves the same as Array#sort_by' do
|
63
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'returning a direction set' do
|
68
|
+
subject { object.sort_by(&block) }
|
69
|
+
|
70
|
+
let(:block) { ->(relation) { directions } }
|
71
|
+
|
72
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
73
|
+
|
74
|
+
its(:directions) { should eql(directions) }
|
75
|
+
|
76
|
+
it 'behaves the same as Array#sort_by' do
|
77
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
78
|
+
end
|
26
79
|
end
|
27
80
|
end
|
28
81
|
|
29
|
-
context '
|
30
|
-
|
82
|
+
context 'without a block' do
|
83
|
+
context 'with an array of attribute names' do
|
84
|
+
subject { object.sort_by([header[:id].name]) }
|
85
|
+
|
86
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
87
|
+
|
88
|
+
its(:directions) { should eql(directions) }
|
89
|
+
|
90
|
+
it 'behaves the same as Array#sort_by' do
|
91
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'with an array of attributes' do
|
96
|
+
subject { object.sort_by([header[:id]]) }
|
97
|
+
|
98
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
99
|
+
|
100
|
+
its(:directions) { should eql(directions) }
|
101
|
+
|
102
|
+
it 'behaves the same as Array#sort_by' do
|
103
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'with an array of directions' do
|
108
|
+
subject { object.sort_by([header[:id].desc]) }
|
109
|
+
|
110
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
31
111
|
|
32
|
-
|
112
|
+
its(:directions) { should eql(directions.reverse) }
|
33
113
|
|
34
|
-
|
114
|
+
it 'behaves the same as Array#sort_by' do
|
115
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] }.reverse)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'with a header' do
|
120
|
+
subject { object.sort_by(header) }
|
121
|
+
|
122
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
123
|
+
|
124
|
+
its(:directions) { should eql(directions) }
|
125
|
+
|
126
|
+
it 'behaves the same as Array#sort_by' do
|
127
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with a direction set' do
|
132
|
+
subject { object.sort_by(directions) }
|
133
|
+
|
134
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
135
|
+
|
136
|
+
its(:directions) { should eql(directions) }
|
137
|
+
|
138
|
+
it 'behaves the same as Array#sort_by' do
|
139
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
140
|
+
end
|
141
|
+
end
|
35
142
|
|
36
|
-
|
143
|
+
context 'with no arguments' do
|
144
|
+
subject { object.sort_by }
|
37
145
|
|
38
|
-
|
39
|
-
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
146
|
+
specify { expect { subject }.to raise_error }
|
40
147
|
end
|
41
148
|
end
|
42
149
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Relation::Operation::Order::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::Order::DirectionSet.coerce(header) }
|
11
|
+
|
12
|
+
it { should be_instance_of(Relation::Operation::Order) }
|
13
|
+
|
14
|
+
its(:directions) { should eql(directions) }
|
15
|
+
|
16
|
+
it 'behaves the same as Array#sort_by' do
|
17
|
+
subject.to_a.should eql(object.to_a.sort_by { |tuple| tuple[:id] })
|
18
|
+
end
|
19
|
+
end
|
@@ -5,8 +5,8 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Reverse, '.new' do
|
6
6
|
subject { object.new(relation) }
|
7
7
|
|
8
|
-
let(:original_relation) { Relation.new([
|
9
|
-
let(:object) { described_class
|
8
|
+
let(:original_relation) { Relation.new([[:id, Integer]], [[1], [2]]) }
|
9
|
+
let(:object) { described_class }
|
10
10
|
|
11
11
|
context 'with an ordered relation' do
|
12
12
|
let(:relation) { original_relation.sort_by { |r| r.id } }
|
@@ -5,13 +5,13 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Reverse, '#directions' do
|
6
6
|
subject { object.directions }
|
7
7
|
|
8
|
-
let(:relation) { Relation.new([
|
9
|
-
let(:object) { described_class.new(ordered)
|
10
|
-
let(:ordered) { relation.sort_by { |r| r.id }
|
8
|
+
let(:relation) { Relation.new([[:id, Integer]], LazyEnumerable.new) }
|
9
|
+
let(:object) { described_class.new(ordered) }
|
10
|
+
let(:ordered) { relation.sort_by { |r| r.id } }
|
11
11
|
|
12
12
|
it_should_behave_like 'an idempotent method'
|
13
13
|
|
14
14
|
it 'reverses the directions' do
|
15
|
-
should
|
15
|
+
should eql(ordered.directions.reverse)
|
16
16
|
end
|
17
17
|
end
|
@@ -5,10 +5,10 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Reverse, '#each' do
|
6
6
|
subject { object.each { |tuple| yields << tuple } }
|
7
7
|
|
8
|
-
let(:object) { described_class.new(order)
|
9
|
-
let(:relation) { Relation.new([
|
10
|
-
let(:order) { relation.sort_by { |r| r.id }
|
11
|
-
let(:yields) { []
|
8
|
+
let(:object) { described_class.new(order) }
|
9
|
+
let(:relation) { Relation.new([[:id, Integer]], [[1], [2], [3]]) }
|
10
|
+
let(:order) { relation.sort_by { |r| r.id } }
|
11
|
+
let(:yields) { [] }
|
12
12
|
|
13
13
|
it_should_behave_like 'an #each method'
|
14
14
|
|
@@ -23,8 +23,8 @@ describe Relation::Operation::Reverse, '#each' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'yields only tuples with the expected data in reverse order' do
|
26
|
-
expect { subject }.to change { yields.dup }
|
27
|
-
from([])
|
28
|
-
to([
|
26
|
+
expect { subject }.to change { yields.dup }
|
27
|
+
.from([])
|
28
|
+
.to([[3], [2], [1]])
|
29
29
|
end
|
30
30
|
end
|
@@ -5,9 +5,9 @@ require 'spec_helper'
|
|
5
5
|
describe Relation::Operation::Reverse::Methods, '#reverse' do
|
6
6
|
subject { object.reverse }
|
7
7
|
|
8
|
-
let(:described_class) { Relation
|
9
|
-
let(:relation) { described_class.new([
|
10
|
-
let(:object) { relation.sort_by { |r| r.id }
|
8
|
+
let(:described_class) { Relation }
|
9
|
+
let(:relation) { described_class.new([[:id, Integer]], LazyEnumerable.new([[1], [2]])) }
|
10
|
+
let(:object) { relation.sort_by { |r| r.id } }
|
11
11
|
|
12
12
|
it { should be_instance_of(Relation::Operation::Reverse) }
|
13
13
|
|
@@ -16,11 +16,11 @@ describe Relation::Operation::Set, '.included' do
|
|
16
16
|
|
17
17
|
it 'delegates to the ancestor' do
|
18
18
|
included_ancestor = false
|
19
|
-
|
19
|
+
mod = Module.new do
|
20
20
|
define_method(:included) { |_| included_ancestor = true }
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
end
|
22
|
+
subject.extend(mod)
|
23
|
+
expect { klass.send(:include, subject) }
|
24
|
+
.to change { included_ancestor }.from(false).to(true)
|
25
25
|
end
|
26
26
|
end
|
@@ -6,24 +6,24 @@ require File.expand_path('../../fixtures/classes', __FILE__)
|
|
6
6
|
describe Relation::Operation::Set::ClassMethods, '#new' do
|
7
7
|
subject { object.new(left, right) }
|
8
8
|
|
9
|
-
let(:header) { [
|
10
|
-
let(:left) { Relation.new(header, [
|
11
|
-
let(:object) { SetOperationSpecs::Object
|
9
|
+
let(:header) { [[:id, Integer]] }
|
10
|
+
let(:left) { Relation.new(header, [[1]]) }
|
11
|
+
let(:object) { SetOperationSpecs::Object }
|
12
12
|
|
13
13
|
context 'with relations having equivalent headers' do
|
14
|
-
let(:right) { Relation.new(header, [
|
14
|
+
let(:right) { Relation.new(header, [[2]]) }
|
15
15
|
|
16
16
|
it { should be_instance_of(object) }
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'with relations having headers with common attributes' do
|
20
|
-
let(:right) { Relation.new([
|
20
|
+
let(:right) { Relation.new([[:id, Integer], [:name, String]], [[2, 'Dan Kubb']]) }
|
21
21
|
|
22
22
|
specify { expect { subject }.to raise_error(InvalidHeaderError, 'the headers must be equivalent') }
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'with relations having different headers' do
|
26
|
-
let(:right) { Relation.new([
|
26
|
+
let(:right) { Relation.new([[:number, Integer]], [[2]]) }
|
27
27
|
|
28
28
|
specify { expect { subject }.to raise_error(InvalidHeaderError, 'the headers must be equivalent') }
|
29
29
|
end
|
@@ -6,12 +6,12 @@ require File.expand_path('../fixtures/classes', __FILE__)
|
|
6
6
|
describe Relation::Operation::Set, '#header' do
|
7
7
|
subject { object.header }
|
8
8
|
|
9
|
-
let(:described_class) { SetOperationSpecs::Object
|
10
|
-
let(:left) { Relation.new([
|
11
|
-
let(:right) { Relation.new([
|
12
|
-
let(:object) { described_class.new(left, right)
|
9
|
+
let(:described_class) { SetOperationSpecs::Object }
|
10
|
+
let(:left) { Relation.new([[:id, Integer]], [[1]]) }
|
11
|
+
let(:right) { Relation.new([[:id, Integer]], [[1]]) }
|
12
|
+
let(:object) { described_class.new(left, right) }
|
13
13
|
|
14
14
|
it_should_behave_like 'an idempotent method'
|
15
15
|
|
16
|
-
it { should
|
16
|
+
it { should be(left.header) }
|
17
17
|
end
|