extensions 0.4.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.
@@ -0,0 +1,190 @@
1
+ 2004-09-23 Gavin Sinclair <gsinclair@soyabean.com.au>
2
+
3
+ * RELEASE: 0.4.0 ===================================================
4
+ * README: Updated with new release info, included sample code, and
5
+ placed links near the beginning.
6
+ * etc/website/upload.sh: updated RDoc directory location.
7
+ * install-doc.rb: ditto, plus call 'rake rerdoc'.
8
+
9
+ 2004-07-19 Gavin Sinclair <gsinclair@soyabean.com.au>
10
+
11
+ * version 0.3.9
12
+ * lib/extensions/ostruct.rb: Override OpenStruct#initialize to
13
+ provide initialization via a block
14
+ * test/tc_ostruct.rb: test OpenStruct#initialize
15
+
16
+ 2004-07-19 Gavin Sinclair <gsinclair@soyabean.com.au>
17
+
18
+ * version 0.3.8
19
+ * lib/extensions/string.rb: implemented String#join
20
+ * lib/extensions/object.rb: implemented Object#not_nil?, #non_nil?,
21
+ and #define_method
22
+ * test/tc_{string,object}.rb: test above methods
23
+ * lib/extensions/_base.rb: made special case for implementing #initialize
24
+ * lib/extensions/_template.rb: removed some cruft
25
+
26
+ 2004-07-18 Gavin Sinclair <gsinclair@soyabean.com.au>
27
+
28
+ * version 0.3.7
29
+ * Rakefile: improved gem spec and test target.
30
+
31
+ 2004-07-18 Gavin Sinclair <gsinclair@soyabean.com.au>
32
+
33
+ * version 0.3.6
34
+ * lib/extensions/array.rb: implemented Array#select!
35
+ * lib/extensions/hash.rb: implemented Hash#select!
36
+ - both methods suggested and implemented by Wayne Vucenic
37
+ * lib/extensions/all.rb: added array.rb and hash.rb to the require
38
+ list (both being new files)
39
+ * test/tc{array,hash}.rb: added test cases for #select!
40
+ * Rakefile: added 'methods' task (list extensions methods)
41
+ * etc/list_methods.rb: removed (Rake handles this now)
42
+
43
+ 2004-07-18 Gavin Sinclair <gsinclair@soyabean.com.au>
44
+
45
+ * version 0.3.5
46
+ * lib/extensions/io.rb: implemented IO.writelines, and improved
47
+ IO.write's documentation.
48
+ * test/tc_io.rb: tested IO.writelines, and improved IO.write's
49
+ test.
50
+
51
+ 2004-07-18 Gavin Sinclair <gsinclair@soyabean.com.au>
52
+
53
+ * version 0.3.4
54
+ * .cvsignore: updated
55
+ * etc/release/.cvsignore: deleted
56
+ * etc/release: removed again
57
+ * Rakefile: added 'test' target
58
+
59
+ 2004-07-17 Gavin Sinclair <gsinclair@soyabean.com.au>
60
+
61
+ * version 0.3.3
62
+ * test/TEST.rb: added
63
+ * etc/release: removed directory and contents (Rake handles packaging
64
+ now)
65
+ * etc/gen-rdoc.rb: removed (Rake handles documentation now)
66
+ * etc/website/upload.sh: removed (Rake handles website upload now)
67
+
68
+ 2004-07-17 Gavin Sinclair <gsinclair@soyabean.com.au>
69
+
70
+ * version 0.3.2
71
+ * lib/extensions/*.rb: moved unit tests to extensions/test/tc_*.rb.
72
+ * test/tc_*.rb: moved unit tests here from library files.
73
+ * Rakefile: first time in repository.
74
+
75
+ 2004-01-24 Gavin Sinclair <gsinclair@soyabean.com.au>
76
+
77
+ * version 0.3.1
78
+ * lib/extensions/string.rb: more efficient algorithm for #expand_tabs;
79
+ thanks to GGaramuno.
80
+
81
+ 2004-01-23 Gavin Sinclair <gsinclair@soyabean.com.au>
82
+
83
+ * RELEASE: 0.3.0 ===================================================
84
+ * etc/gen-rdoc.sh: removed
85
+ * etc/gen-rdoc.rb: introduced
86
+ * install-doc.rb: use gen-rdoc.rb; removed extra 'rdoc' from target
87
+ directory path
88
+ * README: updated information about the new release
89
+ * etc/checklist: added checklist for creating a new release
90
+
91
+ 2004-01-13 Gavin Sinclair <gsinclair@soyabean.com.au>
92
+
93
+ * version 0.2.14
94
+ * lib/extensions/enumerable.rb: implemented Enumerable#partition_by
95
+ -- idea and code by Jason Creighton.
96
+
97
+ 2004-01-13 Gavin Sinclair <gsinclair@soyabean.com.au>
98
+
99
+ * version 0.2.13
100
+ * lib/extensions/numeric.rb: formatting options extended to include
101
+ currency (:usd, :euro, and :percent); submitted by Austin Ziegler.
102
+ * lib/extensions/_base.rb: include project name in error messages.
103
+ * etc/gen-rdoc.sh: explicitly exclude CVS directories.
104
+
105
+ 2003-11-12 Gavin Sinclair <gsinclair@soyabean.com.au>
106
+
107
+ * version 0.2.12
108
+ * lib/extensions/enumerable.rb: implemented Hash#build_hash as a
109
+ workaround to a problem in Ruby that was fixed on 2003-10-24. Also
110
+ added extra documentation to this method.
111
+
112
+ 2003-10-27 Gavin Sinclair <gsinclair@soyabean.com.au>
113
+
114
+ * version 0.2.11
115
+ * lib/extensions/string.rb: modified String#trim, so that
116
+ str.trim('|') now does what str.trim('| ') used to do, and it
117
+ handles blank lines properly. WARNING: non-backwards-compatible.
118
+
119
+ 2003-10-27 Gavin Sinclair <gsinclair@soyabean.com.au>
120
+
121
+ * version 0.2.10
122
+ * lib/extensions/string.rb: fixed String#leftmost indent (blank lines
123
+ threw it off)
124
+
125
+ 2003-10-22 Gavin Sinclair <gsinclair@soyabean.com.au>
126
+
127
+ * version 0.2.9
128
+ * lib/extensions/string.rb: implemented String#cmp to compare strings
129
+ * etc/checklist: couple more points
130
+
131
+ 2003-10-22 Gavin Sinclair <gsinclair@soyabean.com.au>
132
+
133
+ * version 0.2.8
134
+ * lib/extensions/enumerable.rb: more unit tests
135
+
136
+ 2003-10-14 Gavin Sinclair <gsinclair@soyabean.com.au>
137
+
138
+ * version 0.2.7
139
+ * lib/extensions/string.rb: implemented String#line(*args)
140
+ * lib/extensions/string.rb: removed test_leftmost_indent as it is a
141
+ protected method now
142
+
143
+ 2003-10-08 Gavin Sinclair <gsinclair@soyabean.com.au>
144
+
145
+ * version 0.2.6
146
+ * install-doc.rb: reflects new location for etc/gen-rdoc.sh
147
+ * README.1st: simplified
148
+
149
+ 2003-10-08 Gavin Sinclair <gsinclair@soyabean.com.au>
150
+
151
+ * version 0.2.5
152
+ * lib/extensions/object.rb: improved #pp_s documentation
153
+ * README.html: removed (it's just generated anyway)
154
+ * README.1st: introduced
155
+ * etc/doctools/*: moved to etc/
156
+ * etc/gen-rdoc.sh: no longer copy README.html to root directory
157
+ * etc/list-methods.rb: adapt library path to new location
158
+ * README: a bit of tidy-up, and reflect above changes, and some
159
+ other recent changes
160
+
161
+ 2003-10-06 Gavin Sinclair <gsinclair@soyabean.com.au>
162
+
163
+ * versions 0.2.4
164
+ * etc/website/index.html: added; redirects to rdoc/index.html
165
+ * etc/website/upload.sh: changed to upload index.html and rdoc
166
+ directory
167
+ * etc/doctools/gen-rdoc.sh: only copy README.html to root directory
168
+ if -c argument is given
169
+
170
+ 2003-10-06 Gavin Sinclair <gsinclair@soyabean.com.au>
171
+
172
+ * version 0.2.3
173
+ * lib/extensions/object.rb: Added Object#pp_s to return a
174
+ pretty-printed string.
175
+
176
+ 2003-10-05 Gavin Sinclair <gsinclair@soyabean.com.au>
177
+
178
+ * version 0.2.2
179
+ * lib/extensions/enumerable.rb: added Enumerable#mapf and #collectf
180
+
181
+ 2003-10-05 Gavin Sinclair <gsinclair@soyabean.com.au>
182
+
183
+ * version 0.2.1
184
+ * lib/extensions/symbol.rb: added Symbol#to_proc
185
+ * lib/extensions/all.rb: include symbol.rb
186
+ * etc/checklist: added
187
+
188
+ 2003-10-04 Gavin Sinclair <gsinclair@soyabean.com.au>
189
+
190
+ * RELEASE: 0.2.0 ===================================================
data/HISTORY ADDED
@@ -0,0 +1,59 @@
1
+ This file describes the difference between releases, and documents that date
2
+ those releases were made. See ChangeLog for more information.
3
+
4
+ 2003-10-04, v0.2.0 (v0_2_0)
5
+
6
+ - string.rb completed with working functionality, two more methods, and full
7
+ unit tests. New methods:
8
+ String#taballto
9
+ String#leftmost_indent
10
+ String#expand_tabs
11
+
12
+ - Numeric#format_s, adopted from Austin Ziegler's contribution to
13
+ FixNumFormat on the wiki, added.
14
+
15
+ - Fixed important typo in install-doc.rb.
16
+
17
+ - Removed most methods from io.rb as they look cluttered and I'm not exactly
18
+ sure what to do with them! Only IO.write remains, which is the only
19
+ really important one.
20
+
21
+ - Generated RDoc goes to directory "rdoc" not "doc" now. It is installed to
22
+ that directory, and uploaded to http://extensions.rubyforge.org/rdoc with
23
+ etc/doctools/website/upload.sh.
24
+
25
+ - General improvement in documentation.
26
+
27
+ - etc/release directory introduced for generating tarballs from CVS.
28
+
29
+
30
+ 2003-10-02, v0.1 (v0_1)
31
+
32
+ - 'rbxtm' returns the following
33
+
34
+ Class#autoinit
35
+ Enumerable#build_hash
36
+ Enumerable#collect_with_index
37
+ Enumerable#contains?
38
+ Enumerable#has?
39
+ Enumerable#includes?
40
+ Enumerable#map_with_index
41
+ IO::read_binary
42
+ IO::read_text
43
+ IO::write
44
+ IO::write_binary
45
+ IO::write_text
46
+ Integer#even?
47
+ Integer#odd?
48
+ Object#in?
49
+ Object#singleton_class
50
+ String#indent
51
+ String#outdent
52
+ String#tabto
53
+ String#trim
54
+
55
+ - Not all methods are thoroughly tested. String and IO are the only ones
56
+ lacking, I think.
57
+
58
+ - Infrastructure: etc/website/*, etc/doctools/*, README all in good shape.
59
+ etc/release/* nonexistent.
data/README ADDED
@@ -0,0 +1,341 @@
1
+ = Ruby Extensions Project README
2
+
3
+ == Table of Contents
4
+
5
+ 1. Introduction
6
+ 2. Sample Code
7
+ 3. Links
8
+ 4. Current Version and Status
9
+ 5. Installation
10
+ 6. What's Included?
11
+ 7. Usage Information
12
+ 8. Technical Information
13
+ 9. Feedback
14
+ 10. Licence
15
+
16
+
17
+ == Introduction
18
+
19
+ This project contains several extensions to the Ruby standard classes. Many are
20
+ sourced from the Ruby Wiki (see links at end of document).
21
+
22
+ Criteria for inclusion of a method are:
23
+ - the method serves a general purpose
24
+ - it is reasonably clear from the method name what its behaviour is
25
+ - it would not generally be out of place in the language itself
26
+
27
+ Apart from convenience, the benefit of this package is to provide a reference.
28
+ You can use this package for your convenience, and deploy your code with a
29
+ clear dependency on it, since anyone can download it. That is better than
30
+ releasing your package with a few ad hoc standard class modifications, and
31
+ hoping that they don't conflict with any code your users have written.
32
+
33
+ Long story short: it's useful that Ruby allows you to add methods to existing
34
+ classes, even built-ins like String and Array. Some people rightfully are
35
+ uneasy about actually doing so, because of possible conflicts. This project
36
+ offers a standard set of extensions in order to mitigate that uneasiness by
37
+ making them publicly available, and well documented.
38
+
39
+ Thanks to the kind folk at InfoEther, Rich Kilmer and Tom Copeland, for
40
+ providing the means and encouragement to host projects like these at
41
+ http://www.rubyforge.org.
42
+
43
+
44
+ == Sample Code
45
+
46
+ require 'extensions/all'
47
+
48
+ str = "Hello, \n\n world!"
49
+ str.define_method(:heading) {
50
+ ('*** ' + self.join + ' ***').indent(3)
51
+ }
52
+ str.heading # -> " *** Hello, world! ***"
53
+
54
+ person = OpenStruct.new do |p|
55
+ p.name = 'John'
56
+ p.age = 90
57
+ end
58
+
59
+ class Person
60
+ attr_reader :name, :age, :pension
61
+ autoinit :name, :age do |p|
62
+ @pension = 30000 + (@age - 65) * 350
63
+ end
64
+ end
65
+ john = Person.new('John', 90)
66
+ puts john.pension
67
+
68
+ HELP = %{
69
+ | Usage: ...
70
+ | Lorem ipsum...
71
+ }.trim('|')
72
+
73
+ NUMBERS = (1..100)
74
+ squares = NUMBERS.build_hash { |n| [n, n**2] }
75
+ squares[4] # -> 16
76
+ sq_roots = NUMBERS.build_hash { |n| [Math.sqrt(n), n] }
77
+ _4_mod_7 = NUMBERS.partition_by { |n| n % 7 }[4]
78
+
79
+ STR = "Hello, world!"
80
+ STR.starts_with? "Hello" # -> true
81
+ STR.ends_with? "world" # -> false
82
+ File.write("hello.txt", str)
83
+
84
+
85
+ == Links
86
+
87
+ Home Page:: http://extensions.rubyforge.org (includes API documentation)
88
+ Project page:: http://www.rubyforge.org/projects/extensions
89
+ Wiki Page:: http://www.rubygarden.org/ruby?StandardClassExtensions
90
+
91
+
92
+ == Current Version and Status
93
+
94
+ Version 0.4 was released on 2004-09-23 and can be installed as a gem,
95
+ installed via the RPA, or downloaded from the project page. Anybody is
96
+ welcome to access the CVS and see changes as they happen. As always,
97
+ everything included is unit tested and well documented.
98
+
99
+ Version 0.4 is a precursor to version 0.5 where yet more methods will be
100
+ introduced. It just makes sense to release what's currently available before
101
+ committing to that effort. The long-term goal of <tt>extensions</tt> is to
102
+ become part of the <tt>addlib</tt> project.
103
+
104
+ Several methods have been added since version 0.3. <tt>ChangeLog</tt> has all
105
+ the details, and the changes are highlighted below.
106
+
107
+ Version 1.0 will (may?) occur when sufficient time has passed to make me
108
+ confident there are no bugs in this, and after a few more minor versions are
109
+ released with new methods. Nobody has complained about bugs so far, and any
110
+ bugs would be easy to fix, so I have no problem using this package in my own
111
+ production code.
112
+
113
+ The methods listed in this document will always reflect the most recent
114
+ released version, but the online RDoc will reflect what's in the latest CVS.
115
+
116
+
117
+ == Installation
118
+
119
+ The easiest way to install <tt>extensions</tt> is via RubyGems or the RPA.
120
+
121
+ gem install -r extensions
122
+
123
+ rpa update
124
+ rpa install extensions
125
+
126
+ === Tarball installation
127
+
128
+ The tarball version uses Minero Aoki's <tt>install.rb</tt>. Run the
129
+ following, with the last one as root if appropriate.
130
+
131
+ ruby install.rb config
132
+ ruby install.rb setup
133
+ ruby install.rb install
134
+
135
+ This will install the <tt>extensions/*</tt> files somewhere you can load them,
136
+ and +rbxtm+ in a +bin+ directory. I've combined these commands into
137
+ <tt>install.sh</tt> if you want to run that instead.
138
+
139
+ === Installing documentation
140
+
141
+ <tt>extensions</tt> offers you the opportunity to install its RDoc-generated
142
+ API documentation to your hard drive for ease of access. Personally, I find
143
+ it easier to hit the website all the time, but... It only works if you have
144
+ Rake installed.
145
+
146
+ From the base directory, run (as root if that applies to you):
147
+
148
+ ruby install-doc.rb [location]
149
+
150
+ If you don't provide a location, it will default to
151
+ <tt>/usr/local/doc/ruby</tt>. Well, that's on my platform; it will make an
152
+ intelligent guess on yours. This is not a tried and tested documentation
153
+ installer; I wrote it just for this project, so please let me know if you're
154
+ not happy with it for any reason.
155
+
156
+ A side effect of installing the documentation is that it will be generated
157
+ into the <tt>build/rdoc</tt> directory of the package.
158
+
159
+ The "base directory" is the directory you unpacked from the tarball. If you
160
+ installed via RubyGems, you might try this:
161
+
162
+ gem unpack extensions
163
+ cd extensions-0.4.0
164
+ ruby install-doc.rb [location]
165
+ cd ..
166
+ rm -rf extensions-0.4.0
167
+
168
+ <tt>gem unpack</tt> is like having access to the tarball without having to
169
+ manually download it.
170
+
171
+
172
+ == What's included?
173
+
174
+ When you install this package, you can run the command +rbxtm+ ("Ruby
175
+ Extension Methods") to get a list of the methods implemented by this project.
176
+ At time of writing, this command gives (<tt>+</tt> indicates new method since
177
+ 0.3).
178
+
179
+ + Array#select!
180
+ Class#autoinit
181
+ Enumerable#build_hash
182
+ Enumerable#collect_with_index
183
+ Enumerable#collectf
184
+ Enumerable#contains?
185
+ Enumerable#has?
186
+ Enumerable#includes?
187
+ Enumerable#map_with_index
188
+ Enumerable#mapf
189
+ Enumerable#partition_by
190
+ Hash#select!
191
+ IO.write
192
+ IO.writelines
193
+ Integer#even?
194
+ Integer#odd?
195
+ Numeric#format_s
196
+ + Object#define_method
197
+ Object#in?
198
+ + Object#non_nil?
199
+ + Object#not_nil?
200
+ Object#pp_s
201
+ Object#singleton_class
202
+ + OpenStruct.new
203
+ String#cmp
204
+ String#ends_with?
205
+ String#expand_tabs
206
+ String#indent
207
+ + String#join
208
+ String#leftmost_indent
209
+ String#line
210
+ String#outdent
211
+ String#starts_with?
212
+ String#taballto
213
+ String#tabto
214
+ String#trim
215
+ Symbol#to_proc
216
+
217
+ The files that you can load are:
218
+
219
+ extensions/all
220
+ extensions/class
221
+ extensions/enumerable
222
+ extensions/io
223
+ extensions/numeric
224
+ extensions/object
225
+ extensions/ostruct
226
+ extensions/string
227
+ extensions/symbol
228
+
229
+ The RDoc documentation has all the details. You can view this locally after
230
+ running <tt>ruby install-doc.rb</tt>, or you can view it online. See the
231
+ links at the bottom of the page.
232
+
233
+
234
+ == Usage Information
235
+
236
+ Using this package is simple. After installation, just include the following
237
+ line in your Ruby program:
238
+
239
+ require 'extensions/all'
240
+
241
+ Then you can use any of the methods listed above. If you want to only use
242
+ some of the methods, then load the file that names the class whose extensions
243
+ you wish to use. For example:
244
+
245
+ require 'extensions/string'
246
+
247
+ puts report.indent(3)
248
+
249
+ If you install it via RubyGems, then you may need to do this in your code:
250
+
251
+ require 'rubygems'
252
+ require 'extensions/string' # Or whatever you want to load.
253
+
254
+
255
+ == Technical Information
256
+
257
+ === Special library files
258
+
259
+ This package has a simple framework to ensure safety and some correctness.
260
+ See the file <tt>_base.rb</tt> for more information.
261
+
262
+ There is a template used for new files: <tt>_template.rb</tt>. It will raise an error
263
+ if you actually load it.
264
+
265
+ === Unit testing
266
+
267
+ Unit tests are located in the <tt>test/</tt> directory, and are most easily
268
+ run using Rake with <tt>rake test</tt>.
269
+
270
+ === How the package is organised
271
+
272
+ Relative to the root directory of the package:
273
+ bin/rbxtm::
274
+ Lists the methods implemented by all the extensions that are installed.
275
+ This file is installed in the +bin+ directory on the user's machine.
276
+ build/::
277
+ A directory into which RDoc and packages are built.
278
+ etc/checklist::
279
+ Contains a checklist for creating a new teeny version or a new minor
280
+ release.
281
+ etc/website/index.html::
282
+ <tt>index.html</tt> for the website.
283
+ etc/website/upload.sh::
284
+ Copies <tt>index.html</tt> and the entire +rdoc+ directory to the website.
285
+ lib/extensions/*.rb::
286
+ The extensions libraries themselves.
287
+
288
+ In the root directory:
289
+ ChangeLog::
290
+ Records changes to the package (after v0.2).
291
+ HISTORY::
292
+ Documents the main changes between minor versions (before v0.2).
293
+ README::
294
+ Either the file you're reading, or the source file for the file you're
295
+ reading.
296
+ README.1st::
297
+ Instructions for generating documentation (specifically README.html)
298
+ Rakefile::
299
+ Encapsulates all sorts of project tasks: generate documentation, create a
300
+ tarball or gem for release, run unit tests, list the <tt>extensions</tt>
301
+ methods. This replaces three special-purpose scripts and does a better
302
+ job to boot. Thanks Jim!
303
+ VERSION::
304
+ Current version of the package. Used to decide on a directory for
305
+ installing documentation.
306
+ install-doc.rb::
307
+ Generates +rdoc+ documentation and installs it in a directory like
308
+ <tt>/usr/local/doc/ruby/extensions-0.2.0/</tt>.
309
+ install.rb::
310
+ Minero Aoki's installer. Installs the package on your system.
311
+ install.sh::
312
+ Front-end for <tt>install.rb</tt> so you don't have to run it three times.
313
+
314
+ == Feedback
315
+
316
+ If you would like to report a bug, suggest a method for inclusion, or make
317
+ some other suggestion (documentation, package layout, etc.), then head to the
318
+ project page (see links at end of document) and use the bug tracker or feature
319
+ request. If neither of these is appropriate, or if you want to discuss
320
+ something before submitting, please contact me via email.
321
+
322
+
323
+ == Licence
324
+
325
+ Ruby/Extensions (http://extensions.rubyforge.org) is copyrighted free software
326
+ created and maintained by Gavin Sinclair (mailto:gsinclair@soyabean.com.au)
327
+ and released under the same license as Ruby.
328
+
329
+ Standard disclaimer:
330
+ THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
331
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
332
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
333
+ PURPOSE.
334
+
335
+
336
+ ------
337
+
338
+ <i>
339
+ $Id: README,v 1.12 2004/09/23 09:44:43 gsinclair Exp $
340
+ vim: et sw=2 ts=2 sts=2 ai
341
+ </i>