alf 0.12.2 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (549) hide show
  1. data/CHANGELOG.md +186 -80
  2. data/Gemfile +16 -32
  3. data/Gemfile.lock +35 -34
  4. data/LICENCE.md +1 -1
  5. data/Manifest.txt +7 -9
  6. data/README.md +139 -809
  7. data/alf.gemspec +6 -15
  8. data/alf.noespec +16 -34
  9. data/lib/alf.rb +3 -73
  10. data/lib/alf/loader.rb +3 -3
  11. data/lib/alf/version.rb +2 -2
  12. data/spec/spec_helper.rb +3 -18
  13. data/spec/test_alf.rb +8 -0
  14. data/tasks/test.rake +6 -0
  15. data/test/migrations/test_folder_migration.rb +18 -0
  16. data/test/migrations/test_sequel_migration.rb +34 -0
  17. data/test/seeding/test_seeding.rb +49 -0
  18. data/test/test_alf.rb +8 -0
  19. data/test/test_helpers.rb +24 -0
  20. metadata +54 -952
  21. data/TODO.md +0 -21
  22. data/bin/alf +0 -27
  23. data/doc/commands/exec.md +0 -16
  24. data/doc/commands/help.md +0 -11
  25. data/doc/commands/main.md +0 -33
  26. data/doc/commands/show.md +0 -19
  27. data/doc/operators/non_relational/autonum.md +0 -23
  28. data/doc/operators/non_relational/clip.md +0 -31
  29. data/doc/operators/non_relational/coerce.md +0 -15
  30. data/doc/operators/non_relational/compact.md +0 -20
  31. data/doc/operators/non_relational/defaults.md +0 -32
  32. data/doc/operators/non_relational/generator.md +0 -20
  33. data/doc/operators/non_relational/sort.md +0 -24
  34. data/doc/operators/relational/extend.md +0 -18
  35. data/doc/operators/relational/group.md +0 -27
  36. data/doc/operators/relational/heading.md +0 -20
  37. data/doc/operators/relational/intersect.md +0 -13
  38. data/doc/operators/relational/join.md +0 -28
  39. data/doc/operators/relational/matching.md +0 -24
  40. data/doc/operators/relational/minus.md +0 -12
  41. data/doc/operators/relational/not-matching.md +0 -20
  42. data/doc/operators/relational/project.md +0 -28
  43. data/doc/operators/relational/quota.md +0 -21
  44. data/doc/operators/relational/rank.md +0 -27
  45. data/doc/operators/relational/rename.md +0 -17
  46. data/doc/operators/relational/restrict.md +0 -25
  47. data/doc/operators/relational/summarize.md +0 -25
  48. data/doc/operators/relational/ungroup.md +0 -20
  49. data/doc/operators/relational/union.md +0 -14
  50. data/doc/operators/relational/unwrap.md +0 -20
  51. data/doc/operators/relational/wrap.md +0 -24
  52. data/examples/csv/suppliers.csv +0 -6
  53. data/examples/logs/access.log +0 -1000
  54. data/examples/logs/combined.alf +0 -2
  55. data/examples/logs/hits.alf +0 -14
  56. data/examples/logs/not_found.alf +0 -7
  57. data/examples/logs/robots-cheating.alf +0 -11
  58. data/examples/logs/robots.alf +0 -8
  59. data/examples/operators/autonum.alf +0 -6
  60. data/examples/operators/cities.rash +0 -4
  61. data/examples/operators/clip.alf +0 -3
  62. data/examples/operators/compact.alf +0 -2
  63. data/examples/operators/database.alf +0 -5
  64. data/examples/operators/defaults.alf +0 -3
  65. data/examples/operators/extend.alf +0 -3
  66. data/examples/operators/group.alf +0 -3
  67. data/examples/operators/intersect.alf +0 -4
  68. data/examples/operators/join.alf +0 -2
  69. data/examples/operators/matching.alf +0 -2
  70. data/examples/operators/minus.alf +0 -8
  71. data/examples/operators/not_matching.alf +0 -2
  72. data/examples/operators/nulls.rash +0 -3
  73. data/examples/operators/parts.rash +0 -6
  74. data/examples/operators/project.alf +0 -3
  75. data/examples/operators/pseudo-with.alf +0 -7
  76. data/examples/operators/quota.alf +0 -4
  77. data/examples/operators/rank.alf +0 -4
  78. data/examples/operators/rename.alf +0 -3
  79. data/examples/operators/restrict.alf +0 -2
  80. data/examples/operators/schema.yaml +0 -28
  81. data/examples/operators/sort.alf +0 -4
  82. data/examples/operators/summarize.alf +0 -16
  83. data/examples/operators/suppliers.rash +0 -5
  84. data/examples/operators/supplies.rash +0 -12
  85. data/examples/operators/ungroup.alf +0 -4
  86. data/examples/operators/union.alf +0 -3
  87. data/examples/operators/unwrap.alf +0 -4
  88. data/examples/operators/wrap.alf +0 -2
  89. data/lib/alf-csv/alf/csv.rb +0 -3
  90. data/lib/alf-csv/alf/csv/commons.rb +0 -36
  91. data/lib/alf-csv/alf/csv/reader.rb +0 -33
  92. data/lib/alf-csv/alf/csv/renderer.rb +0 -38
  93. data/lib/alf-engine/alf/engine.rb +0 -25
  94. data/lib/alf-engine/alf/engine/aggregate.rb +0 -44
  95. data/lib/alf-engine/alf/engine/autonum.rb +0 -45
  96. data/lib/alf-engine/alf/engine/cesure.rb +0 -45
  97. data/lib/alf-engine/alf/engine/clip.rb +0 -53
  98. data/lib/alf-engine/alf/engine/coerce.rb +0 -46
  99. data/lib/alf-engine/alf/engine/cog.rb +0 -7
  100. data/lib/alf-engine/alf/engine/compact.rb +0 -26
  101. data/lib/alf-engine/alf/engine/compact/set.rb +0 -23
  102. data/lib/alf-engine/alf/engine/compact/uniq.rb +0 -23
  103. data/lib/alf-engine/alf/engine/concat.rb +0 -25
  104. data/lib/alf-engine/alf/engine/defaults.rb +0 -43
  105. data/lib/alf-engine/alf/engine/filter.rb +0 -41
  106. data/lib/alf-engine/alf/engine/generator.rb +0 -50
  107. data/lib/alf-engine/alf/engine/group.rb +0 -7
  108. data/lib/alf-engine/alf/engine/group/hash.rb +0 -40
  109. data/lib/alf-engine/alf/engine/join.rb +0 -7
  110. data/lib/alf-engine/alf/engine/join/hash.rb +0 -35
  111. data/lib/alf-engine/alf/engine/materialize.rb +0 -8
  112. data/lib/alf-engine/alf/engine/materialize/array.rb +0 -78
  113. data/lib/alf-engine/alf/engine/materialize/hash.rb +0 -122
  114. data/lib/alf-engine/alf/engine/quota.rb +0 -7
  115. data/lib/alf-engine/alf/engine/quota/cesure.rb +0 -46
  116. data/lib/alf-engine/alf/engine/rank.rb +0 -7
  117. data/lib/alf-engine/alf/engine/rank/cesure.rb +0 -48
  118. data/lib/alf-engine/alf/engine/rename.rb +0 -39
  119. data/lib/alf-engine/alf/engine/semi.rb +0 -7
  120. data/lib/alf-engine/alf/engine/semi/hash.rb +0 -39
  121. data/lib/alf-engine/alf/engine/set_attr.rb +0 -46
  122. data/lib/alf-engine/alf/engine/sort.rb +0 -28
  123. data/lib/alf-engine/alf/engine/sort/in_memory.rb +0 -39
  124. data/lib/alf-engine/alf/engine/summarize.rb +0 -8
  125. data/lib/alf-engine/alf/engine/summarize/cesure.rb +0 -51
  126. data/lib/alf-engine/alf/engine/summarize/hash.rb +0 -35
  127. data/lib/alf-engine/alf/engine/ungroup.rb +0 -29
  128. data/lib/alf-engine/alf/engine/unwrap.rb +0 -31
  129. data/lib/alf-engine/alf/engine/wrap.rb +0 -39
  130. data/lib/alf-logs/alf/logs.rb +0 -1
  131. data/lib/alf-logs/alf/logs/reader.rb +0 -98
  132. data/lib/alf-sequel/alf/sequel.rb +0 -2
  133. data/lib/alf-sequel/alf/sequel/environment.rb +0 -61
  134. data/lib/alf-sequel/alf/sequel/iterator.rb +0 -21
  135. data/lib/alf-shell/alf/shell.rb +0 -40
  136. data/lib/alf-shell/alf/shell/command.rb +0 -26
  137. data/lib/alf-shell/alf/shell/command/exec.rb +0 -11
  138. data/lib/alf-shell/alf/shell/command/help.rb +0 -30
  139. data/lib/alf-shell/alf/shell/command/main.rb +0 -136
  140. data/lib/alf-shell/alf/shell/command/main/class_methods.rb +0 -46
  141. data/lib/alf-shell/alf/shell/command/show.rb +0 -63
  142. data/lib/alf-shell/alf/shell/doc_manager.rb +0 -72
  143. data/lib/alf-shell/alf/shell/operator.rb +0 -86
  144. data/lib/alf-yaml/alf/yaml.rb +0 -1
  145. data/lib/alf-yaml/alf/yaml/renderer.rb +0 -22
  146. data/lib/alf/aggregator.rb +0 -51
  147. data/lib/alf/aggregator/avg.rb +0 -39
  148. data/lib/alf/aggregator/class_methods.rb +0 -77
  149. data/lib/alf/aggregator/collect.rb +0 -32
  150. data/lib/alf/aggregator/concat.rb +0 -47
  151. data/lib/alf/aggregator/count.rb +0 -32
  152. data/lib/alf/aggregator/instance_methods.rb +0 -119
  153. data/lib/alf/aggregator/max.rb +0 -32
  154. data/lib/alf/aggregator/min.rb +0 -32
  155. data/lib/alf/aggregator/stddev.rb +0 -25
  156. data/lib/alf/aggregator/sum.rb +0 -32
  157. data/lib/alf/aggregator/variance.rb +0 -45
  158. data/lib/alf/environment.rb +0 -34
  159. data/lib/alf/environment/class_methods.rb +0 -95
  160. data/lib/alf/environment/folder.rb +0 -60
  161. data/lib/alf/environment/instance_methods.rb +0 -26
  162. data/lib/alf/errors.rb +0 -5
  163. data/lib/alf/ext.rb +0 -4
  164. data/lib/alf/ext/relation.rb +0 -4
  165. data/lib/alf/iterator.rb +0 -28
  166. data/lib/alf/iterator/class_methods.rb +0 -20
  167. data/lib/alf/iterator/proxy.rb +0 -27
  168. data/lib/alf/lispy.rb +0 -24
  169. data/lib/alf/lispy/instance_methods.rb +0 -157
  170. data/lib/alf/operator.rb +0 -68
  171. data/lib/alf/operator/binary.rb +0 -21
  172. data/lib/alf/operator/class_methods.rb +0 -82
  173. data/lib/alf/operator/experimental.rb +0 -9
  174. data/lib/alf/operator/instance_methods.rb +0 -29
  175. data/lib/alf/operator/non_relational/autonum.rb +0 -19
  176. data/lib/alf/operator/non_relational/clip.rb +0 -20
  177. data/lib/alf/operator/non_relational/coerce.rb +0 -19
  178. data/lib/alf/operator/non_relational/compact.rb +0 -18
  179. data/lib/alf/operator/non_relational/defaults.rb +0 -22
  180. data/lib/alf/operator/non_relational/generator.rb +0 -20
  181. data/lib/alf/operator/non_relational/sort.rb +0 -19
  182. data/lib/alf/operator/nullary.rb +0 -11
  183. data/lib/alf/operator/relational/extend.rb +0 -19
  184. data/lib/alf/operator/relational/group.rb +0 -21
  185. data/lib/alf/operator/relational/heading.rb +0 -20
  186. data/lib/alf/operator/relational/intersect.rb +0 -18
  187. data/lib/alf/operator/relational/join.rb +0 -18
  188. data/lib/alf/operator/relational/matching.rb +0 -18
  189. data/lib/alf/operator/relational/minus.rb +0 -18
  190. data/lib/alf/operator/relational/not_matching.rb +0 -18
  191. data/lib/alf/operator/relational/project.rb +0 -22
  192. data/lib/alf/operator/relational/quota.rb +0 -23
  193. data/lib/alf/operator/relational/rank.rb +0 -22
  194. data/lib/alf/operator/relational/rename.rb +0 -18
  195. data/lib/alf/operator/relational/restrict.rb +0 -18
  196. data/lib/alf/operator/relational/summarize.rb +0 -27
  197. data/lib/alf/operator/relational/ungroup.rb +0 -19
  198. data/lib/alf/operator/relational/union.rb +0 -20
  199. data/lib/alf/operator/relational/unwrap.rb +0 -19
  200. data/lib/alf/operator/relational/wrap.rb +0 -20
  201. data/lib/alf/operator/signature.rb +0 -233
  202. data/lib/alf/operator/unary.rb +0 -16
  203. data/lib/alf/reader.rb +0 -37
  204. data/lib/alf/reader/alf_file.rb +0 -24
  205. data/lib/alf/reader/class_methods.rb +0 -91
  206. data/lib/alf/reader/instance_methods.rb +0 -97
  207. data/lib/alf/reader/rash.rb +0 -28
  208. data/lib/alf/relation.rb +0 -28
  209. data/lib/alf/relation/class_methods.rb +0 -28
  210. data/lib/alf/relation/instance_methods.rb +0 -119
  211. data/lib/alf/renderer.rb +0 -32
  212. data/lib/alf/renderer/class_methods.rb +0 -58
  213. data/lib/alf/renderer/instance_methods.rb +0 -55
  214. data/lib/alf/renderer/rash.rb +0 -33
  215. data/lib/alf/renderer/text.rb +0 -198
  216. data/lib/alf/tools.rb +0 -15
  217. data/lib/alf/tools/coerce.rb +0 -25
  218. data/lib/alf/tools/miscellaneous.rb +0 -111
  219. data/lib/alf/tools/to_lispy.rb +0 -96
  220. data/lib/alf/tools/to_relation.rb +0 -54
  221. data/lib/alf/tools/to_ruby_literal.rb +0 -31
  222. data/lib/alf/tools/tuple_handle.rb +0 -60
  223. data/lib/alf/types.rb +0 -49
  224. data/lib/alf/types/attr_list.rb +0 -160
  225. data/lib/alf/types/attr_name.rb +0 -66
  226. data/lib/alf/types/boolean.rb +0 -25
  227. data/lib/alf/types/heading.rb +0 -135
  228. data/lib/alf/types/ordering.rb +0 -146
  229. data/lib/alf/types/renaming.rb +0 -97
  230. data/lib/alf/types/size.rb +0 -57
  231. data/lib/alf/types/summarization.rb +0 -138
  232. data/lib/alf/types/tuple_computation.rb +0 -136
  233. data/lib/alf/types/tuple_expression.rb +0 -152
  234. data/lib/alf/types/tuple_predicate.rb +0 -73
  235. data/spec/integration/__database__/group.alf +0 -3
  236. data/spec/integration/__database__/parts.rash +0 -6
  237. data/spec/integration/__database__/suppliers.rash +0 -5
  238. data/spec/integration/__database__/suppliers_csv.csv +0 -6
  239. data/spec/integration/__database__/supplies.rash +0 -12
  240. data/spec/integration/alf/example.rash +0 -1
  241. data/spec/integration/alf/test_Relation.rb +0 -32
  242. data/spec/integration/ext/test_relation.rb +0 -16
  243. data/spec/integration/lispy/test_relation.rb +0 -37
  244. data/spec/integration/lispy/test_run.rb +0 -40
  245. data/spec/integration/lispy/test_tuple.rb +0 -36
  246. data/spec/integration/semantics/test_join.alf +0 -9
  247. data/spec/integration/semantics/test_minus.alf +0 -5
  248. data/spec/integration/semantics/test_project.alf +0 -8
  249. data/spec/integration/semantics/test_rank.alf +0 -34
  250. data/spec/integration/shell/alf/alf.db +0 -0
  251. data/spec/integration/shell/alf/alf_e.cmd +0 -1
  252. data/spec/integration/shell/alf/alf_e.stdout +0 -4
  253. data/spec/integration/shell/alf/alf_env.cmd +0 -1
  254. data/spec/integration/shell/alf/alf_env.stdout +0 -5
  255. data/spec/integration/shell/alf/alf_env_sqlite.cmd +0 -1
  256. data/spec/integration/shell/alf/alf_env_sqlite.stdout +0 -9
  257. data/spec/integration/shell/alf/alf_help.cmd +0 -1
  258. data/spec/integration/shell/alf/alf_help.stdout +0 -69
  259. data/spec/integration/shell/alf/alf_implicit.alf +0 -1
  260. data/spec/integration/shell/alf/alf_implicit_exec.cmd +0 -1
  261. data/spec/integration/shell/alf/alf_implicit_exec.stdout +0 -4
  262. data/spec/integration/shell/alf/alf_r.cmd +0 -1
  263. data/spec/integration/shell/alf/alf_r.stdout +0 -5
  264. data/spec/integration/shell/alf/alf_version.cmd +0 -1
  265. data/spec/integration/shell/alf/alf_version.stdout +0 -2
  266. data/spec/integration/shell/alf/alf_yaml.cmd +0 -1
  267. data/spec/integration/shell/alf/alf_yaml.stdout +0 -22
  268. data/spec/integration/shell/alf/rel.rash +0 -1
  269. data/spec/integration/shell/autonum/autonum_0.cmd +0 -1
  270. data/spec/integration/shell/autonum/autonum_0.stdout +0 -9
  271. data/spec/integration/shell/autonum/autonum_1.cmd +0 -1
  272. data/spec/integration/shell/autonum/autonum_1.stdout +0 -9
  273. data/spec/integration/shell/clip/clip_0.cmd +0 -1
  274. data/spec/integration/shell/clip/clip_0.stdout +0 -9
  275. data/spec/integration/shell/clip/clip_1.cmd +0 -1
  276. data/spec/integration/shell/clip/clip_1.stdout +0 -9
  277. data/spec/integration/shell/coerce/coerce_1.cmd +0 -1
  278. data/spec/integration/shell/coerce/coerce_1.stdout +0 -5
  279. data/spec/integration/shell/compact/compact_0.cmd +0 -1
  280. data/spec/integration/shell/compact/compact_0.stdout +0 -9
  281. data/spec/integration/shell/defaults/defaults_0.cmd +0 -1
  282. data/spec/integration/shell/defaults/defaults_0.stdout +0 -9
  283. data/spec/integration/shell/defaults/defaults_1.cmd +0 -1
  284. data/spec/integration/shell/defaults/defaults_1.stdout +0 -9
  285. data/spec/integration/shell/defaults/defaults_2.cmd +0 -1
  286. data/spec/integration/shell/defaults/defaults_2.stdout +0 -9
  287. data/spec/integration/shell/extend/extend_0.cmd +0 -1
  288. data/spec/integration/shell/extend/extend_0.stdout +0 -16
  289. data/spec/integration/shell/generator/generator_1.cmd +0 -1
  290. data/spec/integration/shell/generator/generator_1.stdout +0 -10
  291. data/spec/integration/shell/generator/generator_2.cmd +0 -1
  292. data/spec/integration/shell/generator/generator_2.stdout +0 -5
  293. data/spec/integration/shell/generator/generator_3.cmd +0 -1
  294. data/spec/integration/shell/generator/generator_3.stdout +0 -5
  295. data/spec/integration/shell/group/group_0.cmd +0 -1
  296. data/spec/integration/shell/group/group_0.stdout +0 -32
  297. data/spec/integration/shell/group/group_1.cmd +0 -1
  298. data/spec/integration/shell/group/group_1.stdout +0 -32
  299. data/spec/integration/shell/help/help_1.cmd +0 -1
  300. data/spec/integration/shell/help/help_1.stdout +0 -24
  301. data/spec/integration/shell/intersect/intersect_0.cmd +0 -1
  302. data/spec/integration/shell/intersect/intersect_0.stdout +0 -9
  303. data/spec/integration/shell/join/join_0.cmd +0 -1
  304. data/spec/integration/shell/join/join_0.stdout +0 -16
  305. data/spec/integration/shell/matching/matching_0.cmd +0 -1
  306. data/spec/integration/shell/matching/matching_0.stdout +0 -8
  307. data/spec/integration/shell/minus/minus_0.cmd +0 -1
  308. data/spec/integration/shell/minus/minus_0.stdout +0 -4
  309. data/spec/integration/shell/not-matching/not-matching_0.cmd +0 -1
  310. data/spec/integration/shell/not-matching/not-matching_0.stdout +0 -5
  311. data/spec/integration/shell/project/project_0.cmd +0 -1
  312. data/spec/integration/shell/project/project_0.stdout +0 -9
  313. data/spec/integration/shell/project/project_1.cmd +0 -1
  314. data/spec/integration/shell/project/project_1.stdout +0 -9
  315. data/spec/integration/shell/quota/quota_0.cmd +0 -1
  316. data/spec/integration/shell/quota/quota_0.stdout +0 -16
  317. data/spec/integration/shell/rank/rank_1.cmd +0 -1
  318. data/spec/integration/shell/rank/rank_1.stdout +0 -10
  319. data/spec/integration/shell/rank/rank_2.cmd +0 -1
  320. data/spec/integration/shell/rank/rank_2.stdout +0 -10
  321. data/spec/integration/shell/rank/rank_3.cmd +0 -1
  322. data/spec/integration/shell/rank/rank_3.stdout +0 -10
  323. data/spec/integration/shell/rank/rank_4.cmd +0 -1
  324. data/spec/integration/shell/rank/rank_4.stdout +0 -6
  325. data/spec/integration/shell/rank/rank_5.cmd +0 -1
  326. data/spec/integration/shell/rank/rank_5.stdout +0 -6
  327. data/spec/integration/shell/rename/rename_0.cmd +0 -1
  328. data/spec/integration/shell/rename/rename_0.stdout +0 -9
  329. data/spec/integration/shell/restrict/restrict_0.cmd +0 -1
  330. data/spec/integration/shell/restrict/restrict_0.stdout +0 -6
  331. data/spec/integration/shell/restrict/restrict_1.cmd +0 -1
  332. data/spec/integration/shell/restrict/restrict_1.stdout +0 -6
  333. data/spec/integration/shell/show/show_base.cmd +0 -1
  334. data/spec/integration/shell/show/show_base.stdout +0 -9
  335. data/spec/integration/shell/show/show_base_sort_1.cmd +0 -1
  336. data/spec/integration/shell/show/show_base_sort_1.stdout +0 -9
  337. data/spec/integration/shell/show/show_base_sort_2.cmd +0 -1
  338. data/spec/integration/shell/show/show_base_sort_2.stdout +0 -9
  339. data/spec/integration/shell/show/show_conflictual.cmd +0 -1
  340. data/spec/integration/shell/show/show_conflictual.stdout +0 -5
  341. data/spec/integration/shell/show/show_csv.cmd +0 -1
  342. data/spec/integration/shell/show/show_csv.stdout +0 -6
  343. data/spec/integration/shell/show/show_ff.cmd +0 -1
  344. data/spec/integration/shell/show/show_ff.stdout +0 -10
  345. data/spec/integration/shell/show/show_rash.cmd +0 -1
  346. data/spec/integration/shell/show/show_rash.stdout +0 -5
  347. data/spec/integration/shell/show/show_rash_pretty.cmd +0 -1
  348. data/spec/integration/shell/show/show_rash_pretty.stdout +0 -30
  349. data/spec/integration/shell/show/show_yaml.cmd +0 -1
  350. data/spec/integration/shell/show/show_yaml.stdout +0 -22
  351. data/spec/integration/shell/sort/sort_0.cmd +0 -1
  352. data/spec/integration/shell/sort/sort_0.stdout +0 -9
  353. data/spec/integration/shell/sort/sort_1.cmd +0 -1
  354. data/spec/integration/shell/sort/sort_1.stdout +0 -9
  355. data/spec/integration/shell/sort/sort_2.cmd +0 -1
  356. data/spec/integration/shell/sort/sort_2.stdout +0 -9
  357. data/spec/integration/shell/sort/sort_3.cmd +0 -1
  358. data/spec/integration/shell/sort/sort_3.stdout +0 -9
  359. data/spec/integration/shell/summarize/summarize_0.cmd +0 -1
  360. data/spec/integration/shell/summarize/summarize_0.stdout +0 -8
  361. data/spec/integration/shell/ungroup/ungroup_0.cmd +0 -1
  362. data/spec/integration/shell/ungroup/ungroup_0.stdout +0 -16
  363. data/spec/integration/shell/union/union_0.cmd +0 -1
  364. data/spec/integration/shell/union/union_0.stdout +0 -9
  365. data/spec/integration/shell/unwrap/unwrap_0.cmd +0 -1
  366. data/spec/integration/shell/unwrap/unwrap_0.stdout +0 -9
  367. data/spec/integration/shell/wrap/wrap_0.cmd +0 -1
  368. data/spec/integration/shell/wrap/wrap_0.stdout +0 -9
  369. data/spec/integration/test_alf.rb +0 -34
  370. data/spec/integration/test_examples.rb +0 -15
  371. data/spec/integration/test_lispy.rb +0 -31
  372. data/spec/integration/test_semantics.rb +0 -40
  373. data/spec/integration/test_shell.rb +0 -47
  374. data/spec/regression/alf_file/__FILE__.alf +0 -2
  375. data/spec/regression/alf_file/suppliers.rash +0 -5
  376. data/spec/regression/alf_file/test___FILE__.rb +0 -17
  377. data/spec/regression/heading/test_heading_with_date.rb +0 -12
  378. data/spec/regression/lispy/test_compile.rb +0 -14
  379. data/spec/regression/logs/apache_combined.log +0 -5
  380. data/spec/regression/logs/test_path_attribute.rb +0 -25
  381. data/spec/regression/relation/test_relation_allbut_all.rb +0 -14
  382. data/spec/regression/relation/test_relation_with_date.rb +0 -12
  383. data/spec/regression/restrict/test_restrict_with_keywords.rb +0 -17
  384. data/spec/shared/a_valid_type_implementation.rb +0 -47
  385. data/spec/shared/a_value.rb +0 -12
  386. data/spec/shared/an_operator_class.rb +0 -36
  387. data/spec/unit/alf-core/aggregator/test_avg.rb +0 -22
  388. data/spec/unit/alf-core/aggregator/test_collect.rb +0 -25
  389. data/spec/unit/alf-core/aggregator/test_concat.rb +0 -31
  390. data/spec/unit/alf-core/aggregator/test_count.rb +0 -17
  391. data/spec/unit/alf-core/aggregator/test_max.rb +0 -23
  392. data/spec/unit/alf-core/aggregator/test_min.rb +0 -23
  393. data/spec/unit/alf-core/aggregator/test_stddev.rb +0 -27
  394. data/spec/unit/alf-core/aggregator/test_sum.rb +0 -23
  395. data/spec/unit/alf-core/aggregator/test_variance.rb +0 -29
  396. data/spec/unit/alf-core/assumptions/test_file.rb +0 -17
  397. data/spec/unit/alf-core/assumptions/test_instance_eval.rb +0 -15
  398. data/spec/unit/alf-core/assumptions/test_scoping.rb +0 -29
  399. data/spec/unit/alf-core/assumptions/test_set.rb +0 -64
  400. data/spec/unit/alf-core/environment/examples/suppliers.rash +0 -5
  401. data/spec/unit/alf-core/environment/test_folder.rb +0 -53
  402. data/spec/unit/alf-core/operator/non_relational/test_autonum.rb +0 -48
  403. data/spec/unit/alf-core/operator/non_relational/test_clip.rb +0 -35
  404. data/spec/unit/alf-core/operator/non_relational/test_coerce.rb +0 -29
  405. data/spec/unit/alf-core/operator/non_relational/test_compact.rb +0 -32
  406. data/spec/unit/alf-core/operator/non_relational/test_defaults.rb +0 -53
  407. data/spec/unit/alf-core/operator/non_relational/test_generator.rb +0 -60
  408. data/spec/unit/alf-core/operator/non_relational/test_sort.rb +0 -60
  409. data/spec/unit/alf-core/operator/relational/test_extend.rb +0 -28
  410. data/spec/unit/alf-core/operator/relational/test_group.rb +0 -39
  411. data/spec/unit/alf-core/operator/relational/test_heading.rb +0 -27
  412. data/spec/unit/alf-core/operator/relational/test_intersect.rb +0 -58
  413. data/spec/unit/alf-core/operator/relational/test_join.rb +0 -36
  414. data/spec/unit/alf-core/operator/relational/test_minus.rb +0 -56
  415. data/spec/unit/alf-core/operator/relational/test_project.rb +0 -62
  416. data/spec/unit/alf-core/operator/relational/test_quota.rb +0 -36
  417. data/spec/unit/alf-core/operator/relational/test_rank.rb +0 -48
  418. data/spec/unit/alf-core/operator/relational/test_rename.rb +0 -26
  419. data/spec/unit/alf-core/operator/relational/test_restrict.rb +0 -45
  420. data/spec/unit/alf-core/operator/relational/test_summarize.rb +0 -44
  421. data/spec/unit/alf-core/operator/relational/test_ungroup.rb +0 -29
  422. data/spec/unit/alf-core/operator/relational/test_union.rb +0 -35
  423. data/spec/unit/alf-core/operator/relational/test_unwrap.rb +0 -26
  424. data/spec/unit/alf-core/operator/relational/test_wrap.rb +0 -26
  425. data/spec/unit/alf-core/operator/signature/test_argv2args.rb +0 -82
  426. data/spec/unit/alf-core/operator/signature/test_collect_on.rb +0 -38
  427. data/spec/unit/alf-core/operator/signature/test_initialize.rb +0 -17
  428. data/spec/unit/alf-core/operator/signature/test_install.rb +0 -56
  429. data/spec/unit/alf-core/operator/signature/test_option_parser.rb +0 -36
  430. data/spec/unit/alf-core/operator/signature/test_parse_args.rb +0 -90
  431. data/spec/unit/alf-core/operator/signature/test_to_lispy.rb +0 -102
  432. data/spec/unit/alf-core/operator/signature/test_to_shell.rb +0 -103
  433. data/spec/unit/alf-core/operator/test_non_relational.rb +0 -20
  434. data/spec/unit/alf-core/operator/test_relational.rb +0 -31
  435. data/spec/unit/alf-core/reader/input.rb +0 -2
  436. data/spec/unit/alf-core/reader/test_alf_file.rb +0 -30
  437. data/spec/unit/alf-core/reader/test_initialize.rb +0 -60
  438. data/spec/unit/alf-core/reader/test_looks_a_path.rb +0 -20
  439. data/spec/unit/alf-core/reader/test_rash.rb +0 -31
  440. data/spec/unit/alf-core/relation/test_coerce.rb +0 -53
  441. data/spec/unit/alf-core/relation/test_inspect.rb +0 -20
  442. data/spec/unit/alf-core/relation/test_relops.rb +0 -55
  443. data/spec/unit/alf-core/relation/test_to_a.rb +0 -41
  444. data/spec/unit/alf-core/renderer/test_initialize.rb +0 -60
  445. data/spec/unit/alf-core/test_aggregator.rb +0 -58
  446. data/spec/unit/alf-core/test_environment.rb +0 -30
  447. data/spec/unit/alf-core/test_operator.rb +0 -16
  448. data/spec/unit/alf-core/test_reader.rb +0 -40
  449. data/spec/unit/alf-core/test_relation.rb +0 -75
  450. data/spec/unit/alf-core/test_renderer.rb +0 -53
  451. data/spec/unit/alf-core/text/test_cell.rb +0 -35
  452. data/spec/unit/alf-core/text/test_row.rb +0 -30
  453. data/spec/unit/alf-core/text/test_table.rb +0 -39
  454. data/spec/unit/alf-core/tools/test_class_name.rb +0 -16
  455. data/spec/unit/alf-core/tools/test_coalesce.rb +0 -19
  456. data/spec/unit/alf-core/tools/test_coerce.rb +0 -16
  457. data/spec/unit/alf-core/tools/test_ruby_case.rb +0 -16
  458. data/spec/unit/alf-core/tools/test_to_lispy.rb +0 -145
  459. data/spec/unit/alf-core/tools/test_to_relation.rb +0 -39
  460. data/spec/unit/alf-core/tools/test_to_ruby_literal.rb +0 -10
  461. data/spec/unit/alf-core/tools/test_tuple_handle.rb +0 -52
  462. data/spec/unit/alf-core/tools/test_tuple_heading.rb +0 -15
  463. data/spec/unit/alf-core/tools/test_varargs.rb +0 -19
  464. data/spec/unit/alf-core/types/test_attr_list.rb +0 -188
  465. data/spec/unit/alf-core/types/test_attr_name.rb +0 -78
  466. data/spec/unit/alf-core/types/test_boolean.rb +0 -42
  467. data/spec/unit/alf-core/types/test_class_methods.rb +0 -24
  468. data/spec/unit/alf-core/types/test_heading.rb +0 -146
  469. data/spec/unit/alf-core/types/test_ordering.rb +0 -185
  470. data/spec/unit/alf-core/types/test_renaming.rb +0 -72
  471. data/spec/unit/alf-core/types/test_size.rb +0 -74
  472. data/spec/unit/alf-core/types/test_summarization.rb +0 -95
  473. data/spec/unit/alf-core/types/test_tuple_computation.rb +0 -96
  474. data/spec/unit/alf-core/types/test_tuple_expression.rb +0 -122
  475. data/spec/unit/alf-core/types/test_tuple_predicate.rb +0 -108
  476. data/spec/unit/alf-csv/input.csv +0 -3
  477. data/spec/unit/alf-csv/test_reader.rb +0 -66
  478. data/spec/unit/alf-csv/test_renderer.rb +0 -73
  479. data/spec/unit/alf-engine/compact/test_set.rb +0 -33
  480. data/spec/unit/alf-engine/compact/test_uniq.rb +0 -33
  481. data/spec/unit/alf-engine/group/test_hash.rb +0 -34
  482. data/spec/unit/alf-engine/join/test_hash.rb +0 -55
  483. data/spec/unit/alf-engine/materialize/test_array.rb +0 -28
  484. data/spec/unit/alf-engine/materialize/test_hash.rb +0 -76
  485. data/spec/unit/alf-engine/quota/test_cesure.rb +0 -34
  486. data/spec/unit/alf-engine/rank/test_cesure.rb +0 -47
  487. data/spec/unit/alf-engine/semi/test_hash.rb +0 -58
  488. data/spec/unit/alf-engine/sort/test_in_memory.rb +0 -32
  489. data/spec/unit/alf-engine/summarize/test_cesure.rb +0 -36
  490. data/spec/unit/alf-engine/summarize/test_hash.rb +0 -36
  491. data/spec/unit/alf-engine/test_aggregate.rb +0 -26
  492. data/spec/unit/alf-engine/test_autonum.rb +0 -24
  493. data/spec/unit/alf-engine/test_clip.rb +0 -34
  494. data/spec/unit/alf-engine/test_coerce.rb +0 -35
  495. data/spec/unit/alf-engine/test_compact.rb +0 -33
  496. data/spec/unit/alf-engine/test_concat.rb +0 -38
  497. data/spec/unit/alf-engine/test_defaults.rb +0 -37
  498. data/spec/unit/alf-engine/test_filter.rb +0 -23
  499. data/spec/unit/alf-engine/test_generator.rb +0 -25
  500. data/spec/unit/alf-engine/test_rename.rb +0 -24
  501. data/spec/unit/alf-engine/test_set_attr.rb +0 -38
  502. data/spec/unit/alf-engine/test_sort.rb +0 -32
  503. data/spec/unit/alf-engine/test_ungroup.rb +0 -28
  504. data/spec/unit/alf-engine/test_unwrap.rb +0 -20
  505. data/spec/unit/alf-engine/test_wrap.rb +0 -26
  506. data/spec/unit/alf-logs/apache_combined.log +0 -5
  507. data/spec/unit/alf-logs/postgresql.log +0 -29
  508. data/spec/unit/alf-logs/test_reader.rb +0 -57
  509. data/spec/unit/alf-sequel/alf.db +0 -0
  510. data/spec/unit/alf-sequel/test_environment.rb +0 -74
  511. data/spec/unit/alf-shell/doc_manager/dynamic.md +0 -1
  512. data/spec/unit/alf-shell/doc_manager/example.md +0 -1
  513. data/spec/unit/alf-shell/doc_manager/example_1.txt +0 -11
  514. data/spec/unit/alf-shell/doc_manager/static.md +0 -1
  515. data/spec/unit/alf-shell/doc_manager/test_call.rb +0 -48
  516. data/spec/unit/alf-shell/main/test_class_methods.rb +0 -44
  517. data/spec/unit/alf-shell/operator/test_autonum.rb +0 -28
  518. data/spec/unit/alf-shell/operator/test_clip.rb +0 -29
  519. data/spec/unit/alf-shell/operator/test_coerce.rb +0 -21
  520. data/spec/unit/alf-shell/operator/test_compact.rb +0 -16
  521. data/spec/unit/alf-shell/operator/test_defaults.rb +0 -29
  522. data/spec/unit/alf-shell/operator/test_extend.rb +0 -21
  523. data/spec/unit/alf-shell/operator/test_generator.rb +0 -37
  524. data/spec/unit/alf-shell/operator/test_group.rb +0 -32
  525. data/spec/unit/alf-shell/operator/test_heading.rb +0 -16
  526. data/spec/unit/alf-shell/operator/test_intersect.rb +0 -18
  527. data/spec/unit/alf-shell/operator/test_join.rb +0 -18
  528. data/spec/unit/alf-shell/operator/test_matching.rb +0 -18
  529. data/spec/unit/alf-shell/operator/test_minus.rb +0 -18
  530. data/spec/unit/alf-shell/operator/test_not_matching.rb +0 -18
  531. data/spec/unit/alf-shell/operator/test_project.rb +0 -38
  532. data/spec/unit/alf-shell/operator/test_quota.rb +0 -23
  533. data/spec/unit/alf-shell/operator/test_rank.rb +0 -30
  534. data/spec/unit/alf-shell/operator/test_rename.rb +0 -21
  535. data/spec/unit/alf-shell/operator/test_restrict.rb +0 -35
  536. data/spec/unit/alf-shell/operator/test_sort.rb +0 -49
  537. data/spec/unit/alf-shell/operator/test_summarize.rb +0 -30
  538. data/spec/unit/alf-shell/operator/test_ungroup.rb +0 -28
  539. data/spec/unit/alf-shell/operator/test_union.rb +0 -18
  540. data/spec/unit/alf-shell/operator/test_unwrap.rb +0 -28
  541. data/spec/unit/alf-shell/operator/test_wrap.rb +0 -30
  542. data/tasks/clean.rake +0 -3
  543. data/tasks/debug_mail.rake +0 -75
  544. data/tasks/debug_mail.txt +0 -18
  545. data/tasks/gh-pages.rake +0 -68
  546. data/tasks/integration_test.rake +0 -43
  547. data/tasks/regression_test.rake +0 -44
  548. data/tasks/unit_test.rake +0 -44
  549. data/tasks/yard.rake +0 -51
@@ -1,136 +0,0 @@
1
- module Alf
2
- module Types
3
- #
4
- # Defines the computation of a tuple from expressions mapped to names.
5
- #
6
- # Example:
7
- # computation = TupleComputation[
8
- # :big? => lambda{ status > 20 }
9
- # :who => lambda{ "#{first} #{last}" }
10
- # ]
11
- # computation.call(:last => "Jones", :first => "Bill", :status => 10)
12
- # # => {:big? => false, :who => "Bill Jones"}
13
- #
14
- class TupleComputation
15
-
16
- # @return [Hash] a computation hash, mapping AttrName -> TupleExpression
17
- attr_reader :computation
18
-
19
- #
20
- # Creates a TupleComputation instance
21
- #
22
- # @param [Hash] computation, a mappping AttrName -> TupleExpression
23
- #
24
- def initialize(computation)
25
- @computation = computation
26
- end
27
-
28
- class << self
29
-
30
- # Coerces `arg` to a tuple computation
31
- #
32
- # Implemented coercions are
33
- # - TupleComputation -> self
34
- # - {name => expr, ...} -> {AttrName[name] => TupleExpression[expr], ...}
35
- # - [name, expr, ...] -> {AttrName[name] => TupleExpression[expr], ...}
36
- #
37
- # @param [Object] arg the value to coerce to a tuple computation
38
- # @return [TupleComputation] the computation when the coercion succeeds
39
- def coerce(arg)
40
- case arg
41
- when TupleComputation
42
- arg
43
- when Hash
44
- TupleComputation.new Hash[arg.map{|k,v|
45
- if AttrName === k
46
- v = TupleExpression.coerce(v) if v.is_a?(Proc)
47
- [k, v]
48
- else
49
- [ Tools.coerce(k, AttrName),
50
- Tools.coerce(v, TupleExpression) ]
51
- end
52
- }]
53
- when Array
54
- coerce(Hash[*arg])
55
- else
56
- raise ArgumentError, "Invalid argument `arg` for TupleComputation()"
57
- end
58
- end
59
- alias :[] :coerce
60
-
61
- # Convert commandline arguments to a tuple computation
62
- #
63
- # This method reuses `coerce(Array)` and therefore shares its spec.
64
- #
65
- # @param [Array] args commandline arguments
66
- # @param [Hash] opts coercion options (not used).
67
- # @return [TupleExpression] the expression if coercion succeeds
68
- # @raise [ArgumentError] if the coercion fails.
69
- def from_argv(argv, opts = {})
70
- coerce(argv)
71
- end
72
-
73
- end # class << self
74
-
75
- # Makes the computation in the context of a tuple
76
- #
77
- # This is a convenient method for the following, longer expression:
78
- #
79
- # evaluate(TupleHandle.new.set(tuple))
80
- #
81
- # Note, however, using a Handle as in the example above is much more
82
- # efficient when evaluating the same computation on multiple tuples
83
- # in sequence.
84
- #
85
- # @param [Hash] tuple a Tuple instance
86
- # @return [Object] the resulting tuple
87
- def call(tuple)
88
- evaluate(Tools::TupleHandle.new.set(tuple))
89
- end
90
- alias :[] :call
91
-
92
- # Computes the resulting tuple when expressions are evaluated in the
93
- # context of `handle`
94
- #
95
- # @param [TupleHandle] handle a tuple handle instance.
96
- # @return [Hash] the resulting tuple
97
- def evaluate(handle = nil)
98
- Tools.tuple_collect(@computation){|k,v|
99
- [k, v.is_a?(TupleExpression) ? v.evaluate(handle) : v]
100
- }
101
- end
102
-
103
- # Returns a hash code.
104
- #
105
- # @return [Integer] a hash code for this expression
106
- def hash
107
- @computation.hash
108
- end
109
-
110
- # Checks equality with another computation
111
- #
112
- # @param [TupleComputation] another computation
113
- # @return [Boolean] true if self and other are equal, false otherwise
114
- def ==(other)
115
- other.is_a?(TupleComputation) && (computation == other.computation)
116
- end
117
- alias :eql? :==
118
-
119
- # Converts to an attribute list.
120
- #
121
- # @return [AttrList] a list of computed attribute names
122
- def to_attr_list
123
- AttrList.new(computation.keys)
124
- end
125
-
126
- # Returns a ruby literal for this expression.
127
- #
128
- # @return [String] a literal s.t. `eval(self.to_ruby_literal) == self`
129
- def to_ruby_literal
130
- "Alf::TupleComputation[#{Tools.to_ruby_literal(computation)}]"
131
- end
132
- alias :inspect :to_ruby_literal
133
-
134
- end # class TupleComputation
135
- end # module Types
136
- end # module Alf
@@ -1,152 +0,0 @@
1
- module Alf
2
- module Types
3
- #
4
- # A tuple expression is a Ruby expression whose evaluates in the scope of a
5
- # specific tuple handle.
6
- #
7
- # Example:
8
- # expr = TupleExpression["status * 10"]
9
- # expr.call(:status => 20)
10
- # # => 200
11
- #
12
- class TupleExpression
13
-
14
- # @return [Proc] the lambda expression
15
- attr_reader :expr_lambda
16
-
17
- # @return [String] the expression source code (may be nil)
18
- attr_reader :source
19
-
20
- # Creates a tuple expression from a Proc object
21
- #
22
- # @param [Proc] expr a Proc for the expression
23
- # @param [String] source the source code of the expression (optional)
24
- def initialize(expr, source = nil)
25
- @expr_lambda = expr
26
- @source = source
27
- end
28
-
29
- class << self
30
-
31
- # Coerces `arg` to a tuple expression.
32
- #
33
- # Implemented coercions are:
34
- # - TupleExpression -> self
35
- # - Proc -> TupleExpression.new(arg, nil)
36
- # - String -> TupleExpression.new(..., arg)
37
- # - Symbol -> TupleExpression.new(..., arg)
38
- #
39
- # @param [Object] arg a value to convert to a tuple expression
40
- # @return [TupleExpression] the expression if coercion succeeds
41
- # @raise [ArgumentError] if the coercion fails
42
- def coerce(arg)
43
- case arg
44
- when TupleExpression
45
- arg
46
- when Proc
47
- TupleExpression.new(arg, nil)
48
- when String, Symbol
49
- TupleExpression.new(eval("lambda{ #{arg} }"), arg)
50
- else
51
- raise ArgumentError, "Invalid argument `#{arg}` for TupleExpression()"
52
- end
53
- end
54
- alias :[] :coerce
55
-
56
- # Convert commandline arguments to a tuple expression
57
- #
58
- # Arguments should either be empty or a singleton. In the former case,
59
- # `opts[:default]` is used. In the latter case, the unique argument is
60
- # taken as the expression source code and `coerce` is called on it.
61
- #
62
- # @param [Array] args commandline arguments
63
- # @param [Hash] opts coercion options.
64
- # @return [TupleExpression] the expression if coercion succeeds
65
- # @raise [ArgumentError] if the coercion fails.
66
- def from_argv(argv, opts = {})
67
- raise ArgumentError if argv.size > 1
68
- coerce(argv.first || opts[:default])
69
- end
70
-
71
- end # class << self
72
-
73
- # Evaluates the expression in the context of a TupleHandle
74
- #
75
- # @param [TupleHandle] handle a tuple handle instance.
76
- # @return [Object] the result of evaluating the expression in the context
77
- # of `handle`
78
- def evaluate(handle = nil)
79
- if RUBY_VERSION < "1.9"
80
- handle.instance_eval(&@expr_lambda)
81
- else
82
- handle.instance_exec(&@expr_lambda)
83
- end
84
- end
85
-
86
- # Evaluates the expression on a tuple
87
- #
88
- # This is a convenient method for the following, longer expression:
89
- #
90
- # evaluate(TupleHandle.new.set(tuple))
91
- #
92
- # Note, however, using a Handle as in the example above is much more
93
- # efficient when evaluating the same expression on multiple tuples
94
- # in sequence.
95
- #
96
- # @param [Hash] tuple a Tuple instance
97
- # @return [Object] the result of evaluating the expression on `tuple`
98
- def call(tuple)
99
- evaluate(Tools::TupleHandle.new.set(tuple))
100
- end
101
- alias :[] :call
102
-
103
- # Returns a hash code.
104
- #
105
- # @return [Integer] a hash code for this expression
106
- def hash
107
- @source.nil? ? @expr_lambda.hash : @source.hash
108
- end
109
-
110
- # Checks equality with another expression
111
- #
112
- # @param [TupleExpression] another expression.
113
- # @return [Boolean] true if self and other are equal, false otherwise
114
- def ==(other)
115
- return false unless other.is_a?(TupleExpression)
116
- if source.nil? || other.source.nil?
117
- expr_lambda == other.expr_lambda
118
- else
119
- source == other.source
120
- end
121
- end
122
- alias :eql? :==
123
-
124
- # Returns a ruby literal for this expression.
125
- #
126
- # @return [String] a literal s.t. `eval(self.to_ruby_literal) == self`
127
- def to_ruby_literal
128
- "Alf::#{Tools.class_name(self.class)}[#{Tools.to_ruby_literal(has_source_code!)}]"
129
- end
130
-
131
- # Returns a string representation of this expression
132
- def inspect
133
- to_ruby_literal
134
- rescue NotImplementedError
135
- super
136
- end
137
-
138
- # Asserts that this expression knows its source code or raises a
139
- # NotImplementedError.
140
- #
141
- # @return [String] the source code when known
142
- def has_source_code!
143
- if source.nil?
144
- raise NotImplementedError, "No known source code for this expression"
145
- else
146
- source
147
- end
148
- end
149
-
150
- end # class TupleExpression
151
- end # module Types
152
- end # module Alf
@@ -1,73 +0,0 @@
1
- module Alf
2
- module Types
3
- #
4
- # Specialization of TupleExpression to boolean expressions.
5
- #
6
- class TuplePredicate < TupleExpression
7
-
8
- class << self
9
-
10
- # Coerces `arg` to a TuplePredicate
11
- #
12
- # Implemented coercions are:
13
- # - TuplePredicate -> self
14
- # - TupleExpression -> Renewed on this class
15
- # - true and false -> true and false predicates
16
- # - Proc -> TuplePredicate(arg, nil)
17
- # - String and Symbol -> as for TupleExpression
18
- # - empty Array -> coerce(true)
19
- # - singleton Array -> coerce(arg.first)
20
- # - {"attr" => "value", ...} -> equal predicate with coercions
21
- # - {:attr => ...value..., ...} -> equal predicate without coercions
22
- #
23
- # @param [Object] arg the value to coerce to a TuplePredicate
24
- # @return [TuplePredicate] the predicate if coercion succeeds
25
- # @raise [ArgumentError] if coercion fails
26
- def coerce(arg)
27
- case arg
28
- when TuplePredicate
29
- arg
30
- when TupleExpression
31
- TuplePredicate.new arg.expr_lambda, arg.source
32
- when TrueClass, FalseClass
33
- TuplePredicate.new lambda{ arg }, arg.to_s
34
- when Proc
35
- TuplePredicate.new arg, nil
36
- when String, Symbol
37
- TuplePredicate.new eval("lambda{ #{arg} }"), arg
38
- when Hash
39
- h = Hash[arg.map{|k,v|
40
- (AttrName === k) ?
41
- [k,v] : [Tools.coerce(k, AttrName), Kernel.eval(v)]
42
- }]
43
- source = h.map{|k,v|
44
- "(self.#{k} == #{Tools.to_ruby_literal(v)})"
45
- }.join(" && ")
46
- TuplePredicate.new eval("lambda{ #{source} }"), source
47
- when Array
48
- (arg.size <= 1) ?
49
- coerce(arg.first || true) :
50
- coerce(Hash[*arg])
51
- else
52
- raise ArgumentError, "Invalid argument `#{arg}` for TupleExpression()"
53
- end
54
- end
55
- alias :[] :coerce
56
-
57
- # Convert commandline arguments to a tuple predicate
58
- #
59
- # This method reuses `coerce(Array)` and therefore shares its spec.
60
- #
61
- # @param [Array] args commandline arguments
62
- # @param [Hash] opts coercion options (not used).
63
- # @return [TuplePredicate] the predicate if coercion succeeds
64
- # @raise [ArgumentError] if the coercion fails.
65
- def from_argv(argv)
66
- coerce(argv)
67
- end
68
-
69
- end # class << self
70
-
71
- end # class TuplePredicate
72
- end # module Types
73
- end # module Alf
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env alf
2
- (group :supplies, [:pid, :qty], :supplying)
3
- (group :supplies, [:sid], :supplying, :allbut => true)
@@ -1,6 +0,0 @@
1
- {:pid => 'P1', :name => 'Nut', :color => 'Red', :weight => 12.0, :city => 'London'}
2
- {:pid => 'P2', :name => 'Bolt', :color => 'Green', :weight => 17.0, :city => 'Paris'}
3
- {:pid => 'P3', :name => 'Screw', :color => 'Blue', :weight => 17.0, :city => 'Oslo'}
4
- {:pid => 'P4', :name => 'Screw', :color => 'Red', :weight => 14.0, :city => 'London'}
5
- {:pid => 'P5', :name => 'Cam', :color => 'Blue', :weight => 12.0, :city => 'Paris'}
6
- {:pid => 'P6', :name => 'Cog', :color => 'Red', :weight => 19.0, :city => 'London'}
@@ -1,5 +0,0 @@
1
- {:sid => 'S1', :name => 'Smith', :status => 20, :city => 'London'}
2
- {:sid => 'S2', :name => 'Jones', :status => 10, :city => 'Paris'}
3
- {:sid => 'S3', :name => 'Blake', :status => 30, :city => 'Paris'}
4
- {:sid => 'S4', :name => 'Clark', :status => 20, :city => 'London'}
5
- {:sid => 'S5', :name => 'Adams', :status => 30, :city => 'Athens'}
@@ -1,6 +0,0 @@
1
- sid,name,status,city
2
- S1,Smith,20,London
3
- S2,Jones,10,Paris
4
- S3,Blake,30,Paris
5
- S4,Clark,20,London
6
- S5,Adams,30,Athens
@@ -1,12 +0,0 @@
1
- {:sid => 'S1', :pid => 'P1', :qty => 300}
2
- {:sid => 'S1', :pid => 'P2', :qty => 200}
3
- {:sid => 'S1', :pid => 'P3', :qty => 400}
4
- {:sid => 'S1', :pid => 'P4', :qty => 200}
5
- {:sid => 'S1', :pid => 'P5', :qty => 100}
6
- {:sid => 'S1', :pid => 'P6', :qty => 100}
7
- {:sid => 'S2', :pid => 'P1', :qty => 300}
8
- {:sid => 'S2', :pid => 'P2', :qty => 400}
9
- {:sid => 'S3', :pid => 'P2', :qty => 200}
10
- {:sid => 'S4', :pid => 'P2', :qty => 200}
11
- {:sid => 'S4', :pid => 'P4', :qty => 300}
12
- {:sid => 'S4', :pid => 'P5', :qty => 400}
@@ -1 +0,0 @@
1
- {:name => "Jones"}
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
- module Alf
3
- describe "Relation" do
4
-
5
- let(:expected){ Alf::Relation.new([ {:name => "Jones"} ].to_set) }
6
-
7
- it 'works as expected on a tuple' do
8
- Alf::Relation(:name => "Jones").should eq(expected)
9
- end
10
-
11
- it 'works as expected on a Reader' do
12
- File.open(File.expand_path("../example.rash", __FILE__), "r") do |io|
13
- reader = Alf::Reader.rash(io)
14
- rel = Alf::Relation(reader)
15
- rel.should eq(expected)
16
- end
17
- end
18
-
19
- it 'works as expected on an Operator' do
20
- op = Alf.lispy.compile{
21
- extend(Relation::DEE, :name => lambda{ "Jones" })
22
- }
23
- def op.each(*args, &bl)
24
- raise if defined?(@already_called)
25
- @already_called = true
26
- super
27
- end
28
- Alf::Relation(op).should eq(expected)
29
- end
30
-
31
- end
32
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- describe "Relation()" do
3
-
4
- it 'returns a Relation' do
5
- Relation(:name => "Alf").should be_a(Alf::Relation)
6
- end
7
-
8
- it 'helps building a singleton' do
9
- Relation(:name => "Alf").cardinality.should eq(1)
10
- end
11
-
12
- it 'helps building a list if values' do
13
- Relation(:name => ["Alf", "Myrrha"]).cardinality.should eq(2)
14
- end
15
-
16
- end