sixarm_ruby_ramp 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CHANGELOG.txt +51 -0
- data/INSTALL.txt +32 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +240 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/lib/sixarm_ruby_ramp/array.rb +397 -0
- data/lib/sixarm_ruby_ramp/class.rb +38 -0
- data/lib/sixarm_ruby_ramp/csv.rb +58 -0
- data/lib/sixarm_ruby_ramp/date.rb +55 -0
- data/lib/sixarm_ruby_ramp/enumerable.rb +483 -0
- data/lib/sixarm_ruby_ramp/file.rb +17 -0
- data/lib/sixarm_ruby_ramp/fixnum.rb +34 -0
- data/lib/sixarm_ruby_ramp/hash.rb +238 -0
- data/lib/sixarm_ruby_ramp/integer.rb +26 -0
- data/lib/sixarm_ruby_ramp/io.rb +71 -0
- data/lib/sixarm_ruby_ramp/kernel.rb +84 -0
- data/lib/sixarm_ruby_ramp/math.rb +30 -0
- data/lib/sixarm_ruby_ramp/nil.rb +22 -0
- data/lib/sixarm_ruby_ramp/numeric.rb +44 -0
- data/lib/sixarm_ruby_ramp/object.rb +23 -0
- data/lib/sixarm_ruby_ramp/process.rb +221 -0
- data/lib/sixarm_ruby_ramp/string.rb +230 -0
- data/lib/sixarm_ruby_ramp/symbol.rb +29 -0
- data/lib/sixarm_ruby_ramp/time.rb +61 -0
- data/lib/sixarm_ruby_ramp/xml.rb +204 -0
- data/lib/sixarm_ruby_ramp/yaml.rb +10 -0
- data/lib/sixarm_ruby_ramp.rb +8 -0
- data/test/sixarm_ruby_ramp/io_test.txt +1 -0
- data/test/sixarm_ruby_ramp/xml_test_1.xml +5 -0
- data/test/sixarm_ruby_ramp/xml_test_2.xml +5 -0
- data/test/sixarm_ruby_ramp/xml_test_msword_clean.html +1 -0
- data/test/sixarm_ruby_ramp/xml_test_msword_dirty.html +148 -0
- data/test/sixarm_ruby_ramp_test.rb +9 -0
- data.tar.gz.sig +1 -0
- metadata +113 -0
- metadata.gz.sig +0 -0
data/.gemtest
ADDED
File without changes
|
data/CHANGELOG.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
2.1.0 Spring cleaning for Ruby 1.9.3 with better README, new CHANGELOG, less YAML, etc.
|
2
|
+
2.0.9 Remove Hash#to_yaml_sort and replace its functionality with Hash#sort_by_keys
|
3
|
+
2.0.8 Add Numeric#percent
|
4
|
+
2.0.7 Move YAML#load_xxx methods to new gem
|
5
|
+
2.0.6 Move Date#age_xxx methods to new gem
|
6
|
+
2.0.5 Move String#to_class to new gem
|
7
|
+
2.0.4 Add lib to path
|
8
|
+
2.0.0 Upgrade to Ruby 1.9.2
|
9
|
+
1.9.0 Add Enumerable#mutex? and #nitems?
|
10
|
+
1.8.4 Add YAML#load_dir_key_values
|
11
|
+
1.8.2 Refactored Numeric metric names into their own methods
|
12
|
+
1.8.0 100% rcov coverage
|
13
|
+
1.7.8 Add rcov testing
|
14
|
+
1.7.4 Add Class#publicize_methods, Integer#even?, Integer#odd?
|
15
|
+
1.7.3 Refactor Rails classes to their own gem, add README, LICENSE
|
16
|
+
1.7.2 Gemcutter update
|
17
|
+
1.7.1.8 Add Enumerable#map_with_index
|
18
|
+
1.7.1.6 Add ActiveRecord::SaveExtensions#save_false_then_reload!
|
19
|
+
1.7.1.3 Add XML#strip_xxx
|
20
|
+
1.7.1.2 Update gems: Gemcutter, Ruby 1.9.1, JRuby sqlite3
|
21
|
+
1.7.1.0 Add XML attributes methods #
|
22
|
+
1.7.0.9 Add Enumerable #hash_by, #index_by
|
23
|
+
1.7.0.7 Add Array#to_tsv, String#split_tsv, improve Array#to_csv
|
24
|
+
1.7.0.6 Add Array#shuffle, Array#shuffle!
|
25
|
+
1.7.0.5 Add Array#shifted, Array#rest, Array#car, Array#cdr
|
26
|
+
1.7.0.4 Upgrade IO#readrows and #readrow to use options
|
27
|
+
1.7.0.2 Add Array#to_tdf
|
28
|
+
1.7.0.1 Remove sqlite3 testing dependency
|
29
|
+
1.6.9.6 Add Symbol with comparable and <=>
|
30
|
+
1.6.9.5 Add ActiveRecord testing with sqlite3
|
31
|
+
1.6.9.4 JRuby install and test successful
|
32
|
+
1.6.9.3 Array#join add infix, prefix, suffix
|
33
|
+
1.6.9.2 Improve ri docs
|
34
|
+
1.6.9.1 Add Array#onto, Enumerable#intersect?
|
35
|
+
1.6.9.0 Add IO, File, ActiveRecord#seed
|
36
|
+
1.6.8.9 Add Enumerable#to_h, Array#hash, Hash#each_key!, Hash#each_pair, Hash#each_value!
|
37
|
+
1.6.8.8 Add Hash#map_pair, Hash#size?, Hash#pivot
|
38
|
+
1.6.8.7 Add Math
|
39
|
+
1.6.8.6 Add ActiveRecord SchemaStatements
|
40
|
+
1.6.8.5 Add Integer#maps, String#ACCENTS
|
41
|
+
1.6.8.4 Add XML
|
42
|
+
1.6.8.3 Add ActiveRecord
|
43
|
+
1.6.8.2 Add String#lowcase
|
44
|
+
1.6.8 Add map_to_xxx methods
|
45
|
+
1.6.7 Add CSV
|
46
|
+
1.6.6 Add Array#to_csv, Integer, String#lorem, etc., improve tests
|
47
|
+
1.6.4 Bug fixes: String characters and YAML test files
|
48
|
+
1.6.2 Improve organizaiton of class files to lib/ramp
|
49
|
+
1.6.0 Upgraded to work with Ruby 1.9.1
|
50
|
+
1.5.0 Combined all Ruby extension files into one gem
|
51
|
+
1.0.0 Original
|
data/INSTALL.txt
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
= SixArm.com Ruby Gem Install
|
3
|
+
|
4
|
+
|
5
|
+
First-time users: add our gem certificate and source.
|
6
|
+
When you do this once, it works for all our gems.
|
7
|
+
|
8
|
+
sudo wget http://sixarm.com/sixarm.pem
|
9
|
+
sudo gem cert --add sixarm.pem
|
10
|
+
sudo gem sources --add http://sixarm.com
|
11
|
+
|
12
|
+
Install the gem with advanced options.
|
13
|
+
|
14
|
+
sudo gem install sixarm_ruby_ramp --test --trust-policy HighSecurity
|
15
|
+
|
16
|
+
|
17
|
+
== Notes
|
18
|
+
|
19
|
+
Do you have any questions, comments, suggestions, or feedback?
|
20
|
+
Let us know, we're happy to help. Our email is sixarm@sixarm.com
|
21
|
+
|
22
|
+
Do you want to create your own high security gems?
|
23
|
+
Learn how at http://www.rubygems.org/read/chapter/21
|
24
|
+
|
25
|
+
To see your current gem certificate list:
|
26
|
+
|
27
|
+
sudo gem cert --list
|
28
|
+
|
29
|
+
Our cert looks like this:
|
30
|
+
|
31
|
+
/C=US/ST=California/L=San Francisco/O=SixArm/CN=sixarm.com
|
32
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
= SixArm.com » Ruby » Ramp gem is a toolkit of Ruby base class extensions
|
2
|
+
|
3
|
+
Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
|
4
|
+
Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
|
5
|
+
License:: See LICENSE.txt file
|
6
|
+
|
7
|
+
Ramp is a library of extensions to Ruby base classes, including Array, Date, Enumerable, Hash, Kernel, Numeric, Object, Process, String, Time, and YAML.
|
8
|
+
|
9
|
+
Testing:
|
10
|
+
|
11
|
+
* Each has an associated test class, e.g., ArrayTest, DateTest, etc.
|
12
|
+
* The easy way to run the tests: gem install sixarm_ruby_ramp --test
|
13
|
+
|
14
|
+
|
15
|
+
== Array
|
16
|
+
|
17
|
+
* car, cdr: aka first, rest (see shifted)
|
18
|
+
* choice, choices: one or more random elements from an array
|
19
|
+
* cross: return the cross pairings of an array with another array
|
20
|
+
* divvy: divides an array, like a pie, into a specified number of slices
|
21
|
+
* join: same as Array#join with some improvments
|
22
|
+
* onto: return a hash that maps an array's keys on to another array's values
|
23
|
+
* rotate: moves the first element of an array to the end
|
24
|
+
* rest: return the rest of the items of the array (aka cdr, aka shifted)
|
25
|
+
* shifted, shifted!: return an array with the first n items shifted (aka cdr, aka rest)
|
26
|
+
* shuffle, shuffle!: randomly sort an array efficiently; each of these methods are loaded only if needed (Ruby 1.8.7+ already defines shuffle)
|
27
|
+
* slices: divide an array into specified number of equal size sub-arrays ([1,2,3,4,5,6]slices(3) => [[1,2],[3,4],[5,6]])
|
28
|
+
* to_csv: join a multidimensional array into a string in CSV (Comma Separated Values), with each subarray becoming one 'line' in the output; typically for viewing in a spreadsheet such as Excel.
|
29
|
+
* to_tdf: join a multidimensional array into a string in TDF (Tab Delimited Format); this is an alias for #to_tsv
|
30
|
+
* to_tsv: join a multidimensional array into a string in TSV (Tab Separated Values), with each subarray becoming one 'line' in the output; typically for viewing in a spreadsheet such as Excel.
|
31
|
+
* union: builds an array containing each of the unique elements of sub-arrays ([[1,2,3,4],[2,3,4,5],[3,4,5,6]].union => [1,2,3,4,5,6])
|
32
|
+
|
33
|
+
|
34
|
+
== Class
|
35
|
+
|
36
|
+
* publicize_methods: make all methods public for a block, e.g. to unit test private methods
|
37
|
+
|
38
|
+
|
39
|
+
== CSV
|
40
|
+
|
41
|
+
* http_headers: provides web file download headers for text/csv content type and disposition.
|
42
|
+
|
43
|
+
|
44
|
+
== Date
|
45
|
+
|
46
|
+
* age_days, age_years
|
47
|
+
* between: a random date between two specified dates
|
48
|
+
* to_sql: date as a string formatted as expected for MySQL
|
49
|
+
* weekday?, weekend?: is date a weekday or on the weekend
|
50
|
+
|
51
|
+
|
52
|
+
== Enumerable
|
53
|
+
|
54
|
+
* cartesian_product: return an array of all possible ordered tuples from arrays.
|
55
|
+
* hash_by: convert the array to a hash by mapping each item to a key=>value pair.
|
56
|
+
* index_by: convert the array to a hash by mapping each ite to a key=>item pair.
|
57
|
+
* join: forwards to self.to_a.join
|
58
|
+
* map_id: return the id of an Enumerable object; *requires* that the object respond to an 'id' message
|
59
|
+
* map_to_a, map_to_f, map_to_i, map_to_s, map_to_sym: convert each object to a specific type by calling its respective method to_a, to_i, to_f, to_s, to_sym
|
60
|
+
* map_with_index: for each item, yield to a block with the item and its incrementing index
|
61
|
+
* nitems_until, select_until: return the number of, or an array containing, the leading elements for which block is false or nil.
|
62
|
+
* nitems_while, select_while: return the number of items, or an array containing the leading elements, for which block is not false or nil.
|
63
|
+
* nitems_with_index, select_with_index: calls block with two arguments, the item and its index, for each item in enum. Return the number of, or an array containing, the leading elements for which block is not false or nil.
|
64
|
+
* power_set: return an array with all subsets of the enum's elements
|
65
|
+
|
66
|
+
|
67
|
+
== File
|
68
|
+
|
69
|
+
* File.joindir: wrapper for File.join(File.dirname(...),string,...)
|
70
|
+
|
71
|
+
|
72
|
+
== Fixnum
|
73
|
+
|
74
|
+
* even?: is the number even?
|
75
|
+
* odd?: is the number odd?
|
76
|
+
|
77
|
+
|
78
|
+
== Hash
|
79
|
+
|
80
|
+
* size?: return true if hash has any keys
|
81
|
+
* sort_by_keys: return a new Hash sorted by keys
|
82
|
+
* each_sort: sort the keys then call each
|
83
|
+
* each_key!: passes each key to a specified block and updates hash in place if the key changes
|
84
|
+
* each_pair!: passes each key value pair to a specified block and updates the hash in place if the key or value change.
|
85
|
+
* each_value!: passes each value to a specified block and updates the hash in place if the value changes.
|
86
|
+
* map_pair: map each key-value pair by calling a a block
|
87
|
+
* pivot: aggregates subtotals by keys and values, such as a rollup and rolldown
|
88
|
+
|
89
|
+
|
90
|
+
== Integer
|
91
|
+
|
92
|
+
* maps: syntactic sugar to yield n times to a block, returning an array of any results
|
93
|
+
* odd?: is the number odd?
|
94
|
+
|
95
|
+
|
96
|
+
== IO
|
97
|
+
|
98
|
+
* readrow: reads a row line as with IO#readline, and return the row split it into fields
|
99
|
+
* IO.readrows: reads the entire file specified by name as individual row lines, and return those rows split into fields, in an array of arrays.
|
100
|
+
|
101
|
+
|
102
|
+
== Kernel
|
103
|
+
|
104
|
+
* my_method_name: return the name of the current method
|
105
|
+
* caller_method_name: return the name of the caller method, or the Nth parent up the call stack if the optional caller_index parameter is passed.
|
106
|
+
|
107
|
+
|
108
|
+
== Math
|
109
|
+
|
110
|
+
* ln(x): natural log of x
|
111
|
+
* logn(x,b): log of x in base b
|
112
|
+
|
113
|
+
|
114
|
+
== NilClass
|
115
|
+
|
116
|
+
* blank?: return true (same as Rails)
|
117
|
+
|
118
|
+
|
119
|
+
== Numeric
|
120
|
+
|
121
|
+
* if: return 0 if the passed flag is any of: nil, false, 0, [], {} and otherwise return self
|
122
|
+
* unless: return 0 unless the passed flag is any of: nil, false, 0, [], {} and otherwise return self
|
123
|
+
* percent: return the number as a percentage with optional rounding to decimal points
|
124
|
+
|
125
|
+
|
126
|
+
== Object
|
127
|
+
|
128
|
+
* in?: return boolean indicating whether the object is a member of the specified array parameter
|
129
|
+
|
130
|
+
|
131
|
+
== Process
|
132
|
+
|
133
|
+
Extensions that help debug Ruby programs.
|
134
|
+
|
135
|
+
* (class) ps: output of the system 'ps' command, also including aliases, as raw plain text.
|
136
|
+
* (class) pss: output of the system 'ps' command as a hash with each value set to the right type, e.g., integer, float, etc..
|
137
|
+
|
138
|
+
|
139
|
+
== REXML::Attributes
|
140
|
+
|
141
|
+
* hash: flattens the attributes hash set into a more useful ruby hash, e.g. {:height => 100, :width => 400 }
|
142
|
+
|
143
|
+
|
144
|
+
== REXML::Document
|
145
|
+
|
146
|
+
* remove_attributes: remove all the attributes from the document's elements
|
147
|
+
|
148
|
+
|
149
|
+
== REXML::Element
|
150
|
+
|
151
|
+
* remove_attributes: remove all the attributes from the element
|
152
|
+
|
153
|
+
|
154
|
+
== String
|
155
|
+
|
156
|
+
* capitalize_words (alias to titleize/titlecase): ensures the first character of each word is uppercase.
|
157
|
+
* decrement: decrease the rightmost natural number, defaults to one value lower or by the optional step parameter value.
|
158
|
+
* increment: increase the rightmost natural number, defaults to one value higher or by the optional step parameter value.
|
159
|
+
* lorem: return a short random string, good for use in "lorem ipsum" sample text.
|
160
|
+
* lowcase: translate a string to lowercase, digits and single underscores (e.g. to a method name)
|
161
|
+
* prev/pred: previous string ("b" => "a", "bbc" => "bbb", "a" => "z", "880" => "879")
|
162
|
+
* prev!/pred!: updates variable to the previous string in place (astring = "bbc", astring.prev!, puts astring => "bbb")
|
163
|
+
* (class) prev_char/pred_char: return the previous character, with a changed flag and carry flag; that is, there are three returned values, a string and two booleans.
|
164
|
+
* split_tab: split the string into an array at each embedded tab ("Last\tFirst\tMiddle" => ["last","first","middle"])
|
165
|
+
* split_tsv: split the string into an array at each embedded newline and embedded tab ("A\tB\t\C\nD\tE\tF" => [["A","B","C"],["D","E","F"]])
|
166
|
+
* to_class: the global class reference of a given string
|
167
|
+
* words: split the string into an array of words
|
168
|
+
|
169
|
+
|
170
|
+
== Symbol
|
171
|
+
|
172
|
+
* <=> and include the comparable mixin to compare symbols as strings
|
173
|
+
|
174
|
+
|
175
|
+
== Time
|
176
|
+
|
177
|
+
* (class) stamp: current time in UTC as a timestamp string ("YYYYMMDDHHMMSS")
|
178
|
+
* to_sql: time as a string formatted as expected for MySQL
|
179
|
+
|
180
|
+
|
181
|
+
== XML
|
182
|
+
|
183
|
+
* (class) load_dir: specify a one or more directory patterns and pass each XML file in the matching directories to a block; see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
184
|
+
* (class) strip_all: delete exraneous junk from an XML text string, typically for sanitizing input
|
185
|
+
* (class) strip_attributes: delete all attributes from an XML text string
|
186
|
+
* (class) strip_comments: delete all comments from an XML text string
|
187
|
+
* (class) strip_microsoft: delete all proprietary Microsoft code from an XML text string
|
188
|
+
* (class) strip_unprintables: delete all unprintable characters from an XML text string
|
189
|
+
|
190
|
+
|
191
|
+
== YAML
|
192
|
+
|
193
|
+
* (class) load_dir: specify directory patterns and pass each YAML file in the matching directories to a block; see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
194
|
+
* (class) load_dir_pairs: specify directory patterns and pass each YAML file in the matching directories to a block to process key/value pairs.
|
195
|
+
|
196
|
+
|
197
|
+
== Changes
|
198
|
+
|
199
|
+
- 1.8.2 Refactored Numeric metric names into their own methods
|
200
|
+
- 1.8.0 100% rcov coverage
|
201
|
+
- 1.7.8 Add rcov testing
|
202
|
+
- 1.7.4 Add Class#publicize_methods, Integer#even?, Integer#odd?
|
203
|
+
- 1.7.3 Refactor Rails classes to their own gem, add README, LICENSE
|
204
|
+
- 1.7.2 Gemcutter update
|
205
|
+
- 1.7.1.8 Add Enumerable#map_with_index
|
206
|
+
- 1.7.1.6 Add ActiveRecord::SaveExtensions#save_false_then_reload!
|
207
|
+
- 1.7.1.3 Add XML#strip_xxx
|
208
|
+
- 1.7.1.2 Update gems: Gemcutter, Ruby 1.9.1, JRuby sqlite3
|
209
|
+
- 1.7.1.0 Add XML attributes methods #
|
210
|
+
- 1.7.0.9 Add Enumerable #hash_by, #index_by
|
211
|
+
- 1.7.0.7 Add Array#to_tsv, String#split_tsv, improve Array#to_csv
|
212
|
+
- 1.7.0.6 Add Array#shuffle, Array#shuffle!
|
213
|
+
- 1.7.0.5 Add Array#shifted, Array#rest, Array#car, Array#cdr
|
214
|
+
- 1.7.0.4 Upgrade IO#readrows and #readrow to use options
|
215
|
+
- 1.7.0.2 Add Array#to_tdf
|
216
|
+
- 1.7.0.1 Remove sqlite3 testing dependency
|
217
|
+
- 1.6.9.6 Add Symbol with comparable and <=>
|
218
|
+
- 1.6.9.5 Add ActiveRecord testing with sqlite3
|
219
|
+
- 1.6.9.4 JRuby install and test successful
|
220
|
+
- 1.6.9.3 Array#join add infix, prefix, suffix
|
221
|
+
- 1.6.9.2 Improve ri docs
|
222
|
+
- 1.6.9.1 Add Array#onto, Enumerable#intersect?
|
223
|
+
- 1.6.9.0 Add IO, File, ActiveRecord#seed
|
224
|
+
- 1.6.8.9 Add Enumerable#to_h, Array#hash, Hash#each_key!, Hash#each_pair, Hash#each_value!
|
225
|
+
- 1.6.8.8 Add Hash#map_pair, Hash#size?, Hash#pivot
|
226
|
+
- 1.6.8.7 Add Math
|
227
|
+
- 1.6.8.6 Add ActiveRecord SchemaStatements
|
228
|
+
- 1.6.8.5 Add Integer#maps, String#ACCENTS
|
229
|
+
- 1.6.8.4 Add XML
|
230
|
+
- 1.6.8.3 Add ActiveRecord
|
231
|
+
- 1.6.8.2 Add String#lowcase
|
232
|
+
- 1.6.8 Add map_to_xxx methods
|
233
|
+
- 1.6.7 Add CSV
|
234
|
+
- 1.6.6 Add Array#to_csv, Integer, String#lorem, etc., improve tests
|
235
|
+
- 1.6.4 Bug fixes: String characters and YAML test files
|
236
|
+
- 1.6.2 Improve organizaiton of class files to lib/ramp
|
237
|
+
- 1.6.0 Upgraded to work with Ruby 1.9.1
|
238
|
+
- 1.5.0 Combined all Ruby extension files into one gem
|
239
|
+
- 1.0.0 Original
|
240
|
+
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|