webget_ruby_ramp 1.7.8 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -292,20 +292,16 @@ class Array
292
292
  # This implementation is optimized for speed, not for memory use.
293
293
  # See http://codeidol.com/other/rubyckbk/Arrays/Shuffling-an-Array/
294
294
  #
295
- # This method definition is skipped if Array#shuffle! is already defined.
296
- #
297
295
  # ==Example
298
296
  # list=
299
297
  # list=['a','b','c']
300
298
  # list.shuffle!
301
299
  # list => ['c','a','b']
302
300
 
303
- if !instance_methods.include?('shuffle!')
304
- def shuffle!
305
- each_index do |i|
306
- j = rand(length-i) + i
307
- self[j], self[i] = self[i], self[j]
308
- end
301
+ def shuffle!
302
+ each_index do |i|
303
+ j = rand(length-i) + i
304
+ self[j], self[i] = self[i], self[j]
309
305
  end
310
306
  end
311
307
 
@@ -314,19 +310,14 @@ class Array
314
310
  # This implementation is optimized for speed, not for memory use.
315
311
  # See http://codeidol.com/other/rubyckbk/Arrays/Shuffling-an-Array/
316
312
  #
317
- # This method definition is skipped if Array#shuffle is already defined.
318
- # For example, Ruby 1.8.7 Array#shuffle is already defined.
319
- #
320
313
  # ==Example
321
314
  # list=
322
315
  # list=['a','b','c']
323
316
  # list.shuffle!
324
317
  # list => ['c','a','b']
325
318
 
326
- if !instance_methods.include?('shuffle') and instance_methods.include?('shuffle!')
327
- def shuffle
328
- dup.shuffle!
329
- end
319
+ def shuffle
320
+ dup.shuffle!
330
321
  end
331
322
 
332
323
 
@@ -310,8 +310,8 @@ module Enumerable
310
310
 
311
311
  # Shortcut to Array#join to concatenate the items into a string
312
312
 
313
- def join(prefix=nil,suffix=nil)
314
- to_a.join(prefix,suffix)
313
+ def join(*op)
314
+ to_a.join(*op)
315
315
  end
316
316
 
317
317
 
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Fixnum extensions
4
+
5
+ class Fixnum
6
+
7
+
8
+ # Return true if the number is even
9
+ #
10
+ # ==Example
11
+ # 2.even? => true
12
+ # 3.even? => false
13
+ #
14
+ # From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/4516
15
+
16
+ def even?
17
+ return self & 1 == 0
18
+ end
19
+
20
+
21
+ # Return true if the number is odd
22
+ #
23
+ # ==Example
24
+ # 2.odd? => false
25
+ # 3.odd? => true
26
+ #
27
+ # n.b. we test to see if this method already exists,
28
+ # because this method is defined in Ruby 1.8.7 onward.
29
+ #
30
+ # From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/4516
31
+
32
+ def odd?
33
+ return self & 1 != 0
34
+ end
35
+
36
+
37
+ end
@@ -228,7 +228,7 @@ class Hash
228
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
- else raise ArgumentError, 'Pivot direction must be either: key/keys/up/left/out or val/vals/down/right/in'
231
+ else raise ArgumentError.new('Pivot direction must be either: key/keys/up/left/out or val/vals/down/right/in')
232
232
  end
233
233
  end
234
234
 
@@ -18,29 +18,8 @@ class Integer
18
18
  # returned to the calling code.
19
19
 
20
20
  def maps
21
- (0...self).map{|item| yield item}
21
+ return (0...self).map{|item| yield item}
22
22
  end
23
23
 
24
24
 
25
- # Return true if the number is even
26
- #
27
- # ==Example
28
- # 2.even? => true
29
- # 3.even? => false
30
-
31
- def even?
32
- self % 2 == 0
33
- end
34
-
35
-
36
- # Return true if the number is odd
37
- #
38
- # ==Example
39
- # 2.odd? => false
40
- # 3.odd? => true
41
-
42
- def odd?
43
- self %2 == 1
44
- end
45
-
46
25
  end
@@ -11,13 +11,28 @@ module Kernel
11
11
  # - http://www.ruby-forum.com/topic/75258
12
12
  # - In 1.9 (Ruby CVS HEAD) there is #__method__ and #__callee__
13
13
  # - http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l90
14
+ #-
15
+ # Make this fast because its often doing logging & reporting.
16
+ # Inline this and use $1 because it's empirically faster than /1
14
17
 
15
- def method_name(caller_index=0)
16
- # Make this fast because its often doing logging & reporting.
17
- # Inline this and use $1 because it's empirically faster than /1
18
+ def my_method_name
19
+ caller[0] =~ /`([^']*)'/ and $1
20
+ end
21
+
22
+
23
+ # See:
24
+ # - http://www.ruby-forum.com/topic/75258
25
+ # - In 1.9 (Ruby CVS HEAD) there is #__method__ and #__callee__
26
+ # - http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l90
27
+ #-
28
+ # Make this fast because its often doing logging & reporting.
29
+ # Inline this and use $1 because it's empirically faster than /1
30
+
31
+ def caller_method_name(caller_index=0)
18
32
  caller[caller_index] =~ /`([^']*)'/ and $1
19
33
  end
20
34
 
35
+
21
36
  # Pretty print to a string.
22
37
  #
23
38
  # Created by Graeme Mathieson.
@@ -20,136 +20,155 @@
20
20
  module Process
21
21
 
22
22
 
23
- # Get the 'ps' command as one long text string.
24
- #
25
- # This is typically useful for logging to a text file.
26
-
27
- def self.ps(pid=Process.pid)
28
- `#{self.ps_command} #{pid.to_i}`
29
- end
30
-
31
-
32
- # Get the 'ps' command as a hash of keys and values.
33
- # -
34
- # OPTIMIZE: add dates, times
35
-
36
- def self.pss(pid=Process.pid)
37
- ps=self.ps(pid)
38
- h=Hash[*self.ps_keys.zip(ps.split).flatten]
39
- h['c'] =h['c'].to_i
40
- h['cp'] =h['cp'].to_f
41
- h['egid'] =h['egid'].to_i
42
- h['egroup'] =h['egroup'].to_i
43
- h['uid'] =h['uid'].to_i
44
- h['fgid'] =h['fgid'].to_i
45
- h['lwp'] =h['lwp'].to_i
46
- h['ni'] =h['ni'].to_i
47
- h['nlwp'] =h['nlwp'].to_i
48
- h['pcpu'] =h['pcpu'].to_f
49
- h['pgid'] =h['pgid'].to_i
50
- h['pid'] =h['pid'].to_i
51
- h['pmem'] =h['pmem'].to_f
52
- h['ppid'] =h['ppid'].to_i
53
- h['rgid'] =h['rgid'].to_i
54
- h['rss'] =h['rss'].to_i
55
- h['ruid'] =h['ruid'].to_i
56
- h['sid'] =h['sid'].to_i
57
- h['sgid'] =h['sgid'].to_i
58
- h['suid'] =h['suid'].to_i
59
- self.ps_aliases.each_pair{|key,val| h[key]=h[val]}
60
- return h
61
- end
23
+ # Get the 'ps' command as one long text string.
24
+ #
25
+ # This is typically useful for logging to a text file.
26
+
27
+ def self.ps(pid=Process.pid)
28
+ `#{self.ps_command} #{pid.to_i}`
29
+ end
30
+
31
+
32
+ # Get the 'ps' command as a hash of keys and values.
33
+ # -
34
+ # OPTIMIZE: add dates, times
35
+
36
+ def self.pss(pid=Process.pid)
37
+ ps=self.ps(pid)
38
+ h=Hash[*self.ps_keys.zip(ps.split).flatten]
39
+ h['c'] =h['c'].to_i
40
+ h['cp'] =h['cp'].to_f
41
+ h['egid'] =h['egid'].to_i
42
+ h['egroup'] =h['egroup'].to_i
43
+ h['uid'] =h['uid'].to_i
44
+ h['fgid'] =h['fgid'].to_i
45
+ h['lwp'] =h['lwp'].to_i
46
+ h['ni'] =h['ni'].to_i
47
+ h['nlwp'] =h['nlwp'].to_i
48
+ h['pcpu'] =h['pcpu'].to_f
49
+ h['pgid'] =h['pgid'].to_i
50
+ h['pid'] =h['pid'].to_i
51
+ h['pmem'] =h['pmem'].to_f
52
+ h['ppid'] =h['ppid'].to_i
53
+ h['rgid'] =h['rgid'].to_i
54
+ h['rss'] =h['rss'].to_i
55
+ h['ruid'] =h['ruid'].to_i
56
+ h['sid'] =h['sid'].to_i
57
+ h['sgid'] =h['sgid'].to_i
58
+ h['suid'] =h['suid'].to_i
59
+ self.ps_aliases.each_pair{|key,val| h[key]=h[val]}
60
+ return h
61
+ end
62
+
63
+ # Get the list of process alias keywords as typically defined by the shell.
64
+ #
65
+ # For example, a shell may consider "%cpu" and "pcpu" to be identical.
66
+
67
+ PS_ALIASES_DEFAULT={
68
+ '%cpu'=>'pcpu',
69
+ '%mem'=>'pmem',
70
+ 'sig_block'=>'blocked',
71
+ 'sigmask'=>'blocked',
72
+ 'sig_catch'=>'caught',
73
+ 'sigcatch'=>'caught',
74
+ 'cls'=>'class',
75
+ 'cls'=>'policy',
76
+ 'cputime'=>'time',
77
+ 'gid'=>'egid',
78
+ 'group'=>'egroup',
79
+ 'uid'=>'euid',
80
+ 'uname'=>'euser',
81
+ 'user'=>'euser',
82
+ 'flag'=>'f',
83
+ 'flags'=>'f',
84
+ 'fsuid'=>'fuid',
85
+ 'sig_ignore'=>'ignored',
86
+ 'sigignore'=>'ignored',
87
+ 'spid'=>'lwp',
88
+ 'tid'=>'lwp',
89
+ 'nice'=>'ni',
90
+ 'thcount'=>'nlwp',
91
+ 'sig'=>'pending',
92
+ 'sig_pend'=>'pending',
93
+ 'pgrp'=>'pgid',
94
+ 'rssize'=>'rss',
95
+ 'rsz'=>'rss',
96
+ 'state'=>'s',
97
+ 'sess'=>'sid',
98
+ 'session'=>'sid',
99
+ 'svgid'=>'sgid',
100
+ 'tt'=>'tname',
101
+ 'tty'=>'tname',
102
+ 'vsz'=>'vsize'
103
+ }
104
+
62
105
 
63
106
  # Get the list of process alias keywords as typically defined by the shell.
64
107
  #
65
108
  # For example, a shell may consider "%cpu" and "pcpu" to be identical.
66
109
 
67
110
  def self.ps_aliases
68
- @@ps_aliases||=Hash[*%w'
69
- %cpu pcpu
70
- %mem pmem
71
- sig_block blocked
72
- sigmask blocked
73
- sig_catch caught
74
- sigcatch caught
75
- cls class
76
- cls policy
77
- cputime time
78
- gid egid
79
- group egroup
80
- uid euid
81
- uname euser
82
- user euser
83
- flag f
84
- flags f
85
- fsuid fuid
86
- sig_ignore ignored
87
- sigignore ignored
88
- spid lwp
89
- tid lwp
90
- nice ni
91
- thcount nlwp
92
- sig pending
93
- sig_pend pending
94
- pgrp pgid
95
- rssize rss
96
- rsz rss
97
- state s
98
- sess sid
99
- session sid
100
- svgid sgid
101
- tt tname
102
- tty tname
103
- vsz vsize
104
- ']
105
- end
106
-
107
-
108
- # Set the list of process alias keywords.
109
-
110
- def self.ps_aliases=(aliases)
111
- @@ps_aliases=aliases
112
- end
113
-
114
-
115
- # Get the list of process keywords.
116
- #
117
- # ==Example
118
- # Process.ps_keys => ["blocked","group","pending","size"]
119
-
120
- def self.ps_keys
121
- @@ps_keys||=%w'blocked bsdtime c caught class cp egid egroup eip esp etime euid euser f fgid fgroup fuid fuser group ignored label lwp ni nlwp nwchan pending pcpu pgid pid pmem ppid pri psr rgid rgroup rss rtprio ruid ruser s sched sgi_p sgid sgroup sid sig size stackp start_time stat suid suser sz time tname tpgid vsize wchan'
122
- end
111
+ @@ps_aliases||=PS_ALIASES_DEFAULT
112
+ end
113
+
114
+
115
+ # Set the list of process alias keywords.
116
+ #
117
+ # For example, a shell may consider "%cpu" and "pcpu" to be identical.
118
+
119
+ def self.ps_aliases=(aliases)
120
+ @@ps_aliases=aliases
121
+ end
122
+
123
+
124
+ # The list of process keywords.
125
+
126
+ PS_KEYS_DEFAULT=%w'blocked bsdtime c caught class cp egid egroup eip esp etime euid euser f fgid fgroup fuid fuser group ignored label lwp ni nlwp nwchan pending pcpu pgid pid pmem ppid pri psr rgid rgroup rss rtprio ruid ruser s sched sgi_p sgid sgroup sid sig size stackp start_time stat suid suser sz time tname tpgid vsize wchan'
127
+
128
+
129
+ # Get the list of process keywords.
130
+ #
131
+ # ==Example
132
+ # Process.ps_keys => ["blocked","group","pending","size"]
133
+
134
+ def self.ps_keys
135
+ @@ps_keys||=PS_KEYS_DEFAULT
136
+ end
123
137
 
124
138
 
125
- # Set the list of process keywords.
126
- #
127
- # ==Example
128
- # Process.ps_keys = ["blocked","group","pending","size"]
139
+ # Set the list of process keywords.
140
+ #
141
+ # ==Example
142
+ # Process.ps_keys = ["blocked","group","pending","size"]
143
+
144
+ def self.ps_keys=(keys)
145
+ @@ps_keys=keys
146
+ end
147
+
129
148
 
130
- def self.ps_keys=(keys)
131
- @@ps_keys=keys
132
- end
149
+ # The process command, i.e. what the sytem will call for the "ps" command.
133
150
 
151
+ PS_COMMAND_DEFAULT='ps h ww -o "'+self.ps_keys.join(',')+'"'
134
152
 
135
- # Get the process command, i.e. what the sytem will call for the "ps" command.
136
- #
137
- # ==Example
138
- # Process.ps_command => "ps h ww -o blocked,group,pending,size"
153
+
154
+ # Get the process command, i.e. what the sytem will call for the "ps" command.
155
+ #
156
+ # ==Example
157
+ # Process.ps_command => "ps h ww -o blocked,group,pending,size"
139
158
 
140
- def self.ps_command
141
- @@ps_command||='ps h ww -o "'+self.ps_keys.join(',')+'"'
142
- end
159
+ def self.ps_command
160
+ @@ps_command||=PS_COMMAND_DEFAULT
161
+ end
143
162
 
144
163
 
145
- # Set the process command, i.e. what the sytem will call for the "ps" command.
146
- #
147
- # ==Example
148
- # Process.ps_command = "ps h ww -o blocked,group,pending,size"
164
+ # Set the process command, i.e. what the sytem will call for the "ps" command.
165
+ #
166
+ # ==Example
167
+ # Process.ps_command = "ps h ww -o blocked,group,pending,size"
149
168
 
150
- def self.ps_command=(command)
151
- @@ps_comannd=command
152
- end
169
+ def self.ps_command=(command)
170
+ @@ps_command=command
171
+ end
153
172
 
154
173
 
155
174
  end
@@ -4,31 +4,8 @@
4
4
 
5
5
  class String
6
6
 
7
- ACCENTS = Hash[*'
8
- à a á a â a ã a ä a å a ā a ă a
9
- æ ae
10
- ď d đ d
11
- ç c ć c č c ĉ c ċ c
12
- è e é e ê e ë e ē e ę e ě e ĕ e ė e
13
- ƒ f
14
- ĝ g ğ g ġ g ģ g
15
- ĥ h ħ h
16
- ì i ì i í i î i ï i ī i ĩ i ĭ i
17
- į j ı j ij j ĵ j
18
- ķ k ĸ k
19
- ł l ľ l ĺ l ļ l ŀ l
20
- ñ n ń n ň n ņ n ʼn n ŋ n
21
- ò o ó o ô o õ o ö o ø o ō o ő o ŏ o ŏ o
22
- œ oek
23
- ą q
24
- ŕ r ř r ŗ r
25
- ś s š s ş s ŝ s ș s
26
- ť t ţ t ŧ t ț t
27
- ù u ú u û u ü u ū u ů u ű u ŭ u ũ u ų u
28
- ŵ w
29
- ý y ÿ y ŷ y
30
- ž z ż z ź z
31
- '.split]
7
+ ACCENTS = Hash[*'à a á a â a ã a ä a å a ā a ă a æ ae ď d đ d ç c ć c č c ĉ c ċ c è e é e ê e ë e ē e ę e ě e ĕ e ė e ƒ f ĝ g ğ g ġ g ģ g ĥ h ħ h ì i ì i í i î i ï i ī i ĩ i ĭ i į j ı j ij j ĵ j ķ k ĸ k ł l ľ l ĺ l ļ l ŀ l
8
+ ñ n ń n ň n ņ n ʼn n ŋ n ò o ó o ô o õ o ö o ø o ō o ő o ŏ o ŏ o œ oek ą q ŕ r ř r ŗ r ś s š s ş s ŝ s ș s ť t ţ t ŧ t ț t ù u ú u û u ü u ū u ů u ű u ŭ u ũ u ų u ŵ w ý y ÿ y ŷ y ž z ż z ź z'.split]
32
9
 
33
10
 
34
11
  # Return the string with words capitalized
@@ -73,6 +73,12 @@ Testing:
73
73
  * File.joindir: wrapper for File.join(File.dirname(...),string,...)
74
74
 
75
75
 
76
+ == Fixnum
77
+
78
+ * even?: is the number even?
79
+ * odd?: is the number odd?
80
+
81
+
76
82
  == Hash
77
83
 
78
84
  * size?: return true if hash has any keys
@@ -87,7 +93,6 @@ Testing:
87
93
 
88
94
  == Integer
89
95
 
90
- * even?: is the number even?
91
96
  * maps: syntactic sugar to yield n times to a block, returning an array of any results (e.g. 3.maps{rand} => [0.4351325,0.7778625,0.158613534])
92
97
  * odd?: is the number odd?
93
98
 
@@ -100,8 +105,8 @@ Testing:
100
105
 
101
106
  == Kernel
102
107
 
103
- * method_name:
104
- * method_name_of_caller: returns the name of the method which called the current method, or the Nth parent up the call stack if the optional caller_index parameter is passed.
108
+ * my_method_name: returns the name of the current method
109
+ * caller_method_name: returns the name of the caller method, or the Nth parent up the call stack if the optional caller_index parameter is passed.
105
110
 
106
111
 
107
112
  == Math
@@ -194,6 +199,7 @@ Extensions that help debug Ruby programs.
194
199
 
195
200
  == Changes
196
201
 
202
+ - 1.8.0 100% rcov coverage
197
203
  - 1.7.8 Add rcov testing
198
204
  - 1.7.4 Add Class#publicize_methods, Integer#even?, Integer#odd?
199
205
  - 1.7.3 Refactor Rails classes to their own gem, add README, LICENSE
@@ -236,7 +242,7 @@ Extensions that help debug Ruby programs.
236
242
 
237
243
  =end
238
244
 
239
- ['array','class','csv','date','enumerable','file','hash','integer','io','kernel','math','nil','numeric','object','process','string','symbol','time','xml','yaml'].map{|x|
245
+ ['array','class','csv','date','enumerable','file','fixnum','hash','integer','io','kernel','math','nil','numeric','object','process','string','symbol','time','xml','yaml'].map{|x|
240
246
  require File.dirname(__FILE__) + "/webget_ruby_ramp/#{x}.rb"
241
247
  }
242
248
 
@@ -40,6 +40,20 @@ class DateTest < Test::Unit::TestCase
40
40
  end
41
41
 
42
42
 
43
+ def test_between
44
+ d1= Date.parse('2008-01-01')
45
+ d2= Date.parse('2009-01-01')
46
+ d3= Date.between(d1,d2)
47
+ assert(d3>=d1)
48
+ assert(d3<=d2)
49
+ end
50
+
51
+
52
+ def self.between(min,max)
53
+ min+rand(max-min)
54
+ end
55
+
56
+
43
57
  # for test_age_years and test_age_days
44
58
  BIRTHDATE = Date.new(1980,10,31)
45
59
  VALENTINES = Date.new(2008,02,14)
@@ -180,17 +180,17 @@ class EnumerableTest < Test::Unit::TestCase
180
180
 
181
181
 
182
182
  def test_join_0
183
- a=['a','b','c']
183
+ a='a'..'c'
184
184
  assert_equal("abc",a.join,"join()")
185
185
  end
186
186
 
187
187
  def test_join_1
188
- a=['a','b','c']
188
+ a='a'..'c'
189
189
  assert_equal("a+b+c",a.join('+'),"join('+')")
190
190
  end
191
191
 
192
192
  def test_join_2
193
- a=['a','b','c']
193
+ a='a'..'c'
194
194
  assert_equal("+a-+b-+c-",a.join("+","-"),"join('+','-')")
195
195
  end
196
196
 
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'webget_ruby_ramp'
3
+
4
+
5
+ class FixnumTest < Test::Unit::TestCase
6
+
7
+ def test_even_with_true
8
+ assert(2.even?)
9
+ end
10
+
11
+ def test_even_with_false
12
+ assert(!3.even?)
13
+ end
14
+
15
+ def test_odd_with_true
16
+ assert(3.odd?)
17
+ end
18
+
19
+ def test_odd_with_false
20
+ assert(!2.odd?)
21
+ end
22
+
23
+ end
24
+
@@ -64,6 +64,22 @@ class HashTest < Test::Unit::TestCase
64
64
  end
65
65
 
66
66
 
67
+ def test_each_pair_bang_with_same_key_different_value
68
+ actual = { "a" => "b", "c" => "d" }
69
+ expect = { "a" => "B", "c" => "D" }
70
+ actual.each_pair! {|key,value| [key, value.upcase] }
71
+ assert_equal(expect,actual)
72
+ end
73
+
74
+
75
+ def test_each_pair_bang_with_same_key_same_value
76
+ actual = { "a" => "b", "c" => "d" }
77
+ expect = { "a" => "b", "c" => "d" }
78
+ actual.each_pair! {|key,value| [key, value] }
79
+ assert_equal(expect,actual)
80
+ end
81
+
82
+
67
83
  def test_each_value_bang
68
84
  actual = { "a" => "b", "c" => "d" }
69
85
  expect = { "a" => "B", "c" => "D" }
@@ -1,6 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'webget_ruby_ramp'
3
3
 
4
+
4
5
  class IntegerTest < Test::Unit::TestCase
5
6
 
6
7
  def test_maps
@@ -15,21 +16,5 @@ class IntegerTest < Test::Unit::TestCase
15
16
  assert_equal(expect,actual)
16
17
  end
17
18
 
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
-
34
19
  end
35
20
 
@@ -3,13 +3,25 @@ require 'webget_ruby_ramp'
3
3
 
4
4
  class KernelTest < Test::Unit::TestCase
5
5
 
6
- def test_method_name
7
- assert_equal('test_method_name',method_name)
8
- end
6
+ def test_my_method_name
7
+ assert_equal('test_my_method_name', my_method_name)
8
+ end
9
9
 
10
- def test_pp_s
11
- assert_equal(":foo\n",pp_s(:foo))
12
- end
10
+ def test_caller_method_name
11
+ assert_equal('test_caller_method_name', caller_method_name)
12
+ end
13
+
14
+ def test_caller_method_name_with_index_0
15
+ assert_equal('test_caller_method_name_with_index_0', caller_method_name(0))
16
+ end
17
+
18
+ def test_caller_method_name_with_index_1
19
+ assert_equal('__send__', caller_method_name(1))
20
+ end
21
+
22
+ def test_pp_s
23
+ assert_equal(":foo\n",pp_s(:foo))
24
+ end
13
25
 
14
26
  end
15
27
 
@@ -19,6 +19,48 @@ class ProcessTest < Test::Unit::TestCase
19
19
  assert(p.size>0,"pss size > 0")
20
20
  assert(p['pcpu']!=nil,"ps_hash pcpu != nil")
21
21
  end
22
+
23
+ def test_ps_aliases
24
+ assert(Process.ps_aliases.is_a?Hash)
25
+ end
26
+
27
+ def test_ps_aliases_default
28
+ assert(Process::PS_ALIASES_DEFAULT.is_a?Hash)
29
+ end
30
+
31
+ def test_ps_aliases_eq
32
+ Process.ps_aliases={'a'=>'b', 'c'=>'d'}
33
+ assert_equal({'a'=>'b', 'c'=>'d'}, Process.ps_aliases)
34
+ Process.ps_aliases=Process::PS_ALIASES_DEFAULT
35
+ end
36
+
37
+ def test_ps_command
38
+ assert(Process.ps_command.is_a?String)
39
+ end
40
+
41
+ def test_ps_command_default
42
+ assert(Process::PS_COMMAND_DEFAULT.is_a?String)
43
+ end
44
+
45
+ def test_ps_command_eq
46
+ Process.ps_command='abc'
47
+ assert_equal('abc', Process.ps_command)
48
+ Process.ps_command=Process::PS_COMMAND_DEFAULT
49
+ end
50
+
51
+ def test_ps_keys
52
+ assert(Process.ps_keys.is_a?Array)
53
+ end
54
+
55
+ def test_ps_keys_default
56
+ assert(Process::PS_KEYS_DEFAULT.is_a?Array)
57
+ end
58
+
59
+ def test_ps_keys_eq
60
+ Process.ps_keys=['a','b','c']
61
+ assert_equal(['a','b','c'], Process.ps_keys)
62
+ Process.ps_keys=Process::PS_KEYS_DEFAULT
63
+ end
22
64
 
23
65
  end
24
66
 
@@ -5,6 +5,11 @@ require 'webget_ruby_ramp'
5
5
  class StringTest < Test::Unit::TestCase
6
6
 
7
7
 
8
+ def test_accents
9
+ assert(String::ACCENTS.is_a?Hash)
10
+ end
11
+
12
+
8
13
  def test_capitalize_words
9
14
  assert_equal("Foo Goo Hoo","foo goo hoo".capitalize_words)
10
15
  end
@@ -25,6 +30,11 @@ class StringTest < Test::Unit::TestCase
25
30
  end
26
31
 
27
32
 
33
+ def test_xid
34
+ assert_equal('foo_goo_hoo',"Foo GOO**_**Hoo".to_xid)
35
+ end
36
+
37
+
28
38
  def test_lowcase
29
39
  assert_equal('foo_goo_hoo',"Foo GOO**_**Hoo".lowcase)
30
40
  end
@@ -7,18 +7,42 @@ class XMLTest < Test::Unit::TestCase
7
7
  @@formatter=REXML::Formatters::Default.new
8
8
 
9
9
  def test_load_dir_files
10
- dirpath=File.join(MYDIR,'xml_test_*.xml')
11
- expect=[File.join(MYDIR,'xml_test_1.xml'),File.join(MYDIR,'xml_test_2.xml')]
12
- actual=Dir[dirpath].sort
13
- assert_equal(expect,actual,"Dir[#{dirpath}] expects test data files")
10
+ dirpath=File.join(MYDIR,'xml_test_*.xml')
11
+ expect=[File.join(MYDIR,'xml_test_1.xml'),File.join(MYDIR,'xml_test_2.xml')]
12
+ actual=Dir[dirpath].sort
13
+ assert_equal(expect,actual,"Dir[#{dirpath}] expects test data files")
14
14
  end
15
15
 
16
16
  def test_load_dir
17
- dirpath=File.join(MYDIR,'xml_test_*.xml')
18
- expect="abcdef"
19
- actual=''
20
- XML.load_dir(dirpath){|doc| doc.elements.each('foo/bar'){|e| actual+=e.attributes['x']}}
21
- assert_equal(expect,actual,'XML.load_dir')
17
+ dirpath=File.join(MYDIR,'xml_test_*.xml')
18
+ expect="abcdef"
19
+ actual=''
20
+ XML.load_dir(dirpath){|doc| doc.elements.each('foo/bar'){|e| actual+=e.attributes['x']}}
21
+ assert_equal(expect,actual,'XML.load_dir')
22
+ end
23
+
24
+ def test_load_elements
25
+ dirpath=File.join(MYDIR,'xml_test_*.xml')
26
+ expect="<bar x='a'/><bar x='b'/><bar x='c'/><bar x='d'/><bar x='e'/><bar x='f'/>"
27
+ actual=''
28
+ XML.load_elements(dirpath,'foo/bar'){|elem| actual+=elem.to_s }
29
+ assert_equal(expect,actual,'XML.load_elements')
30
+ end
31
+
32
+ def test_load_attributes
33
+ dirpath=File.join(MYDIR,'xml_test_*.xml')
34
+ expect="xaxbxcxdxexf"
35
+ actual=''
36
+ XML.load_attributes(dirpath,'foo/bar'){|attributes| actual+=attributes.sort.to_s }
37
+ assert_equal(expect,actual,'XML.load_attributes')
38
+ end
39
+
40
+ def test_load_attributes_hash
41
+ dirpath=File.join(MYDIR,'xml_test_*.xml')
42
+ expect="xaxbxcxdxexf"
43
+ actual=''
44
+ XML.load_attributes_hash(dirpath,'foo/bar'){|attributes_hash| actual+=attributes_hash.to_s }
45
+ assert_equal(expect,actual,'XML.load_attributes_hash')
22
46
  end
23
47
 
24
48
  def test_attributes_to_hash
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ]VT�^ �����a�%�a�t����a3���?��N��m���)�&�1��ju�*�*�<��%���5pބS���5vwhN5��3i���5Dsb��É������IAMěP�?�g�$S�/�
1
+ 0��壳>m%ka eB��_���E���o���LjPV���npZae/����������� ���}��9G��H����AI4(M�*ʆ�/"I��$��Y9
2
+ Y(��O o!Y�&�͒Vijv�
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.8
4
+ version: 1.8.0
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-03 00:00:00 -08:00
35
+ date: 2010-03-05 00:00:00 -08:00
36
36
  default_executable:
37
37
  dependencies: []
38
38
 
@@ -54,6 +54,7 @@ files:
54
54
  - lib/webget_ruby_ramp/date.rb
55
55
  - lib/webget_ruby_ramp/enumerable.rb
56
56
  - lib/webget_ruby_ramp/file.rb
57
+ - lib/webget_ruby_ramp/fixnum.rb
57
58
  - lib/webget_ruby_ramp/hash.rb
58
59
  - lib/webget_ruby_ramp/integer.rb
59
60
  - lib/webget_ruby_ramp/io.rb
@@ -110,6 +111,7 @@ test_files:
110
111
  - test/webget_ruby_ramp/date_test.rb
111
112
  - test/webget_ruby_ramp/enumerable_test.rb
112
113
  - test/webget_ruby_ramp/file_test.rb
114
+ - test/webget_ruby_ramp/fixnum_test.rb
113
115
  - test/webget_ruby_ramp/hash_test.rb
114
116
  - test/webget_ruby_ramp/integer_test.rb
115
117
  - test/webget_ruby_ramp/io_test.rb
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- ;��ZwM��T%|���Φ�<�E��К�LBG��iZ@ ��\���B94 � ��[�_//�\��=��m�ސ�L��֊�o�����_�5H�ȹF�xlc��[9�󅍷gJ�!ԙ#2�N��
1
+ ���D�h6y2P�`eF��=Y}��DPh#ZZ���fY�_�]^��.����y��h���E�G�i�EPÆI<���.&���X���2�`Z��U����2��hy;Z�^f}���m�pf��