godfat-ludy 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +226 -0
- data/LICENSE +201 -0
- data/NOTICE +21 -0
- data/README +212 -0
- data/Rakefile +56 -0
- data/TODO +21 -0
- data/bin/ludy +11 -0
- data/lib/ludy.rb +74 -0
- data/lib/ludy/all.rb +3 -0
- data/lib/ludy/array.rb +3 -0
- data/lib/ludy/array/body.rb +9 -0
- data/lib/ludy/array/choice.rb +16 -0
- data/lib/ludy/array/combine.rb +17 -0
- data/lib/ludy/array/combos.rb +35 -0
- data/lib/ludy/array/count.rb +9 -0
- data/lib/ludy/array/filter.rb +4 -0
- data/lib/ludy/array/foldl.rb +5 -0
- data/lib/ludy/array/foldr.rb +8 -0
- data/lib/ludy/array/head.rb +4 -0
- data/lib/ludy/array/map_with_index.rb +8 -0
- data/lib/ludy/array/pad.rb +13 -0
- data/lib/ludy/array/product.rb +16 -0
- data/lib/ludy/array/rotate.rb +21 -0
- data/lib/ludy/array/tail.rb +8 -0
- data/lib/ludy/blackhole.rb +17 -0
- data/lib/ludy/class.rb +3 -0
- data/lib/ludy/class/undef_all_methods.rb +9 -0
- data/lib/ludy/deprecated/aspect.rb +26 -0
- data/lib/ludy/deprecated/callstack.rb +24 -0
- data/lib/ludy/deprecated/curry.rb +29 -0
- data/lib/ludy/deprecated/rambda.rb +23 -0
- data/lib/ludy/deprecated/this.rb +14 -0
- data/lib/ludy/deprecated/untranspose.rb +12 -0
- data/lib/ludy/deprecated/unzip.rb +7 -0
- data/lib/ludy/dices.rb +66 -0
- data/lib/ludy/hash.rb +3 -0
- data/lib/ludy/hash/reverse_merge.rb +11 -0
- data/lib/ludy/helpers/check_box.rb +24 -0
- data/lib/ludy/kernel.rb +3 -0
- data/lib/ludy/kernel/deep_copy.rb +8 -0
- data/lib/ludy/kernel/defun.rb +10 -0
- data/lib/ludy/kernel/ergo.rb +16 -0
- data/lib/ludy/kernel/id.rb +8 -0
- data/lib/ludy/kernel/if_else.rb +14 -0
- data/lib/ludy/kernel/m.rb +5 -0
- data/lib/ludy/kernel/maybe.rb +9 -0
- data/lib/ludy/kernel/public_send.rb +15 -0
- data/lib/ludy/kernel/singleton_method.rb +15 -0
- data/lib/ludy/kernel/tap.rb +12 -0
- data/lib/ludy/lazy.rb +32 -0
- data/lib/ludy/list.rb +21 -0
- data/lib/ludy/message_dispatcher.rb +57 -0
- data/lib/ludy/namespace.rb +71 -0
- data/lib/ludy/paginator.rb +145 -0
- data/lib/ludy/pattern_matcher.rb +41 -0
- data/lib/ludy/proc.rb +3 -0
- data/lib/ludy/proc/bind.rb +21 -0
- data/lib/ludy/proc/chain.rb +17 -0
- data/lib/ludy/proc/compose.rb +9 -0
- data/lib/ludy/proc/curry.rb +42 -0
- data/lib/ludy/symbol.rb +3 -0
- data/lib/ludy/symbol/curry.rb +10 -0
- data/lib/ludy/symbol/to_msg.rb +10 -0
- data/lib/ludy/symbol/to_proc.rb +9 -0
- data/lib/ludy/tasks.rb +3 -0
- data/lib/ludy/tasks/common.rb +7 -0
- data/lib/ludy/tasks/preprocess_cpp.rb +70 -0
- data/lib/ludy/tasks/preprocess_cpp/attr_builder.rb +49 -0
- data/lib/ludy/tasks/preprocess_cpp/debug_hook.rb +36 -0
- data/lib/ludy/tasks/preprocess_cpp/header_guard.rb +17 -0
- data/lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb +45 -0
- data/lib/ludy/timer.rb +30 -0
- data/lib/ludy/variable.rb +29 -0
- data/lib/ludy/version.rb +9 -0
- data/lib/ludy/y_combinator.rb +11 -0
- data/lib/ludy/z_combinator.rb +11 -0
- data/lib/puzzle_generator.rb +53 -0
- data/lib/puzzle_generator/chain.rb +35 -0
- data/lib/puzzle_generator/chained_map.rb +113 -0
- data/lib/puzzle_generator/colored_map.rb +59 -0
- data/lib/puzzle_generator/map.rb +126 -0
- data/lib/puzzle_generator/misc.rb +137 -0
- data/lib/puzzle_generator/puzzle.rb +65 -0
- data/ludy.gemspec +25 -0
- data/spec/ludy_spec.rb +30 -0
- data/spec/spec_helper.rb +17 -0
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +126 -0
- data/tasks/git.rake +41 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +268 -0
- data/tasks/spec.rake +55 -0
- data/tasks/svn.rake +48 -0
- data/tasks/test.rake +38 -0
- data/test/deprecated/callstack.rb +18 -0
- data/test/deprecated/curry.rb +34 -0
- data/test/deprecated/rambda.rb +15 -0
- data/test/deprecated/this.rb +69 -0
- data/test/deprecated/ts_ludy.rb +26 -0
- data/test/deprecated/unzip_and_untranspose.rb +13 -0
- data/test/example_puzzle.rb +178 -0
- data/test/helper.rb +3 -0
- data/test/ludy/test_array.rb +63 -0
- data/test/ludy/test_class.rb +13 -0
- data/test/ludy/test_defun.rb +37 -0
- data/test/ludy/test_dices.rb +32 -0
- data/test/ludy/test_hash.rb +13 -0
- data/test/ludy/test_kernel.rb +36 -0
- data/test/ludy/test_lazy.rb +18 -0
- data/test/ludy/test_paginator.rb +84 -0
- data/test/ludy/test_proc.rb +58 -0
- data/test/ludy/test_require_all.rb +21 -0
- data/test/ludy/test_symbol.rb +15 -0
- data/test/ludy/test_variable.rb +39 -0
- data/test/ludy/test_y_combinator.rb +21 -0
- data/test/ludy/test_z_combinator.rb +20 -0
- data/test/multiruby.sh +2 -0
- metadata +252 -0
data/CHANGES
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
= ludy changes history
|
2
|
+
|
3
|
+
== ludy 0.1.13, 2008-06-14
|
4
|
+
|
5
|
+
* fixed the package... i am so dumb
|
6
|
+
|
7
|
+
== ludy 0.1.12, 2008-06-14
|
8
|
+
|
9
|
+
* added NullPaginator and NullPage for represent 0 page.
|
10
|
+
* changed repository from svn to git.
|
11
|
+
|
12
|
+
== ludy 0.1.11, 2008-03-25
|
13
|
+
|
14
|
+
* fixed tasks function into private method of Kernel.
|
15
|
+
* fixed version comparison.
|
16
|
+
* fixed encoding using # -*- coding: utf-8 -*- instead of $KCODE
|
17
|
+
* updated tasks/preprocess_cpp/debug_hook from std::cerr to std::clog.
|
18
|
+
|
19
|
+
== ludy 0.1.10, 2008.02.07
|
20
|
+
|
21
|
+
* fixed an offset bug in paginator. if the offset was equal to the count,
|
22
|
+
there should be no page existed.
|
23
|
+
* fixed and updated rdoc presentation
|
24
|
+
* fixed a warning of shadowing variables in ruby 1.9
|
25
|
+
|
26
|
+
* added the offset test in test_paginator
|
27
|
+
* make some Kernel method private
|
28
|
+
|
29
|
+
== ludy 0.1.9, 2008.02.07
|
30
|
+
|
31
|
+
* fixed a bug in RailsPaginator, which ignored opts for count.
|
32
|
+
* fixed a possible bug in puzzle_generator... (not happened before?)
|
33
|
+
* fixed a stupid timeout message bug...
|
34
|
+
|
35
|
+
* added multiruby test (from ZenTest) with ruby 1.8.6-p111, 1.9.0-0, svn trunk
|
36
|
+
* added Array#head, Array#choice!, Array#count
|
37
|
+
* added Array#product, which came from ruby 1.9 (implemented by combos in ruby 1.8)
|
38
|
+
* added Kernel#deep_copy, by Marshal idiom
|
39
|
+
* added Hash#reverse_merge
|
40
|
+
* added a simple and stupid timer........
|
41
|
+
|
42
|
+
* removed Array#reverse_map, use reverse.map instead
|
43
|
+
* renamed test_helper to helper
|
44
|
+
|
45
|
+
* puzzle_generator was never always dependent on facets now!
|
46
|
+
* ludy was never always dependent on rake now!
|
47
|
+
|
48
|
+
* change my nickname to binary string... for ruby-svn
|
49
|
+
* updated tasks from bones 1.3.2
|
50
|
+
* better Rakefile support, with version automatic extraction from README and
|
51
|
+
better way to display tasks for default task. (no sh 'rake --tasks' now)
|
52
|
+
* rake clean now clean out the *.rbc for rubinius
|
53
|
+
* Array#rotate is re-implemented.
|
54
|
+
|
55
|
+
== ludy 0.1.8, 2008.01.31
|
56
|
+
|
57
|
+
* change the way displaying debug message
|
58
|
+
|
59
|
+
== ludy 0.1.7, 2008.01.31
|
60
|
+
|
61
|
+
* added preprocess_cpp tools, debug_hook and debug_include
|
62
|
+
|
63
|
+
== ludy 0.1.6, 2008.01.31
|
64
|
+
|
65
|
+
* make erubis don't trim...
|
66
|
+
|
67
|
+
== ludy 0.1.5, 2008.01.31
|
68
|
+
|
69
|
+
* fixed task preprocess:erubis presentation error.
|
70
|
+
|
71
|
+
== ludy 0.1.4, 2008.01.31
|
72
|
+
|
73
|
+
* added Page#begin and Page#end for real index in the data
|
74
|
+
* added Paginator#count for counter.call wrapper
|
75
|
+
|
76
|
+
* rename from Ludy::eout to Ludy::erbout
|
77
|
+
* added erubis support
|
78
|
+
* rename task from erb:preprocess to preprocess:erb and preprocess:erubis
|
79
|
+
* task preprocess would preprocess with erb and erubis
|
80
|
+
* rename PROJ to Project with open struct. use Project.name now
|
81
|
+
|
82
|
+
== ludy 0.1.3, 2008.01.23
|
83
|
+
|
84
|
+
* renamed next_page to next, and prev_page to prev
|
85
|
+
* added Page#page to get the page number of that page.
|
86
|
+
* added Ludy::eout to use in erb's block, see ludy/tasks/common.rb
|
87
|
+
i would extract it to erb or somewhere else someday.
|
88
|
+
* better header_guard usage, with block
|
89
|
+
|
90
|
+
== ludy 0.1.2, 2008.01.17
|
91
|
+
|
92
|
+
* aims to add functional stuffs, list comprehension is working in progress
|
93
|
+
* Paginator series are added.
|
94
|
+
* more rdocs are added.
|
95
|
+
|
96
|
+
== ludy 0.1.1, 2008.01.10
|
97
|
+
|
98
|
+
* add Array#tail and Array#map_with_index to make the task of
|
99
|
+
template forward parameters work again. (without depend on facets)
|
100
|
+
|
101
|
+
* add some todo notes.
|
102
|
+
|
103
|
+
== ludy 0.1.0, 2008.01.08
|
104
|
+
|
105
|
+
* directory structure rearranged
|
106
|
+
now you would like to require something like:
|
107
|
+
require 'ludy/proc/bind'
|
108
|
+
require 'ludy/lazy'
|
109
|
+
require 'ludy/kernel/defun'
|
110
|
+
require 'puzzle_generator'
|
111
|
+
...
|
112
|
+
the load path is now manipulated by ludy.rb, with require guard,
|
113
|
+
to make sure that all .rb is only required once. (all the same require path.)
|
114
|
+
|
115
|
+
* you can now:
|
116
|
+
require 'ludy/kernel' # for all kernel method
|
117
|
+
require 'ludy/all' # for all ludy things
|
118
|
+
|
119
|
+
* there's no require_ludy anymore.
|
120
|
+
|
121
|
+
* project skeleton is now built through Mr Bones 1.3.0, see NOTICE
|
122
|
+
|
123
|
+
* many things are now deprecated. they are hard to implemented correctly,
|
124
|
+
or useless, or easy to be replaced, or for some other reasons.
|
125
|
+
|
126
|
+
* ludy is now compatible with ruby 1.9. and a few ruby 1.9's features are
|
127
|
+
now added in ludy to help improve compatibility between ruby versions.
|
128
|
+
|
129
|
+
* ludy executable is added. it simply call rake with ludy tasks, so:
|
130
|
+
$ ludy test # to run all tests
|
131
|
+
$ ludy doc # generate rdoc
|
132
|
+
$ ludy # see all ludy tasks
|
133
|
+
|
134
|
+
* ludy_ext.rb is split into many other .rb
|
135
|
+
|
136
|
+
* C++ ERB meta-programming is added.
|
137
|
+
|
138
|
+
* multi re-implementation is done. the new one is called defun.
|
139
|
+
it supports overloading(ad-hoc polymorphism), multi-method,
|
140
|
+
pattern matching, and perhaps others?
|
141
|
+
|
142
|
+
* rdoc support is added.
|
143
|
+
|
144
|
+
* http://ludy.rubyforge.org would now insist on the latest rdoc.
|
145
|
+
|
146
|
+
* Array#reverse_map, Array#body, Array#rotate, Array#combos, etc. is added.
|
147
|
+
|
148
|
+
== ludy 0.0.9, 2008.01.07
|
149
|
+
|
150
|
+
* Proc#bind added, see test/tc_bind.rb
|
151
|
+
|
152
|
+
== ludy 0.0.8, 2007.12.06
|
153
|
+
|
154
|
+
* ludy_ext:
|
155
|
+
added:
|
156
|
+
* Array#untranspose!
|
157
|
+
* Array#unzip!
|
158
|
+
|
159
|
+
changed:
|
160
|
+
* Kernel#curry support Symbol
|
161
|
+
|
162
|
+
* puzzle_generator added...
|
163
|
+
|
164
|
+
== ludy 0.0.7, 2007.10.08
|
165
|
+
|
166
|
+
* ludy_ext:
|
167
|
+
added:
|
168
|
+
* Array#untranspose
|
169
|
+
* Array#unzip
|
170
|
+
* Array#combine!
|
171
|
+
* Object#m
|
172
|
+
* Kernel#id
|
173
|
+
|
174
|
+
== ludy 0.0.6, 2007.09.15
|
175
|
+
|
176
|
+
* ludy_ext:
|
177
|
+
added:
|
178
|
+
* Array#combine
|
179
|
+
|
180
|
+
moved:
|
181
|
+
* move Symbol#to_proc to Symbol#to_msg,
|
182
|
+
and take back the original Symbol#to_proc implementation.
|
183
|
+
|
184
|
+
* change the way we require
|
185
|
+
|
186
|
+
== ludy 0.0.5, 2007.09.15
|
187
|
+
|
188
|
+
i forgot what i'd done... (days ago)
|
189
|
+
but sure there's Symbol#to_proc and Symbol#to_msg,
|
190
|
+
also, please read unit test.
|
191
|
+
|
192
|
+
== ludy 0.0.4, 2007.08.12
|
193
|
+
|
194
|
+
* ludy_ext:
|
195
|
+
renamed:
|
196
|
+
* Proc#curry => Proc#__curry__
|
197
|
+
|
198
|
+
added:
|
199
|
+
* Kernel#curry
|
200
|
+
|
201
|
+
strongly suggest that use Kernel#curry instead of Proc#__curry__,
|
202
|
+
see unit test for usage and changes
|
203
|
+
|
204
|
+
== ludy 0.0.3, 2007.08.07
|
205
|
+
|
206
|
+
* ludy_ext:
|
207
|
+
added:
|
208
|
+
* Proc#curry
|
209
|
+
* Proc#compose
|
210
|
+
* Proc#chain
|
211
|
+
* Symbol#to_proc
|
212
|
+
* Array#foldl
|
213
|
+
* Array#foldr
|
214
|
+
* Array#filter
|
215
|
+
|
216
|
+
removed:
|
217
|
+
* Fixnum#collect # see tc_ludy_ext.rb#test_fixnum_collect for reason
|
218
|
+
|
219
|
+
info:
|
220
|
+
* ruby2ruby has NilClass#method_missing return nil,
|
221
|
+
so i can't just make it return blackhole
|
222
|
+
|
223
|
+
* module Curry:
|
224
|
+
see test/tc_curry.rb for usage
|
225
|
+
|
226
|
+
see unit test for usage
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/NOTICE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
= notice for other stuffs
|
2
|
+
|
3
|
+
* this project skeleton is built through Mr Bones 1.3.0:
|
4
|
+
gem install bones
|
5
|
+
http://codeforpeople.rubyforge.org/bones/
|
6
|
+
|
7
|
+
* for puzzle_generator, Ruby Facets is needed: (no longer needed now!)
|
8
|
+
gem install facets
|
9
|
+
http://facets.rubyforge.org/
|
10
|
+
|
11
|
+
* defun is re-implemented gem multi:
|
12
|
+
gem install multi
|
13
|
+
http://multi.rubyforge.org/
|
14
|
+
|
15
|
+
* preprocessing tools with erubis:
|
16
|
+
gem install erubis
|
17
|
+
http://www.kuwata-lab.com/erubis/
|
18
|
+
|
19
|
+
* multiruby test with ZenTest (test for ruby 1.8.6-p111, 1.9.0-0, svn trunk)
|
20
|
+
gem install ZenTest
|
21
|
+
http://www.zenspider.com/ZSS/Products/ZenTest/
|
data/README
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
= ludy 0.1.13
|
2
|
+
by Lin Jen-Shin (a.k.a. godfat-真常[http://godfat.org])
|
3
|
+
strip any number: 18god29fat7029 (at] godfat32 -dooot- 20org
|
4
|
+
* rdoc[http://ludy.rubyforge.org]
|
5
|
+
* rubyforge-project[http://rubyforge.org/projects/ludy]
|
6
|
+
* github-project[http://github.com/godfat/ludy]
|
7
|
+
* redmine-project[https://redmine.godfat.org/projects/show/ludy]
|
8
|
+
|
9
|
+
== DESCRIPTION:
|
10
|
+
|
11
|
+
Aims to extend Ruby standard library, providing some useful tools that's not existed in the standard library, especially for functional programming.
|
12
|
+
|
13
|
+
== FEATURES:
|
14
|
+
|
15
|
+
1. ludy standard library extension, especially for functional programming.
|
16
|
+
2. rails/array paginator, included since 0.1.2
|
17
|
+
3. c++ erb meta-programming, included since 0.1.0 (support erubis 2.5+)
|
18
|
+
4. puzzle_generator, included since 0.0.8
|
19
|
+
|
20
|
+
== SYNOPSIS:
|
21
|
+
|
22
|
+
please see unit test for all examples.
|
23
|
+
|
24
|
+
$ ludy test # run all ludy tests
|
25
|
+
$ ludy # see all tasks related to ludy
|
26
|
+
|
27
|
+
please don't run any task about release... contact me first
|
28
|
+
if you would like to make changes into official ludy release.
|
29
|
+
|
30
|
+
require 'ludy/all' # for all ludy things
|
31
|
+
require 'ludy/kernel' # for all kernel methods
|
32
|
+
require 'ludy/tasks' # for all ludy tasks
|
33
|
+
require 'ludy/proc/curry' # for proc's method curry
|
34
|
+
|
35
|
+
you can make any change and then $ ludy gem:install on your local machine.
|
36
|
+
below is some example extracted from unit test.
|
37
|
+
|
38
|
+
curry:
|
39
|
+
require 'ludy/proc/curry'
|
40
|
+
assert_equal 29, :+.to_proc.curry[18][11]
|
41
|
+
|
42
|
+
bind:
|
43
|
+
require 'ludy/proc/bind'
|
44
|
+
assert_equal [9,8,7], ([1,2,3].map &(lambda{|lhs, rhs| lhs-rhs}.bind 10, :_1))
|
45
|
+
|
46
|
+
defun:
|
47
|
+
require 'ludy/kernel/defun'
|
48
|
+
defun :fact, 0 do |n|
|
49
|
+
1
|
50
|
+
end
|
51
|
+
|
52
|
+
defun :fact, Integer do |n|
|
53
|
+
n * fact(n-1)
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_equal 3628800, fact(10)
|
57
|
+
|
58
|
+
defun :f, Integer do |n| 1; end
|
59
|
+
defun :f, String do |n| '2'; end
|
60
|
+
defun(:f, Integer, Integer) do |n,g| 3; end
|
61
|
+
|
62
|
+
assert_equal 1, f(10)
|
63
|
+
assert_equal '2', f('')
|
64
|
+
assert_equal 3, f(1,1)
|
65
|
+
assert_raise NoMethodError do f('1', 2); end
|
66
|
+
|
67
|
+
lazy:
|
68
|
+
require 'ludy/lazy'
|
69
|
+
Y = lambda{|f|
|
70
|
+
lambda{|x| lazy{f[x[x]]} }[lambda{|x| lazy{f[x[x]]} }]
|
71
|
+
}
|
72
|
+
|
73
|
+
y_combinator:
|
74
|
+
require 'ludy/y_combinator'
|
75
|
+
fact = Y[lambda{|this|
|
76
|
+
lambda{|n| n==1 ? 1 : n*this[n-1]}
|
77
|
+
}]
|
78
|
+
assert_equal(3628800, fact[10])
|
79
|
+
|
80
|
+
paginator:
|
81
|
+
pager = Ludy::RailsPaginator.new(Topic)
|
82
|
+
pager = Ludy::ArrayPaginator.new(TestPaginator.data)
|
83
|
+
# or the most flexible paginator:
|
84
|
+
pager = Ludy::Paginator.new(
|
85
|
+
lambda{ |offset, per_page|
|
86
|
+
# if for rails,
|
87
|
+
# Data.find :all, :offset => offset, :limit => per_page
|
88
|
+
TestPaginator.data[offset, per_page]
|
89
|
+
}, lambda{
|
90
|
+
# if for rails,
|
91
|
+
# Data.count
|
92
|
+
TestPaginator.data.size
|
93
|
+
})
|
94
|
+
pager.per_page = 10
|
95
|
+
|
96
|
+
pager.page(1)
|
97
|
+
pager[1] # same as above
|
98
|
+
pager.page(2).next.prev.each{|e| e} # you can enumerate
|
99
|
+
pager[3].map{|e| e*2}
|
100
|
+
pager.size # number of pages
|
101
|
+
pager.inject(0){|r, i| r += i.inject &:+ } # total sum of all data
|
102
|
+
|
103
|
+
ludy tasks:
|
104
|
+
|
105
|
+
|
106
|
+
header_guard:
|
107
|
+
require 'ludy/tasks/erb_cpp/header_guard'
|
108
|
+
Project.name = 'header_sample' # remember to set project name
|
109
|
+
|
110
|
+
# in utils/SimpleTest.hpp.erb
|
111
|
+
<% header_guard do %>
|
112
|
+
class C;
|
113
|
+
<% end %>
|
114
|
+
|
115
|
+
# run preprocessing task
|
116
|
+
$ rake preprocessing
|
117
|
+
|
118
|
+
# produce:
|
119
|
+
#ifndef _HEADER_SAMPLE_UTILS_SIMPLETEST_
|
120
|
+
#define _HEADER_SAMPLE_UTILS_SIMPLETEST_
|
121
|
+
class C;
|
122
|
+
#endif
|
123
|
+
|
124
|
+
attr_builder:
|
125
|
+
require 'ludy/tasks/erb_cpp' # it would require all erb_cpp tasks.
|
126
|
+
|
127
|
+
# in MapSetting.hpp.erb
|
128
|
+
class MapSetting{
|
129
|
+
<%= accessor :int, :frequency %>
|
130
|
+
<%= accessor :double, :speed, :damage_factor %>
|
131
|
+
<%= reader :int, :width, :height, :size %>
|
132
|
+
};
|
133
|
+
|
134
|
+
# run preprocessing task
|
135
|
+
$ rake preprocessing
|
136
|
+
|
137
|
+
# produce:
|
138
|
+
class MapSetting{
|
139
|
+
public:
|
140
|
+
int frequency() const{ return frequency_; }
|
141
|
+
public:
|
142
|
+
MapSetting& frequency(int const& new_frequency){ frequency_ = new_frequency; return *this; }
|
143
|
+
private:
|
144
|
+
int frequency_;
|
145
|
+
|
146
|
+
public:
|
147
|
+
double speed() const{ return speed_; }
|
148
|
+
double damage_factor() const{ return damage_factor_; }
|
149
|
+
public:
|
150
|
+
MapSetting& speed(double const& new_speed){ speed_ = new_speed; return *this; }
|
151
|
+
MapSetting& damage_factor(double const& new_damage_factor){ damage_factor_ = new_damage_factor; return *this; }
|
152
|
+
private:
|
153
|
+
double speed_, damage_factor_;
|
154
|
+
|
155
|
+
public:
|
156
|
+
int width() const{ return width_; }
|
157
|
+
int height() const{ return height_; }
|
158
|
+
int size() const{ return size_; }
|
159
|
+
private:
|
160
|
+
int width_, height_, size_;
|
161
|
+
};
|
162
|
+
|
163
|
+
template_forward_parameters:
|
164
|
+
require 'ludy/tasks/erb_cpp/template_forward_parameters'
|
165
|
+
|
166
|
+
# in test.hpp.erb
|
167
|
+
<% for_template_parameters_within(1..5, []){ |args_list| %>
|
168
|
+
template <%= template_parameters args_list %>
|
169
|
+
static element_type create(<%= forward_parameters args_list %>){
|
170
|
+
return element_type(SPool::Instance().construct(<%= arguments args_list %>), Deleter());
|
171
|
+
}
|
172
|
+
<% } %>
|
173
|
+
|
174
|
+
# run preprocessing task
|
175
|
+
$ rake preprocess
|
176
|
+
|
177
|
+
# one of the produce: (can't list all...)
|
178
|
+
template <class T0, class T1, class T2, class T3>
|
179
|
+
static element_type create(T0 const& a, T1 const& b, T2 & c, T3 const& d){
|
180
|
+
return element_type(SPool::Instance().construct(a, b, c, d), Deleter());
|
181
|
+
}
|
182
|
+
|
183
|
+
== REQUIREMENTS:
|
184
|
+
|
185
|
+
* ruby 1.8/1.9 (1.9 is prefered...)
|
186
|
+
* rake in some features
|
187
|
+
* erb in task preprocess:erb
|
188
|
+
* gem erubis if you are using preprocess:erubis
|
189
|
+
* gem facets is recommended if you are using puzzle_generator
|
190
|
+
* gem ZenTest if you are running multiruby.sh in test
|
191
|
+
|
192
|
+
== INSTALL:
|
193
|
+
|
194
|
+
* sudo gem install ludy
|
195
|
+
|
196
|
+
== LICENSE:
|
197
|
+
|
198
|
+
Apache License 2.0
|
199
|
+
|
200
|
+
Copyright (c) 2008, Lin Jen-Shin (a.k.a. godfat 真常)
|
201
|
+
|
202
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
203
|
+
you may not use this file except in compliance with the License.
|
204
|
+
You may obtain a copy of the License at
|
205
|
+
|
206
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
207
|
+
|
208
|
+
Unless required by applicable law or agreed to in writing, software
|
209
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
210
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
211
|
+
See the License for the specific language governing permissions and
|
212
|
+
limitations under the License.
|