webget_ruby_ramp 1.8.0 → 1.8.2
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.
- data.tar.gz.sig +2 -2
- data/README.rdoc +24 -7
- data/lib/webget_ruby_ramp.rb +2 -2
- data/lib/webget_ruby_ramp/array.rb +56 -43
- data/lib/webget_ruby_ramp/class.rb +3 -1
- data/lib/webget_ruby_ramp/csv.rb +4 -4
- data/lib/webget_ruby_ramp/date.rb +12 -12
- data/lib/webget_ruby_ramp/enumerable.rb +101 -46
- data/lib/webget_ruby_ramp/file.rb +2 -2
- data/lib/webget_ruby_ramp/fixnum.rb +4 -7
- data/lib/webget_ruby_ramp/hash.rb +18 -15
- data/lib/webget_ruby_ramp/integer.rb +8 -7
- data/lib/webget_ruby_ramp/io.rb +24 -20
- data/lib/webget_ruby_ramp/kernel.rb +32 -0
- data/lib/webget_ruby_ramp/math.rb +10 -2
- data/lib/webget_ruby_ramp/nil.rb +5 -2
- data/lib/webget_ruby_ramp/numeric.rb +5 -71
- data/lib/webget_ruby_ramp/object.rb +4 -3
- data/lib/webget_ruby_ramp/process.rb +54 -7
- data/lib/webget_ruby_ramp/string.rb +54 -24
- data/lib/webget_ruby_ramp/symbol.rb +16 -0
- data/lib/webget_ruby_ramp/time.rb +19 -11
- data/lib/webget_ruby_ramp/xml.rb +30 -20
- data/lib/webget_ruby_ramp/yaml.rb +5 -4
- data/test/webget_ruby_ramp/numeric_test.rb +0 -60
- data/test/webget_ruby_ramp/string_test.rb +0 -5
- metadata +2 -2
- metadata.gz.sig +1 -1
@@ -4,6 +4,22 @@
|
|
4
4
|
|
5
5
|
class Symbol
|
6
6
|
|
7
|
+
# Compare this symbol to another symbol.
|
8
|
+
#
|
9
|
+
# @example Less than
|
10
|
+
# :foo <=> :goo
|
11
|
+
# => -1
|
12
|
+
#
|
13
|
+
# @example Equal
|
14
|
+
# :foo <=> :foo
|
15
|
+
# => 0
|
16
|
+
#
|
17
|
+
# @example Greater than
|
18
|
+
# :foo <=> :bar
|
19
|
+
# => 1
|
20
|
+
#
|
21
|
+
# @return [-1,0,1] -1 if this is < that, 0
|
22
|
+
|
7
23
|
include Comparable
|
8
24
|
def <=>(that)
|
9
25
|
self.to_s<=>that.to_s
|
@@ -5,14 +5,15 @@
|
|
5
5
|
class Time
|
6
6
|
|
7
7
|
|
8
|
-
#
|
8
|
+
# @return [String] a time stamp string in standard format: "YYYY-MM-DD HH:MM:SSZ"
|
9
9
|
#
|
10
10
|
# This standard format is specified in IETF RFC 3339 and ISO 8601.
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# @see http://www.ietf.org/rfc/rfc3339.txt
|
13
13
|
#
|
14
|
-
#
|
15
|
-
# Time.now.stamp
|
14
|
+
# @example
|
15
|
+
# Time.now.stamp
|
16
|
+
# => "2010-12-31 12:59:59Z"
|
16
17
|
|
17
18
|
def stamp
|
18
19
|
getutc.strftime('%Y-%m-%d %H:%M:%SZ')
|
@@ -21,20 +22,24 @@ class Time
|
|
21
22
|
|
22
23
|
# Shorthand for Time.now.stamp
|
23
24
|
#
|
24
|
-
#
|
25
|
-
# Time.stamp
|
25
|
+
# @example
|
26
|
+
# Time.stamp
|
27
|
+
# => "2010-12-31 12:59:59Z"
|
28
|
+
#
|
29
|
+
# @return [String] Time.now.stamp
|
26
30
|
|
27
31
|
def self.stamp
|
28
32
|
now.stamp
|
29
33
|
end
|
30
34
|
|
31
35
|
|
32
|
-
#
|
36
|
+
# @return [String] time packed into a short string: "YYYYMMDDHHMMSS"
|
33
37
|
#
|
34
38
|
# The time is converted to UTC.
|
35
39
|
#
|
36
|
-
#
|
37
|
-
# Time.now.pack
|
40
|
+
# @example
|
41
|
+
# Time.now.pack
|
42
|
+
# => "20101231125959"
|
38
43
|
|
39
44
|
def pack
|
40
45
|
getutc.strftime('%Y%m%d%H%M%S')
|
@@ -43,8 +48,11 @@ class Time
|
|
43
48
|
|
44
49
|
# Shorthand for Time.now.pack
|
45
50
|
#
|
46
|
-
#
|
47
|
-
# Time.pack
|
51
|
+
# @example
|
52
|
+
# Time.pack
|
53
|
+
# => "20101231125959"
|
54
|
+
#
|
55
|
+
# @return [String] Time.now.pack
|
48
56
|
|
49
57
|
def self.pack
|
50
58
|
now.pack
|
data/lib/webget_ruby_ramp/xml.rb
CHANGED
@@ -11,12 +11,12 @@ module XML
|
|
11
11
|
#
|
12
12
|
# See [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# @example To load xml documents
|
15
15
|
# XML.load_dir('/tmp/*.xml'){|xml_document|
|
16
16
|
# #...whatever you want to do with each xml document
|
17
17
|
# }
|
18
18
|
#
|
19
|
-
#
|
19
|
+
# @example To load xml documents in files beginning in "foo" or "bar"
|
20
20
|
# XML.load_dir('/tmp/foo*.yaml','/tmp/bar*.xml','){|xml_document|
|
21
21
|
# #...whatever you want to do with the xml document
|
22
22
|
# }
|
@@ -36,7 +36,7 @@ module XML
|
|
36
36
|
|
37
37
|
# Sugar to load elements from a file.
|
38
38
|
#
|
39
|
-
#
|
39
|
+
# @example
|
40
40
|
# XML.load_attributes('config.xml','userlist/user'){|element| pp element.attributes['first_name'] }
|
41
41
|
|
42
42
|
def XML.load_elements(dirpath,xpath)
|
@@ -50,7 +50,7 @@ module XML
|
|
50
50
|
|
51
51
|
# Sugar to load attributes from a file.
|
52
52
|
#
|
53
|
-
#
|
53
|
+
# @example
|
54
54
|
# XML.load_attributes('config.xml','userlist/user'){|attributes| pp attributes['first_name'] }
|
55
55
|
|
56
56
|
def XML.load_attributes(dirpath,xpath)
|
@@ -61,7 +61,7 @@ module XML
|
|
61
61
|
|
62
62
|
# Sugar to load attributes hash from a file.
|
63
63
|
#
|
64
|
-
#
|
64
|
+
# @example
|
65
65
|
# XML.load_attributes('config.xml','userlist/user'){|attributes| pp attributes['first_name'] }
|
66
66
|
|
67
67
|
def XML.load_attributes_hash(dirpath,xpath)
|
@@ -75,16 +75,18 @@ module XML
|
|
75
75
|
# comments, and generally anything else we might need
|
76
76
|
# to enable the XML parser to handle a dirty document.
|
77
77
|
#
|
78
|
-
# ==Example
|
79
|
-
# # This example shows curly braces instead of angle braces because of HTML formatting
|
80
|
-
# s="{foo a=b c=d}{!--comment--}Hello{!-[if bar]}Microsoft{![endif]}World{/foo}"
|
81
|
-
# XML.strip_all(s) => "{foo}HelloWorld{/foo}"
|
82
|
-
#
|
83
78
|
# This method calls these in order:
|
84
79
|
# - XML.strip_unprintables
|
85
80
|
# - XML.strip_microsoft
|
86
81
|
# - XML.strip_comments
|
87
82
|
# - XML.strip_attributes
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
# # This example shows curly braces instead of angle braces because of HTML formatting
|
86
|
+
# s="{foo a=b c=d}{!--comment--}Hello{!-[if bar]}Microsoft{![endif]}World{/foo}"
|
87
|
+
# XML.strip_all(s) => "{foo}HelloWorld{/foo}"
|
88
|
+
#
|
89
|
+
# @return [String] the text, stripped of unprintables, Microsoft markup, comments, and attributes
|
88
90
|
|
89
91
|
def XML.strip_all(xml_text)
|
90
92
|
return XML.strip_attributes(XML.strip_comments(XML.strip_microsoft(XML.strip_unprintables(xml_text))))
|
@@ -93,9 +95,11 @@ module XML
|
|
93
95
|
|
94
96
|
# Strip out all attributes from the xml text's tags.
|
95
97
|
#
|
96
|
-
#
|
98
|
+
# @example
|
97
99
|
# s="<foo a=b c=d e=f>Hello</foo>"
|
98
100
|
# XML.strip_attributes(s) => "<foo>Hello</foo>"
|
101
|
+
#
|
102
|
+
# @return [String] the text, stripped of attributes
|
99
103
|
|
100
104
|
def XML.strip_attributes(xml_text)
|
101
105
|
return xml_text.gsub(/<(\/?\w+).*?>/im){"<#{$1}>"} # delete attributes
|
@@ -104,10 +108,12 @@ module XML
|
|
104
108
|
|
105
109
|
# Strip out all comments from the xml text.
|
106
110
|
#
|
107
|
-
#
|
111
|
+
# @example
|
108
112
|
# # This example shows curly braces instead of angle braces because of HTML formatting
|
109
113
|
# s="Hello{!--comment--}World"
|
110
114
|
# XML.strip_comments(s) => "HelloWorld"
|
115
|
+
#
|
116
|
+
# @return [String] the text, stripped of comments
|
111
117
|
|
112
118
|
def XML.strip_comments(xml_text)
|
113
119
|
return xml_text.gsub(/<!.*?>/im,'')
|
@@ -116,9 +122,11 @@ module XML
|
|
116
122
|
|
117
123
|
# Strip out all microsoft proprietary codes.
|
118
124
|
#
|
119
|
-
#
|
125
|
+
# @example
|
120
126
|
# s="Hello<!-[if foo]>Microsoft<![endif]->World"
|
121
127
|
# XML.strip_microsoft(s) => "HelloWorld"
|
128
|
+
#
|
129
|
+
# @return [String] the text, stripped of Microsoft markup
|
122
130
|
|
123
131
|
def XML.strip_microsoft(xml_text)
|
124
132
|
return xml_text.gsub(/<!-*\[if\b.*?<!\[endif\]-*>/im,'')
|
@@ -127,9 +135,11 @@ module XML
|
|
127
135
|
|
128
136
|
# Strip out all unprintable characters from the input string.
|
129
137
|
#
|
130
|
-
#
|
138
|
+
# @example
|
131
139
|
# s="Hello\XXXWorld" # where XXX is unprintable
|
132
140
|
# XML.strip_unprintables(s) => "HelloWorld"
|
141
|
+
#
|
142
|
+
# @return [String] the text, stripped of unprintables
|
133
143
|
|
134
144
|
def XML.strip_unprintables(xml_text)
|
135
145
|
return xml_text.gsub(/[^[:print:]]/, "")
|
@@ -142,9 +152,9 @@ end
|
|
142
152
|
|
143
153
|
class REXML::Attributes
|
144
154
|
|
145
|
-
#
|
155
|
+
# @return a new hash of the attribute keys and values.
|
146
156
|
#
|
147
|
-
#
|
157
|
+
# @example
|
148
158
|
# attributes.to_hash => {"src"=>"pic.jpg", "height" => "100", "width" => "200"}
|
149
159
|
|
150
160
|
def to_hash
|
@@ -162,9 +172,9 @@ class REXML::Document
|
|
162
172
|
|
163
173
|
# Remove all attributes from the document's elements.
|
164
174
|
#
|
165
|
-
#
|
175
|
+
# @return the document.
|
166
176
|
#
|
167
|
-
#
|
177
|
+
# @see Element#remove_attributes
|
168
178
|
|
169
179
|
def remove_attributes
|
170
180
|
self.elements.each("//") { |elem| elem.attributes.each_attribute{|attribute| attribute.remove }}
|
@@ -180,9 +190,9 @@ class REXML::Element
|
|
180
190
|
|
181
191
|
# Remove all attributes from the element.
|
182
192
|
#
|
183
|
-
#
|
193
|
+
# @return the element.
|
184
194
|
#
|
185
|
-
#
|
195
|
+
# @see Document#remove_attributes
|
186
196
|
|
187
197
|
def remove_attributes
|
188
198
|
self.attributes.each_attribute{|attribute| attribute.remove }
|
@@ -6,17 +6,18 @@ require 'yaml'
|
|
6
6
|
|
7
7
|
module YAML
|
8
8
|
|
9
|
+
|
9
10
|
# Specify one or more directory patterns and pass each YAML file in the matching directories to a block.
|
10
11
|
#
|
11
|
-
#
|
12
|
+
# @see [Dir#glob](http://www.ruby-doc.org/core/classes/Dir.html#M002347) for pattern details.
|
12
13
|
#
|
13
|
-
#
|
14
|
+
# @example To load documents in files ending in ".yaml"
|
14
15
|
# YAML.load_dir('/tmp/*.yaml'){|yaml_document|
|
15
16
|
# #...whatever you want to do with each yaml document
|
16
17
|
# }
|
17
18
|
#
|
18
|
-
#
|
19
|
-
# YAML.load_dir('/tmp
|
19
|
+
# @example To load documents in files beginning in "foo" or "bar"
|
20
|
+
# YAML.load_dir('/tmp/foo*.yaml','/tmp/bar*.yaml','){|yaml_document|
|
20
21
|
# #...whatever you want to do with the yaml document
|
21
22
|
# }
|
22
23
|
|
@@ -24,65 +24,5 @@ class NumericTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
|
-
def test_peta
|
28
|
-
assert_equal(1,1000000000000000.peta)
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def test_tera
|
33
|
-
assert_equal(1,1000000000000.tera)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def test_giga
|
38
|
-
assert_equal(1,1000000000.giga)
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
def test_mega
|
43
|
-
assert_equal(1,1000000.mega)
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def test_kilo
|
48
|
-
assert_equal(1,1000.kilo)
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def test_hecto
|
53
|
-
assert_equal(1,100.hecto)
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def test_deka
|
58
|
-
assert_equal(1,10.deka)
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def test_deci
|
63
|
-
assert_equal(1,0.1.deci)
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
def test_centi
|
68
|
-
assert_equal(1,0.01.centi)
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def test_milli
|
73
|
-
assert_equal(1,0.001.milli)
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def test_micro
|
78
|
-
assert_equal(1,0.000001.micro)
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def test_nano
|
83
|
-
assert_equal(1,0.000000001.nano)
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
27
|
end
|
88
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webget_ruby_ramp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WebGet
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
32
32
|
DXnLFY0cVuBnNDMOOFl8vk1qIcZjcTovhzgcixpG6Uk5qmUsKHRLQf4oQJx7TfLK
|
33
33
|
-----END CERTIFICATE-----
|
34
34
|
|
35
|
-
date: 2010-03-
|
35
|
+
date: 2010-03-21 00:00:00 -07:00
|
36
36
|
default_executable:
|
37
37
|
dependencies: []
|
38
38
|
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
��u�6�������ށ"C҂��i�˷"�H7��}����vg��u�=��3��@���F��& q��r��/�_��͠WB���:P�b"����f�'����G��AJW����W�龈 ����Sm
|