axiom 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -1
  3. data/.rubocop.yml +7 -0
  4. data/.travis.yml +10 -7
  5. data/Gemfile +4 -0
  6. data/Gemfile.devtools +27 -13
  7. data/Guardfile +2 -2
  8. data/README.md +36 -30
  9. data/TODO +22 -24
  10. data/axiom.gemspec +9 -9
  11. data/benchmarks/memory.rb +1 -2
  12. data/benchmarks/speed.rb +7 -8
  13. data/config/flay.yml +1 -1
  14. data/config/reek.yml +19 -7
  15. data/config/rubocop.yml +6 -9
  16. data/lib/axiom.rb +28 -13
  17. data/lib/axiom/aggregate/mean.rb +4 -3
  18. data/lib/axiom/aggregate/sum.rb +1 -1
  19. data/lib/axiom/algebra/extension.rb +1 -1
  20. data/lib/axiom/algebra/join.rb +4 -27
  21. data/lib/axiom/algebra/product.rb +3 -3
  22. data/lib/axiom/algebra/projection.rb +2 -2
  23. data/lib/axiom/algebra/rename.rb +2 -2
  24. data/lib/axiom/algebra/rename/aliases.rb +3 -3
  25. data/lib/axiom/algebra/summarization.rb +3 -3
  26. data/lib/axiom/attribute.rb +5 -4
  27. data/lib/axiom/attribute/comparable.rb +15 -11
  28. data/lib/axiom/attribute/date.rb +1 -1
  29. data/lib/axiom/attribute/date_time.rb +1 -1
  30. data/lib/axiom/attribute/length_comparable.rb +39 -0
  31. data/lib/axiom/attribute/numeric.rb +1 -26
  32. data/lib/axiom/attribute/relation.rb +64 -0
  33. data/lib/axiom/attribute/string.rb +1 -28
  34. data/lib/axiom/attribute/time.rb +1 -1
  35. data/lib/axiom/attribute/tuple.rb +50 -0
  36. data/lib/axiom/attribute/value_comparable.rb +42 -0
  37. data/lib/axiom/function.rb +1 -1
  38. data/lib/axiom/function/binary.rb +4 -16
  39. data/lib/axiom/function/comparable.rb +1 -1
  40. data/lib/axiom/function/connective/conjunction.rb +1 -1
  41. data/lib/axiom/function/connective/disjunction.rb +1 -1
  42. data/lib/axiom/function/connective/negation.rb +1 -1
  43. data/lib/axiom/function/numeric/exponentiation.rb +1 -1
  44. data/lib/axiom/function/numeric/square_root.rb +1 -1
  45. data/lib/axiom/function/predicate/enumerable.rb +0 -14
  46. data/lib/axiom/function/predicate/exclusion.rb +1 -1
  47. data/lib/axiom/function/predicate/inclusion.rb +1 -1
  48. data/lib/axiom/function/proposition.rb +12 -25
  49. data/lib/axiom/function/unary.rb +92 -106
  50. data/lib/axiom/relation.rb +3 -3
  51. data/lib/axiom/relation/base.rb +15 -0
  52. data/lib/axiom/relation/header.rb +25 -22
  53. data/lib/axiom/relation/index.rb +91 -0
  54. data/lib/axiom/relation/keys.rb +3 -3
  55. data/lib/axiom/relation/materialized.rb +48 -4
  56. data/lib/axiom/relation/operation/binary.rb +5 -5
  57. data/lib/axiom/relation/operation/group.rb +95 -0
  58. data/lib/axiom/relation/operation/limit.rb +15 -15
  59. data/lib/axiom/relation/operation/offset.rb +12 -12
  60. data/lib/axiom/relation/operation/reverse.rb +9 -9
  61. data/lib/axiom/relation/operation/set.rb +1 -1
  62. data/lib/axiom/relation/operation/{order.rb → sorted.rb} +29 -28
  63. data/lib/axiom/relation/operation/{order → sorted}/direction.rb +4 -4
  64. data/lib/axiom/relation/operation/{order → sorted}/direction_set.rb +3 -3
  65. data/lib/axiom/relation/operation/ungroup.rb +82 -0
  66. data/lib/axiom/relation/operation/unwrap.rb +80 -0
  67. data/lib/axiom/relation/operation/wrap.rb +85 -0
  68. data/lib/axiom/relation/proxy.rb +5 -6
  69. data/lib/axiom/relation/variable.rb +1 -2
  70. data/lib/axiom/support/aliasable.rb +3 -5
  71. data/lib/axiom/support/equalizer.rb +10 -12
  72. data/lib/axiom/support/operation/binary.rb +3 -2
  73. data/lib/axiom/support/operation/unary.rb +1 -1
  74. data/lib/axiom/tuple.rb +76 -26
  75. data/lib/axiom/types/relation.rb +13 -0
  76. data/lib/axiom/types/tuple.rb +13 -0
  77. data/lib/axiom/version.rb +1 -1
  78. data/spec/integration/axiom/relation/efficient_enumerable_spec.rb +9 -9
  79. data/spec/integration/axiom/relation/writable_relations_spec.rb +12 -12
  80. data/spec/shared/invertible_method_behaviour.rb +1 -1
  81. data/spec/spec_helper.rb +8 -6
  82. data/spec/unit/axiom/aggregate/call_spec.rb +7 -12
  83. data/spec/unit/axiom/aggregate/class_methods/default_spec.rb +7 -2
  84. data/spec/unit/axiom/aggregate/default_spec.rb +1 -1
  85. data/spec/unit/axiom/aggregate/finalize_spec.rb +1 -1
  86. data/spec/unit/axiom/aggregate/maximum/type_spec.rb +2 -6
  87. data/spec/unit/axiom/aggregate/mean/class_methods/call_spec.rb +2 -2
  88. data/spec/unit/axiom/aggregate/mean/class_methods/finalize_spec.rb +10 -3
  89. data/spec/unit/axiom/aggregate/minimum/type_spec.rb +2 -6
  90. data/spec/unit/axiom/aggregate/sum/default_spec.rb +32 -6
  91. data/spec/unit/axiom/aggregate/sum/type_spec.rb +2 -6
  92. data/spec/unit/axiom/aggregate/variance/class_methods/call_spec.rb +6 -6
  93. data/spec/unit/axiom/algebra/difference/each_spec.rb +3 -3
  94. data/spec/unit/axiom/algebra/extension/class_methods/new_spec.rb +1 -1
  95. data/spec/unit/axiom/algebra/extension/each_spec.rb +2 -2
  96. data/spec/unit/axiom/algebra/intersection/each_spec.rb +3 -3
  97. data/spec/unit/axiom/algebra/join/each_spec.rb +6 -6
  98. data/spec/unit/axiom/algebra/product/each_spec.rb +2 -2
  99. data/spec/unit/axiom/algebra/projection/each_spec.rb +2 -2
  100. data/spec/unit/axiom/algebra/rename/directions_spec.rb +3 -3
  101. data/spec/unit/axiom/algebra/rename/each_spec.rb +2 -2
  102. data/spec/unit/axiom/algebra/restriction/delete_spec.rb +3 -3
  103. data/spec/unit/axiom/algebra/restriction/each_spec.rb +12 -11
  104. data/spec/unit/axiom/algebra/restriction/insert_spec.rb +3 -3
  105. data/spec/unit/axiom/algebra/restriction/methods/restrict_spec.rb +4 -4
  106. data/spec/unit/axiom/algebra/summarization/each_spec.rb +2 -2
  107. data/spec/unit/axiom/algebra/summarization/eql_spec.rb +1 -1
  108. data/spec/unit/axiom/algebra/summarization/summaries/summarize_by_spec.rb +4 -4
  109. data/spec/unit/axiom/algebra/summarization/summaries/to_hash_spec.rb +2 -2
  110. data/spec/unit/axiom/algebra/summarization/summary/summarize_by_spec.rb +1 -1
  111. data/spec/unit/axiom/algebra/union/each_spec.rb +4 -4
  112. data/spec/unit/axiom/aliasable/fixtures/classes.rb +3 -1
  113. data/spec/unit/axiom/aliasable/inheritable_alias_spec.rb +18 -27
  114. data/spec/unit/axiom/attribute/call_spec.rb +1 -1
  115. data/spec/unit/axiom/attribute/class_methods/coerce_spec.rb +57 -51
  116. data/spec/unit/axiom/attribute/class_methods/new_spec.rb +1 -1
  117. data/spec/unit/axiom/attribute/comparable/asc_spec.rb +4 -2
  118. data/spec/unit/axiom/attribute/comparable/desc_spec.rb +4 -2
  119. data/spec/unit/axiom/attribute/comparable/range_spec.rb +20 -0
  120. data/spec/unit/axiom/attribute/eql_spec.rb +1 -1
  121. data/spec/unit/axiom/attribute/equality_operator_spec.rb +1 -1
  122. data/spec/unit/axiom/attribute/include_predicate_spec.rb +1 -1
  123. data/spec/unit/axiom/attribute/name_spec.rb +1 -1
  124. data/spec/unit/axiom/attribute/optional_predicate_spec.rb +1 -1
  125. data/spec/unit/axiom/attribute/relation/class_methods/new_spec.rb +56 -0
  126. data/spec/unit/axiom/attribute/relation/class_methods/type_spec.rb +13 -0
  127. data/spec/unit/axiom/attribute/relation/header_spec.rb +13 -0
  128. data/spec/unit/axiom/attribute/relation/new_relation_spec.rb +15 -0
  129. data/spec/unit/axiom/attribute/rename_spec.rb +1 -1
  130. data/spec/unit/axiom/attribute/required_predicate_spec.rb +1 -1
  131. data/spec/unit/axiom/attribute/tuple/class_methods/new_spec.rb +56 -0
  132. data/spec/unit/axiom/attribute/tuple/class_methods/type_spec.rb +13 -0
  133. data/spec/unit/axiom/attribute/tuple/header_spec.rb +13 -0
  134. data/spec/unit/axiom/equalizer/class_method/new_spec.rb +24 -54
  135. data/spec/unit/axiom/evaluator/context/add_spec.rb +7 -7
  136. data/spec/unit/axiom/evaluator/context/element_reader_spec.rb +4 -4
  137. data/spec/unit/axiom/evaluator/context/functions_spec.rb +1 -1
  138. data/spec/unit/axiom/evaluator/context/method_missing_spec.rb +3 -3
  139. data/spec/unit/axiom/evaluator/context/respond_to_predicate_spec.rb +3 -3
  140. data/spec/unit/axiom/evaluator/context/send_spec.rb +8 -8
  141. data/spec/unit/axiom/function/binary/call_spec.rb +1 -1
  142. data/spec/unit/axiom/function/binary/type_spec.rb +12 -10
  143. data/spec/unit/axiom/function/comparable/class_methods/included_spec.rb +2 -2
  144. data/spec/unit/axiom/function/connective/negation/inverse_spec.rb +1 -1
  145. data/spec/unit/axiom/function/predicate/call_spec.rb +5 -4
  146. data/spec/unit/axiom/function/predicate/enumerable/call_spec.rb +12 -2
  147. data/spec/unit/axiom/function/predicate/eql_spec.rb +4 -3
  148. data/spec/unit/axiom/function/predicate/equality/methods/eq_spec.rb +5 -1
  149. data/spec/unit/axiom/function/predicate/exclusion/class_methods/call_spec.rb +37 -8
  150. data/spec/unit/axiom/function/predicate/exclusion/methods/exclude_spec.rb +6 -2
  151. data/spec/unit/axiom/function/predicate/greater_than/methods/gt_spec.rb +5 -1
  152. data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/methods/gte_spec.rb +5 -1
  153. data/spec/unit/axiom/function/predicate/inclusion/class_methods/call_spec.rb +37 -8
  154. data/spec/unit/axiom/function/predicate/inclusion/methods/include_spec.rb +6 -2
  155. data/spec/unit/axiom/function/predicate/inequality/methods/ne_spec.rb +5 -1
  156. data/spec/unit/axiom/function/predicate/less_than/methods/lt_spec.rb +5 -1
  157. data/spec/unit/axiom/function/predicate/less_than_or_equal_to/methods/lte_spec.rb +5 -1
  158. data/spec/unit/axiom/function/predicate/match/methods/match_spec.rb +7 -3
  159. data/spec/unit/axiom/function/predicate/no_match/methods/no_match_spec.rb +6 -2
  160. data/spec/unit/axiom/function/proposition/call_spec.rb +6 -4
  161. data/spec/unit/axiom/function/proposition/class_methods/{new_spec.rb → coerce_spec.rb} +17 -17
  162. data/spec/unit/axiom/function/proposition/eql_spec.rb +4 -4
  163. data/spec/unit/axiom/function/proposition/equality_operator_spec.rb +3 -3
  164. data/spec/unit/axiom/function/proposition/inverse_spec.rb +4 -4
  165. data/spec/unit/axiom/function/proposition/rename_spec.rb +1 -1
  166. data/spec/unit/axiom/function/type_spec.rb +1 -1
  167. data/spec/unit/axiom/function/unary/call_spec.rb +1 -1
  168. data/spec/unit/axiom/function/unary/callable/call_spec.rb +3 -13
  169. data/spec/unit/axiom/function/unary/callable/included_spec.rb +2 -2
  170. data/spec/unit/axiom/function/unary/type_spec.rb +11 -1
  171. data/spec/unit/axiom/relation/base/eql_spec.rb +1 -1
  172. data/spec/unit/axiom/relation/base/equality_operator_spec.rb +138 -0
  173. data/spec/unit/axiom/relation/class_methods/new_spec.rb +7 -7
  174. data/spec/unit/axiom/relation/directions_spec.rb +2 -2
  175. data/spec/unit/axiom/relation/each_spec.rb +5 -5
  176. data/spec/unit/axiom/relation/element_reader_spec.rb +1 -1
  177. data/spec/unit/axiom/relation/empty/each_spec.rb +1 -1
  178. data/spec/unit/axiom/relation/empty_predicate_spec.rb +1 -1
  179. data/spec/unit/axiom/relation/eql_spec.rb +1 -1
  180. data/spec/unit/axiom/relation/equality_operator_spec.rb +1 -1
  181. data/spec/unit/axiom/relation/header/class_methods/coerce_spec.rb +2 -2
  182. data/spec/unit/axiom/relation/header/class_methods/new_spec.rb +3 -3
  183. data/spec/unit/axiom/relation/header/context_spec.rb +2 -2
  184. data/spec/unit/axiom/relation/header/each_spec.rb +2 -2
  185. data/spec/unit/axiom/relation/header/extend_spec.rb +1 -1
  186. data/spec/unit/axiom/relation/header/{call_spec.rb → fetch_spec.rb} +1 -1
  187. data/spec/unit/axiom/relation/header/project_spec.rb +1 -1
  188. data/spec/unit/axiom/relation/header/rename_spec.rb +19 -5
  189. data/spec/unit/axiom/relation/header/size_spec.rb +14 -0
  190. data/spec/unit/axiom/relation/header_spec.rb +1 -1
  191. data/spec/unit/axiom/relation/index/each_spec.rb +33 -0
  192. data/spec/unit/axiom/relation/index/element_reader_spec.rb +17 -0
  193. data/spec/unit/axiom/relation/index/left_shift_operator_spec.rb +23 -0
  194. data/spec/unit/axiom/relation/index/merge_spec.rb +19 -0
  195. data/spec/unit/axiom/relation/keys/class_methods/coerce_spec.rb +19 -2
  196. data/spec/unit/axiom/relation/keys/class_methods/new_spec.rb +1 -1
  197. data/spec/unit/axiom/relation/keys/each_spec.rb +2 -2
  198. data/spec/unit/axiom/relation/materialize_spec.rb +1 -1
  199. data/spec/unit/axiom/relation/materialized/class_methods/new_spec.rb +30 -4
  200. data/spec/unit/axiom/relation/materialized/directions_spec.rb +1 -1
  201. data/spec/unit/axiom/relation/materialized/materialized_predicate_spec.rb +1 -1
  202. data/spec/unit/axiom/relation/materialized_predicate_spec.rb +1 -1
  203. data/spec/unit/axiom/relation/operation/binary/class_methods/included_spec.rb +2 -2
  204. data/spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb +6 -6
  205. data/spec/unit/axiom/relation/operation/combination/class_methods/combine_tuples_spec.rb +4 -4
  206. data/spec/unit/axiom/relation/operation/group/each_spec.rb +33 -0
  207. data/spec/unit/axiom/relation/operation/group/header_spec.rb +22 -0
  208. data/spec/unit/axiom/relation/operation/group/methods/group_spec.rb +25 -0
  209. data/spec/unit/axiom/relation/operation/limit/class_methods/new_spec.rb +4 -4
  210. data/spec/unit/axiom/relation/operation/limit/directions_spec.rb +3 -3
  211. data/spec/unit/axiom/relation/operation/limit/each_spec.rb +4 -4
  212. data/spec/unit/axiom/relation/operation/limit/limit_spec.rb +2 -2
  213. data/spec/unit/axiom/relation/operation/offset/class_methods/new_spec.rb +4 -4
  214. data/spec/unit/axiom/relation/operation/offset/directions_spec.rb +3 -3
  215. data/spec/unit/axiom/relation/operation/offset/each_spec.rb +4 -4
  216. data/spec/unit/axiom/relation/operation/offset/offset_spec.rb +2 -2
  217. data/spec/unit/axiom/relation/operation/reverse/class_methods/new_spec.rb +6 -6
  218. data/spec/unit/axiom/relation/operation/reverse/directions_spec.rb +3 -3
  219. data/spec/unit/axiom/relation/operation/reverse/each_spec.rb +4 -4
  220. data/spec/unit/axiom/relation/operation/set/class_methods/included_spec.rb +2 -2
  221. data/spec/unit/axiom/relation/operation/{order → sorted}/ascending/class_methods/call_spec.rb +22 -1
  222. data/spec/unit/axiom/relation/operation/sorted/ascending/class_methods/reverse_spec.rb +11 -0
  223. data/spec/unit/axiom/relation/operation/{order/descending → sorted/ascending}/reverse_spec.rb +2 -2
  224. data/spec/unit/axiom/relation/operation/{order → sorted}/class_methods/new_spec.rb +4 -4
  225. data/spec/unit/axiom/relation/operation/{order → sorted}/delete_spec.rb +12 -6
  226. data/spec/unit/axiom/relation/operation/{order → sorted}/descending/class_methods/call_spec.rb +22 -1
  227. data/spec/unit/axiom/relation/operation/sorted/descending/class_methods/reverse_spec.rb +11 -0
  228. data/spec/unit/axiom/relation/operation/{order/ascending → sorted/descending}/reverse_spec.rb +2 -2
  229. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/attribute_spec.rb +4 -4
  230. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/call_spec.rb +7 -7
  231. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/class_methods/coerce_spec.rb +2 -2
  232. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/eql_predicate_spec.rb +4 -4
  233. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/name_spec.rb +4 -4
  234. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/rename_spec.rb +5 -5
  235. data/spec/unit/axiom/relation/operation/{order → sorted}/direction/reverse_spec.rb +9 -9
  236. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/attributes_spec.rb +1 -1
  237. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/coerce_spec.rb +3 -3
  238. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/new_spec.rb +1 -1
  239. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/eql_spec.rb +1 -1
  240. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/equality_operator_spec.rb +1 -1
  241. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/project_spec.rb +1 -1
  242. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/rename_spec.rb +1 -1
  243. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/reverse_spec.rb +2 -2
  244. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/sort_tuples_spec.rb +1 -1
  245. data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/to_ary_spec.rb +1 -1
  246. data/spec/unit/axiom/relation/operation/{order → sorted}/directions_spec.rb +1 -1
  247. data/spec/unit/axiom/relation/operation/{order → sorted}/each_spec.rb +3 -3
  248. data/spec/unit/axiom/relation/operation/{order → sorted}/eql_spec.rb +1 -1
  249. data/spec/unit/axiom/relation/operation/{order → sorted}/header_spec.rb +1 -1
  250. data/spec/unit/axiom/relation/operation/{order → sorted}/insert_spec.rb +12 -6
  251. data/spec/unit/axiom/relation/operation/{order → sorted}/methods/sort_by_spec.rb +24 -24
  252. data/spec/unit/axiom/relation/operation/sorted/methods/sort_spec.rb +19 -0
  253. data/spec/unit/axiom/relation/operation/ungroup/each_spec.rb +33 -0
  254. data/spec/unit/axiom/relation/operation/ungroup/header_spec.rb +19 -0
  255. data/spec/unit/axiom/relation/operation/ungroup/methods/ungroup_spec.rb +21 -0
  256. data/spec/unit/axiom/relation/operation/unwrap/each_spec.rb +33 -0
  257. data/spec/unit/axiom/relation/operation/unwrap/header_spec.rb +19 -0
  258. data/spec/unit/axiom/relation/operation/unwrap/methods/unwrap_spec.rb +21 -0
  259. data/spec/unit/axiom/relation/operation/wrap/each_spec.rb +33 -0
  260. data/spec/unit/axiom/relation/operation/wrap/header_spec.rb +22 -0
  261. data/spec/unit/axiom/relation/operation/wrap/methods/wrap_spec.rb +25 -0
  262. data/spec/unit/axiom/relation/proxy/each_spec.rb +2 -2
  263. data/spec/unit/axiom/relation/proxy/respond_to_predicate_spec.rb +48 -12
  264. data/spec/unit/axiom/relation/replace_spec.rb +8 -8
  265. data/spec/unit/axiom/tuple/class_methods/coerce_spec.rb +7 -1
  266. data/spec/unit/axiom/tuple/{call_spec.rb → fetch_spec.rb} +1 -1
  267. data/spec/unit/axiom/tuple/inspect_spec.rb +14 -0
  268. data/spec/unit/axiom/tuple/rename_spec.rb +17 -0
  269. data/spec/unit/axiom/tuple/size_spec.rb +14 -0
  270. data/spec/unit/axiom/tuple/to_ary_spec.rb +22 -5
  271. data/spec/unit/axiom/tuple/to_hash_spec.rb +14 -0
  272. data/spec/unit/axiom/types/relation/class_methods/primitive_spec.rb +13 -0
  273. data/spec/unit/axiom/types/tuple/class_methods/primitive_spec.rb +13 -0
  274. data/spec/unit/axiom/visitable/accept_spec.rb +1 -1
  275. data/spec/unit/date/pred_spec.rb +1 -1
  276. data/spec/unit/time/pred_spec.rb +1 -1
  277. metadata +631 -107
  278. data/spec/unit/axiom/aggregate/hash_spec.rb +0 -15
  279. data/spec/unit/axiom/algebra/extension/hash_spec.rb +0 -15
  280. data/spec/unit/axiom/algebra/projection/hash_spec.rb +0 -16
  281. data/spec/unit/axiom/algebra/rename/aliases/hash_spec.rb +0 -15
  282. data/spec/unit/axiom/algebra/rename/hash_spec.rb +0 -15
  283. data/spec/unit/axiom/algebra/restriction/hash_spec.rb +0 -15
  284. data/spec/unit/axiom/algebra/summarization/hash_spec.rb +0 -16
  285. data/spec/unit/axiom/attribute/hash_spec.rb +0 -21
  286. data/spec/unit/axiom/attribute/numeric/hash_spec.rb +0 -17
  287. data/spec/unit/axiom/attribute/string/hash_spec.rb +0 -25
  288. data/spec/unit/axiom/equalizer/methods/eql_spec.rb +0 -49
  289. data/spec/unit/axiom/equalizer/methods/equality_operator_spec.rb +0 -85
  290. data/spec/unit/axiom/function/binary/invertible/class_methods/included_spec.rb +0 -29
  291. data/spec/unit/axiom/function/predicate/hash_spec.rb +0 -16
  292. data/spec/unit/axiom/function/predicate/inverse_spec.rb +0 -17
  293. data/spec/unit/axiom/function/proposition/hash_spec.rb +0 -14
  294. data/spec/unit/axiom/function/unary/hash_spec.rb +0 -18
  295. data/spec/unit/axiom/function/unary/invertible/class_methods/included_spec.rb +0 -29
  296. data/spec/unit/axiom/operation/binary/hash_spec.rb +0 -16
  297. data/spec/unit/axiom/operation/unary/hash_spec.rb +0 -15
  298. data/spec/unit/axiom/relation/base/hash_spec.rb +0 -16
  299. data/spec/unit/axiom/relation/hash_spec.rb +0 -19
  300. data/spec/unit/axiom/relation/header/hash_spec.rb +0 -15
  301. data/spec/unit/axiom/relation/operation/limit/hash_spec.rb +0 -16
  302. data/spec/unit/axiom/relation/operation/offset/hash_spec.rb +0 -16
  303. data/spec/unit/axiom/relation/operation/order/ascending/class_methods/reverse_spec.rb +0 -11
  304. data/spec/unit/axiom/relation/operation/order/descending/class_methods/reverse_spec.rb +0 -11
  305. data/spec/unit/axiom/relation/operation/order/direction/hash_spec.rb +0 -15
  306. data/spec/unit/axiom/relation/operation/order/direction_set/hash_spec.rb +0 -15
  307. data/spec/unit/axiom/relation/operation/order/hash_spec.rb +0 -15
  308. data/spec/unit/axiom/relation/operation/order/methods/sort_spec.rb +0 -19
  309. data/spec/unit/axiom/relation/proxy/hash_spec.rb +0 -26
  310. data/spec/unit/axiom/relation/proxy/method_missing_spec.rb +0 -24
  311. data/spec/unit/axiom/tuple/hash_spec.rb +0 -15
@@ -14,12 +14,12 @@ describe Algebra::Projection, '#each' do
14
14
 
15
15
  it 'yields only tuples' do
16
16
  subject
17
- yields.each { |tuple| tuple.should be_instance_of(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.should be(object.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
@@ -13,17 +13,17 @@ describe Algebra::Rename, '#directions' do
13
13
 
14
14
  it_should_behave_like 'an idempotent method'
15
15
 
16
- it { should be_instance_of(Relation::Operation::Order::DirectionSet) }
16
+ it { should be_instance_of(Relation::Operation::Sorted::DirectionSet) }
17
17
 
18
18
  it { should be_empty }
19
19
  end
20
20
 
21
- context 'containing an ordered relation' do
21
+ context 'containing a sorted relation' do
22
22
  let(:operand) { relation.sort_by { [relation[:id]] } }
23
23
 
24
24
  it_should_behave_like 'an idempotent method'
25
25
 
26
- it { should be_instance_of(Relation::Operation::Order::DirectionSet) }
26
+ it { should be_instance_of(Relation::Operation::Sorted::DirectionSet) }
27
27
 
28
28
  it { should == [Attribute::Integer.new(:other_id).asc] }
29
29
  end
@@ -13,12 +13,12 @@ describe Algebra::Rename, '#each' do
13
13
 
14
14
  it 'yields only tuples' do
15
15
  subject
16
- yields.each { |tuple| tuple.should be_instance_of(Tuple) }
16
+ yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
17
17
  end
18
18
 
19
19
  it 'yields only tuples with the expected header' do
20
20
  subject
21
- yields.each { |tuple| tuple.header.should be(object.header) }
21
+ yields.each { |tuple| expect(tuple.header).to be(object.header) }
22
22
  end
23
23
 
24
24
  it 'yields only tuples with the expected data' do
@@ -18,9 +18,9 @@ describe Algebra::Restriction, '#delete' do
18
18
 
19
19
  it 'passes expected relations into the deletion' do
20
20
  subject = self.subject.operand
21
- subject.left.should be(operand)
22
- subject.right.should be_kind_of(described_class)
23
- subject.right.predicate.should be(predicate)
21
+ expect(subject.left).to be(operand)
22
+ expect(subject.right).to be_kind_of(described_class)
23
+ expect(subject.right.predicate).to be(predicate)
24
24
  end
25
25
 
26
26
  its(:predicate) { should be(predicate) }
@@ -5,9 +5,10 @@ require 'spec_helper'
5
5
  describe Algebra::Restriction, '#each' do
6
6
  subject { object.each { |tuple| yields << tuple } }
7
7
 
8
- let(:object) { described_class.new(relation, predicate) }
9
- let(:relation) { Relation.new([[:id, Integer]], [[1]]) }
10
- let(:yields) { [] }
8
+ let(:object) { described_class.new(relation, predicate) }
9
+ let(:relation) { Relation.new([attribute], [[1]]) }
10
+ let(:attribute) { Attribute::Integer.new(:id) }
11
+ let(:yields) { [] }
11
12
 
12
13
  context 'when predicate is a Proc' do
13
14
  let(:predicate) { proc { true } }
@@ -16,12 +17,12 @@ describe Algebra::Restriction, '#each' do
16
17
 
17
18
  it 'yields only tuples' do
18
19
  subject
19
- yields.each { |tuple| tuple.should be_instance_of(Tuple) }
20
+ yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
20
21
  end
21
22
 
22
23
  it 'yields only tuples with the expected header' do
23
24
  subject
24
- yields.each { |tuple| tuple.header.should be(object.header) }
25
+ yields.each { |tuple| expect(tuple.header).to be(object.header) }
25
26
  end
26
27
 
27
28
  it 'yields only tuples with the expected data' do
@@ -32,18 +33,18 @@ describe Algebra::Restriction, '#each' do
32
33
  end
33
34
 
34
35
  context 'when predicate is a Function' do
35
- let(:predicate) { Function::Proposition::Tautology.instance }
36
+ let(:predicate) { attribute.eq(1) }
36
37
 
37
38
  it_should_behave_like 'an #each method'
38
39
 
39
40
  it 'yields only tuples' do
40
41
  subject
41
- yields.each { |tuple| tuple.should be_instance_of(Tuple) }
42
+ yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
42
43
  end
43
44
 
44
45
  it 'yields only tuples with the expected header' do
45
46
  subject
46
- yields.each { |tuple| tuple.header.should be(object.header) }
47
+ yields.each { |tuple| expect(tuple.header).to be(object.header) }
47
48
  end
48
49
 
49
50
  it 'yields only tuples with the expected data' do
@@ -60,12 +61,12 @@ describe Algebra::Restriction, '#each' do
60
61
 
61
62
  it 'yields only tuples' do
62
63
  subject
63
- yields.each { |tuple| tuple.should be_instance_of(Tuple) }
64
+ yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
64
65
  end
65
66
 
66
67
  it 'yields only tuples with the expected header' do
67
68
  subject
68
- yields.each { |tuple| tuple.header.should be(object.header) }
69
+ yields.each { |tuple| expect(tuple.header).to be(object.header) }
69
70
  end
70
71
 
71
72
  it 'yields only tuples with the expected data' do
@@ -82,7 +83,7 @@ describe Algebra::Restriction, '#each' do
82
83
 
83
84
  it 'yields no tuples' do
84
85
  subject
85
- yields.should be_empty
86
+ expect(yields).to be_empty
86
87
  end
87
88
  end
88
89
  end
@@ -18,9 +18,9 @@ describe Algebra::Restriction, '#insert' do
18
18
 
19
19
  it 'passes expected relations into the insertion' do
20
20
  subject = self.subject.operand
21
- subject.left.should be(operand)
22
- subject.right.should be_kind_of(described_class)
23
- subject.right.predicate.should be(predicate)
21
+ expect(subject.left).to be(operand)
22
+ expect(subject.right).to be_kind_of(described_class)
23
+ expect(subject.right.predicate).to be(predicate)
24
24
  end
25
25
 
26
26
  its(:predicate) { should be(predicate) }
@@ -17,7 +17,7 @@ describe Algebra::Restriction::Methods, '#restrict' do
17
17
  it { should be_instance_of(Algebra::Restriction) }
18
18
 
19
19
  it 'sets the predicate' do
20
- subject.predicate.should be(predicate)
20
+ expect(subject.predicate).to be(predicate)
21
21
  end
22
22
 
23
23
  it 'behaves the same as Enumerable#select' do
@@ -33,7 +33,7 @@ describe Algebra::Restriction::Methods, '#restrict' do
33
33
  it { should be_instance_of(Algebra::Restriction) }
34
34
 
35
35
  it 'sets the predicate' do
36
- subject.predicate.should eql(object[:id].eq(1))
36
+ expect(subject.predicate).to eql(object[:id].eq(1))
37
37
  end
38
38
 
39
39
  it 'behaves the same as Enumerable#select' do
@@ -49,7 +49,7 @@ describe Algebra::Restriction::Methods, '#restrict' do
49
49
  it { should be_instance_of(Algebra::Restriction) }
50
50
 
51
51
  it 'sets the predicate' do
52
- subject.predicate.should eql(tautology.and(object[:id].eq(1).and(object[:name].eq('Dan Kubb'))))
52
+ expect(subject.predicate).to eql(tautology.and(object[:id].eq(1).and(object[:name].eq('Dan Kubb'))))
53
53
  end
54
54
 
55
55
  it 'behaves the same as Enumerable#select' do
@@ -65,7 +65,7 @@ describe Algebra::Restriction::Methods, '#restrict' do
65
65
  it { should be_instance_of(Algebra::Restriction) }
66
66
 
67
67
  it 'sets the predicate' do
68
- subject.predicate.should eql(tautology.and(object[:id].eq(1).and(object[:name].eq('Dan Kubb'))))
68
+ expect(subject.predicate).to eql(tautology.and(object[:id].eq(1).and(object[:name].eq('Dan Kubb'))))
69
69
  end
70
70
 
71
71
  it 'behaves the same as Enumerable#select' do
@@ -14,12 +14,12 @@ describe Algebra::Summarization, '#each' do
14
14
 
15
15
  it 'yields only tuples' do
16
16
  subject
17
- yields.each { |tuple| tuple.should be_instance_of(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.should eql(object.header) }
22
+ yields.each { |tuple| expect(tuple.header).to eql(object.header) }
23
23
  end
24
24
 
25
25
  it 'yields only tuples with the expected data' do
@@ -55,7 +55,7 @@ describe Algebra::Summarization, '#eql?' do
55
55
 
56
56
  context 'with an object having a different summarize_by' do
57
57
  let(:other_operand) { operand }
58
- let(:other_summarize_by) { operand.project([]).sort_by {} }
58
+ let(:other_summarize_by) { operand.project([]).sort_by(&EMPTY_PROC) }
59
59
  let(:other_summarizers) { summarizers }
60
60
  let(:other) { described_class.new(other_operand, other_summarize_by, other_summarizers) }
61
61
 
@@ -15,14 +15,14 @@ describe Algebra::Summarization::Summaries, '#summarize_by' do
15
15
  it_should_behave_like 'a command method'
16
16
 
17
17
  it 'passes the tuple to the aggregate function' do
18
- summarizer.should_receive(:call).with(nil, tuple)
18
+ expect(summarizer).to receive(:call).with(nil, tuple)
19
19
  subject
20
20
  end
21
21
 
22
22
  it 'aggregates the value returned by the summarizer' do
23
23
  key, value = subject.to_hash.first
24
- key.should eql(:count)
25
- value.should be_instance_of(Algebra::Summarization::Summary)
26
- value.call(tuple.project(header)).should eql(1)
24
+ expect(key).to eql(:count)
25
+ expect(value).to be_instance_of(Algebra::Summarization::Summary)
26
+ expect(value.call(tuple.project(header))).to eql(1)
27
27
  end
28
28
  end
@@ -11,7 +11,7 @@ describe Algebra::Summarization::Summaries, '#to_hash' do
11
11
 
12
12
  it 'matches the expected value' do
13
13
  key, value = subject.first
14
- key.should eql(:count)
15
- value.should be_instance_of(Algebra::Summarization::Summary)
14
+ expect(key).to eql(:count)
15
+ expect(value).to be_instance_of(Algebra::Summarization::Summary)
16
16
  end
17
17
  end
@@ -18,6 +18,6 @@ describe Algebra::Summarization::Summary, '#summarize_by' do
18
18
  subject
19
19
  __memoized.delete(:subject) # bypass subject cache
20
20
  end
21
- object.call(projection).should eql(2)
21
+ expect(object.call(projection)).to eql(2)
22
22
  end
23
23
  end
@@ -17,12 +17,12 @@ describe Algebra::Union, '#each' do
17
17
 
18
18
  it 'yields only tuples' do
19
19
  subject
20
- yields.each { |tuple| tuple.should be_instance_of(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.should eql(object.header) }
25
+ yields.each { |tuple| expect(tuple.header).to eql(object.header) }
26
26
  end
27
27
 
28
28
  it 'yields only tuples with the expected data' do
@@ -39,12 +39,12 @@ describe Algebra::Union, '#each' do
39
39
 
40
40
  it 'yields only tuples' do
41
41
  subject
42
- yields.each { |tuple| tuple.should be_instance_of(Tuple) }
42
+ yields.each { |tuple| expect(tuple).to be_instance_of(Tuple) }
43
43
  end
44
44
 
45
45
  it 'yields only tuples with the expected header' do
46
46
  subject
47
- yields.each { |tuple| tuple.header.should eql(object.header) }
47
+ yields.each { |tuple| expect(tuple.header).to eql(object.header) }
48
48
  end
49
49
 
50
50
  it 'yields only tuples with the expected data' do
@@ -4,6 +4,8 @@ module AliasableSpecs
4
4
  class Object
5
5
  extend Aliasable
6
6
 
7
- def test; end
7
+ def test(arguments, &block)
8
+ end
9
+
8
10
  end # class Object
9
11
  end # module AliasableSpecs
@@ -6,45 +6,36 @@ require File.expand_path('../fixtures/classes', __FILE__)
6
6
  describe Aliasable, '#inheritable_alias' do
7
7
  subject { object.inheritable_alias(aliases) }
8
8
 
9
- let(:aliases) { { other: :test } }
10
9
  let(:object) { Class.new(AliasableSpecs::Object) }
10
+ let(:aliases) { { other: :test } }
11
11
  let(:aliasable) { object.new }
12
+ let(:arg) { double('arg') }
12
13
 
13
14
  it_should_behave_like 'a command method'
14
15
 
15
- it 'creates a method #other' do
16
- expect { subject }.to change { aliasable.respond_to?(:other) }
17
- .from(false)
18
- .to(true)
16
+ it 'creates a method alias' do
17
+ expect { subject }
18
+ .to change { aliasable.respond_to?(:other) }.from(false).to(true)
19
19
  end
20
20
 
21
- it 'aliases #other to #test' do
21
+ it 'forwards arguments to aliased method' do
22
22
  subject
23
- retval = double('Return Value')
24
- aliasable.should_receive(:test).and_return(retval)
25
- aliasable.other.should be(retval)
23
+ expect(aliasable).to receive(:test).with(arg)
24
+ aliasable.other(arg)
26
25
  end
27
26
 
28
- specification = proc do
29
- object.class_eval do
30
- def test
31
- caller
32
- end
33
- end
34
-
27
+ it 'forwards the block to aliased method' do
35
28
  subject
36
-
37
- file, line = aliasable.other.first.split(':')[0, 2]
38
-
39
- File.expand_path(file).should eql(File.expand_path('../../../../../lib/axiom/support/aliasable.rb', __FILE__))
40
- line.to_i.should be(38)
29
+ yieldparam = double('yieldparam')
30
+ expect(aliasable).to receive(:test).and_yield(yieldparam)
31
+ expect { |block| aliasable.other(arg, &block) }
32
+ .to yield_with_args(yieldparam)
41
33
  end
42
34
 
43
- it 'sets the file and line number properly' do
44
- if RUBY_PLATFORM.include?('java')
45
- pending('Kernel#caller returns the incorrect line number in JRuby', &specification)
46
- else
47
- instance_eval(&specification)
48
- end
35
+ it 'returns value from aliased method' do
36
+ subject
37
+ retval = double('retval')
38
+ expect(aliasable).to receive(:test).and_return(retval)
39
+ expect(aliasable.other(arg)).to be(retval)
49
40
  end
50
41
  end
@@ -11,7 +11,7 @@ describe Attribute, '#call' do
11
11
  let(:tuple) { Tuple.new(header, [1]) }
12
12
 
13
13
  before do
14
- described_class.stub(type: Types::Object)
14
+ allow(described_class).to receive(:type).and_return(Types::Object)
15
15
  end
16
16
 
17
17
  it { should == 1 }
@@ -5,87 +5,93 @@ require 'spec_helper'
5
5
  describe Attribute, '.coerce' do
6
6
  subject { object.coerce(argument) }
7
7
 
8
- let(:object) { described_class }
8
+ describe 'with the class' do
9
+ let(:object) { described_class }
9
10
 
10
- context 'when the argument is an Attribute' do
11
- let(:argument) { Attribute::Integer.new(:id) }
11
+ context 'when the argument is an Attribute' do
12
+ let(:argument) { Attribute::Integer.new(:id) }
12
13
 
13
- it { should be(argument) }
14
- end
14
+ it { should be(argument) }
15
+ end
15
16
 
16
- context 'when the argument responds to #to_ary and does not include options' do
17
- let(:argument) { [:id, Integer] }
17
+ context 'when the argument responds to #to_ary and does not include options' do
18
+ let(:argument) { [:id, Integer] }
18
19
 
19
- it { should be_instance_of(Attribute::Integer) }
20
+ it { should be_instance_of(Attribute::Integer) }
20
21
 
21
- its(:name) { should == :id }
22
- end
22
+ its(:name) { should == :id }
23
+ end
23
24
 
24
- context 'when the argument responds to #to_ary and includes options' do
25
- let(:argument) { [:id, Integer, { required: false }] }
25
+ context 'when the argument responds to #to_ary and includes options' do
26
+ let(:argument) { [:id, Integer, { required: false }] }
26
27
 
27
- it { should be_instance_of(Attribute::Integer) }
28
+ it { should be_instance_of(Attribute::Integer) }
28
29
 
29
- its(:name) { should == :id }
30
+ its(:name) { should == :id }
30
31
 
31
- its(:required?) { should be(false) }
32
- end
32
+ its(:required?) { should be(false) }
33
+ end
33
34
 
34
- context 'when the argument does not respond to #to_ary, but does respond to #to_sym' do
35
- let(:argument) { :id }
35
+ context 'when the argument does not respond to #to_ary, but does respond to #to_sym' do
36
+ let(:argument) { :id }
36
37
 
37
- it { should be_instance_of(Attribute::Object) }
38
+ it { should be_instance_of(Attribute::Object) }
38
39
 
39
- its(:name) { should == :id }
40
- end
40
+ its(:name) { should == :id }
41
+ end
41
42
 
42
- context 'when the argument does not respond to #to_ary or #to_sym' do
43
- let(:argument) { Integer }
43
+ context 'when the argument does not respond to #to_ary or #to_sym' do
44
+ let(:argument) { Integer }
44
45
 
45
- specify { expect { subject }.to raise_error(NoMethodError) }
46
+ specify { expect { subject }.to raise_error(NoMethodError) }
47
+ end
46
48
  end
47
- end
48
49
 
49
- describe Attribute::Boolean, '.coerce' do
50
- subject { object.coerce(argument) }
50
+ describe 'with a subclass' do
51
+ subject { object.coerce(argument) }
51
52
 
52
- let(:object) { described_class }
53
+ let(:object) { Class.new(described_class) }
53
54
 
54
- context 'when the argument is an Attribute' do
55
- let(:argument) { Attribute::Integer.new(:id) }
55
+ context 'when the argument is an Attribute' do
56
+ let(:argument) { Attribute::Integer.new(:id) }
56
57
 
57
- it { should be(argument) }
58
- end
58
+ it { should be(argument) }
59
+ end
59
60
 
60
- context 'when the argument responds to #to_ary and does not include options' do
61
- let(:argument) { [:id, Integer] }
61
+ context 'when the argument responds to #to_ary and does not include options' do
62
+ let(:argument) { [:id, Integer] }
62
63
 
63
- it { should be_instance_of(Attribute::Integer) }
64
+ it { should be_instance_of(Attribute::Integer) }
64
65
 
65
- its(:name) { should == :id }
66
- end
66
+ its(:name) { should == :id }
67
+ end
67
68
 
68
- context 'when the argument responds to #to_ary and includes options' do
69
- let(:argument) { [:id, Integer, { required: false }] }
69
+ context 'when the argument responds to #to_ary and includes options' do
70
+ let(:argument) { [:id, Integer, { required: false }] }
70
71
 
71
- it { should be_instance_of(Attribute::Integer) }
72
+ it { should be_instance_of(Attribute::Integer) }
72
73
 
73
- its(:name) { should == :id }
74
+ its(:name) { should == :id }
74
75
 
75
- its(:required?) { should be(false) }
76
- end
76
+ its(:required?) { should be(false) }
77
+ end
77
78
 
78
- context 'when the argument does not respond to #to_ary, but does respond to #to_sym' do
79
- let(:argument) { :id }
79
+ context 'when the argument does not respond to #to_ary, but does respond to #to_sym' do
80
+ let(:argument) { :id }
80
81
 
81
- it { should be_instance_of(described_class) }
82
+ before do
83
+ allow(object).to receive(:type)
84
+ end
82
85
 
83
- its(:name) { should == :id }
84
- end
86
+ it { should be_instance_of(object) }
87
+
88
+ its(:name) { should == :id }
89
+ end
85
90
 
86
- context 'when the argument does not respond to #to_ary or #to_sym' do
87
- let(:argument) { Integer }
91
+ context 'when the argument does not respond to #to_ary or #to_sym' do
92
+ let(:argument) { Integer }
88
93
 
89
- specify { expect { subject }.to raise_error(NoMethodError) }
94
+ specify { expect { subject }.to raise_error(NoMethodError) }
95
+ end
90
96
  end
91
97
  end