webget_ruby_ramp 1.7.3 → 1.7.4
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 +1 -1
- data/LICENSE.txt +12 -0
- data/README.rdoc +226 -0
- data/lib/webget_ruby_ramp.rb +10 -2
- data/lib/webget_ruby_ramp/array.rb +2 -0
- data/lib/webget_ruby_ramp/class.rb +36 -0
- data/lib/webget_ruby_ramp/csv.rb +8 -3
- data/lib/webget_ruby_ramp/date.rb +17 -13
- data/lib/webget_ruby_ramp/enumerable.rb +2 -0
- data/lib/webget_ruby_ramp/file.rb +2 -0
- data/lib/webget_ruby_ramp/hash.rb +13 -1
- data/lib/webget_ruby_ramp/integer.rb +24 -0
- data/lib/webget_ruby_ramp/io.rb +2 -0
- data/lib/webget_ruby_ramp/kernel.rb +2 -0
- data/lib/webget_ruby_ramp/math.rb +2 -0
- data/lib/webget_ruby_ramp/nil.rb +2 -0
- data/lib/webget_ruby_ramp/numeric.rb +5 -6
- data/lib/webget_ruby_ramp/object.rb +2 -0
- data/lib/webget_ruby_ramp/process.rb +3 -1
- data/lib/webget_ruby_ramp/string.rb +2 -0
- data/lib/webget_ruby_ramp/symbol.rb +2 -0
- data/lib/webget_ruby_ramp/time.rb +2 -0
- data/lib/webget_ruby_ramp/xml.rb +2 -0
- data/lib/webget_ruby_ramp/yaml.rb +2 -0
- data/test/webget_ruby_ramp/array_test.rb +218 -75
- data/test/webget_ruby_ramp/class_test.rb +76 -0
- data/test/webget_ruby_ramp/csv_test.rb +35 -8
- data/test/webget_ruby_ramp/date_test.rb +14 -2
- data/test/webget_ruby_ramp/enumerable_test.rb +2 -2
- data/test/webget_ruby_ramp/hash_test.rb +91 -4
- data/test/webget_ruby_ramp/integer_test.rb +16 -0
- data/test/webget_ruby_ramp/math_test.rb +1 -0
- data/test/webget_ruby_ramp/numeric_test.rb +60 -0
- metadata +6 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'webget_ruby_ramp'
|
3
|
+
|
4
|
+
class ClassTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
|
7
|
+
METHOD_REGEXP = /^[abc]\W*$/
|
8
|
+
def test_publicize_methods
|
9
|
+
|
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')
|
14
|
+
|
15
|
+
# Now we test inside the block
|
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')
|
20
|
+
}
|
21
|
+
|
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')
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
class My
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def a
|
37
|
+
end
|
38
|
+
|
39
|
+
def a!
|
40
|
+
end
|
41
|
+
|
42
|
+
def a=
|
43
|
+
end
|
44
|
+
|
45
|
+
def a?
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def b
|
51
|
+
end
|
52
|
+
|
53
|
+
def b!
|
54
|
+
end
|
55
|
+
|
56
|
+
def b=
|
57
|
+
end
|
58
|
+
|
59
|
+
def b?
|
60
|
+
end
|
61
|
+
|
62
|
+
public
|
63
|
+
|
64
|
+
def c
|
65
|
+
end
|
66
|
+
|
67
|
+
def c!
|
68
|
+
end
|
69
|
+
|
70
|
+
def c=
|
71
|
+
end
|
72
|
+
|
73
|
+
def c?
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -3,16 +3,43 @@ require 'webget_ruby_ramp'
|
|
3
3
|
|
4
4
|
class CSVTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def test_http_headers
|
7
|
+
h=CSV.http_headers
|
8
|
+
assert_equal('text/csv',h["Content-Type"])
|
9
|
+
assert_equal("attachment; filename=\"data.csv\"",h["Content-Disposition"])
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_http_headers_with_filename
|
13
|
+
h=CSV.http_headers(:filename=>'foo')
|
14
|
+
assert_equal('text/csv',h["Content-Type"])
|
15
|
+
assert_equal("attachment; filename=\"foo\"",h["Content-Disposition"])
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_http_headers_adjust_for_broken_msie_with_request_as_firefox
|
19
|
+
headers = {:request => MockRequest.new('HTTP_USER_AGENT' => 'firefox')}
|
20
|
+
headers = CSV.http_headers_adjust_for_broken_msie(headers)
|
21
|
+
assert_equal(nil,headers[:content_type])
|
22
|
+
assert_equal(nil,headers[:cache])
|
10
23
|
end
|
11
24
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
assert_equal(
|
25
|
+
def test_http_headers_adjust_for_broken_msie_with_request_as_msie
|
26
|
+
headers = {:request => MockRequest.new('HTTP_USER_AGENT' => 'msie')}
|
27
|
+
headers = CSV.http_headers_adjust_for_broken_msie(headers)
|
28
|
+
assert_equal('text/plain',headers[:content_type])
|
29
|
+
assert_equal(false,headers[:cache])
|
16
30
|
end
|
17
31
|
|
18
32
|
end
|
33
|
+
|
34
|
+
class MockRequest
|
35
|
+
|
36
|
+
def initialize(env)
|
37
|
+
@env=env
|
38
|
+
end
|
39
|
+
|
40
|
+
def env
|
41
|
+
@env
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
@@ -30,8 +30,13 @@ class DateTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
|
-
def
|
34
|
-
|
33
|
+
def test_to_sql_with_non_zero_month_and_mday
|
34
|
+
assert_equal('2007-12-31',Date.new(2007,12,31).to_sql)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def test_to_sql_with_zero_month_and_mday
|
39
|
+
assert_equal('2007-01-02',Date.new(2007,1,2).to_sql)
|
35
40
|
end
|
36
41
|
|
37
42
|
|
@@ -48,6 +53,9 @@ class DateTest < Test::Unit::TestCase
|
|
48
53
|
assert_equal(28,BIRTHDATE.age_years(NEW_YEARS_EVE), '> birthday')
|
49
54
|
end
|
50
55
|
|
56
|
+
def test_age_years_with_non_date
|
57
|
+
assert_raise(ArgumentError){ BIRTHDATE.age_years('') }
|
58
|
+
end
|
51
59
|
|
52
60
|
def test_age_days
|
53
61
|
assert_equal( 9967,BIRTHDATE.age_days(VALENTINES), '< birthday')
|
@@ -55,6 +63,10 @@ class DateTest < Test::Unit::TestCase
|
|
55
63
|
assert_equal(10288,BIRTHDATE.age_days(NEW_YEARS_EVE), '> birthday')
|
56
64
|
end
|
57
65
|
|
66
|
+
def test_age_days_with_non_date
|
67
|
+
assert_raise(ArgumentError){ BIRTHDATE.age_days('') }
|
68
|
+
end
|
69
|
+
|
58
70
|
|
59
71
|
end
|
60
72
|
|
@@ -5,8 +5,8 @@ require 'set'
|
|
5
5
|
class EnumerableTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
ITEMS = ['a','b','c']
|
8
|
-
MAPTEST = [123,"456"]
|
9
|
-
RGB = ["red","green","blue"]
|
8
|
+
MAPTEST = [123,"456"] # to test typecasts-- one is numeric and one is string
|
9
|
+
RGB = ["red","green","blue"] # to test case changes
|
10
10
|
|
11
11
|
|
12
12
|
########################################################################
|
@@ -4,15 +4,35 @@ require 'webget_ruby_ramp'
|
|
4
4
|
class HashTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
|
7
|
-
def
|
7
|
+
def test_size_true
|
8
8
|
h = {'a'=>'b'}
|
9
9
|
assert(h.size?)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def test_size_false
|
10
14
|
h = {}
|
11
15
|
assert(!h.size?)
|
12
16
|
end
|
13
17
|
|
14
18
|
|
15
|
-
def
|
19
|
+
def test_each_sort
|
20
|
+
out = []
|
21
|
+
h = {'c' => 'z', 'b' => 'y', 'a' => 'x'}
|
22
|
+
h.each_sort{|key,val| out << key.upcase; out << val.upcase}
|
23
|
+
assert_equal(['A','X','B','Y','C','Z'], out)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_each_sort_with_empty
|
28
|
+
out = []
|
29
|
+
h = {}
|
30
|
+
h.each_sort{|key,val| out << key.upcase; out << val.upcase}
|
31
|
+
assert_equal([], out)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_each_key_bang
|
16
36
|
actual = { "a" => "b", "c" => "d" }
|
17
37
|
expect = { "A" => "b", "C" => "d" }
|
18
38
|
actual.each_key! {|key| key.upcase }
|
@@ -20,7 +40,15 @@ class HashTest < Test::Unit::TestCase
|
|
20
40
|
end
|
21
41
|
|
22
42
|
|
23
|
-
def
|
43
|
+
def test_each_key_bang_with_empty
|
44
|
+
actual = {}
|
45
|
+
expect = {}
|
46
|
+
actual.each_key! {|key| key.upcase }
|
47
|
+
assert_equal(expect,actual)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def test_each_pair_bang
|
24
52
|
actual = { "a" => "b", "c" => "d" }
|
25
53
|
expect = { "A" => "B", "C" => "D" }
|
26
54
|
actual.each_pair! {|key,value| [key.upcase, value.upcase] }
|
@@ -28,7 +56,15 @@ class HashTest < Test::Unit::TestCase
|
|
28
56
|
end
|
29
57
|
|
30
58
|
|
31
|
-
def
|
59
|
+
def test_each_pair_bang_with_empty
|
60
|
+
actual = {}
|
61
|
+
expect = {}
|
62
|
+
actual.each_pair! {|key,value| [key.upcase, value.upcase] }
|
63
|
+
assert_equal(expect,actual)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def test_each_value_bang
|
32
68
|
actual = { "a" => "b", "c" => "d" }
|
33
69
|
expect = { "a" => "B", "c" => "D" }
|
34
70
|
actual.each_value! {|value| value.upcase }
|
@@ -36,14 +72,36 @@ class HashTest < Test::Unit::TestCase
|
|
36
72
|
end
|
37
73
|
|
38
74
|
|
75
|
+
def test_each_value_bang_with_empty
|
76
|
+
actual = {}
|
77
|
+
expect = {}
|
78
|
+
actual.each_value! {|value| value.upcase }
|
79
|
+
assert_equal(expect,actual)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
39
83
|
def test_map_pair
|
40
84
|
h = {"a"=>"b", "c"=>"d", "e"=>"f" }
|
41
85
|
expect=["ab","cd","ef"]
|
42
86
|
actual=h.map_pair{|key,value| key+value }.sort
|
43
87
|
assert_equal(expect,actual,h.inspect)
|
44
88
|
end
|
89
|
+
|
90
|
+
|
91
|
+
def test_map_pair_with_empty
|
92
|
+
h = {}
|
93
|
+
expect=[]
|
94
|
+
actual=h.map_pair{|key,value| key+value }.sort
|
95
|
+
assert_equal(expect,actual,h.inspect)
|
96
|
+
end
|
45
97
|
|
46
98
|
|
99
|
+
def test_to_yaml_sort
|
100
|
+
h = {"a"=>"b", "c"=>"d", "e"=>"f" }
|
101
|
+
assert_equal("--- \na: b\nc: d\ne: f\n", h.to_yaml_sort)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
47
105
|
def pivotable
|
48
106
|
h=Hash.new
|
49
107
|
h['a']=Hash.new
|
@@ -98,6 +156,35 @@ class HashTest < Test::Unit::TestCase
|
|
98
156
|
end
|
99
157
|
|
100
158
|
|
159
|
+
def test_pivot_direction_up_with_true
|
160
|
+
Hash.publicize_methods do
|
161
|
+
assert({}.pivot_direction_up?('key'))
|
162
|
+
assert({}.pivot_direction_up?('keys'))
|
163
|
+
assert({}.pivot_direction_up?('up'))
|
164
|
+
assert({}.pivot_direction_up?('left'))
|
165
|
+
assert({}.pivot_direction_up?('out'))
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
def test_pivot_direction_up_with_false
|
171
|
+
Hash.publicize_methods do
|
172
|
+
assert(!{}.pivot_direction_up?('val'))
|
173
|
+
assert(!{}.pivot_direction_up?('vals'))
|
174
|
+
assert(!{}.pivot_direction_up?('down'))
|
175
|
+
assert(!{}.pivot_direction_up?('right'))
|
176
|
+
assert(!{}.pivot_direction_up?('in'))
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
def test_pivot_direction_up_with_invalid
|
182
|
+
Hash.publicize_methods do
|
183
|
+
assert_raise(ArgumentError){ {}.pivot_direction_up?('nonsense') }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
101
188
|
end
|
102
189
|
|
103
190
|
|
@@ -15,5 +15,21 @@ class IntegerTest < Test::Unit::TestCase
|
|
15
15
|
assert_equal(expect,actual)
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_even_with_true
|
19
|
+
assert(2.even?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_even_with_false
|
23
|
+
assert(!3.even?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_odd_with_true
|
27
|
+
assert(3.odd?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_odd_with_false
|
31
|
+
assert(!2.odd?)
|
32
|
+
end
|
33
|
+
|
18
34
|
end
|
19
35
|
|
@@ -23,6 +23,66 @@ class NumericTest < Test::Unit::TestCase
|
|
23
23
|
assert_equal(5,5.unless(false))
|
24
24
|
end
|
25
25
|
|
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
|
+
|
26
86
|
|
27
87
|
end
|
28
88
|
|
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
|
+
version: 1.7.4
|
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-
|
35
|
+
date: 2010-02-19 00:00:00 -08:00
|
36
36
|
default_executable:
|
37
37
|
dependencies: []
|
38
38
|
|
@@ -45,8 +45,11 @@ extensions: []
|
|
45
45
|
extra_rdoc_files: []
|
46
46
|
|
47
47
|
files:
|
48
|
+
- README.rdoc
|
49
|
+
- LICENSE.txt
|
48
50
|
- lib/webget_ruby_ramp.rb
|
49
51
|
- lib/webget_ruby_ramp/array.rb
|
52
|
+
- lib/webget_ruby_ramp/class.rb
|
50
53
|
- lib/webget_ruby_ramp/csv.rb
|
51
54
|
- lib/webget_ruby_ramp/date.rb
|
52
55
|
- lib/webget_ruby_ramp/enumerable.rb
|
@@ -102,6 +105,7 @@ specification_version: 3
|
|
102
105
|
summary: "WebGet Ruby Gem: Ramp gem provides base extensions to ruby classes and rails classes."
|
103
106
|
test_files:
|
104
107
|
- test/webget_ruby_ramp/array_test.rb
|
108
|
+
- test/webget_ruby_ramp/class_test.rb
|
105
109
|
- test/webget_ruby_ramp/csv_test.rb
|
106
110
|
- test/webget_ruby_ramp/date_test.rb
|
107
111
|
- test/webget_ruby_ramp/enumerable_test.rb
|