veritas 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (660) hide show
  1. data/.gemtest +0 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +20 -10
  5. data/Guardfile +22 -0
  6. data/README.rdoc +5 -6
  7. data/Rakefile +4 -2
  8. data/TODO +18 -23
  9. data/config/flay.yml +1 -1
  10. data/config/flog.yml +1 -1
  11. data/config/roodi.yml +1 -1
  12. data/config/site.reek +3 -3
  13. data/lib/veritas/aggregate/count.rb +55 -0
  14. data/lib/veritas/aggregate/maximum.rb +59 -0
  15. data/lib/veritas/aggregate/mean.rb +81 -0
  16. data/lib/veritas/aggregate/minimum.rb +59 -0
  17. data/lib/veritas/aggregate/standard_deviation.rb +58 -0
  18. data/lib/veritas/aggregate/sum.rb +81 -0
  19. data/lib/veritas/aggregate/variance.rb +81 -0
  20. data/lib/veritas/aggregate.rb +116 -0
  21. data/lib/veritas/algebra/difference.rb +3 -1
  22. data/lib/veritas/algebra/extension.rb +12 -10
  23. data/lib/veritas/algebra/intersection.rb +3 -1
  24. data/lib/veritas/algebra/join.rb +17 -15
  25. data/lib/veritas/algebra/product.rb +4 -2
  26. data/lib/veritas/algebra/projection.rb +4 -3
  27. data/lib/veritas/algebra/rename/aliases.rb +6 -4
  28. data/lib/veritas/algebra/rename.rb +12 -3
  29. data/lib/veritas/algebra/restriction.rb +13 -12
  30. data/lib/veritas/algebra/summarization/summaries.rb +59 -0
  31. data/lib/veritas/algebra/summarization/summary.rb +83 -0
  32. data/lib/veritas/algebra/summarization.rb +88 -75
  33. data/lib/veritas/algebra/union.rb +4 -2
  34. data/lib/veritas/attribute/boolean.rb +5 -3
  35. data/lib/veritas/attribute/class.rb +2 -0
  36. data/lib/veritas/attribute/comparable.rb +11 -5
  37. data/lib/veritas/attribute/date.rb +2 -0
  38. data/lib/veritas/attribute/date_time.rb +2 -0
  39. data/lib/veritas/attribute/decimal.rb +2 -0
  40. data/lib/veritas/attribute/float.rb +4 -0
  41. data/lib/veritas/attribute/integer.rb +2 -0
  42. data/lib/veritas/attribute/numeric.rb +6 -4
  43. data/lib/veritas/attribute/object.rb +7 -4
  44. data/lib/veritas/attribute/orderable.rb +2 -0
  45. data/lib/veritas/attribute/string.rb +39 -13
  46. data/lib/veritas/attribute/time.rb +2 -0
  47. data/lib/veritas/attribute.rb +92 -36
  48. data/lib/veritas/core_ext/date.rb +2 -0
  49. data/lib/veritas/core_ext/range.rb +2 -0
  50. data/lib/veritas/core_ext/time.rb +2 -0
  51. data/lib/veritas/function/binary.rb +107 -0
  52. data/lib/veritas/function/comparable.rb +55 -0
  53. data/lib/veritas/{logic → function}/connective/conjunction.rb +24 -6
  54. data/lib/veritas/{logic → function}/connective/disjunction.rb +24 -6
  55. data/lib/veritas/{logic → function}/connective/negation.rb +34 -13
  56. data/lib/veritas/function/connective.rb +21 -0
  57. data/lib/veritas/function/numeric/absolute.rb +62 -0
  58. data/lib/veritas/function/numeric/addition.rb +62 -0
  59. data/lib/veritas/function/numeric/binary.rb +26 -0
  60. data/lib/veritas/function/numeric/division.rb +71 -0
  61. data/lib/veritas/function/numeric/exponentiation.rb +68 -0
  62. data/lib/veritas/function/numeric/modulo.rb +53 -0
  63. data/lib/veritas/function/numeric/multiplication.rb +62 -0
  64. data/lib/veritas/function/numeric/square_root.rb +86 -0
  65. data/lib/veritas/function/numeric/subtraction.rb +62 -0
  66. data/lib/veritas/function/numeric/unary.rb +23 -0
  67. data/lib/veritas/function/numeric/unary_minus.rb +74 -0
  68. data/lib/veritas/function/numeric/unary_plus.rb +76 -0
  69. data/lib/veritas/function/numeric.rb +11 -0
  70. data/lib/veritas/{logic → function}/predicate/enumerable.rb +4 -2
  71. data/lib/veritas/{logic → function}/predicate/equality.rb +5 -3
  72. data/lib/veritas/{logic → function}/predicate/exclusion.rb +5 -5
  73. data/lib/veritas/{logic → function}/predicate/greater_than.rb +5 -3
  74. data/lib/veritas/{logic → function}/predicate/greater_than_or_equal_to.rb +5 -3
  75. data/lib/veritas/{logic → function}/predicate/inclusion.rb +5 -5
  76. data/lib/veritas/{logic → function}/predicate/inequality.rb +4 -2
  77. data/lib/veritas/{logic → function}/predicate/less_than.rb +5 -3
  78. data/lib/veritas/{logic → function}/predicate/less_than_or_equal_to.rb +5 -3
  79. data/lib/veritas/{logic → function}/predicate/match.rb +17 -3
  80. data/lib/veritas/{logic → function}/predicate/no_match.rb +5 -3
  81. data/lib/veritas/function/predicate.rb +26 -0
  82. data/lib/veritas/{logic → function}/proposition/contradiction.rb +7 -4
  83. data/lib/veritas/{logic → function}/proposition/tautology.rb +7 -4
  84. data/lib/veritas/{logic → function}/proposition.rb +29 -4
  85. data/lib/veritas/function/string/length.rb +68 -0
  86. data/lib/veritas/{logic/connective → function}/unary.rb +48 -12
  87. data/lib/veritas/function.rb +128 -0
  88. data/lib/veritas/relation/base.rb +38 -0
  89. data/lib/veritas/relation/empty.rb +2 -0
  90. data/lib/veritas/relation/header.rb +14 -37
  91. data/lib/veritas/relation/materialized.rb +9 -0
  92. data/lib/veritas/relation/operation/binary.rb +3 -2
  93. data/lib/veritas/relation/operation/combination.rb +2 -0
  94. data/lib/veritas/relation/operation/limit.rb +11 -1
  95. data/lib/veritas/relation/operation/offset.rb +11 -1
  96. data/lib/veritas/relation/operation/order/direction.rb +2 -0
  97. data/lib/veritas/relation/operation/order/direction_set.rb +5 -3
  98. data/lib/veritas/relation/operation/order.rb +15 -7
  99. data/lib/veritas/relation/operation/reverse.rb +4 -2
  100. data/lib/veritas/relation/operation/set.rb +2 -0
  101. data/lib/veritas/relation/operation/unary.rb +3 -2
  102. data/lib/veritas/relation.rb +9 -6
  103. data/lib/veritas/support/abstract_class.rb +2 -0
  104. data/lib/veritas/support/aliasable.rb +2 -0
  105. data/lib/veritas/support/evaluator.rb +37 -16
  106. data/lib/veritas/support/immutable.rb +5 -5
  107. data/lib/veritas/support/operation/binary.rb +2 -0
  108. data/lib/veritas/support/operation/unary.rb +2 -0
  109. data/lib/veritas/support/visitable.rb +2 -0
  110. data/lib/veritas/tuple.rb +13 -9
  111. data/lib/veritas/version.rb +3 -1
  112. data/lib/veritas.rb +60 -25
  113. data/spec/integration/veritas/algebra/join_spec.rb +2 -0
  114. data/spec/integration/veritas/algebra/product_spec.rb +2 -0
  115. data/spec/integration/veritas/algebra/projection_spec.rb +2 -0
  116. data/spec/integration/veritas/algebra/summarization_spec.rb +9 -9
  117. data/spec/integration/veritas/relation/efficient_enumerable_spec.rb +2 -0
  118. data/spec/shared/command_method_behavior.rb +2 -0
  119. data/spec/shared/each_method_behaviour.rb +2 -0
  120. data/spec/shared/hash_method_behavior.rb +2 -0
  121. data/spec/shared/idempotent_method_behavior.rb +2 -0
  122. data/spec/spec_helper.rb +13 -0
  123. data/spec/unit/date/pred_spec.rb +2 -0
  124. data/spec/unit/range/overlaps_spec.rb +2 -0
  125. data/spec/unit/range/to_inclusive_spec.rb +2 -0
  126. data/spec/unit/time/pred_spec.rb +2 -0
  127. data/spec/unit/veritas/abstract_class/class_methods/new_spec.rb +2 -0
  128. data/spec/unit/veritas/aggregate/call_spec.rb +43 -0
  129. data/spec/unit/veritas/{logic/proposition → aggregate}/class_methods/call_spec.rb +3 -1
  130. data/spec/unit/veritas/aggregate/class_methods/default_spec.rb +11 -0
  131. data/spec/unit/veritas/aggregate/class_methods/finalize_spec.rb +12 -0
  132. data/spec/unit/veritas/aggregate/count/class_methods/call_spec.rb +30 -0
  133. data/spec/unit/veritas/aggregate/count/class_methods/default_spec.rb +13 -0
  134. data/spec/unit/veritas/aggregate/count/methods/count_spec.rb +14 -0
  135. data/spec/unit/veritas/aggregate/count/type_spec.rb +12 -0
  136. data/spec/unit/veritas/aggregate/default_spec.rb +17 -0
  137. data/spec/unit/veritas/aggregate/finalize_spec.rb +18 -0
  138. data/spec/unit/veritas/aggregate/maximum/class_methods/call_spec.rb +36 -0
  139. data/spec/unit/veritas/aggregate/maximum/class_methods/default_spec.rb +13 -0
  140. data/spec/unit/veritas/aggregate/maximum/methods/maximum_spec.rb +16 -0
  141. data/spec/unit/veritas/aggregate/maximum/type_spec.rb +20 -0
  142. data/spec/unit/veritas/aggregate/mean/class_methods/call_spec.rb +30 -0
  143. data/spec/unit/veritas/aggregate/mean/class_methods/default_spec.rb +15 -0
  144. data/spec/unit/veritas/aggregate/mean/class_methods/finalize_spec.rb +16 -0
  145. data/spec/unit/veritas/aggregate/mean/methods/mean_spec.rb +16 -0
  146. data/spec/unit/veritas/aggregate/mean/type_spec.rb +12 -0
  147. data/spec/unit/veritas/aggregate/minimum/class_methods/call_spec.rb +36 -0
  148. data/spec/unit/veritas/aggregate/minimum/class_methods/default_spec.rb +13 -0
  149. data/spec/unit/veritas/aggregate/minimum/methods/minimum_spec.rb +16 -0
  150. data/spec/unit/veritas/aggregate/minimum/type_spec.rb +20 -0
  151. data/spec/unit/veritas/aggregate/standard_deviation/class_methods/finalize_spec.rb +34 -0
  152. data/spec/unit/veritas/aggregate/standard_deviation/methods/standard_deviation_spec.rb +16 -0
  153. data/spec/unit/veritas/aggregate/standard_deviation/type_spec.rb +12 -0
  154. data/spec/unit/veritas/aggregate/sum/class_methods/call_spec.rb +30 -0
  155. data/spec/unit/veritas/aggregate/sum/class_methods/default_spec.rb +13 -0
  156. data/spec/unit/veritas/aggregate/sum/default_spec.rb +27 -0
  157. data/spec/unit/veritas/aggregate/sum/methods/sum_spec.rb +14 -0
  158. data/spec/unit/veritas/aggregate/sum/type_spec.rb +20 -0
  159. data/spec/unit/veritas/aggregate/type_spec.rb +13 -0
  160. data/spec/unit/veritas/aggregate/variance/class_methods/call_spec.rb +30 -0
  161. data/spec/unit/veritas/aggregate/variance/class_methods/default_spec.rb +15 -0
  162. data/spec/unit/veritas/aggregate/variance/class_methods/finalize_spec.rb +26 -0
  163. data/spec/unit/veritas/aggregate/variance/methods/variance_spec.rb +16 -0
  164. data/spec/unit/veritas/aggregate/variance/type_spec.rb +12 -0
  165. data/spec/unit/veritas/algebra/difference/each_spec.rb +2 -0
  166. data/spec/unit/veritas/algebra/difference/methods/difference_spec.rb +2 -0
  167. data/spec/unit/veritas/algebra/extension/class_methods/new_spec.rb +2 -0
  168. data/spec/unit/veritas/algebra/extension/each_spec.rb +2 -0
  169. data/spec/unit/veritas/algebra/extension/eql_spec.rb +2 -0
  170. data/spec/unit/veritas/algebra/extension/extensions_spec.rb +2 -0
  171. data/spec/unit/veritas/algebra/extension/hash_spec.rb +2 -0
  172. data/spec/unit/veritas/algebra/extension/header_spec.rb +2 -0
  173. data/spec/unit/veritas/algebra/extension/methods/extend_spec.rb +2 -0
  174. data/spec/unit/veritas/algebra/extension/operand_spec.rb +2 -0
  175. data/spec/unit/veritas/algebra/intersection/each_spec.rb +2 -0
  176. data/spec/unit/veritas/algebra/intersection/methods/intersect_spec.rb +2 -0
  177. data/spec/unit/veritas/algebra/join/class_methods/new_spec.rb +2 -0
  178. data/spec/unit/veritas/algebra/join/each_spec.rb +2 -0
  179. data/spec/unit/veritas/algebra/join/methods/join_spec.rb +3 -14
  180. data/spec/unit/veritas/algebra/product/class_methods/new_spec.rb +2 -0
  181. data/spec/unit/veritas/algebra/product/each_spec.rb +2 -0
  182. data/spec/unit/veritas/algebra/product/methods/product_spec.rb +2 -0
  183. data/spec/unit/veritas/algebra/projection/each_spec.rb +2 -0
  184. data/spec/unit/veritas/algebra/projection/eql_spec.rb +2 -0
  185. data/spec/unit/veritas/algebra/projection/hash_spec.rb +2 -0
  186. data/spec/unit/veritas/algebra/projection/header_spec.rb +2 -0
  187. data/spec/unit/veritas/algebra/projection/methods/project_spec.rb +2 -0
  188. data/spec/unit/veritas/algebra/projection/methods/remove_spec.rb +2 -0
  189. data/spec/unit/veritas/algebra/rename/aliases/class_methods/coerce_spec.rb +2 -0
  190. data/spec/unit/veritas/algebra/rename/aliases/class_methods/new_spec.rb +2 -0
  191. data/spec/unit/veritas/algebra/rename/aliases/each_spec.rb +2 -0
  192. data/spec/unit/veritas/algebra/rename/aliases/element_reference_spec.rb +2 -0
  193. data/spec/unit/veritas/algebra/rename/aliases/empty_spec.rb +2 -0
  194. data/spec/unit/veritas/algebra/rename/aliases/eql_spec.rb +2 -0
  195. data/spec/unit/veritas/algebra/rename/aliases/equal_value_spec.rb +2 -0
  196. data/spec/unit/veritas/algebra/rename/aliases/hash_spec.rb +2 -0
  197. data/spec/unit/veritas/algebra/rename/aliases/to_hash_spec.rb +2 -0
  198. data/spec/unit/veritas/algebra/rename/aliases/union_spec.rb +2 -0
  199. data/spec/unit/veritas/algebra/rename/aliases_spec.rb +2 -0
  200. data/spec/unit/veritas/algebra/rename/directions_spec.rb +4 -2
  201. data/spec/unit/veritas/algebra/rename/each_spec.rb +2 -0
  202. data/spec/unit/veritas/algebra/rename/eql_spec.rb +2 -0
  203. data/spec/unit/veritas/algebra/rename/hash_spec.rb +2 -0
  204. data/spec/unit/veritas/algebra/rename/header_spec.rb +2 -0
  205. data/spec/unit/veritas/algebra/rename/methods/rename_spec.rb +2 -0
  206. data/spec/unit/veritas/algebra/restriction/each_spec.rb +36 -6
  207. data/spec/unit/veritas/algebra/restriction/eql_spec.rb +2 -0
  208. data/spec/unit/veritas/algebra/restriction/hash_spec.rb +2 -0
  209. data/spec/unit/veritas/algebra/restriction/methods/restrict_spec.rb +9 -26
  210. data/spec/unit/veritas/algebra/restriction/predicate_spec.rb +2 -0
  211. data/spec/unit/veritas/algebra/summarization/class_methods/new_spec.rb +30 -0
  212. data/spec/unit/veritas/algebra/summarization/each_spec.rb +2 -0
  213. data/spec/unit/veritas/algebra/summarization/eql_spec.rb +2 -0
  214. data/spec/unit/veritas/algebra/summarization/hash_spec.rb +2 -0
  215. data/spec/unit/veritas/algebra/summarization/header_spec.rb +4 -2
  216. data/spec/unit/veritas/algebra/summarization/methods/summarize_spec.rb +19 -10
  217. data/spec/unit/veritas/algebra/summarization/summaries/summarize_by_spec.rb +26 -0
  218. data/spec/unit/veritas/algebra/summarization/summaries/to_hash_spec.rb +16 -0
  219. data/spec/unit/veritas/algebra/summarization/{summarize_by_spec.rb → summarize_per_spec.rb} +6 -4
  220. data/spec/unit/veritas/algebra/summarization/summarizers_spec.rb +3 -1
  221. data/spec/unit/veritas/algebra/summarization/summary/call_spec.rb +43 -0
  222. data/spec/unit/veritas/algebra/summarization/summary/summarize_by_spec.rb +20 -0
  223. data/spec/unit/veritas/algebra/union/each_spec.rb +2 -0
  224. data/spec/unit/veritas/algebra/union/methods/union_spec.rb +2 -0
  225. data/spec/unit/veritas/aliasable/fixtures/classes.rb +2 -0
  226. data/spec/unit/veritas/aliasable/inheritable_alias_spec.rb +3 -1
  227. data/spec/unit/veritas/attribute/boolean/class_methods/primitive_spec.rb +2 -0
  228. data/spec/unit/veritas/attribute/boolean/valid_value_spec.rb +2 -0
  229. data/spec/unit/veritas/attribute/call_spec.rb +2 -0
  230. data/spec/unit/veritas/attribute/class/class_methods/primitive_spec.rb +2 -0
  231. data/spec/unit/veritas/attribute/class_methods/coerce_spec.rb +36 -0
  232. data/spec/unit/veritas/attribute/class_methods/descendants_spec.rb +27 -0
  233. data/spec/unit/veritas/attribute/class_methods/infer_type_spec.rb +121 -0
  234. data/spec/unit/veritas/attribute/class_methods/inherited_spec.rb +25 -0
  235. data/spec/unit/veritas/attribute/class_methods/name_from_spec.rb +2 -0
  236. data/spec/unit/veritas/attribute/class_methods/new_spec.rb +2 -0
  237. data/spec/unit/veritas/attribute/comparable/comparable_spec.rb +3 -3
  238. data/spec/unit/veritas/attribute/comparable/fixtures/classes.rb +2 -0
  239. data/spec/unit/veritas/attribute/date/class_methods/primitive_spec.rb +2 -0
  240. data/spec/unit/veritas/attribute/date/range_spec.rb +2 -0
  241. data/spec/unit/veritas/attribute/date_time/class_methods/primitive_spec.rb +2 -0
  242. data/spec/unit/veritas/attribute/date_time/range_spec.rb +2 -0
  243. data/spec/unit/veritas/attribute/decimal/class_methods/primitive_spec.rb +2 -0
  244. data/spec/unit/veritas/attribute/eql_spec.rb +2 -0
  245. data/spec/unit/veritas/attribute/equal_value_spec.rb +2 -0
  246. data/spec/unit/veritas/attribute/float/class_methods/primitive_spec.rb +2 -0
  247. data/spec/unit/veritas/attribute/float/size_spec.rb +21 -0
  248. data/spec/unit/veritas/attribute/hash_spec.rb +2 -0
  249. data/spec/unit/veritas/attribute/inspect_spec.rb +2 -0
  250. data/spec/unit/veritas/attribute/integer/class_methods/primitive_spec.rb +2 -0
  251. data/spec/unit/veritas/attribute/joinable_spec.rb +2 -0
  252. data/spec/unit/veritas/attribute/name_spec.rb +2 -0
  253. data/spec/unit/veritas/attribute/numeric/class_methods/primitive_spec.rb +2 -0
  254. data/spec/unit/veritas/attribute/numeric/joinable_spec.rb +2 -0
  255. data/spec/unit/veritas/attribute/numeric/size_spec.rb +4 -2
  256. data/spec/unit/veritas/attribute/numeric/valid_value_spec.rb +2 -0
  257. data/spec/unit/veritas/attribute/object/class_methods/primitive_spec.rb +2 -0
  258. data/spec/unit/veritas/attribute/options_spec.rb +2 -0
  259. data/spec/unit/veritas/attribute/orderable/asc_spec.rb +2 -0
  260. data/spec/unit/veritas/attribute/orderable/desc_spec.rb +2 -0
  261. data/spec/unit/veritas/attribute/orderable/fixtures/classes.rb +2 -0
  262. data/spec/unit/veritas/attribute/rename_spec.rb +2 -0
  263. data/spec/unit/veritas/attribute/required_spec.rb +2 -0
  264. data/spec/unit/veritas/attribute/string/class_methods/primitive_spec.rb +2 -0
  265. data/spec/unit/veritas/attribute/string/joinable_spec.rb +5 -3
  266. data/spec/unit/veritas/attribute/string/max_length_spec.rb +20 -0
  267. data/spec/unit/veritas/attribute/string/min_length_spec.rb +20 -0
  268. data/spec/unit/veritas/attribute/string/valid_value_spec.rb +3 -1
  269. data/spec/unit/veritas/attribute/time/class_methods/primitive_spec.rb +2 -0
  270. data/spec/unit/veritas/attribute/time/range_spec.rb +2 -0
  271. data/spec/unit/veritas/attribute/type_spec.rb +12 -0
  272. data/spec/unit/veritas/attribute/valid_primitive_spec.rb +2 -0
  273. data/spec/unit/veritas/attribute/valid_value_spec.rb +2 -0
  274. data/spec/unit/veritas/evaluator/context/add_spec.rb +46 -0
  275. data/spec/unit/veritas/evaluator/context/element_reference_spec.rb +14 -0
  276. data/spec/unit/veritas/evaluator/context/functions_spec.rb +16 -0
  277. data/spec/unit/veritas/{logic/connective → function}/binary/call_spec.rb +10 -8
  278. data/spec/unit/veritas/{logic/connective → function}/binary/equal_value_spec.rb +3 -1
  279. data/spec/unit/veritas/{logic/connective → function}/binary/fixtures/classes.rb +5 -1
  280. data/spec/unit/veritas/function/binary/invertible/inverse_spec.rb +39 -0
  281. data/spec/unit/veritas/{logic/connective → function}/binary/rename_spec.rb +3 -1
  282. data/spec/unit/veritas/{logic/expression → function}/class_methods/call_spec.rb +3 -1
  283. data/spec/unit/veritas/{logic/predicate → function}/class_methods/extract_value_spec.rb +3 -1
  284. data/spec/unit/veritas/function/class_methods/rename_attributes_spec.rb +29 -0
  285. data/spec/unit/veritas/{logic/predicate → function}/comparable/class_methods/call_spec.rb +3 -1
  286. data/spec/unit/veritas/{logic/predicate → function}/comparable/fixtures/classes.rb +3 -1
  287. data/spec/unit/veritas/function/comparable/inspect_spec.rb +15 -0
  288. data/spec/unit/veritas/{logic → function}/connective/conjunction/class_methods/call_spec.rb +3 -1
  289. data/spec/unit/veritas/{logic → function}/connective/conjunction/inspect_spec.rb +3 -1
  290. data/spec/unit/veritas/function/connective/conjunction/inverse_spec.rb +24 -0
  291. data/spec/unit/veritas/{logic → function}/connective/conjunction/methods/and_spec.rb +4 -2
  292. data/spec/unit/veritas/{logic → function}/connective/conjunction/methods/fixtures/classes.rb +3 -1
  293. data/spec/unit/veritas/{logic → function}/connective/disjunction/class_methods/call_spec.rb +3 -1
  294. data/spec/unit/veritas/{logic → function}/connective/disjunction/inspect_spec.rb +3 -1
  295. data/spec/unit/veritas/function/connective/disjunction/inverse_spec.rb +24 -0
  296. data/spec/unit/veritas/{logic → function}/connective/disjunction/methods/fixtures/classes.rb +3 -1
  297. data/spec/unit/veritas/{logic → function}/connective/disjunction/methods/or_spec.rb +4 -2
  298. data/spec/unit/veritas/function/connective/inspect_spec.rb +12 -0
  299. data/spec/unit/veritas/{logic → function}/connective/negation/class_methods/call_spec.rb +3 -1
  300. data/spec/unit/veritas/{logic → function}/connective/negation/inspect_spec.rb +4 -2
  301. data/spec/unit/veritas/{logic → function}/connective/negation/inverse_spec.rb +3 -1
  302. data/spec/unit/veritas/function/connective/negation/methods/fixtures/classes.rb +8 -0
  303. data/spec/unit/veritas/function/connective/negation/methods/not_spec.rb +39 -0
  304. data/spec/unit/veritas/function/connective/type_spec.rb +12 -0
  305. data/spec/unit/veritas/function/eql_spec.rb +14 -0
  306. data/spec/unit/veritas/function/equal_value_spec.rb +14 -0
  307. data/spec/unit/veritas/function/fixtures/classes.rb +6 -0
  308. data/spec/unit/veritas/{logic/expression → function}/hash_spec.rb +5 -3
  309. data/spec/unit/veritas/{logic/expression → function}/inspect_spec.rb +5 -3
  310. data/spec/unit/veritas/function/numeric/absolute/class_methods/call_spec.rb +21 -0
  311. data/spec/unit/veritas/function/numeric/absolute/inspect_spec.rb +11 -0
  312. data/spec/unit/veritas/function/numeric/absolute/methods/absolute_spec.rb +16 -0
  313. data/spec/unit/veritas/function/numeric/addition/class_methods/call_spec.rb +13 -0
  314. data/spec/unit/veritas/function/numeric/addition/class_methods/inverse_spec.rb +11 -0
  315. data/spec/unit/veritas/function/numeric/addition/class_methods/operation_spec.rb +11 -0
  316. data/spec/unit/veritas/function/numeric/addition/inspect_spec.rb +11 -0
  317. data/spec/unit/veritas/function/numeric/addition/methods/add_spec.rb +19 -0
  318. data/spec/unit/veritas/function/numeric/binary/type_spec.rb +33 -0
  319. data/spec/unit/veritas/function/numeric/division/class_methods/call_spec.rb +13 -0
  320. data/spec/unit/veritas/function/numeric/division/class_methods/inverse_spec.rb +11 -0
  321. data/spec/unit/veritas/function/numeric/division/class_methods/operation_spec.rb +11 -0
  322. data/spec/unit/veritas/function/numeric/division/inspect_spec.rb +11 -0
  323. data/spec/unit/veritas/function/numeric/division/methods/divide_spec.rb +19 -0
  324. data/spec/unit/veritas/function/numeric/division/type_spec.rb +11 -0
  325. data/spec/unit/veritas/function/numeric/exponentiation/class_methods/call_spec.rb +13 -0
  326. data/spec/unit/veritas/function/numeric/exponentiation/class_methods/operation_spec.rb +11 -0
  327. data/spec/unit/veritas/function/numeric/exponentiation/inspect_spec.rb +11 -0
  328. data/spec/unit/veritas/function/numeric/exponentiation/inverse_spec.rb +18 -0
  329. data/spec/unit/veritas/function/numeric/exponentiation/methods/exponent_spec.rb +19 -0
  330. data/spec/unit/veritas/function/numeric/modulo/class_methods/call_spec.rb +13 -0
  331. data/spec/unit/veritas/function/numeric/modulo/class_methods/operation_spec.rb +11 -0
  332. data/spec/unit/veritas/function/numeric/modulo/inspect_spec.rb +11 -0
  333. data/spec/unit/veritas/function/numeric/modulo/methods/modulo_spec.rb +19 -0
  334. data/spec/unit/veritas/function/numeric/multiplication/class_methods/call_spec.rb +13 -0
  335. data/spec/unit/veritas/function/numeric/multiplication/class_methods/inverse_spec.rb +11 -0
  336. data/spec/unit/veritas/function/numeric/multiplication/class_methods/operation_spec.rb +11 -0
  337. data/spec/unit/veritas/function/numeric/multiplication/inspect_spec.rb +11 -0
  338. data/spec/unit/veritas/function/numeric/multiplication/methods/multiply_spec.rb +19 -0
  339. data/spec/unit/veritas/function/numeric/square_root/class_methods/call_spec.rb +12 -0
  340. data/spec/unit/veritas/function/numeric/square_root/inspect_spec.rb +11 -0
  341. data/spec/unit/veritas/function/numeric/square_root/inverse_spec.rb +14 -0
  342. data/spec/unit/veritas/function/numeric/square_root/methods/square_root_spec.rb +16 -0
  343. data/spec/unit/veritas/function/numeric/square_root/type_spec.rb +11 -0
  344. data/spec/unit/veritas/function/numeric/subtraction/class_methods/call_spec.rb +13 -0
  345. data/spec/unit/veritas/function/numeric/subtraction/class_methods/inverse_spec.rb +11 -0
  346. data/spec/unit/veritas/function/numeric/subtraction/class_methods/operation_spec.rb +11 -0
  347. data/spec/unit/veritas/function/numeric/subtraction/inspect_spec.rb +11 -0
  348. data/spec/unit/veritas/function/numeric/subtraction/methods/subtract_spec.rb +19 -0
  349. data/spec/unit/veritas/function/numeric/unary/type_spec.rb +21 -0
  350. data/spec/unit/veritas/function/numeric/unary_minus/class_methods/call_spec.rb +21 -0
  351. data/spec/unit/veritas/function/numeric/unary_minus/class_methods/inverse_spec.rb +11 -0
  352. data/spec/unit/veritas/function/numeric/unary_minus/inspect_spec.rb +11 -0
  353. data/spec/unit/veritas/function/numeric/unary_minus/methods/unary_minus_spec.rb +16 -0
  354. data/spec/unit/veritas/function/numeric/unary_plus/class_methods/call_spec.rb +21 -0
  355. data/spec/unit/veritas/function/numeric/unary_plus/class_methods/inverse_spec.rb +11 -0
  356. data/spec/unit/veritas/function/numeric/unary_plus/inspect_spec.rb +11 -0
  357. data/spec/unit/veritas/function/numeric/unary_plus/methods/unary_plus_spec.rb +16 -0
  358. data/spec/unit/veritas/{logic → function}/predicate/call_spec.rb +3 -1
  359. data/spec/unit/veritas/{logic → function}/predicate/class_methods/call_spec.rb +3 -1
  360. data/spec/unit/veritas/{logic → function}/predicate/enumerable/class_methods/compare_method_spec.rb +3 -1
  361. data/spec/unit/veritas/{logic → function}/predicate/eql_spec.rb +3 -1
  362. data/spec/unit/veritas/{logic/predicate/inequality → function/predicate/equality}/class_methods/call_spec.rb +5 -3
  363. data/spec/unit/veritas/function/predicate/equality/class_methods/inverse_spec.rb +11 -0
  364. data/spec/unit/veritas/{logic → function}/predicate/equality/class_methods/operation_spec.rb +3 -1
  365. data/spec/unit/veritas/{logic → function}/predicate/equality/class_methods/reverse_spec.rb +3 -1
  366. data/spec/unit/veritas/{logic/predicate/greater_than_or_equal_to → function/predicate/equality}/inspect_spec.rb +4 -2
  367. data/spec/unit/veritas/{logic/predicate/greater_than → function/predicate/equality}/inverse_spec.rb +4 -2
  368. data/spec/unit/veritas/{logic → function}/predicate/equality/methods/eq_spec.rb +4 -2
  369. data/spec/unit/veritas/{logic → function}/predicate/equality/methods/fixtures/classes.rb +3 -1
  370. data/spec/unit/veritas/{logic → function}/predicate/exclusion/class_methods/call_spec.rb +3 -1
  371. data/spec/unit/veritas/function/predicate/exclusion/class_methods/inverse_spec.rb +11 -0
  372. data/spec/unit/veritas/{logic/predicate/inclusion → function/predicate/exclusion}/inspect_spec.rb +2 -2
  373. data/spec/unit/veritas/{logic/predicate/inclusion → function/predicate/exclusion}/inverse_spec.rb +4 -2
  374. data/spec/unit/veritas/{logic → function}/predicate/exclusion/methods/exclude_spec.rb +4 -2
  375. data/spec/unit/veritas/{logic → function}/predicate/exclusion/methods/fixtures/classes.rb +3 -1
  376. data/spec/unit/veritas/{logic → function}/predicate/fixtures/classes.rb +3 -1
  377. data/spec/unit/veritas/{logic → function}/predicate/greater_than/class_methods/call_spec.rb +3 -1
  378. data/spec/unit/veritas/function/predicate/greater_than/class_methods/inverse_spec.rb +11 -0
  379. data/spec/unit/veritas/{logic → function}/predicate/greater_than/class_methods/operation_spec.rb +3 -1
  380. data/spec/unit/veritas/function/predicate/greater_than/class_methods/reverse_spec.rb +11 -0
  381. data/spec/unit/veritas/{logic/predicate/equality → function/predicate/greater_than}/inspect_spec.rb +4 -2
  382. data/spec/unit/veritas/{logic/predicate/less_than → function/predicate/greater_than}/inverse_spec.rb +4 -2
  383. data/spec/unit/veritas/{logic → function}/predicate/greater_than/methods/fixtures/classes.rb +3 -1
  384. data/spec/unit/veritas/{logic → function}/predicate/greater_than/methods/gt_spec.rb +4 -2
  385. data/spec/unit/veritas/{logic → function}/predicate/greater_than_or_equal_to/class_methods/call_spec.rb +3 -1
  386. data/spec/unit/veritas/function/predicate/greater_than_or_equal_to/class_methods/inverse_spec.rb +11 -0
  387. data/spec/unit/veritas/{logic → function}/predicate/greater_than_or_equal_to/class_methods/operation_spec.rb +3 -1
  388. data/spec/unit/veritas/function/predicate/greater_than_or_equal_to/class_methods/reverse_spec.rb +11 -0
  389. data/spec/unit/veritas/function/predicate/greater_than_or_equal_to/inspect_spec.rb +12 -0
  390. data/spec/unit/veritas/{logic → function}/predicate/greater_than_or_equal_to/inverse_spec.rb +4 -2
  391. data/spec/unit/veritas/{logic → function}/predicate/greater_than_or_equal_to/methods/fixtures/classes.rb +3 -1
  392. data/spec/unit/veritas/{logic → function}/predicate/greater_than_or_equal_to/methods/gte_spec.rb +4 -2
  393. data/spec/unit/veritas/{logic → function}/predicate/hash_spec.rb +3 -1
  394. data/spec/unit/veritas/{logic → function}/predicate/inclusion/class_methods/call_spec.rb +3 -1
  395. data/spec/unit/veritas/function/predicate/inclusion/class_methods/inverse_spec.rb +11 -0
  396. data/spec/unit/veritas/{logic/predicate/exclusion → function/predicate/inclusion}/inspect_spec.rb +2 -2
  397. data/spec/unit/veritas/{logic/predicate/exclusion → function/predicate/inclusion}/inverse_spec.rb +4 -2
  398. data/spec/unit/veritas/{logic → function}/predicate/inclusion/methods/fixtures/classes.rb +3 -1
  399. data/spec/unit/veritas/{logic → function}/predicate/inclusion/methods/include_spec.rb +4 -2
  400. data/spec/unit/veritas/{logic/predicate/equality → function/predicate/inequality}/class_methods/call_spec.rb +5 -3
  401. data/spec/unit/veritas/function/predicate/inequality/class_methods/inverse_spec.rb +11 -0
  402. data/spec/unit/veritas/{logic → function}/predicate/inequality/class_methods/operation_spec.rb +3 -1
  403. data/spec/unit/veritas/function/predicate/inequality/class_methods/reverse_spec.rb +11 -0
  404. data/spec/unit/veritas/{logic → function}/predicate/inequality/inspect_spec.rb +4 -2
  405. data/spec/unit/veritas/{logic/predicate/equality → function/predicate/inequality}/inverse_spec.rb +4 -2
  406. data/spec/unit/veritas/{logic → function}/predicate/inequality/methods/fixtures/classes.rb +3 -1
  407. data/spec/unit/veritas/{logic → function}/predicate/inequality/methods/ne_spec.rb +4 -2
  408. data/spec/unit/veritas/{logic → function}/predicate/inspect_spec.rb +3 -1
  409. data/spec/unit/veritas/function/predicate/inverse_spec.rb +17 -0
  410. data/spec/unit/veritas/{logic → function}/predicate/less_than/class_methods/call_spec.rb +3 -1
  411. data/spec/unit/veritas/function/predicate/less_than/class_methods/inverse_spec.rb +11 -0
  412. data/spec/unit/veritas/{logic → function}/predicate/less_than/class_methods/operation_spec.rb +3 -1
  413. data/spec/unit/veritas/function/predicate/less_than/class_methods/reverse_spec.rb +11 -0
  414. data/spec/unit/veritas/{logic/predicate/greater_than → function/predicate/less_than}/inspect_spec.rb +4 -2
  415. data/spec/unit/veritas/{logic/predicate/inequality → function/predicate/less_than}/inverse_spec.rb +4 -2
  416. data/spec/unit/veritas/{logic → function}/predicate/less_than/methods/fixtures/classes.rb +3 -1
  417. data/spec/unit/veritas/{logic → function}/predicate/less_than/methods/lt_spec.rb +4 -2
  418. data/spec/unit/veritas/{logic → function}/predicate/less_than_or_equal_to/class_methods/call_spec.rb +3 -1
  419. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/class_methods/inverse_spec.rb +11 -0
  420. data/spec/unit/veritas/{logic → function}/predicate/less_than_or_equal_to/class_methods/operation_spec.rb +3 -1
  421. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/class_methods/reverse_spec.rb +11 -0
  422. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/inspect_spec.rb +12 -0
  423. data/spec/unit/veritas/function/predicate/less_than_or_equal_to/inverse_spec.rb +22 -0
  424. data/spec/unit/veritas/{logic → function}/predicate/less_than_or_equal_to/methods/fixtures/classes.rb +3 -1
  425. data/spec/unit/veritas/{logic → function}/predicate/less_than_or_equal_to/methods/lte_spec.rb +4 -2
  426. data/spec/unit/veritas/{logic → function}/predicate/match/class_methods/call_spec.rb +3 -1
  427. data/spec/unit/veritas/function/predicate/match/class_methods/inverse_spec.rb +11 -0
  428. data/spec/unit/veritas/{logic → function}/predicate/match/class_methods/operation_spec.rb +3 -1
  429. data/spec/unit/veritas/{logic → function}/predicate/match/inspect_spec.rb +4 -2
  430. data/spec/unit/veritas/{logic → function}/predicate/match/inverse_spec.rb +4 -2
  431. data/spec/unit/veritas/{logic → function}/predicate/match/methods/fixtures/classes.rb +3 -1
  432. data/spec/unit/veritas/{logic → function}/predicate/match/methods/match_spec.rb +4 -2
  433. data/spec/unit/veritas/{logic → function}/predicate/no_match/class_methods/call_spec.rb +3 -1
  434. data/spec/unit/veritas/function/predicate/no_match/class_methods/inverse_spec.rb +11 -0
  435. data/spec/unit/veritas/{logic → function}/predicate/no_match/class_methods/operation_spec.rb +3 -1
  436. data/spec/unit/veritas/{logic → function}/predicate/no_match/inspect_spec.rb +4 -2
  437. data/spec/unit/veritas/{logic → function}/predicate/no_match/inverse_spec.rb +4 -2
  438. data/spec/unit/veritas/{logic → function}/predicate/no_match/methods/fixtures/classes.rb +3 -1
  439. data/spec/unit/veritas/{logic → function}/predicate/no_match/methods/no_match_spec.rb +4 -2
  440. data/spec/unit/veritas/function/predicate/type_spec.rb +14 -0
  441. data/spec/unit/veritas/{logic → function}/proposition/call_spec.rb +5 -3
  442. data/spec/unit/veritas/function/proposition/class_methods/call_spec.rb +11 -0
  443. data/spec/unit/veritas/{logic → function}/proposition/class_methods/new_spec.rb +5 -3
  444. data/spec/unit/veritas/{logic → function}/proposition/contradiction/and_spec.rb +3 -1
  445. data/spec/unit/veritas/{logic → function}/proposition/contradiction/class_methods/call_spec.rb +3 -1
  446. data/spec/unit/veritas/function/proposition/contradiction/class_methods/inverse_spec.rb +11 -0
  447. data/spec/unit/veritas/{logic → function}/proposition/contradiction/inspect_spec.rb +3 -1
  448. data/spec/unit/veritas/{logic → function}/proposition/contradiction/inverse_spec.rb +4 -2
  449. data/spec/unit/veritas/{logic → function}/proposition/contradiction/or_spec.rb +3 -1
  450. data/spec/unit/veritas/{logic → function}/proposition/eql_spec.rb +6 -4
  451. data/spec/unit/veritas/{logic → function}/proposition/equal_value_spec.rb +6 -4
  452. data/spec/unit/veritas/function/proposition/hash_spec.rb +14 -0
  453. data/spec/unit/veritas/function/proposition/inspect_spec.rb +16 -0
  454. data/spec/unit/veritas/{logic → function}/proposition/inverse_spec.rb +4 -2
  455. data/spec/unit/veritas/{logic/expression → function/proposition}/rename_spec.rb +4 -3
  456. data/spec/unit/veritas/{logic → function}/proposition/tautology/and_spec.rb +3 -1
  457. data/spec/unit/veritas/{logic → function}/proposition/tautology/class_methods/call_spec.rb +3 -1
  458. data/spec/unit/veritas/function/proposition/tautology/class_methods/inverse_spec.rb +11 -0
  459. data/spec/unit/veritas/{logic → function}/proposition/tautology/inspect_spec.rb +3 -1
  460. data/spec/unit/veritas/{logic → function}/proposition/tautology/inverse_spec.rb +4 -2
  461. data/spec/unit/veritas/{logic → function}/proposition/tautology/or_spec.rb +3 -1
  462. data/spec/unit/veritas/function/proposition/type_spec.rb +12 -0
  463. data/spec/unit/veritas/function/rename_spec.rb +14 -0
  464. data/spec/unit/veritas/function/string/length/class_methods/call_spec.rb +12 -0
  465. data/spec/unit/veritas/function/string/length/inspect_spec.rb +11 -0
  466. data/spec/unit/veritas/function/string/length/methods/length_spec.rb +14 -0
  467. data/spec/unit/veritas/function/string/length/type_spec.rb +11 -0
  468. data/spec/unit/veritas/function/type_spec.rb +13 -0
  469. data/spec/unit/veritas/{logic/connective → function}/unary/call_spec.rb +3 -1
  470. data/spec/unit/veritas/{logic/connective → function}/unary/equal_value_spec.rb +3 -1
  471. data/spec/unit/veritas/{logic/connective → function}/unary/fixtures/classes.rb +5 -1
  472. data/spec/unit/veritas/function/unary/invertible/inverse_spec.rb +37 -0
  473. data/spec/unit/veritas/{logic/connective → function}/unary/rename_spec.rb +4 -2
  474. data/spec/unit/veritas/immutable/class_methods/freeze_object_spec.rb +2 -0
  475. data/spec/unit/veritas/immutable/class_methods/new_spec.rb +2 -0
  476. data/spec/unit/veritas/immutable/dup_spec.rb +2 -0
  477. data/spec/unit/veritas/immutable/fixtures/classes.rb +6 -4
  478. data/spec/unit/veritas/immutable/freeze_spec.rb +2 -0
  479. data/spec/unit/veritas/immutable/memoize_spec.rb +28 -4
  480. data/spec/unit/veritas/immutable/memoized_spec.rb +2 -0
  481. data/spec/unit/veritas/immutable/memory/element_reference_spec.rb +2 -0
  482. data/spec/unit/veritas/immutable/memory/element_set_spec.rb +5 -3
  483. data/spec/unit/veritas/immutable/module_methods/included_spec.rb +2 -0
  484. data/spec/unit/veritas/immutable/module_methods/memoize_spec.rb +9 -1
  485. data/spec/unit/veritas/operation/binary/eql_spec.rb +2 -0
  486. data/spec/unit/veritas/operation/binary/hash_spec.rb +2 -0
  487. data/spec/unit/veritas/operation/binary/left_spec.rb +2 -0
  488. data/spec/unit/veritas/operation/binary/right_spec.rb +2 -0
  489. data/spec/unit/veritas/operation/unary/eql_spec.rb +2 -0
  490. data/spec/unit/veritas/operation/unary/hash_spec.rb +2 -0
  491. data/spec/unit/veritas/operation/unary/operand_spec.rb +2 -0
  492. data/spec/unit/veritas/relation/base/name_spec.rb +45 -0
  493. data/spec/unit/veritas/relation/class_methods/new_spec.rb +2 -0
  494. data/spec/unit/veritas/relation/directions_spec.rb +3 -1
  495. data/spec/unit/veritas/relation/each_spec.rb +2 -0
  496. data/spec/unit/veritas/relation/element_reference_spec.rb +2 -0
  497. data/spec/unit/veritas/relation/empty/each_spec.rb +2 -0
  498. data/spec/unit/veritas/relation/empty/empty_spec.rb +2 -0
  499. data/spec/unit/veritas/relation/empty/header_spec.rb +2 -0
  500. data/spec/unit/veritas/relation/empty_spec.rb +2 -0
  501. data/spec/unit/veritas/relation/eql_spec.rb +2 -0
  502. data/spec/unit/veritas/relation/equal_value_spec.rb +2 -0
  503. data/spec/unit/veritas/relation/hash_spec.rb +2 -0
  504. data/spec/unit/veritas/relation/header/class_methods/coerce_spec.rb +2 -0
  505. data/spec/unit/veritas/relation/header/class_methods/new_spec.rb +2 -0
  506. data/spec/unit/veritas/relation/header/difference_spec.rb +2 -0
  507. data/spec/unit/veritas/relation/header/each_spec.rb +2 -0
  508. data/spec/unit/veritas/relation/header/element_reference_spec.rb +2 -0
  509. data/spec/unit/veritas/relation/header/empty_spec.rb +2 -0
  510. data/spec/unit/veritas/relation/header/eql_spec.rb +2 -0
  511. data/spec/unit/veritas/relation/header/equal_value_spec.rb +2 -0
  512. data/spec/unit/veritas/relation/header/hash_spec.rb +5 -3
  513. data/spec/unit/veritas/relation/header/inspect_spec.rb +2 -0
  514. data/spec/unit/veritas/relation/header/intersect_spec.rb +2 -0
  515. data/spec/unit/veritas/relation/header/project_spec.rb +2 -0
  516. data/spec/unit/veritas/relation/header/rename_spec.rb +2 -0
  517. data/spec/unit/veritas/relation/header/to_ary_spec.rb +2 -0
  518. data/spec/unit/veritas/relation/header/union_spec.rb +2 -0
  519. data/spec/unit/veritas/relation/header_spec.rb +2 -0
  520. data/spec/unit/veritas/relation/materialize_spec.rb +2 -0
  521. data/spec/unit/veritas/relation/materialized/class_methods/new_spec.rb +2 -0
  522. data/spec/unit/veritas/relation/materialized/directions_spec.rb +27 -0
  523. data/spec/unit/veritas/relation/materialized/empty_spec.rb +2 -0
  524. data/spec/unit/veritas/relation/materialized/materialize_spec.rb +2 -0
  525. data/spec/unit/veritas/relation/materialized/size_spec.rb +2 -0
  526. data/spec/unit/veritas/relation/operation/binary/class_methods/new_spec.rb +2 -0
  527. data/spec/unit/veritas/relation/operation/binary/fixtures/classes.rb +2 -0
  528. data/spec/unit/veritas/relation/operation/binary/header_spec.rb +2 -0
  529. data/spec/unit/veritas/relation/operation/combination/class_methods/combine_tuples_spec.rb +2 -0
  530. data/spec/unit/veritas/relation/operation/combination/fixtures/classes.rb +2 -0
  531. data/spec/unit/veritas/relation/operation/combination/header_spec.rb +2 -0
  532. data/spec/unit/veritas/relation/operation/limit/class_methods/new_spec.rb +2 -0
  533. data/spec/unit/veritas/relation/operation/limit/directions_spec.rb +15 -0
  534. data/spec/unit/veritas/relation/operation/limit/each_spec.rb +2 -0
  535. data/spec/unit/veritas/relation/operation/limit/eql_spec.rb +2 -0
  536. data/spec/unit/veritas/relation/operation/limit/hash_spec.rb +2 -0
  537. data/spec/unit/veritas/relation/operation/limit/limit_spec.rb +2 -0
  538. data/spec/unit/veritas/relation/operation/limit/methods/first_spec.rb +2 -0
  539. data/spec/unit/veritas/relation/operation/limit/methods/last_spec.rb +2 -0
  540. data/spec/unit/veritas/relation/operation/limit/methods/take_spec.rb +2 -0
  541. data/spec/unit/veritas/relation/operation/offset/class_methods/new_spec.rb +2 -0
  542. data/spec/unit/veritas/relation/operation/offset/directions_spec.rb +15 -0
  543. data/spec/unit/veritas/relation/operation/offset/each_spec.rb +2 -0
  544. data/spec/unit/veritas/relation/operation/offset/eql_spec.rb +2 -0
  545. data/spec/unit/veritas/relation/operation/offset/hash_spec.rb +2 -0
  546. data/spec/unit/veritas/relation/operation/offset/methods/drop_spec.rb +2 -0
  547. data/spec/unit/veritas/relation/operation/offset/offset_spec.rb +2 -0
  548. data/spec/unit/veritas/relation/operation/order/ascending/class_methods/call_spec.rb +2 -0
  549. data/spec/unit/veritas/relation/operation/order/ascending/class_methods/reverse_spec.rb +2 -0
  550. data/spec/unit/veritas/relation/operation/order/ascending/reverse_spec.rb +2 -0
  551. data/spec/unit/veritas/relation/operation/order/class_methods/new_spec.rb +2 -0
  552. data/spec/unit/veritas/relation/operation/order/descending/class_methods/call_spec.rb +2 -0
  553. data/spec/unit/veritas/relation/operation/order/descending/class_methods/reverse_spec.rb +2 -0
  554. data/spec/unit/veritas/relation/operation/order/descending/reverse_spec.rb +2 -0
  555. data/spec/unit/veritas/relation/operation/order/direction/attribute_spec.rb +2 -0
  556. data/spec/unit/veritas/relation/operation/order/direction/call_spec.rb +2 -0
  557. data/spec/unit/veritas/relation/operation/order/direction/class_methods/coerce_spec.rb +2 -0
  558. data/spec/unit/veritas/relation/operation/order/direction/eql_spec.rb +2 -0
  559. data/spec/unit/veritas/relation/operation/order/direction/hash_spec.rb +2 -0
  560. data/spec/unit/veritas/relation/operation/order/direction/rename_spec.rb +2 -0
  561. data/spec/unit/veritas/relation/operation/order/direction/reverse_spec.rb +2 -0
  562. data/spec/unit/veritas/relation/operation/order/direction_set/attributes_spec.rb +2 -0
  563. data/spec/unit/veritas/relation/operation/order/direction_set/class_methods/coerce_spec.rb +2 -0
  564. data/spec/unit/veritas/relation/operation/order/direction_set/each_spec.rb +2 -0
  565. data/spec/unit/veritas/relation/operation/order/direction_set/empty_spec.rb +2 -0
  566. data/spec/unit/veritas/relation/operation/order/direction_set/eql_spec.rb +2 -0
  567. data/spec/unit/veritas/relation/operation/order/direction_set/equal_value_spec.rb +2 -0
  568. data/spec/unit/veritas/relation/operation/order/direction_set/hash_spec.rb +2 -0
  569. data/spec/unit/veritas/relation/operation/order/direction_set/project_spec.rb +2 -0
  570. data/spec/unit/veritas/relation/operation/order/direction_set/rename_spec.rb +2 -0
  571. data/spec/unit/veritas/relation/operation/order/direction_set/reverse_spec.rb +4 -0
  572. data/spec/unit/veritas/relation/operation/order/direction_set/sort_tuples_spec.rb +2 -0
  573. data/spec/unit/veritas/relation/operation/order/direction_set/to_ary_spec.rb +2 -0
  574. data/spec/unit/veritas/relation/operation/order/direction_set/union_spec.rb +2 -0
  575. data/spec/unit/veritas/relation/operation/order/directions_spec.rb +5 -3
  576. data/spec/unit/veritas/relation/operation/order/each_spec.rb +2 -0
  577. data/spec/unit/veritas/relation/operation/order/eql_spec.rb +2 -0
  578. data/spec/unit/veritas/relation/operation/order/hash_spec.rb +2 -0
  579. data/spec/unit/veritas/relation/operation/order/header_spec.rb +2 -0
  580. data/spec/unit/veritas/relation/operation/order/methods/order_spec.rb +2 -14
  581. data/spec/unit/veritas/relation/operation/reverse/class_methods/new_spec.rb +2 -0
  582. data/spec/unit/veritas/relation/operation/reverse/directions_spec.rb +17 -0
  583. data/spec/unit/veritas/relation/operation/reverse/each_spec.rb +2 -0
  584. data/spec/unit/veritas/relation/operation/reverse/methods/reverse_spec.rb +2 -0
  585. data/spec/unit/veritas/relation/operation/set/class_methods/new_spec.rb +2 -0
  586. data/spec/unit/veritas/relation/operation/set/fixtures/classes.rb +2 -0
  587. data/spec/unit/veritas/relation/operation/set/header_spec.rb +2 -0
  588. data/spec/unit/veritas/relation/operation/unary/fixtures/classes.rb +2 -0
  589. data/spec/unit/veritas/relation/operation/unary/header_spec.rb +2 -0
  590. data/spec/unit/veritas/tuple/class_methods/coerce_spec.rb +2 -0
  591. data/spec/unit/veritas/tuple/element_reference_spec.rb +2 -0
  592. data/spec/unit/veritas/tuple/eql_spec.rb +2 -0
  593. data/spec/unit/veritas/tuple/equal_value_spec.rb +2 -0
  594. data/spec/unit/veritas/tuple/extend_spec.rb +29 -4
  595. data/spec/unit/veritas/tuple/hash_spec.rb +3 -1
  596. data/spec/unit/veritas/tuple/header_spec.rb +2 -0
  597. data/spec/unit/veritas/tuple/inspect_spec.rb +2 -0
  598. data/spec/unit/veritas/tuple/join_spec.rb +2 -0
  599. data/spec/unit/veritas/tuple/project_spec.rb +2 -0
  600. data/spec/unit/veritas/tuple/to_ary_spec.rb +4 -0
  601. data/spec/unit/veritas/visitable/accept_spec.rb +2 -0
  602. data/tasks/metrics/ci.rake +7 -0
  603. data/tasks/{quality → metrics}/flay.rake +0 -0
  604. data/tasks/{quality → metrics}/flog.rake +0 -0
  605. data/tasks/{quality → metrics}/heckle.rake +25 -3
  606. data/tasks/{quality → metrics}/metric_fu.rake +3 -0
  607. data/tasks/{quality → metrics}/reek.rake +0 -0
  608. data/tasks/{quality → metrics}/roodi.rake +0 -0
  609. data/tasks/{quality → metrics}/yardstick.rake +0 -0
  610. data/tasks/spec.rake +1 -0
  611. data/veritas.gemspec +332 -580
  612. metadata +375 -584
  613. data/lib/veritas/logic/connective/binary.rb +0 -70
  614. data/lib/veritas/logic/connective.rb +0 -24
  615. data/lib/veritas/logic/expression.rb +0 -99
  616. data/lib/veritas/logic/predicate/comparable.rb +0 -57
  617. data/lib/veritas/logic/predicate.rb +0 -99
  618. data/spec/unit/veritas/algebra/projection/directions_spec.rb +0 -24
  619. data/spec/unit/veritas/algebra/summarization/class_methods/summarize_spec.rb +0 -26
  620. data/spec/unit/veritas/attribute/string/length_spec.rb +0 -20
  621. data/spec/unit/veritas/evaluator/expression/add_spec.rb +0 -21
  622. data/spec/unit/veritas/evaluator/expression/expressions_spec.rb +0 -13
  623. data/spec/unit/veritas/logic/connective/inspect_spec.rb +0 -10
  624. data/spec/unit/veritas/logic/connective/inverse_spec.rb +0 -26
  625. data/spec/unit/veritas/logic/connective/negation/methods/fixtures/classes.rb +0 -6
  626. data/spec/unit/veritas/logic/connective/negation/methods/not_spec.rb +0 -24
  627. data/spec/unit/veritas/logic/expression/eql_spec.rb +0 -12
  628. data/spec/unit/veritas/logic/expression/equal_value_spec.rb +0 -12
  629. data/spec/unit/veritas/logic/expression/fixtures/classes.rb +0 -4
  630. data/spec/unit/veritas/logic/expression/inverse_spec.rb +0 -16
  631. data/spec/unit/veritas/logic/predicate/comparable/inspect_spec.rb +0 -13
  632. data/spec/unit/veritas/logic/predicate/equal_value_spec.rb +0 -64
  633. data/spec/unit/veritas/logic/predicate/equality/class_methods/inverse_spec.rb +0 -9
  634. data/spec/unit/veritas/logic/predicate/exclusion/class_methods/inverse_spec.rb +0 -9
  635. data/spec/unit/veritas/logic/predicate/greater_than/class_methods/inverse_spec.rb +0 -9
  636. data/spec/unit/veritas/logic/predicate/greater_than/class_methods/reverse_spec.rb +0 -9
  637. data/spec/unit/veritas/logic/predicate/greater_than_or_equal_to/class_methods/inverse_spec.rb +0 -9
  638. data/spec/unit/veritas/logic/predicate/greater_than_or_equal_to/class_methods/reverse_spec.rb +0 -9
  639. data/spec/unit/veritas/logic/predicate/inclusion/class_methods/inverse_spec.rb +0 -9
  640. data/spec/unit/veritas/logic/predicate/inequality/class_methods/inverse_spec.rb +0 -9
  641. data/spec/unit/veritas/logic/predicate/inequality/class_methods/reverse_spec.rb +0 -9
  642. data/spec/unit/veritas/logic/predicate/inverse_spec.rb +0 -31
  643. data/spec/unit/veritas/logic/predicate/less_than/class_methods/inverse_spec.rb +0 -9
  644. data/spec/unit/veritas/logic/predicate/less_than/class_methods/reverse_spec.rb +0 -9
  645. data/spec/unit/veritas/logic/predicate/less_than/inspect_spec.rb +0 -10
  646. data/spec/unit/veritas/logic/predicate/less_than_or_equal_to/class_methods/inverse_spec.rb +0 -9
  647. data/spec/unit/veritas/logic/predicate/less_than_or_equal_to/class_methods/reverse_spec.rb +0 -9
  648. data/spec/unit/veritas/logic/predicate/less_than_or_equal_to/inspect_spec.rb +0 -10
  649. data/spec/unit/veritas/logic/predicate/less_than_or_equal_to/inverse_spec.rb +0 -20
  650. data/spec/unit/veritas/logic/predicate/match/class_methods/inverse_spec.rb +0 -9
  651. data/spec/unit/veritas/logic/predicate/no_match/class_methods/inverse_spec.rb +0 -9
  652. data/spec/unit/veritas/logic/predicate/rename_spec.rb +0 -45
  653. data/spec/unit/veritas/logic/proposition/contradiction/class_methods/inverse_spec.rb +0 -9
  654. data/spec/unit/veritas/logic/proposition/hash_spec.rb +0 -12
  655. data/spec/unit/veritas/logic/proposition/inspect_spec.rb +0 -14
  656. data/spec/unit/veritas/logic/proposition/tautology/class_methods/inverse_spec.rb +0 -9
  657. data/spec/unit/veritas/relation/header/index_spec.rb +0 -20
  658. data/spec/unit/veritas/relation/operation/binary/directions_spec.rb +0 -17
  659. data/spec/unit/veritas/relation/operation/unary/directions_spec.rb +0 -16
  660. data/tasks/quality/ci.rake +0 -2
data/.gemtest ADDED
File without changes
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @$(basename `pwd`) --create
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ bundler_args: --without guard metrics
2
+ script: "bundle exec rake spec"
3
+ rvm:
4
+ - ree
5
+ - 1.8.7
6
+ - 1.9.2
7
+ - ruby-head
8
+ - rbx
data/Gemfile CHANGED
@@ -1,25 +1,35 @@
1
+ # encoding: utf-8
2
+
1
3
  source :rubygems
2
4
 
3
5
  group :development do
4
- gem 'backports', '~> 2.1.0'
5
- gem 'jeweler', '~> 1.5.2'
6
- gem 'rake', '~> 0.8.7'
6
+ gem 'backports', '~> 2.2.1'
7
+ gem 'jeweler', '~> 1.6.0'
8
+ gem 'rake', '~> 0.9.0'
7
9
  gem 'rspec', '~> 1.3.2'
8
- gem 'yard', '~> 0.6.8'
10
+ gem 'yard', '~> 0.7.1'
9
11
  end
10
12
 
11
- group :jruby do
12
- platform :jruby do
13
- gem 'jruby-openssl', '~> 0.7.3'
14
- end
13
+ group :guard do
14
+ gem 'growl', '~> 1.0.3'
15
+ gem 'guard', '~> 0.3.4'
16
+ gem 'guard-bundler', '~> 0.1.3'
17
+ gem 'guard-ego', '~> 0.0.1'
18
+ gem 'guard-rspec', '~> 0.3.1'
15
19
  end
16
20
 
17
21
  group :benchmarks do
18
22
  gem 'rbench', '~> 0.2.3'
19
23
  end
20
24
 
25
+ platform :jruby do
26
+ group :jruby do
27
+ gem 'jruby-openssl', '~> 0.7.4'
28
+ end
29
+ end
30
+
21
31
  platforms :mri_18 do
22
- group :quality do
32
+ group :metrics do
23
33
  gem 'flay', '~> 1.4.2'
24
34
  gem 'flog', '~> 2.5.1'
25
35
  gem 'heckle', '~> 1.4.3'
@@ -30,6 +40,6 @@ platforms :mri_18 do
30
40
  gem 'reek', '~> 1.2.8', :git => 'git://github.com/dkubb/reek.git'
31
41
  gem 'roodi', '~> 2.1.0'
32
42
  gem 'ruby2ruby', '= 1.2.2'
33
- gem 'yardstick', '~> 0.3.0'
43
+ gem 'yardstick', '~> 0.4.0'
34
44
  end
35
45
  end
data/Guardfile ADDED
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ guard 'ego' do
4
+ watch('Guardfile')
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ end
10
+
11
+ guard 'rspec' do
12
+ # run all specs if the spec_helper or supporting files files are modified
13
+ watch('spec/spec_helper.rb') { 'spec' }
14
+ watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
15
+
16
+ # run unit specs if associated lib code is modified
17
+ watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
18
+ watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
19
+
20
+ # run a spec if it is modified
21
+ watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
22
+ end
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Simplifies querying of structured data using relational algebra
4
4
 
5
+ http://travis-ci.org/dkubb/veritas.png
6
+
5
7
  == Usage
6
8
 
7
9
  relation = Veritas::Relation.new([ [ :id, Integer ] ], [ [ 1 ] ])
@@ -34,11 +36,9 @@ Simplifies querying of structured data using relational algebra
34
36
  new_relation = relation.difference(other) # OR relation - other
35
37
 
36
38
  # restriction
37
- new_relation = relation.restrict(relation.name.eq('other'))
38
39
  new_relation = relation.restrict { |r| r[:a].eq('other').and(r[:b].gte(42)) }
39
40
 
40
41
  # theta-join
41
- new_relation = relation.join(other, relation[:a].gte(other[:b]))
42
42
  new_relation = relation.join(other) { |r| r[:a].gte(r[:b]) }
43
43
 
44
44
  # NOTE: theta-join is effectively restricting a product of the relations
@@ -48,7 +48,7 @@ Simplifies querying of structured data using relational algebra
48
48
  new_relation = relation.extend { |r| r.add(:total) { |t| t[:unit_price] * t[:quantity] } }
49
49
 
50
50
  # summarize
51
- new_relation = relation.summarize(relation.project([ :name ])) { |r| r.add(:count, r[:name].count)
51
+ new_relation = relation.summarize(relation.project([ :name ])) { |r| r.add(:count, r[:name].count) }
52
52
  new_relation = relation.summarize(relation.project([ :name ])) { |r| r.add(:count) { |acc, t| acc.to_i + 1 } }
53
53
 
54
54
  # Non-Relational Operators
@@ -64,7 +64,6 @@ Simplifies querying of structured data using relational algebra
64
64
  relation = relation.each { |tuple| ... }
65
65
 
66
66
  # order by attribute and direction
67
- new_relation = relation.order([ relation[:a].desc, relation[:b] ])
68
67
  new_relation = relation.order { |r| [ r[:a].desc, r[:b] ] }
69
68
 
70
69
  # reverse the relation (only allowed if ordered)
@@ -112,9 +111,9 @@ This is 100% complete now.
112
111
 
113
112
  === Phase 2: RDBMS Engines
114
113
 
115
- The second phase of this project will be to add an RDBMS based engine, and move the in-memory matching to it's own engine. I'll also be working on a system where if the primary engine cannot carry out some operation, that it first look at alternate forms (eg. using a join instead of an intersection), and then fall-back to in-memory matching. I also want to look at re-arranging queries so that all the operations that can be performed natively are "pushed down" the hierarchy and then the in-memory matching is performed last.
114
+ The second phase of this project will be to add a RDBMS based engine, and move the in-memory matching to it's own engine. I'll also be working on a system where if the primary engine cannot carry out some operation, that it first look at alternate forms (eg. using a join instead of an intersection), and then fall-back to in-memory matching. I also want to look at re-arranging queries so that all the operations that can be performed natively are "pushed down" the hierarchy and then the in-memory matching is performed last.
116
115
 
117
- This is 80% complete. I have finished a first pass on the veritas-sql-compiler[https://github.com/dkubb/veritas-sql-compiler] which is a visitor that walks the AST and produces SQL for every operation except extend and summarize. To finish those I will need to add function support to veritas that are introspectable (i.e. not Proc objects). Once I can introspect them, then I can serialize them to SQL and other query languages.
116
+ This is 90% complete. I have finished a first pass on the veritas-sql-compiler[https://github.com/dkubb/veritas-sql-compiler] which is a visitor that walks the AST and produces SQL for every operation except extend and summarize. To finish those I will need to add function support to veritas that are introspectable (i.e. not Proc objects). Once I can introspect them, then I can serialize them to SQL and other query languages.
118
117
 
119
118
  === Phase 3: DataMapper Integration
120
119
 
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rake'
2
4
 
3
5
  require File.expand_path('../lib/veritas/version', __FILE__)
4
6
 
5
7
  begin
6
- gem('jeweler', '~> 1.5.2') if respond_to?(:gem, true)
8
+ gem('jeweler', '~> 1.6.0') if respond_to?(:gem, true)
7
9
  require 'jeweler'
8
10
 
9
11
  Jeweler::Tasks.new do |gem|
@@ -21,5 +23,5 @@ begin
21
23
 
22
24
  FileList['tasks/**/*.rake'].each { |task| import task }
23
25
  rescue LoadError
24
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.5.2'
26
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler -v 1.6.0'
25
27
  end
data/TODO CHANGED
@@ -1,6 +1,3 @@
1
- * Add Extension and Summarization Functions
2
- * Overview: https://gist.github.com/584588
3
-
4
1
  * Remove Order, Reverse, Limit and Offset from the Relation inheritance chain
5
2
  * Instead make it so they are proxy classes that wrap Relations, but
6
3
  proxy method calls to the Relation methods, and then wrap the return
@@ -8,12 +5,6 @@
8
5
  * Also this will allow knowledge of #directions to be removed from
9
6
  all the Relation classes. Only the Ranking classes will need to know
10
7
  about directions.
11
- * We can also do things like optimize away an Order that is not
12
- wrapped by a Limit/Offset if it is wrapped in Join or Set relation.
13
- We can do this because joining sorted relations results in
14
- an undefined sort order depending on the algorithm used to join
15
- the tuples. The correct approach to get unambiguous results is to
16
- wrap the Join in an Order.
17
8
  * The Reverse class will probably not be needed either. All we need is
18
9
  for the #reverse method to create a new Order with the directions
19
10
  reversed.
@@ -21,11 +12,7 @@
21
12
  and instead wrap materialized relations in the Order object
22
13
  if any.
23
14
 
24
- * Allow Inclusion match to accept a Relation
25
- * Ensure that Inclusion can have the left/right be an Array of
26
- Attributes.
27
- * Consider transforming the value provided to an Inclusion into
28
- a Relation.
15
+ * Add Relation#nest and Relation#unnest
29
16
 
30
17
  * Update Attributes so that constraints are modelled using predicates,
31
18
  so that when "join-ability" is tested, the predicates can just be
@@ -35,11 +22,26 @@
35
22
  caller. This will allow a "complex" predicate to set the errors
36
23
  on tuples, while still allowing all the same objects to be used.
37
24
 
25
+ * Update memoization to take into account the arguments passed into
26
+ the method. It should memoize differently for different
27
+ methods. Perhaps it could have a special case for methods
28
+ with a 0-arity vs n-arity methods, but it needs to handle cases
29
+ like with #hash that accept no args, and #optimize that accepts
30
+ 1 arg.
31
+
38
32
  * Add Relation#antijoin
33
+ * Allows "NOT EXISTS/IN" type queries to be executes where every tuple
34
+ from the relation is returned that *does not* join with the tuples in
35
+ the operand.
39
36
 
40
- * Add Relation#nest and Relation#unnest
37
+ * Inclusion/Exclusion improvements:
38
+ * Allow attribute/function expressions to exist within the enumerable part
39
+ of the Inclusion and Exclusion operations
40
+ * The #call method should propagate the Tuple down to each callable entry
41
+ in the Enumerable.
41
42
 
42
- * Add aliases for some common operations in Method classes, eg:
43
+ * Update context to return an object that allows aliasing of ruby-ish predicates
44
+ to specific operations, eg:
43
45
  * Predicates:
44
46
  * Alias #== to #eq (may break alot)
45
47
  * Alias #!= to #ne (in 1.9 only)
@@ -51,10 +53,3 @@
51
53
  * Direction:
52
54
  * Alias #@+ to #asc
53
55
  * Alias #@- to #desc
54
-
55
- * Update memoization to take into account the arguments passed into
56
- the method. It should memoize differently for different
57
- methods. Perhaps it could have a special case for methods
58
- with a 0-arity vs n-arity methods, but it needs to handle cases
59
- like with #hash that accept no args, and #optimize that accepts
60
- 1 arg.
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 68
3
- total_score: 778
3
+ total_score: 654
data/config/flog.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 16.8
2
+ threshold: 15.7
data/config/roodi.yml CHANGED
@@ -11,7 +11,7 @@ EmptyRescueBodyCheck: { }
11
11
  ForLoopCheck: { }
12
12
  # TODO: decrease line_count to 5 to 10
13
13
  MethodLineCountCheck: { line_count: 14 }
14
- MethodNameCheck: { pattern: !ruby/regexp /\A(?:[a-z](?:_?[a-z])+[?!=]?|\[\]=?|==|<=>|[+*&|-])\z/ }
14
+ MethodNameCheck: { pattern: !ruby/regexp /\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|[+*&|-])\z/ }
15
15
  ModuleLineCountCheck: { line_count: 392 }
16
16
  ModuleNameCheck: { pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/ }
17
17
  # TODO: decrease parameter_count to 2 or less
data/config/site.reek CHANGED
@@ -8,10 +8,10 @@ UncommunicativeParameterName:
8
8
  - !ruby/regexp /[0-9]$/
9
9
  - !ruby/regexp /[A-Z]/
10
10
  LargeClass:
11
- max_methods: 16 # TODO: decrease max_methods to 10-15 or less
11
+ max_methods: 15 # TODO: decrease max_methods to 10-15 or less
12
12
  exclude: []
13
13
  enabled: true
14
- max_instance_variables: 3
14
+ max_instance_variables: 5
15
15
  UncommunicativeMethodName:
16
16
  accept: []
17
17
  exclude: []
@@ -91,6 +91,6 @@ ControlCouple:
91
91
  exclude: []
92
92
  enabled: true
93
93
  LongYieldList:
94
- max_params: 1
94
+ max_params: 2
95
95
  exclude: []
96
96
  enabled: true
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The count of a series of values
7
+ class Count < Aggregate
8
+
9
+ DEFAULT = 0
10
+
11
+ # Return the count for a series of values
12
+ #
13
+ # @example
14
+ # count = Count.call(count, value)
15
+ #
16
+ # @param [Integer] count
17
+ #
18
+ # @param [Object] _value
19
+ #
20
+ # @return [Integer]
21
+ #
22
+ # @api public
23
+ def self.call(count, value)
24
+ value.nil? ? count : count.succ
25
+ end
26
+
27
+ # Return the type returned from #call
28
+ #
29
+ # @return [Class<Attribute::Integer>]
30
+ #
31
+ # @api public
32
+ def type
33
+ Attribute::Integer
34
+ end
35
+
36
+ module Methods
37
+
38
+ # Return a count aggregate function
39
+ #
40
+ # @example
41
+ # count = attribute.count
42
+ #
43
+ # @param [Attribute]
44
+ #
45
+ # @return [Count]
46
+ #
47
+ # @api public
48
+ def count
49
+ Count.new(self)
50
+ end
51
+
52
+ end # module Methods
53
+ end # class Count
54
+ end # class Aggregate
55
+ end # module Veritas
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The maximum value in a sequence of numbers
7
+ class Maximum < Aggregate
8
+
9
+ DEFAULT = -Float::INFINITY
10
+
11
+ # Return the maximum value for a sequence of numbers
12
+ #
13
+ # @example
14
+ # maximum = Maximum.call(maximum, value)
15
+ #
16
+ # @param [Numeric] maximum
17
+ #
18
+ # @param [Numeric] value
19
+ #
20
+ # @return [Numeric]
21
+ #
22
+ # @api public
23
+ def self.call(maximum, value)
24
+ return maximum if value.nil?
25
+ value > maximum ? value : maximum
26
+ end
27
+
28
+ # Return the type returned from #call
29
+ #
30
+ # @return [Class<Attribute::Numeric>]
31
+ #
32
+ # @api public
33
+ def type
34
+ Attribute.infer_type(operand)
35
+ end
36
+
37
+ module Methods
38
+ extend Aliasable
39
+
40
+ inheritable_alias(:max => :maximum)
41
+
42
+ # Return a maximum aggregate function
43
+ #
44
+ # @example
45
+ # maximum = attribute.maximum
46
+ #
47
+ # @param [Attribute]
48
+ #
49
+ # @return [Maximum]
50
+ #
51
+ # @api public
52
+ def maximum
53
+ Maximum.new(self)
54
+ end
55
+
56
+ end # module Methods
57
+ end # class Maximum
58
+ end # class Aggregate
59
+ end # module Veritas
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The mean of a sequence of numbers
7
+ class Mean < Aggregate
8
+
9
+ DEFAULT = [ 0, nil ].freeze
10
+
11
+ # Return the count and mean for a sequence of numbers
12
+ #
13
+ # @example
14
+ # count, mean = Mean.call([ count, mean ], value)
15
+ #
16
+ # @param [Array(Integer, Numeric)] accumulator
17
+ #
18
+ # @param [Numeric] value
19
+ #
20
+ # @return [Array(Integer, Numeric)]
21
+ #
22
+ # @api public
23
+ def self.call(accumulator, value)
24
+ return accumulator if value.nil?
25
+ count, mean = accumulator
26
+ count = Count.call(count, value)
27
+ [ count, mean.nil? ? value.to_f : mean + ((value - mean) / count.to_f) ]
28
+ end
29
+
30
+ # Extract the mean from the accumulator
31
+ #
32
+ # @example
33
+ # mean = Mean.finalize(accumulator)
34
+ #
35
+ # @param [Array(Integer, Numeric)] accumulator
36
+ #
37
+ # @return [Float]
38
+ # returned for a non-empty set
39
+ # @return [nil]
40
+ # returned for an empty set
41
+ #
42
+ # @api public
43
+ def self.finalize(accumulator)
44
+ accumulator.last
45
+ end
46
+
47
+ # Return the type returned from #call
48
+ #
49
+ # @return [Class<Attribute::Float>]
50
+ #
51
+ # @api public
52
+ def type
53
+ Attribute::Float
54
+ end
55
+
56
+ module Methods
57
+ extend Aliasable
58
+
59
+ inheritable_alias(
60
+ :average => :mean,
61
+ :avg => :mean
62
+ )
63
+
64
+ # Return a mean aggregate function
65
+ #
66
+ # @example
67
+ # mean = attribute.mean
68
+ #
69
+ # @param [Attribute]
70
+ #
71
+ # @return [Mean]
72
+ #
73
+ # @api public
74
+ def mean
75
+ Mean.new(self)
76
+ end
77
+
78
+ end # module Methods
79
+ end # class Mean
80
+ end # class Aggregate
81
+ end # module Veritas
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The maximum value in a sequence of numbers
7
+ class Minimum < Aggregate
8
+
9
+ DEFAULT = Float::INFINITY
10
+
11
+ # Return the minimum value for a sequence of numbers
12
+ #
13
+ # @example
14
+ # minimum = Minimum.call(minimum, value)
15
+ #
16
+ # @param [Numeric] minimum
17
+ #
18
+ # @param [Numeric] value
19
+ #
20
+ # @return [Numeric]
21
+ #
22
+ # @api public
23
+ def self.call(minimum, value)
24
+ return minimum if value.nil?
25
+ value < minimum ? value : minimum
26
+ end
27
+
28
+ # Return the type returned from #call
29
+ #
30
+ # @return [Class<Attribute::Numeric>]
31
+ #
32
+ # @api public
33
+ def type
34
+ Attribute.infer_type(operand)
35
+ end
36
+
37
+ module Methods
38
+ extend Aliasable
39
+
40
+ inheritable_alias(:min => :minimum)
41
+
42
+ # Return a minimum aggregate function
43
+ #
44
+ # @example
45
+ # minimum = attribute.minimum
46
+ #
47
+ # @param [Attribute]
48
+ #
49
+ # @return [Minimum]
50
+ #
51
+ # @api public
52
+ def minimum
53
+ Minimum.new(self)
54
+ end
55
+
56
+ end # module Methods
57
+ end # class Minimum
58
+ end # class Aggregate
59
+ end # module Veritas
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The standard deviation of a sequence of numbers
7
+ class StandardDeviation < Variance
8
+
9
+ # Calculate the standard deviation from the accumulator
10
+ #
11
+ # @example
12
+ # standard_deviation = StandardDeviation.finalize(accumulator)
13
+ #
14
+ # @param [Array(Numeric, Integer, Numeric)] accumulator
15
+ #
16
+ # @return [Float]
17
+ # returned for a non-empty set
18
+ # @return [nil]
19
+ # returned for an empty set
20
+ #
21
+ # @api public
22
+ def self.finalize(*)
23
+ variance = super
24
+ Math.sqrt(variance) if variance
25
+ end
26
+
27
+ # Return the type returned from #call
28
+ #
29
+ # @return [Class<Attribute::Float>]
30
+ #
31
+ # @api public
32
+ def type
33
+ Attribute::Float
34
+ end
35
+
36
+ module Methods
37
+ extend Aliasable
38
+
39
+ inheritable_alias(:stddev => :standard_deviation)
40
+
41
+ # Return a standard deviation aggregate function
42
+ #
43
+ # @example
44
+ # standard_deviation = attribute.standard_deviation
45
+ #
46
+ # @param [Attribute]
47
+ #
48
+ # @return [StandardDeviation]
49
+ #
50
+ # @api public
51
+ def standard_deviation
52
+ StandardDeviation.new(self)
53
+ end
54
+
55
+ end # module Methods
56
+ end # class StandardDeviation
57
+ end # class Aggregate
58
+ end # module Veritas
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+
3
+ module Veritas
4
+ class Aggregate
5
+
6
+ # The sum of a sequence of numbers
7
+ class Sum < Aggregate
8
+
9
+ DEFAULT = 0
10
+
11
+ # Return the sum for a sequence of numbers
12
+ #
13
+ # @example
14
+ # sum = Sum.call(sum, value)
15
+ #
16
+ # @param [Numeric] sum
17
+ #
18
+ # @param [Object] value
19
+ #
20
+ # @return [Numeric]
21
+ #
22
+ # @api public
23
+ def self.call(sum, value)
24
+ return sum if value.nil?
25
+ sum + value
26
+ end
27
+
28
+ # Return the default sum
29
+ #
30
+ # @example when the operand is a float
31
+ # default = sum.default # => 0.0
32
+ #
33
+ # @example when the operand is a decimal
34
+ # default = sum.default # => BigDecimal('0.0')
35
+ #
36
+ # @example when the operand is an integer
37
+ # default = sum.default # => 0
38
+ #
39
+ # @return [Numeric]
40
+ #
41
+ # @todo refactor once functions know their return types
42
+ #
43
+ # @api public
44
+ def default
45
+ type = self.type
46
+ if type.equal?(Attribute::Float) then super.to_f
47
+ elsif type.equal?(Attribute::Decimal) then BigDecimal(super.to_s)
48
+ else
49
+ super
50
+ end
51
+ end
52
+
53
+ # Return the type returned from #call
54
+ #
55
+ # @return [Class<Attribute::Numeric>]
56
+ #
57
+ # @api public
58
+ def type
59
+ Attribute.infer_type(operand)
60
+ end
61
+
62
+ module Methods
63
+
64
+ # Return a sum aggregate function
65
+ #
66
+ # @example
67
+ # sum = attribute.sum
68
+ #
69
+ # @param [Attribute]
70
+ #
71
+ # @return [Sum]
72
+ #
73
+ # @api public
74
+ def sum
75
+ Sum.new(self)
76
+ end
77
+
78
+ end # module Methods
79
+ end # class Sum
80
+ end # class Aggregate
81
+ end # module Veritas