webget_ruby_ramp 1.7.4 → 1.7.5

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.rdoc CHANGED
@@ -9,10 +9,8 @@ License:: LGPL, GNU Lesser General Public License
9
9
  Ramp is a library of extensions to Ruby base classes, including Array, Date, Enumerable, Hash, Kernel, Numeric, Object, Process, String, Time, and YAML.
10
10
 
11
11
  Testing:
12
- <ul>
13
- <li>Each has an associated test class, e.g., ArrayTest, DateTest, etc.
14
- <li>The easy way to run the tests: gem install webget_ruby_ramp --test
15
- </ul>
12
+ * Each has an associated test class, e.g., ArrayTest, DateTest, etc.
13
+ * The easy way to run the tests: gem install webget_ruby_ramp --test
16
14
 
17
15
 
18
16
  == Array
@@ -6,7 +6,6 @@ require 'date'
6
6
 
7
7
  class Date
8
8
 
9
-
10
9
  # Return true if the date is a weekday: Mon, Tue, Wed, Thu, Fri
11
10
  #
12
11
  # ==Example
@@ -50,7 +49,7 @@ class Date
50
49
  # d.to_sql => "2007-12-31"
51
50
 
52
51
  def to_sql
53
- return to_time.strftime("%Y-%m-%d")
52
+ return sprintf("%04d-%02d-%02d",year,month,mday)
54
53
  end
55
54
 
56
55
 
@@ -225,7 +225,7 @@ class Hash
225
225
  protected
226
226
 
227
227
  def pivot_direction_up?(direction_name)
228
- case direction_name
228
+ case direction_name.to_s
229
229
  when 'key','keys','up','left','out' then return true
230
230
  when 'val','vals','down','right','in' then return false
231
231
  else raise ArgumentError, 'Pivot direction must be either: key/keys/up/left/out or val/vals/down/right/in'
@@ -4,10 +4,50 @@
4
4
 
5
5
  class Time
6
6
 
7
- # Return current time in UTC as a timestamp string "YYYYMMDDHHMMSS"
7
+
8
+ # Return a time stamp string in standard format: "YYYY-MM-DD HH:MM:SSZ"
9
+ #
10
+ # This standard format is specified in IETF RFC 3339 and ISO 8601.
11
+ #
12
+ # See http://www.ietf.org/rfc/rfc3339.txt
13
+ #
14
+ # ==Example
15
+ # Time.now.stamp => "2010-12-31 12:59:59Z"
16
+
17
+ def stamp
18
+ getutc.strftime('%Y-%m-%d %H:%M:%SZ')
19
+ end
20
+
21
+
22
+ # Shorthand for Time.now.stamp
23
+ #
24
+ # ==Example
25
+ # Time.stamp => "2010-12-31 12:59:59Z"
8
26
 
9
27
  def self.stamp
10
- now.utc.strftime('%Y%m%d%H%M%S')
28
+ now.stamp
29
+ end
30
+
31
+
32
+ # Return time packed into a short string: "YYYYMMDDHHMMSS"
33
+ #
34
+ # The time is converted to UTC.
35
+ #
36
+ # ==Example
37
+ # Time.now.pack => "20101231125959"
38
+
39
+ def pack
40
+ getutc.strftime('%Y%m%d%H%M%S')
41
+ end
42
+
43
+
44
+ # Shorthand for Time.now.pack
45
+ #
46
+ # ==Example
47
+ # Time.pack => "20101231125959"
48
+
49
+ def self.pack
50
+ now.pack
11
51
  end
12
52
 
13
53
  end
@@ -8,24 +8,33 @@ class ClassTest < Test::Unit::TestCase
8
8
  def test_publicize_methods
9
9
 
10
10
  # Before we test the block, ensure our setup is correct
11
- assert_equal([:a,:a!,:a=,:a?],My.private_instance_methods.grep(METHOD_REGEXP),'private methods before block')
12
- assert_equal([:b,:b!,:b=,:b?],My.protected_instance_methods.grep(METHOD_REGEXP),'protected methods before block')
13
- assert_equal([:c,:c!,:c=,:c?],My.public_instance_methods.grep(METHOD_REGEXP),'public methods before block')
11
+ assert_equal(["a","a!","a=","a?"],My.private_instance_methods.grep_sort_to_s(METHOD_REGEXP),'private methods before block')
12
+ assert_equal(["b","b!","b=","b?"],My.protected_instance_methods.grep_sort_to_s(METHOD_REGEXP),'protected methods before block')
13
+ assert_equal(["c","c!","c=","c?"],My.public_instance_methods.grep_sort_to_s(METHOD_REGEXP),'public methods before block')
14
14
 
15
15
  # Now we test inside the block
16
16
  My.publicize_methods{
17
- assert_equal([],My.private_instance_methods.grep(METHOD_REGEXP),'private methods inside block')
18
- assert_equal([],My.protected_instance_methods.grep(METHOD_REGEXP),'protected methods inside block')
19
- assert_equal([:a,:a!,:a=,:a?,:b,:b!,:b=,:b?,:c,:c!,:c=,:c?],My.public_instance_methods.grep(METHOD_REGEXP).sort,'public methods inside block')
17
+ assert_equal([],My.private_instance_methods.grep_sort_to_s(METHOD_REGEXP),'private methods inside block')
18
+ assert_equal([],My.protected_instance_methods.grep_sort_to_s(METHOD_REGEXP),'protected methods inside block')
19
+ assert_equal(["a","a!","a=","a?","b","b!","b=","b?","c","c!","c=","c?"],My.public_instance_methods.grep_sort_to_s(METHOD_REGEXP),'public methods inside block')
20
20
  }
21
21
 
22
22
  # After we test the block, ensure our setup is restored
23
- assert_equal([:a,:a!,:a=,:a?],My.private_instance_methods.grep(METHOD_REGEXP),'private methods before block')
24
- assert_equal([:b,:b!,:b=,:b?],My.protected_instance_methods.grep(METHOD_REGEXP),'protected methods before block')
25
- assert_equal([:c,:c!,:c=,:c?],My.public_instance_methods.grep(METHOD_REGEXP),'public methods before block')
23
+ assert_equal(["a","a!","a=","a?"],My.private_instance_methods.grep_sort_to_s(METHOD_REGEXP),'private methods before block')
24
+ assert_equal(["b","b!","b=","b?"],My.protected_instance_methods.grep_sort_to_s(METHOD_REGEXP),'protected methods before block')
25
+ assert_equal(["c","c!","c=","c?"],My.public_instance_methods.grep_sort_to_s(METHOD_REGEXP),'public methods before block')
26
26
 
27
27
  end
28
28
 
29
+ protected
30
+
31
+ end
32
+
33
+
34
+ class Array
35
+ def grep_sort_to_s(regexp)
36
+ grep(regexp).sort.map{|x| x.to_s}
37
+ end
29
38
  end
30
39
 
31
40
 
@@ -130,7 +130,7 @@ class HashTest < Test::Unit::TestCase
130
130
 
131
131
 
132
132
  def test_pivot_vals_with_block
133
- p=pivotable.pivot(:vals){|items| items.sort.inject{|sum,x| sum+=x}}
133
+ p=pivotable.pivot(:vals){|items| items.sort.inject(""){|sum,x| sum+=x}}
134
134
  assert_equal(['x','y','z'], p.keys.sort)
135
135
  assert_equal('mps', p['x'])
136
136
  assert_equal('nqt', p['y'])
@@ -148,7 +148,7 @@ class HashTest < Test::Unit::TestCase
148
148
 
149
149
 
150
150
  def test_pivot_keys_with_block
151
- p=pivotable.pivot(:keys){|items| items.sort.inject{|sum,x| sum+=x}}
151
+ p=pivotable.pivot(:keys){|items| items.sort.inject(""){|sum,x| sum+=x}}
152
152
  assert_equal(['a','b','c'], p.keys.sort)
153
153
  assert_equal('mno', p['a'])
154
154
  assert_equal('pqr', p['b'])
@@ -3,10 +3,26 @@ require 'webget_ruby_ramp'
3
3
 
4
4
  class TimeTest < Test::Unit::TestCase
5
5
 
6
- def test_log
7
- t=Time.stamp
8
- assert(t=~/^\d\d\d\d\d\d\d\d\d\d\d\d\d\d$/,"time format is correct")
6
+ def test_stamp_with_class_method
7
+ t=Time.stamp
8
+ assert(t=~/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\dZ$/,t)
9
9
  end
10
10
 
11
+ def test_stamp_with_instance_method
12
+ t=Time.now.stamp
13
+ assert(t=~/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\dZ$/,t)
14
+ end
15
+
16
+ def test_pack_with_class_method
17
+ t=Time.pack
18
+ assert(t=~/^\d\d\d\d\d\d\d\d\d\d\d\d\d\d$/,t)
19
+ end
20
+
21
+ def test_pack_with_instance_method
22
+ t=Time.now.pack
23
+ assert(t=~/^\d\d\d\d\d\d\d\d\d\d\d\d\d\d$/,t)
24
+ end
25
+
26
+
11
27
  end
12
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.7.4
4
+ version: 1.7.5
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-02-19 00:00:00 -08:00
35
+ date: 2010-03-03 00:00:00 -08:00
36
36
  default_executable:
37
37
  dependencies: []
38
38
 
metadata.gz.sig CHANGED
Binary file