alf 0.9.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. data/CHANGELOG.md +255 -129
  2. data/Gemfile +31 -1
  3. data/Gemfile.lock +17 -20
  4. data/LICENCE.md +1 -1
  5. data/Manifest.txt +2 -0
  6. data/README.md +37 -43
  7. data/TODO.md +1 -1
  8. data/alf.gemspec +10 -7
  9. data/alf.noespec +24 -13
  10. data/bin/alf +2 -2
  11. data/doc/commands/exec.md +16 -0
  12. data/doc/commands/help.md +11 -0
  13. data/doc/commands/main.md +33 -0
  14. data/doc/commands/show.md +19 -0
  15. data/doc/operators/non_relational/autonum.md +23 -0
  16. data/doc/operators/non_relational/clip.md +31 -0
  17. data/doc/operators/non_relational/coerce.md +15 -0
  18. data/doc/operators/non_relational/compact.md +20 -0
  19. data/doc/operators/non_relational/defaults.md +32 -0
  20. data/doc/operators/non_relational/generator.md +20 -0
  21. data/doc/operators/non_relational/sort.md +24 -0
  22. data/doc/operators/relational/extend.md +18 -0
  23. data/doc/operators/relational/group.md +27 -0
  24. data/doc/operators/relational/intersect.md +13 -0
  25. data/doc/operators/relational/join.md +27 -0
  26. data/doc/operators/relational/matching.md +20 -0
  27. data/doc/operators/relational/minus.md +12 -0
  28. data/doc/operators/relational/not-matching.md +20 -0
  29. data/doc/operators/relational/project.md +28 -0
  30. data/doc/operators/relational/quota.md +21 -0
  31. data/doc/operators/relational/rank.md +27 -0
  32. data/doc/operators/relational/rename.md +17 -0
  33. data/doc/operators/relational/restrict.md +25 -0
  34. data/doc/operators/relational/summarize.md +25 -0
  35. data/doc/operators/relational/ungroup.md +20 -0
  36. data/doc/operators/relational/union.md +14 -0
  37. data/doc/operators/relational/unwrap.md +20 -0
  38. data/doc/operators/relational/wrap.md +24 -0
  39. data/examples/csv/suppliers.csv +6 -0
  40. data/examples/logs/access.log +1000 -0
  41. data/examples/logs/combined.alf +2 -0
  42. data/examples/logs/hits.alf +14 -0
  43. data/examples/logs/not_found.alf +7 -0
  44. data/examples/logs/robots-cheating.alf +11 -0
  45. data/examples/logs/robots.alf +8 -0
  46. data/examples/northwind/customers.csv +92 -0
  47. data/examples/northwind/northwind.db +0 -0
  48. data/examples/northwind/orders.csv +831 -0
  49. data/examples/operators/clip.alf +1 -1
  50. data/examples/operators/database.alf +5 -6
  51. data/examples/operators/defaults.alf +1 -1
  52. data/examples/operators/group.alf +1 -1
  53. data/examples/operators/project.alf +2 -1
  54. data/examples/operators/pseudo-with.alf +2 -2
  55. data/examples/operators/quota.alf +2 -2
  56. data/examples/operators/summarize.alf +2 -2
  57. data/lib/alf/aggregator/aggregators.rb +77 -0
  58. data/lib/alf/aggregator/base.rb +95 -0
  59. data/lib/alf/aggregator/class_methods.rb +57 -0
  60. data/lib/alf/buffer/sorted.rb +48 -0
  61. data/lib/alf/command/class_methods.rb +27 -0
  62. data/lib/alf/command/doc_manager.rb +72 -0
  63. data/lib/alf/command/exec.rb +12 -0
  64. data/lib/alf/command/help.rb +31 -0
  65. data/lib/alf/command/main.rb +146 -0
  66. data/lib/alf/command/show.rb +33 -0
  67. data/lib/alf/environment/base.rb +37 -0
  68. data/lib/alf/environment/class_methods.rb +93 -0
  69. data/lib/alf/environment/explicit.rb +38 -0
  70. data/lib/alf/environment/folder.rb +62 -0
  71. data/lib/alf/extra/csv.rb +104 -0
  72. data/lib/alf/extra/logs.rb +100 -0
  73. data/lib/alf/extra/sequel.rb +77 -0
  74. data/lib/alf/{yaml.rb → extra/yaml.rb} +0 -0
  75. data/lib/alf/extra.rb +5 -0
  76. data/lib/alf/iterator/base.rb +38 -0
  77. data/lib/alf/iterator/class_methods.rb +22 -0
  78. data/lib/alf/iterator/proxy.rb +33 -0
  79. data/lib/alf/lispy/instance_methods.rb +157 -0
  80. data/lib/alf/operator/base.rb +74 -0
  81. data/lib/alf/operator/binary.rb +32 -0
  82. data/lib/alf/operator/cesure.rb +45 -0
  83. data/lib/alf/operator/class_methods.rb +132 -0
  84. data/lib/alf/operator/experimental.rb +9 -0
  85. data/lib/alf/operator/non_relational/autonum.rb +24 -0
  86. data/lib/alf/operator/non_relational/clip.rb +20 -0
  87. data/lib/alf/operator/non_relational/coerce.rb +21 -0
  88. data/lib/alf/operator/non_relational/compact.rb +62 -0
  89. data/lib/alf/operator/non_relational/defaults.rb +25 -0
  90. data/lib/alf/operator/non_relational/generator.rb +38 -0
  91. data/lib/alf/operator/non_relational/sort.rb +23 -0
  92. data/lib/alf/operator/nullary.rb +20 -0
  93. data/lib/alf/operator/relational/extend.rb +24 -0
  94. data/lib/alf/operator/relational/group.rb +32 -0
  95. data/lib/alf/operator/relational/intersect.rb +37 -0
  96. data/lib/alf/operator/relational/join.rb +106 -0
  97. data/lib/alf/operator/relational/matching.rb +45 -0
  98. data/lib/alf/operator/relational/minus.rb +37 -0
  99. data/lib/alf/operator/relational/not_matching.rb +45 -0
  100. data/lib/alf/operator/relational/project.rb +22 -0
  101. data/lib/alf/operator/relational/quota.rb +51 -0
  102. data/lib/alf/operator/relational/rank.rb +55 -0
  103. data/lib/alf/operator/relational/rename.rb +19 -0
  104. data/lib/alf/operator/relational/restrict.rb +20 -0
  105. data/lib/alf/operator/relational/summarize.rb +83 -0
  106. data/lib/alf/operator/relational/ungroup.rb +25 -0
  107. data/lib/alf/operator/relational/union.rb +32 -0
  108. data/lib/alf/operator/relational/unwrap.rb +21 -0
  109. data/lib/alf/operator/relational/wrap.rb +22 -0
  110. data/lib/alf/operator/shortcut.rb +53 -0
  111. data/lib/alf/operator/signature.rb +262 -0
  112. data/lib/alf/operator/transform.rb +27 -0
  113. data/lib/alf/operator/unary.rb +38 -0
  114. data/lib/alf/reader/alf_file.rb +24 -0
  115. data/lib/alf/reader/base.rb +119 -0
  116. data/lib/alf/reader/class_methods.rb +82 -0
  117. data/lib/alf/reader/rash.rb +28 -0
  118. data/lib/alf/relation/class_methods.rb +37 -0
  119. data/lib/alf/relation/instance_methods.rb +127 -0
  120. data/lib/alf/renderer/base.rb +72 -0
  121. data/lib/alf/renderer/class_methods.rb +58 -0
  122. data/lib/alf/renderer/rash.rb +19 -0
  123. data/lib/alf/{text.rb → renderer/text.rb} +1 -1
  124. data/lib/alf/tools/coerce.rb +14 -0
  125. data/lib/alf/tools/miscellaneous.rb +77 -0
  126. data/lib/alf/tools/to_lispy.rb +99 -0
  127. data/lib/alf/tools/to_ruby_literal.rb +14 -0
  128. data/lib/alf/tools/tuple_handle.rb +50 -0
  129. data/lib/alf/types/attr_list.rb +56 -0
  130. data/lib/alf/types/attr_name.rb +28 -0
  131. data/lib/alf/types/boolean.rb +12 -0
  132. data/lib/alf/types/heading.rb +96 -0
  133. data/lib/alf/types/ordering.rb +93 -0
  134. data/lib/alf/types/renaming.rb +57 -0
  135. data/lib/alf/types/summarization.rb +76 -0
  136. data/lib/alf/types/tuple_computation.rb +61 -0
  137. data/lib/alf/types/tuple_expression.rb +61 -0
  138. data/lib/alf/types/tuple_predicate.rb +49 -0
  139. data/lib/alf/version.rb +2 -2
  140. data/lib/alf.rb +193 -3714
  141. data/spec/integration/__database__/group.alf +1 -1
  142. data/spec/integration/__database__/suppliers_csv.csv +6 -0
  143. data/spec/integration/command/alf/alf.db +0 -0
  144. data/spec/integration/command/alf/alf_env_sqlite.cmd +1 -0
  145. data/spec/integration/command/alf/alf_env_sqlite.stdout +9 -0
  146. data/spec/integration/command/alf/alf_help.cmd +1 -0
  147. data/spec/integration/command/alf/alf_help.stdout +67 -0
  148. data/spec/integration/command/autonum/autonum_0.cmd +1 -1
  149. data/spec/integration/command/coerce/coerce_1.cmd +1 -0
  150. data/spec/integration/command/coerce/coerce_1.stdout +5 -0
  151. data/spec/integration/command/defaults/defaults_0.cmd +1 -1
  152. data/spec/integration/command/defaults/defaults_0.stdout +9 -9
  153. data/spec/integration/command/defaults/defaults_2.cmd +1 -0
  154. data/spec/integration/command/defaults/defaults_2.stdout +9 -0
  155. data/spec/integration/command/generator/generator_1.cmd +1 -0
  156. data/spec/integration/command/generator/generator_1.stdout +10 -0
  157. data/spec/integration/command/generator/generator_2.cmd +1 -0
  158. data/spec/integration/command/generator/generator_2.stdout +5 -0
  159. data/spec/integration/command/generator/generator_3.cmd +1 -0
  160. data/spec/integration/command/generator/generator_3.stdout +5 -0
  161. data/spec/integration/command/group/group_0.cmd +1 -1
  162. data/spec/integration/command/group/group_1.cmd +1 -1
  163. data/spec/integration/command/help/help_1.cmd +1 -0
  164. data/spec/integration/command/help/help_1.stdout +22 -0
  165. data/spec/integration/command/quota/quota_0.cmd +1 -1
  166. data/spec/integration/command/rank/rank_1.cmd +1 -1
  167. data/spec/integration/command/rank/rank_1.stdout +10 -10
  168. data/spec/integration/command/rank/rank_2.cmd +1 -1
  169. data/spec/integration/command/rank/rank_2.stdout +10 -10
  170. data/spec/integration/command/rank/rank_3.cmd +1 -1
  171. data/spec/integration/command/rank/rank_3.stdout +10 -10
  172. data/spec/integration/command/rank/rank_4.cmd +1 -1
  173. data/spec/integration/command/rank/rank_5.cmd +1 -1
  174. data/spec/integration/command/show/show_csv.cmd +1 -0
  175. data/spec/integration/command/show/show_csv.stdout +6 -0
  176. data/spec/integration/command/show/show_rash_2.cmd +1 -1
  177. data/spec/integration/command/show/show_rash_2.stdout +5 -5
  178. data/spec/integration/command/sort/sort_0.cmd +1 -1
  179. data/spec/integration/command/sort/sort_1.cmd +1 -1
  180. data/spec/integration/command/sort/sort_1.stdout +2 -2
  181. data/spec/integration/command/sort/sort_2.cmd +1 -0
  182. data/spec/integration/command/sort/sort_2.stdout +9 -0
  183. data/spec/integration/command/sort/sort_3.cmd +1 -0
  184. data/spec/integration/command/sort/sort_3.stdout +9 -0
  185. data/spec/integration/command/summarize/summarize_0.cmd +1 -1
  186. data/spec/integration/command/ungroup/ungroup_0.cmd +1 -1
  187. data/spec/integration/command/wrap/wrap_0.cmd +1 -1
  188. data/spec/integration/semantics/test_project.alf +5 -6
  189. data/spec/integration/semantics/test_rank.alf +16 -16
  190. data/spec/integration/test_command.rb +17 -6
  191. data/spec/integration/test_examples.rb +1 -1
  192. data/spec/regression/logs/apache_combined.log +5 -0
  193. data/spec/regression/logs/test_path_attribute.rb +25 -0
  194. data/spec/regression/relation/test_relation_allbut_all.rb +14 -0
  195. data/spec/shared/an_operator_class.rb +10 -5
  196. data/spec/spec_helper.rb +1 -7
  197. data/spec/unit/assumptions/test_set.rb +64 -0
  198. data/spec/unit/command/doc_manager/dynamic.md +1 -0
  199. data/spec/unit/command/doc_manager/example.md +1 -0
  200. data/spec/unit/command/doc_manager/example_1.txt +11 -0
  201. data/spec/unit/command/doc_manager/static.md +1 -0
  202. data/spec/unit/command/doc_manager/test_call.rb +49 -0
  203. data/spec/unit/csv/input.csv +3 -0
  204. data/spec/unit/csv/test_reader.rb +66 -0
  205. data/spec/unit/csv/test_renderer.rb +73 -0
  206. data/spec/unit/lispy/test_relation.rb +37 -0
  207. data/spec/unit/lispy/test_run.rb +40 -0
  208. data/spec/unit/lispy/test_tuple.rb +36 -0
  209. data/spec/unit/logs/apache_combined.log +5 -0
  210. data/spec/unit/logs/postgresql.log +29 -0
  211. data/spec/unit/logs/test_reader.rb +56 -0
  212. data/spec/unit/operator/non_relational/compact/{buffer_based.rb → test_buffer_based.rb} +0 -0
  213. data/spec/unit/operator/non_relational/test_clip.rb +1 -1
  214. data/spec/unit/operator/non_relational/test_coerce.rb +35 -0
  215. data/spec/unit/operator/non_relational/test_defaults.rb +15 -2
  216. data/spec/unit/operator/non_relational/test_generator.rb +78 -0
  217. data/spec/unit/operator/relational/join/test_hash_based.rb +4 -4
  218. data/spec/unit/operator/relational/matching/test_hash_based.rb +6 -6
  219. data/spec/unit/operator/relational/not_matching/test_hash_based.rb +4 -4
  220. data/spec/unit/operator/relational/summarize/test_hash_based.rb +10 -6
  221. data/spec/unit/operator/relational/summarize/test_sort_based.rb +18 -7
  222. data/spec/unit/operator/relational/test_group.rb +8 -8
  223. data/spec/unit/operator/relational/test_intersect.rb +3 -3
  224. data/spec/unit/operator/relational/test_minus.rb +3 -3
  225. data/spec/unit/operator/relational/test_project.rb +12 -2
  226. data/spec/unit/operator/relational/test_quota.rb +5 -6
  227. data/spec/unit/operator/relational/test_summarize.rb +9 -11
  228. data/spec/unit/operator/relational/test_union.rb +1 -1
  229. data/spec/unit/operator/relational/test_wrap.rb +1 -1
  230. data/spec/unit/operator/signature/test_collect_on.rb +45 -0
  231. data/spec/unit/operator/signature/test_initialize.rb +17 -0
  232. data/spec/unit/operator/signature/test_install.rb +56 -0
  233. data/spec/unit/operator/signature/test_option_parser.rb +36 -0
  234. data/spec/unit/operator/signature/test_parse_args.rb +60 -0
  235. data/spec/unit/operator/signature/test_parse_argv.rb +87 -0
  236. data/spec/unit/operator/signature/test_to_lispy.rb +102 -0
  237. data/spec/unit/operator/signature/test_to_shell.rb +103 -0
  238. data/spec/unit/operator/test_non_relational.rb +3 -1
  239. data/spec/unit/relation/test_relops.rb +20 -15
  240. data/spec/unit/sequel/alf.db +0 -0
  241. data/spec/unit/sequel/test_environment.rb +54 -0
  242. data/spec/unit/test_aggregator.rb +32 -22
  243. data/spec/unit/test_environment.rb +5 -0
  244. data/spec/unit/test_lispy.rb +4 -0
  245. data/spec/unit/test_relation.rb +5 -0
  246. data/spec/unit/text/test_cell.rb +6 -6
  247. data/spec/unit/text/test_row.rb +3 -3
  248. data/spec/unit/text/test_table.rb +6 -6
  249. data/spec/unit/tools/test_coalesce.rb +15 -0
  250. data/spec/unit/tools/test_coerce.rb +10 -0
  251. data/spec/unit/tools/test_to_lispy.rb +138 -0
  252. data/spec/unit/tools/test_to_ruby_literal.rb +10 -0
  253. data/spec/unit/tools/test_tuple_handle.rb +1 -59
  254. data/spec/unit/types/test_attr_list.rb +106 -0
  255. data/spec/unit/types/test_attr_name.rb +52 -0
  256. data/spec/unit/{test_heading.rb → types/test_heading.rb} +10 -0
  257. data/spec/unit/types/test_ordering.rb +127 -0
  258. data/spec/unit/types/test_renaming.rb +55 -0
  259. data/spec/unit/types/test_summarization.rb +63 -0
  260. data/spec/unit/types/test_tuple_computation.rb +60 -0
  261. data/spec/unit/types/test_tuple_expression.rb +64 -0
  262. data/spec/unit/types/test_tuple_predicate.rb +79 -0
  263. data/tasks/debug_mail.rake +1 -1
  264. data/tasks/debug_mail.txt +5 -0
  265. data/tasks/gh-pages.rake +63 -0
  266. metadata +325 -52
  267. data/spec/unit/operator/test_command_methods.rb +0 -38
  268. data/spec/unit/tools/test_ordering_key.rb +0 -94
  269. data/spec/unit/tools/test_parse_commandline_args.rb +0 -47
  270. data/spec/unit/tools/test_projection_key.rb +0 -83
data/CHANGELOG.md CHANGED
@@ -1,164 +1,290 @@
1
- # 0.9.3 / FIX ME
1
+ # 0.10.0 / 2011-08-15
2
2
 
3
- * New operators (available both in shell and in Lispy DSL)
3
+ ## New recognized data sources
4
4
 
5
- * Added MATCHING and NOT MATCHING operators. These operators are useful
6
- shortcuts for the following expressions.
7
-
8
- (matching l, r) := (project (join l, r), [l's attributes])
9
- (not_matching l, r) := (minus l, (matching l, r))
5
+ * Alf now provides an Environment implementation on top of a SQL database.
6
+ This means that SQL tables can now be used as data-sources. This feature
7
+ relies on the sequel gem ('gem install sequel' is required), that drives
8
+ recognized SQL servers. Then (don't forget that ALF_OPTS also exists):
9
+
10
+ % alf --env=postgres://user:password@host/database show table
11
+
12
+ * Alf now recognizes and allows manipulating .csv files as first-class data
13
+ sources. CSV output is also supported of course. Under ruby <= 1.9, the
14
+ fastercsv gem is required ('gem install fastercsv' is required). Then:
15
+
16
+ % alf restrict suppliers.csv -- "city == 'Paris'" (input)
17
+ % alf show suppliers --csv (output)
18
+
19
+ * Alf now recognizes and allows manipulating .log files as first-class data
20
+ sources. This feature relies on request-log-analyzer gem that provides the
21
+ parsers that Alf uses, and the log formats it recognizes
22
+ ('gem install request-log-analyzer' is required). See examples/logs.
23
+
24
+ ## New operators and enhancements
25
+
26
+ * A GENERATOR operator is introduced. It allows generating a relation with one
27
+ auto-number attribute, up to a given size.
28
+
29
+ * A COERCE operator is introduced. It provides a quick way to obtain type-safe
30
+ relations from type-unsafe sources like .csv files. For example:
31
+
32
+ % alf coerce mydirtyfile.csv -- name String price Float at Time
10
33
 
11
- For example:
12
-
13
- # Give suppliers that supply at least one part
14
- (matching suppliers, supplies)
34
+ The coerce operator is of course available in Ruby as well:
35
+
36
+ (coerce "mydirtyfile.csv", :name => String, :price => Float, :at => Time)
37
+
38
+ * The DEFAULTS (non-relational) operator now accepts default values as tuple
39
+ expressions. When used in shell, provided default values are now evaluated
40
+ that way. This allows specifying default values as being computed on the
41
+ current tuple.
15
42
 
16
- # Give suppliers that don't supply any part
17
- (not_matching suppliers, supplies)
43
+ * Aggregations in the Lispy DSL must not be prefixed by Agg:: anymore.
18
44
 
19
- * Added RANK operator. The RANK operator is useful for for computing quota
20
- queries, as shown below. See 'alf help rank' for details.
21
-
22
- # Give the three heaviest parts
23
- (allbut (restrict (rank :parts, [[:weight, :desc]], :pos), lambda{ pos < 3 }), [:pos])
45
+ ## Miscellaneous enhancements
24
46
 
25
- * Enhancements when using Alf in shell
47
+ * Added 'alf --input-reader' to specify $stdin format (csv, rash, etc.)
48
+ * Added 'alf -Ipath' that mimics ruby's -I (add path to $LOAD_PATH before run)
49
+ * Lispy#run supports command arguments to be passed as a string
50
+ * Lispy#run supports piped commands, with '|' as in shell
26
51
 
27
- * added alf's -r option, that mimics ruby's one (require library before run)
52
+ ## Hurting changes to Lispy DSL (and therefore to Relation)
28
53
 
29
- * When alf is invoked in shell using bin/alf (and only in this case),
30
- ENV['ALF_OPTS'] is used a global options to apply as they were specified
31
- inline:
32
-
33
- % export ALF_OPTS="--env=. --yaml"
34
- % alf show suppliers
35
-
36
- is the same as
37
-
38
- % alf --env=. --yaml show suppliers
39
-
40
- * 'alf --help' now distinguish experimental operators from those coming from
41
- the (much more stable) TUTORIAL D specification. The former should be used
42
- with care as they specification may change at any time.
54
+ * The attribute-name syntax of aggregation operators has been removed. The Agg::
55
+ prefix must not be specified anymore.
43
56
 
44
- * Enhancements when using Alf in Ruby
57
+ Agg::sum(:qty) # !! error !!
58
+ Agg::sum{ qty } # !! error !!
59
+ sum{ qty } # simply, and only!
45
60
 
46
- * Alf.lispy now accepts any argument recognized by Environment.autodetect; it
47
- obtains its working Environment this way. Among others:
48
-
49
- Alf.lispy(Alf::Environment.folder("path/to/an/existing/folder"))
50
-
51
- is the same as:
61
+ * The group aggregation operator has been removed. It will probably be replaced
62
+ in a future version. In the meantime, the GROUP relational operator allows
63
+ obtaining similar results.
64
+
65
+ * Lispy syntax of CLIP has changed (when used with --allbut option)
66
+
67
+ (clip :suppliers, [:name, :city], true) (before)
68
+ (clip :suppliers, [:name, :city], :allbut => true) (after)
69
+
70
+ * Lispy syntax of DEFAULTS has changed (when used with --strict option)
71
+
72
+ (defaults :suppliers, {:country => 'Belgium'}, true) (before)
73
+ (defaults :suppliers, {:country => 'Belgium'}, :strict => true) (after)
74
+
75
+ * Lispy syntax of GROUP has changed (when used with --allbut option)
76
+
77
+ (group :supplies, [:sid], :supplying, true) (before)
78
+ (group :supplies, [:sid], :supplying, :allbut => true) (after)
79
+
80
+ * Lispy syntax of PROJECT has changed (when used with --allbut option)
81
+
82
+ (project :suppliers, [:name, :city], true) (before)
83
+ (project :suppliers, [:name, :city], :allbut => true) (after)
84
+
85
+ * Lispy syntax of SUMMARIZE has changed (when used with --allbut option)
86
+
87
+ (summarize :supplies, [:qty, :pid], {...}, true) (before)
88
+ (summarize :supplies, [:qty, :pid], {...}, :allbut => true) (after)
89
+
90
+ ## Hurting changes in shell
91
+
92
+ * The attribute-name syntax of aggregation operators has been removed
93
+
94
+ sum(:qty) # !! error !!
95
+ sum{ qty } # works
96
+
97
+ * Shell syntax of GROUP has changed (option separator before introduced name)
98
+
99
+ % alf --text group supplies -- pid qty supplying (before)
100
+ % alf --text group supplies -- pid qty -- supplying (after)
101
+
102
+ * Shell syntax of WRAP has changed (option separator before introduced name)
103
+
104
+ % alf --text wrap suppliers -- city status loc_and_status (before)
105
+ % alf --text wrap suppliers -- city status -- loc_and_status (after)
106
+
107
+ * Shell syntax of QUOTA has changed (--by and --order become pure arguments)
108
+
109
+ % alf quota supplies --by=sid --order=qty -- position count sum_qty "sum{ qty }" (before)
110
+ % alf quota supplies -- sid -- qty -- position count sum_qty "sum{ qty }" (after)
111
+
112
+ * Shell syntax of RANK has changed (--order becomes a pure argument)
113
+
114
+ % alf rank parts --order=weight,desc,pid,asc -- position (before)
115
+ % alf rank parts -- weight desc pid asc -- position (after)
116
+
117
+ * Shell syntax of SUMMARIZE has changed (--by becomes a pure argument)
118
+
119
+ % alf summarize supplies --by=sid -- total_qty "sum{ qty }" (before)
120
+ % alf summarize supplies -- sid -- total_qty "sum{ qty }" (after)
121
+
122
+ ## Bug fixes
123
+
124
+ * [In shell] Options are now correctly parsed in presence of option separators.
125
+ That is, every argument after a '--' separator is considered a non-option
126
+ argument.
127
+
128
+ # 0.9.3 / 2011-07-23
129
+
130
+ ## New operators (available both in shell and in Lispy DSL)
131
+
132
+ * Added MATCHING and NOT MATCHING operators. These operators are useful
133
+ shortcuts for the following expressions.
134
+
135
+ (matching l, r) := (project (join l, r), [l's attributes])
136
+ (not_matching l, r) := (minus l, (matching l, r))
52
137
 
53
- Alf.lispy("path/to/an/existing/folder")
138
+ For example:
139
+
140
+ # Give suppliers who supply at least one part
141
+ (matching suppliers, supplies)
54
142
 
55
- * Added Relation::DUM and Relation::DEE constants (relations of empty heading
56
- with no and one tuple, respectively). They are also available as DUM and DEE
57
- in Lispy functional expressions.
143
+ # Give suppliers who don't supply any part
144
+ (not_matching suppliers, supplies)
145
+
146
+ * Added RANK operator, which is useful for for computing quota queries as
147
+ illustrated below. See 'alf help rank' for details.
58
148
 
59
- * Added a Heading abstraction, as a set of attribute (name, type) pairs
149
+ # Give the three heaviest parts
150
+ (restrict (rank :parts, [[:weight, :desc]], :pos), lambda{ pos < 3 })
60
151
 
61
- * Internal enhancements (extension points)
152
+ ## Enhancements when using Alf in shell
62
153
 
63
- * The Reader and Renderer classes now accept a Hash of options as third
64
- argument of the constructor (friendly varargs applies there). These options
65
- can be used by extension points.
66
-
67
- * The Environment class now provides a class-based registering mechanism 'ala'
68
- Reader and Renderer. This allows auto-detecting the target environment when
69
- --env=... is used in shell. See Environment.autodetect and
70
- Environment#recognizes? for contributing to this extension point.
71
-
72
- * Internals now rely on Myrrha for code generation. This means that all
73
- datatypes can now be safely used in relations and dumped to .rash files in
74
- particular.
75
-
76
- * Bug fixes
77
-
78
- * Added Relation#allbut, forgotten in two previous releases
79
- * Fixed (join xxx, DEE) and (join xxx, DUM)
80
- * Fixed scoping bug when using attributes named :path, :expr or :block in
81
- Lispy compiled expressions (coming from .alf files)
82
- * Fixed 'alf --yaml show suppliers' that renderer a --text table instead of
83
- a yaml output
84
- * Fixed bugs when using Date and Time attributes with .rash files
85
- * Fixed bugs when using Date and Time attributes in restrict expressions
86
- compiled from the commandline
87
- * Fixed a few bugs when using attribute names that are ruby keywords
88
- (restrict & extend)
154
+ * added 'alf -r', that mimics 'ruby -r' (require library before run)
155
+
156
+ * When alf is invoked in shell (and only in this case), ALF_OPTS is used as
157
+ global options to apply as if they were specified inline:
158
+
159
+ % export ALF_OPTS="--env=. --yaml"
160
+ % alf show suppliers
161
+
162
+ is the same as
163
+
164
+ % alf --env=. --yaml show suppliers
165
+
166
+ * 'alf --help' now distinguishes experimental operators (quota in particular)
167
+ from those coming from the (much more stable) **Tutorial D** specification. The
168
+ former should be used with care as their specification may change at any
169
+ time.
170
+
171
+ ## Enhancements when using Alf in Ruby
172
+
173
+ * Alf.lispy now accepts any argument recognized by Environment.autodetect; it
174
+ obtains its working Environment that way. Among others:
175
+
176
+ Alf.lispy(Alf::Environment.folder("path/to/an/existing/folder"))
177
+
178
+ is the same as:
179
+
180
+ Alf.lispy("path/to/an/existing/folder")
181
+
182
+ * Added Relation::DUM and Relation::DEE constants (relations of empty heading
183
+ with no and one tuple, respectively). They are also available as DUM and DEE
184
+ in Lispy functional expressions.
185
+
186
+ * Added a Heading abstraction, as a set of attribute (name, type) pairs.
187
+
188
+ ## Internal enhancements (extension points)
189
+
190
+ * The Reader and Renderer classes accept a Hash of options as third
191
+ constructor argument. These options can be used by extension points.
192
+
193
+ * The Environment class now provides a class-based registering mechanism 'ala'
194
+ Reader and Renderer. This allows auto-detecting the target environment when
195
+ --env=... is used in shell. See Environment.autodetect and
196
+ Environment#recognizes? for contributing to this extension point.
197
+
198
+ * Internals now rely on Myrrha for code generation. This means that all
199
+ datatypes can now be safely used in relations and dumped to .rash files in
200
+ particular.
201
+
202
+ ## Bug fixes
203
+
204
+ * Added Relation#allbut, forgotten in two previous releases
205
+ * Fixed (join xxx, DEE) and (join xxx, DUM)
206
+ * Fixed scoping bug when using attributes named :path, :expr or :block in
207
+ Lispy compiled expressions (coming from .alf files)
208
+ * Fixed 'alf --yaml show suppliers' that renderer a --text table instead of
209
+ a yaml output
210
+ * Fixed bugs when using Date and Time attributes with .rash files
211
+ * Fixed bugs when using Date and Time attributes in restrict expressions
212
+ compiled from the commandline
213
+ * Fixed a few bugs when using attribute names that are ruby keywords
214
+ (restrict & extend)
89
215
 
90
216
  # 0.9.2 / 2011.07.13
91
217
 
92
- * Bug fixes
218
+ # Bug fixes
93
219
 
94
- * Fixed the "alf show" command (undefined method `chain')
220
+ * Fixed the "alf show" command (undefined method `chain')
95
221
 
96
222
  # 0.9.1 / 2011.07.13
97
223
 
98
- * Enhancements (public APIs)
224
+ ## Enhancements (public APIs)
99
225
 
100
- * Added the in-memory Alf::Relation data structure and associated tooling.
101
- This allows using Alf in a object-oriented usual way, in addition to the
102
- functional DSL:
103
-
104
- Alf.lispy.evaluate {
105
- (join (restrict :suppliers, lambda{ status > 10 }), :cities)
106
- }
107
-
108
- is equivalent to
109
-
110
- suppliers, cities = [...], [...]
111
- suppliers.restrict(lambda{ status > 10 }).join(cities)
112
-
113
- see README about how to obtain suppliers and cities relations in the first
114
- place.
226
+ * Added the in-memory Alf::Relation data structure and associated tooling.
227
+ This allows using Alf in a object-oriented usual way, in addition to the
228
+ functional DSL:
229
+
230
+ Alf.lispy.evaluate {
231
+ (join (restrict :suppliers, lambda{ status > 10 }), :cities)
232
+ }
115
233
 
116
- * Summarize now accepts a --allbut option, to specify 'by' attributes from an
117
- exclusion perspective
234
+ is equivalent to
235
+
236
+ suppliers, cities = [...], [...]
237
+ suppliers.restrict(lambda{ status > 10 }).join(cities)
238
+
239
+ see README about how to obtain suppliers and cities relations in the first
240
+ place.
118
241
 
119
- * .alf files are now evaluated in such a way that backtraces are "traceability
120
- friendly"
242
+ * Summarize now accepts a --allbut option, to specify 'by' attributes from an
243
+ exclusion perspective
121
244
 
122
- * Non backward-compatible changes to public APIs
245
+ * .alf files are now evaluated in such a way that backtraces are "traceability
246
+ friendly"
123
247
 
124
- * Lispy#with has been removed because not being stable enough. The clean way
125
- of reusing sub-queries is as follows (non purely functional, so far)
126
-
127
- kept_suppliers = (restrict :suppliers, lambda{ status > 10 })
128
- with_countries = (join kept_suppliers, :cities)
129
- supplying = (join with_countries, :supplies)
130
- (summarize supplying,
131
- [:country],
132
- :which => Agg::group(:pid),
133
- :total => Agg::sum{ qty })
134
-
135
- * As a consequence, named data sources (Symbols, like :suppliers above) are
136
- now resolved at compile time, which is less powerful, yet much simpler and
137
- sound.
138
-
139
- * Nest and Unnest have been renamed to Wrap and Unwrap respectively. This is
140
- to better conform to TUTORIAL D's terminology.
141
-
142
- * Lispy#chain was kept public in 0.9.0 by error and has been entirely removed
143
- from the DSL.
248
+ ## Non backward-compatible changes to public APIs
249
+
250
+ * Lispy#with has been removed because not being stable enough. The clean way
251
+ of reusing sub-queries is as follows (non purely functional, so far)
252
+
253
+ kept_suppliers = (restrict :suppliers, lambda{ status > 10 })
254
+ with_countries = (join kept_suppliers, :cities)
255
+ supplying = (join with_countries, :supplies)
256
+ (summarize supplying,
257
+ [:country],
258
+ :which => Agg::group(:pid),
259
+ :total => Agg::sum{ qty })
260
+
261
+ * As a consequence, named data sources (Symbols, like :suppliers above) are
262
+ now resolved at compile time, which is less powerful, yet much simpler and
263
+ sound.
144
264
 
145
- * Enhancements (internals)
265
+ * Nest and Unnest have been renamed to Wrap and Unwrap respectively. This is
266
+ to better conform to **Tutorial D**'s terminology.
267
+
268
+ * Lispy#chain was kept public in 0.9.0 by error and has been entirely removed
269
+ from the DSL.
146
270
 
147
- * Reader.reader delegates to Reader.coerce when its first argument is not
148
- a String. This allows calling Reader.reader(args.first || $stdin) in quickl
149
- commands for example.
150
-
151
- * Operator, Operator::Relational and Operator::NonRelational have a .each
152
- class method that yields operator classes
271
+ ## Enhancements (internals)
272
+
273
+ * Reader.reader delegates to Reader.coerce when its first argument is not
274
+ a String. This allows calling Reader.reader(args.first || $stdin) in quickl
275
+ commands for example.
276
+
277
+ * Operator, Operator::Relational and Operator::NonRelational have a .each
278
+ class method that yields operator classes
153
279
 
154
- * Bug fixes
280
+ ## Bug fixes
155
281
 
156
- * Fixed a bug that led to an Nil error when using unary operators on $stdin
157
- * Fixed a bug when summarizing or sorting on Symbol attributes with ruby 1.8
158
- * Fixed numerous crashes under rubinius
282
+ * Fixed a bug that led to an Nil error when using unary operators on $stdin
283
+ * Fixed a bug when summarizing or sorting on Symbol attributes with ruby 1.8
284
+ * Fixed numerous crashes under rubinius
159
285
 
160
286
  # 0.9.0 / 2011.06.19
161
287
 
162
- * Enhancements
288
+ ## Enhancements
163
289
 
164
- * Birthday!
290
+ * Birthday!
data/Gemfile CHANGED
@@ -1,2 +1,32 @@
1
1
  source 'http://rubygems.org'
2
- gemspec :name => "alf"
2
+
3
+ group :runtime do
4
+ gem "quickl", "~> 0.4.0"
5
+ gem "myrrha", "~> 1.2.0"
6
+ end
7
+
8
+ group :test do
9
+ gem "rake", "~> 0.9.2"
10
+ gem "rspec", "~> 2.6.0"
11
+ end
12
+
13
+ group :release do
14
+ gem "rake", "~> 0.9.2"
15
+ gem "rspec", "~> 2.6.0"
16
+ gem "wlang", "~> 0.10.2"
17
+ end
18
+
19
+ group :doc do
20
+ gem "rcov", "~> 0.9.9"
21
+ gem "yard", "~> 0.7.2"
22
+ gem "bluecloth", "~> 2.1.0"
23
+ gem "redcarpet", "~> 1.17.2"
24
+ end
25
+
26
+ group :extra do
27
+ gem "fastercsv", "~> 1.5.4"
28
+ gem "request-log-analyzer", "~> 1.11.0"
29
+ gem "sequel", "~> 3.25.0"
30
+ gem "sqlite3", "~> 1.3.0"
31
+ end
32
+
data/Gemfile.lock CHANGED
@@ -1,25 +1,16 @@
1
- PATH
2
- remote: .
3
- specs:
4
- alf (0.9.3)
5
- myrrha (~> 1.0.0)
6
- quickl (~> 0.2.2)
7
-
8
1
  GEM
9
2
  remote: http://rubygems.org/
10
3
  specs:
11
- bluecloth (2.0.11)
4
+ bluecloth (2.1.0)
12
5
  diff-lcs (1.1.2)
13
- highline (1.6.2)
14
- myrrha (1.0.0)
15
- noe (1.3.0)
16
- highline (~> 1.6.0)
17
- quickl (~> 0.2.0)
18
- wlang (~> 0.10.1)
19
- quickl (0.2.2)
6
+ fastercsv (1.5.4)
7
+ myrrha (1.2.0)
8
+ quickl (0.4.0)
20
9
  rake (0.9.2)
21
10
  rcov (0.9.9)
22
11
  rcov (0.9.9-java)
12
+ redcarpet (1.17.2)
13
+ request-log-analyzer (1.11.0)
23
14
  rspec (2.6.0)
24
15
  rspec-core (~> 2.6.0)
25
16
  rspec-expectations (~> 2.6.0)
@@ -28,6 +19,8 @@ GEM
28
19
  rspec-expectations (2.6.0)
29
20
  diff-lcs (~> 1.1.2)
30
21
  rspec-mocks (2.6.0)
22
+ sequel (3.25.0)
23
+ sqlite3 (1.3.3)
31
24
  wlang (0.10.2)
32
25
  yard (0.7.2)
33
26
 
@@ -36,12 +29,16 @@ PLATFORMS
36
29
  ruby
37
30
 
38
31
  DEPENDENCIES
39
- alf!
40
- bluecloth (~> 2.0.9)
41
- bundler (~> 1.0)
42
- noe (~> 1.3.0)
32
+ bluecloth (~> 2.1.0)
33
+ fastercsv (~> 1.5.4)
34
+ myrrha (~> 1.2.0)
35
+ quickl (~> 0.4.0)
43
36
  rake (~> 0.9.2)
44
37
  rcov (~> 0.9.9)
38
+ redcarpet (~> 1.17.2)
39
+ request-log-analyzer (~> 1.11.0)
45
40
  rspec (~> 2.6.0)
46
- wlang (~> 0.10.1)
41
+ sequel (~> 3.25.0)
42
+ sqlite3 (~> 1.3.0)
43
+ wlang (~> 0.10.2)
47
44
  yard (~> 0.7.2)
data/LICENCE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The MIT Licence
2
2
 
3
- Copyright (c) 2011 - Bernard Lambeau
3
+ Copyright (c) 2011 - Bernard Lambeau & The University of Louvain (Belgium)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/Manifest.txt CHANGED
@@ -1,4 +1,6 @@
1
1
  bin/**/*
2
+ doc/commands/**/*
3
+ doc/operators/**/*
2
4
  examples/**/*
3
5
  lib/**/*
4
6
  spec/**/*