rhodes 0.2.2 → 0.2.3

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.
@@ -1,3 +1,6 @@
1
+ == 0.2.3 2009-01-26
2
+ * added newgem dependency
3
+
1
4
  == 0.2.2 2009-01-23
2
5
  * fixed bug in layout.erb template
3
6
 
data/Rakefile CHANGED
@@ -17,10 +17,8 @@ $hoe = Hoe.new('rhodes', Rhodes::VERSION) do |p|
17
17
  ['rspec'],
18
18
  ['templater'],
19
19
  ['diff-lcs'],
20
- ['extlib']
21
- ]
22
- p.extra_dev_deps = [
23
- ['newgem', ">= #{::Newgem::VERSION}"]
20
+ ['extlib'],
21
+ ['newgem']
24
22
  ]
25
23
 
26
24
  p.clean_globs |= %w[**/.DS_Store tmp *.log]
@@ -238,20 +238,20 @@ class Date
238
238
  # Full month names, in English. Months count from 1 to 12; a
239
239
  # month's numerical representation indexed into this array
240
240
  # gives the name of that month (hence the first element is nil).
241
- MONTHNAMES = [nil] + %w(January February March April May June July
242
- August September October November December)
241
+ #MONTHNAMES = [nil] + %w(January February March April May June July
242
+ # August September October November December)
243
243
 
244
244
  # Full names of days of the week, in English. Days of the week
245
245
  # count from 0 to 6 (except in the commercial week); a day's numerical
246
246
  # representation indexed into this array gives the name of that day.
247
- DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
247
+ #DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
248
248
 
249
249
  # Abbreviated month names, in English.
250
- ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun
251
- Jul Aug Sep Oct Nov Dec)
250
+ #ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun
251
+ # Jul Aug Sep Oct Nov Dec)
252
252
 
253
253
  # Abbreviated day names, in English.
254
- ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
254
+ #ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
255
255
 
256
256
  [MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYNAMES].each do |xs|
257
257
  xs.each{|x| x.freeze unless x.nil?}.freeze
@@ -1738,7 +1738,7 @@ class Time
1738
1738
  def to_time() getlocal end
1739
1739
 
1740
1740
  def to_date
1741
- jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY)
1741
+ jd = Date.__send__(:civil_to_jd, year(), mon(), mday(), Date::ITALY)
1742
1742
  Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
1743
1743
  end
1744
1744
 
@@ -1755,7 +1755,7 @@ end
1755
1755
 
1756
1756
  class Date
1757
1757
 
1758
- def to_time() Time.local(year, mon, mday) end
1758
+ def to_time() Time.local(year(), mon(), mday()) end
1759
1759
  def to_date() self end
1760
1760
  def to_datetime() DateTime.new!(jd_to_ajd(jd, 0, 0), @of, @sg) end
1761
1761
 
@@ -1778,7 +1778,7 @@ class DateTime < Date
1778
1778
  def to_time
1779
1779
  d = new_offset(0)
1780
1780
  d.instance_eval do
1781
- Time.utc(year, mon, mday, hour, min, sec + sec_fraction)
1781
+ Time.utc(year(), mon(), mday(), hour(), min(), sec + sec_fraction)
1782
1782
  end.
1783
1783
  getlocal
1784
1784
  end
@@ -1,12 +1,34 @@
1
1
  # format.rb: Written by Tadayoshi Funaba 1999-2008
2
2
  # $Id: format.rb,v 2.43 2008-01-17 20:16:31+09 tadf Exp $
3
3
 
4
+ if defined? RHO_ME
5
+ require 'rationalME'
6
+ end
7
+
4
8
  require 'rational'
5
9
 
6
10
  class Date
7
11
 
8
12
  #SECONDS_IN_DAY = 60*60*24
9
13
  #SECONDS_IN_DAY = Rational(1, 86400)
14
+
15
+ #From date.rb:
16
+ # Full month names, in English. Months count from 1 to 12; a
17
+ # month's numerical representation indexed into this array
18
+ # gives the name of that month (hence the first element is nil).
19
+ MONTHNAMES = [nil] + %w(January February March April May June July
20
+ August September October November December)
21
+
22
+ # Full names of days of the week, in English. Days of the week
23
+ # count from 0 to 6 (except in the commercial week); a day's numerical
24
+ # representation indexed into this array gives the name of that day.
25
+ DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
26
+
27
+ # Abbreviated month names, in English.
28
+ ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun
29
+ Jul Aug Sep Oct Nov Dec)
30
+ # Abbreviated day names, in English.
31
+ ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
10
32
 
11
33
  module Format # :nodoc:
12
34
 
@@ -245,28 +267,28 @@ class Date
245
267
  when 'C', 'EC'; emit_sn((year / 100).floor, 2, f)
246
268
  when 'c', 'Ec'; emit_a(strftime('%a %b %e %H:%M:%S %Y'), 0, f)
247
269
  when 'D'; emit_a(strftime('%m/%d/%y'), 0, f)
248
- when 'd', 'Od'; emit_n(mday, 2, f)
249
- when 'e', 'Oe'; emit_a(mday, 2, f)
270
+ when 'd', 'Od'; emit_n(mday(), 2, f)
271
+ when 'e', 'Oe'; emit_a(mday(), 2, f)
250
272
  when 'F'
251
273
  if m == '%F'
252
274
  format('%.4d-%02d-%02d', year(), mon(), mday()) # 4p
253
275
  else
254
276
  emit_a(strftime('%Y-%m-%d'), 0, f)
255
277
  end
256
- when 'G'; emit_sn(cwyear, 4, f)
278
+ when 'G'; emit_sn(cwyear(), 4, f)
257
279
  when 'g'; emit_n(cwyear % 100, 2, f)
258
- when 'H', 'OH'; emit_n(hour, 2, f)
280
+ when 'H', 'OH'; emit_n(hour(), 2, f)
259
281
  when 'h'; emit_ad(strftime('%b'), 0, f)
260
282
  when 'I', 'OI'; emit_n((hour % 12).nonzero? || 12, 2, f)
261
- when 'j'; emit_n(yday, 3, f)
262
- when 'k'; emit_a(hour, 2, f)
283
+ when 'j'; emit_n(yday(), 3, f)
284
+ when 'k'; emit_a(hour(), 2, f)
263
285
  when 'L'
264
286
  w = f[:w] || 3
265
287
  u = 10**w
266
288
  emit_n((sec_fraction * u).floor, w, f)
267
289
  when 'l'; emit_a((hour % 12).nonzero? || 12, 2, f)
268
- when 'M', 'OM'; emit_n(min, 2, f)
269
- when 'm', 'Om'; emit_n(mon, 2, f)
290
+ when 'M', 'OM'; emit_n(min(), 2, f)
291
+ when 'm', 'Om'; emit_n(mon(), 2, f)
270
292
  when 'N'
271
293
  w = f[:w] || 9
272
294
  u = 10**w
@@ -279,7 +301,7 @@ class Date
279
301
  emit_sn(s, 1, f)
280
302
  when 'R'; emit_a(strftime('%H:%M'), 0, f)
281
303
  when 'r'; emit_a(strftime('%I:%M:%S %p'), 0, f)
282
- when 'S', 'OS'; emit_n(sec, 2, f)
304
+ when 'S', 'OS'; emit_n(sec(), 2, f)
283
305
  when 's'
284
306
  s = ((ajd - UNIX_EPOCH_IN_AJD) / Rational(1, 86400)).round
285
307
  emit_sn(s, 1, f)
@@ -292,10 +314,10 @@ class Date
292
314
  when 't'; emit_a("\t", 0, f)
293
315
  when 'U', 'W', 'OU', 'OW'
294
316
  emit_n(if c[-1,1] == 'U' then wnum0 else wnum1 end, 2, f)
295
- when 'u', 'Ou'; emit_n(cwday, 1, f)
296
- when 'V', 'OV'; emit_n(cweek, 2, f)
317
+ when 'u', 'Ou'; emit_n(cwday(), 1, f)
318
+ when 'V', 'OV'; emit_n(cweek(), 2, f)
297
319
  when 'v'; emit_a(strftime('%e-%b-%Y'), 0, f)
298
- when 'w', 'Ow'; emit_n(wday, 1, f)
320
+ when 'w', 'Ow'; emit_n(wday(), 1, f)
299
321
  when 'X', 'EX'; emit_a(strftime('%H:%M:%S'), 0, f)
300
322
  when 'x', 'Ex'; emit_a(strftime('%m/%d/%y'), 0, f)
301
323
  when 'Y', 'EY'; emit_sn(year(), 4, f)
@@ -1,6 +1,6 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  unless defined? Rhodes::DBVERSION
6
6
  DBVERSION = '0.2.2'
@@ -135,179 +135,3 @@ module Singleton
135
135
  end
136
136
 
137
137
  end
138
-
139
-
140
- if __FILE__ == $0
141
-
142
- def num_of_instances(klass)
143
- "#{ObjectSpace.each_object(klass){}} #{klass} instance(s)"
144
- end
145
-
146
- # The basic and most important example.
147
-
148
- class SomeSingletonClass
149
- include Singleton
150
- end
151
- puts "There are #{num_of_instances(SomeSingletonClass)}"
152
-
153
- a = SomeSingletonClass.instance
154
- b = SomeSingletonClass.instance # a and b are same object
155
- puts "basic test is #{a == b}"
156
-
157
- begin
158
- SomeSingletonClass.new
159
- rescue NoMethodError => mes
160
- puts mes
161
- end
162
-
163
-
164
-
165
- puts "\nThreaded example with exception and customized #_instantiate?() hook"; p
166
- Thread.abort_on_exception = false
167
-
168
- class Ups < SomeSingletonClass
169
- def initialize
170
- self.class.__sleep
171
- puts "initialize called by thread ##{Thread.current[:i]}"
172
- end
173
- end
174
-
175
- class << Ups
176
- def _instantiate?
177
- @enter.push Thread.current[:i]
178
- while false.equal?(@singleton__instance__)
179
- @singleton__mutex__.unlock
180
- sleep 0.08
181
- @singleton__mutex__.lock
182
- end
183
- @leave.push Thread.current[:i]
184
- @singleton__instance__
185
- end
186
-
187
- def __sleep
188
- sleep(rand(0.08))
189
- end
190
-
191
- def new
192
- begin
193
- __sleep
194
- raise "boom - thread ##{Thread.current[:i]} failed to create instance"
195
- ensure
196
- # simple flip-flop
197
- class << self
198
- remove_method :new
199
- end
200
- end
201
- end
202
-
203
- def instantiate_all
204
- @enter = []
205
- @leave = []
206
- 1.upto(9) {|i|
207
- Thread.new {
208
- begin
209
- Thread.current[:i] = i
210
- __sleep
211
- instance
212
- rescue RuntimeError => mes
213
- puts mes
214
- end
215
- }
216
- }
217
- puts "Before there were #{num_of_instances(self)}"
218
- sleep 3
219
- puts "Now there is #{num_of_instances(self)}"
220
- puts "#{@enter.join '; '} was the order of threads entering the waiting loop"
221
- puts "#{@leave.join '; '} was the order of threads leaving the waiting loop"
222
- end
223
- end
224
-
225
-
226
- Ups.instantiate_all
227
- # results in message like
228
- # Before there were 0 Ups instance(s)
229
- # boom - thread #6 failed to create instance
230
- # initialize called by thread #3
231
- # Now there is 1 Ups instance(s)
232
- # 3; 2; 1; 8; 4; 7; 5 was the order of threads entering the waiting loop
233
- # 3; 2; 1; 7; 4; 8; 5 was the order of threads leaving the waiting loop
234
-
235
-
236
- puts "\nLets see if class level cloning really works"
237
- Yup = Ups.clone
238
- def Yup.new
239
- begin
240
- __sleep
241
- raise "boom - thread ##{Thread.current[:i]} failed to create instance"
242
- ensure
243
- # simple flip-flop
244
- class << self
245
- remove_method :new
246
- end
247
- end
248
- end
249
- Yup.instantiate_all
250
-
251
-
252
- puts "\n\n","Customized marshalling"
253
- class A
254
- include Singleton
255
- attr_accessor :persist, :die
256
- def _dump(depth)
257
- # this strips the @die information from the instance
258
- Marshal.dump(@persist,depth)
259
- end
260
- end
261
-
262
- def A._load(str)
263
- instance.persist = Marshal.load(str)
264
- instance
265
- end
266
-
267
- a = A.instance
268
- a.persist = ["persist"]
269
- a.die = "die"
270
- a.taint
271
-
272
- stored_state = Marshal.dump(a)
273
- # change state
274
- a.persist = nil
275
- a.die = nil
276
- b = Marshal.load(stored_state)
277
- p a == b # => true
278
- p a.persist # => ["persist"]
279
- p a.die # => nil
280
-
281
-
282
- puts "\n\nSingleton with overridden default #inherited() hook"
283
- class Up
284
- end
285
- def Up.inherited(sub_klass)
286
- puts "#{sub_klass} subclasses #{self}"
287
- end
288
-
289
-
290
- class Middle < Up
291
- include Singleton
292
- end
293
-
294
- class Down < Middle; end
295
-
296
- puts "and basic \"Down test\" is #{Down.instance == Down.instance}\n
297
- Various exceptions"
298
-
299
- begin
300
- module AModule
301
- include Singleton
302
- end
303
- rescue TypeError => mes
304
- puts mes #=> Inclusion of the OO-Singleton module in module AModule
305
- end
306
-
307
- begin
308
- 'aString'.extend Singleton
309
- rescue NoMethodError => mes
310
- puts mes #=> undefined method `extend_object' for Singleton:Module
311
- end
312
-
313
- end
@@ -41,6 +41,9 @@
41
41
  #
42
42
 
43
43
  require 'date/format'
44
+ if defined? RHO_ME
45
+ require 'dateME'
46
+ end
44
47
 
45
48
  #
46
49
  # Implements the extensions to the Time class that are described in the
@@ -484,356 +487,3 @@ class Time
484
487
  end
485
488
  alias iso8601 xmlschema
486
489
  end
487
-
488
- if __FILE__ == $0
489
- require 'test/unit'
490
-
491
- class TimeExtentionTest < Test::Unit::TestCase # :nodoc:
492
- def test_rfc822
493
- assert_equal(Time.utc(1976, 8, 26, 14, 30) + 4 * 3600,
494
- Time.rfc2822("26 Aug 76 14:30 EDT"))
495
- assert_equal(Time.utc(1976, 8, 27, 9, 32) + 7 * 3600,
496
- Time.rfc2822("27 Aug 76 09:32 PDT"))
497
- end
498
-
499
- def test_rfc2822
500
- assert_equal(Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600,
501
- Time.rfc2822("Fri, 21 Nov 1997 09:55:06 -0600"))
502
- assert_equal(Time.utc(2003, 7, 1, 10, 52, 37) - 2 * 3600,
503
- Time.rfc2822("Tue, 1 Jul 2003 10:52:37 +0200"))
504
- assert_equal(Time.utc(1997, 11, 21, 10, 1, 10) + 6 * 3600,
505
- Time.rfc2822("Fri, 21 Nov 1997 10:01:10 -0600"))
506
- assert_equal(Time.utc(1997, 11, 21, 11, 0, 0) + 6 * 3600,
507
- Time.rfc2822("Fri, 21 Nov 1997 11:00:00 -0600"))
508
- assert_equal(Time.utc(1997, 11, 24, 14, 22, 1) + 8 * 3600,
509
- Time.rfc2822("Mon, 24 Nov 1997 14:22:01 -0800"))
510
- begin
511
- Time.at(-1)
512
- rescue ArgumentError
513
- # ignore
514
- else
515
- assert_equal(Time.utc(1969, 2, 13, 23, 32, 54) + 3 * 3600 + 30 * 60,
516
- Time.rfc2822("Thu, 13 Feb 1969 23:32:54 -0330"))
517
- assert_equal(Time.utc(1969, 2, 13, 23, 32, 0) + 3 * 3600 + 30 * 60,
518
- Time.rfc2822(" Thu,
519
- 13
520
- Feb
521
- 1969
522
- 23:32
523
- -0330 (Newfoundland Time)"))
524
- end
525
- assert_equal(Time.utc(1997, 11, 21, 9, 55, 6),
526
- Time.rfc2822("21 Nov 97 09:55:06 GMT"))
527
- assert_equal(Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600,
528
- Time.rfc2822("Fri, 21 Nov 1997 09 : 55 : 06 -0600"))
529
- assert_raise(ArgumentError) {
530
- # inner comment is not supported.
531
- Time.rfc2822("Fri, 21 Nov 1997 09(comment): 55 : 06 -0600")
532
- }
533
- end
534
-
535
- def test_rfc2616
536
- t = Time.utc(1994, 11, 6, 8, 49, 37)
537
- assert_equal(t, Time.httpdate("Sun, 06 Nov 1994 08:49:37 GMT"))
538
- assert_equal(t, Time.httpdate("Sunday, 06-Nov-94 08:49:37 GMT"))
539
- assert_equal(t, Time.httpdate("Sun Nov 6 08:49:37 1994"))
540
- assert_equal(Time.utc(1995, 11, 15, 6, 25, 24),
541
- Time.httpdate("Wed, 15 Nov 1995 06:25:24 GMT"))
542
- assert_equal(Time.utc(1995, 11, 15, 4, 58, 8),
543
- Time.httpdate("Wed, 15 Nov 1995 04:58:08 GMT"))
544
- assert_equal(Time.utc(1994, 11, 15, 8, 12, 31),
545
- Time.httpdate("Tue, 15 Nov 1994 08:12:31 GMT"))
546
- assert_equal(Time.utc(1994, 12, 1, 16, 0, 0),
547
- Time.httpdate("Thu, 01 Dec 1994 16:00:00 GMT"))
548
- assert_equal(Time.utc(1994, 10, 29, 19, 43, 31),
549
- Time.httpdate("Sat, 29 Oct 1994 19:43:31 GMT"))
550
- assert_equal(Time.utc(1994, 11, 15, 12, 45, 26),
551
- Time.httpdate("Tue, 15 Nov 1994 12:45:26 GMT"))
552
- assert_equal(Time.utc(1999, 12, 31, 23, 59, 59),
553
- Time.httpdate("Fri, 31 Dec 1999 23:59:59 GMT"))
554
-
555
- assert_equal(Time.utc(2007, 12, 23, 11, 22, 33),
556
- Time.httpdate('Sunday, 23-Dec-07 11:22:33 GMT'))
557
- end
558
-
559
- def test_rfc3339
560
- t = Time.utc(1985, 4, 12, 23, 20, 50, 520000)
561
- s = "1985-04-12T23:20:50.52Z"
562
- assert_equal(t, Time.iso8601(s))
563
- assert_equal(s, t.iso8601(2))
564
-
565
- t = Time.utc(1996, 12, 20, 0, 39, 57)
566
- s = "1996-12-19T16:39:57-08:00"
567
- assert_equal(t, Time.iso8601(s))
568
- # There is no way to generate time string with arbitrary timezone.
569
- s = "1996-12-20T00:39:57Z"
570
- assert_equal(t, Time.iso8601(s))
571
- assert_equal(s, t.iso8601)
572
-
573
- t = Time.utc(1990, 12, 31, 23, 59, 60)
574
- s = "1990-12-31T23:59:60Z"
575
- assert_equal(t, Time.iso8601(s))
576
- # leap second is representable only if timezone file has it.
577
- s = "1990-12-31T15:59:60-08:00"
578
- assert_equal(t, Time.iso8601(s))
579
-
580
- begin
581
- Time.at(-1)
582
- rescue ArgumentError
583
- # ignore
584
- else
585
- t = Time.utc(1937, 1, 1, 11, 40, 27, 870000)
586
- s = "1937-01-01T12:00:27.87+00:20"
587
- assert_equal(t, Time.iso8601(s))
588
- end
589
- end
590
-
591
- # http://www.w3.org/TR/xmlschema-2/
592
- def test_xmlschema
593
- assert_equal(Time.utc(1999, 5, 31, 13, 20, 0) + 5 * 3600,
594
- Time.xmlschema("1999-05-31T13:20:00-05:00"))
595
- assert_equal(Time.local(2000, 1, 20, 12, 0, 0),
596
- Time.xmlschema("2000-01-20T12:00:00"))
597
- assert_equal(Time.utc(2000, 1, 20, 12, 0, 0),
598
- Time.xmlschema("2000-01-20T12:00:00Z"))
599
- assert_equal(Time.utc(2000, 1, 20, 12, 0, 0) - 12 * 3600,
600
- Time.xmlschema("2000-01-20T12:00:00+12:00"))
601
- assert_equal(Time.utc(2000, 1, 20, 12, 0, 0) + 13 * 3600,
602
- Time.xmlschema("2000-01-20T12:00:00-13:00"))
603
- assert_equal(Time.utc(2000, 3, 4, 23, 0, 0) - 3 * 3600,
604
- Time.xmlschema("2000-03-04T23:00:00+03:00"))
605
- assert_equal(Time.utc(2000, 3, 4, 20, 0, 0),
606
- Time.xmlschema("2000-03-04T20:00:00Z"))
607
- assert_equal(Time.local(2000, 1, 15, 0, 0, 0),
608
- Time.xmlschema("2000-01-15T00:00:00"))
609
- assert_equal(Time.local(2000, 2, 15, 0, 0, 0),
610
- Time.xmlschema("2000-02-15T00:00:00"))
611
- assert_equal(Time.local(2000, 1, 15, 12, 0, 0),
612
- Time.xmlschema("2000-01-15T12:00:00"))
613
- assert_equal(Time.utc(2000, 1, 16, 12, 0, 0),
614
- Time.xmlschema("2000-01-16T12:00:00Z"))
615
- assert_equal(Time.local(2000, 1, 1, 12, 0, 0),
616
- Time.xmlschema("2000-01-01T12:00:00"))
617
- assert_equal(Time.utc(1999, 12, 31, 23, 0, 0),
618
- Time.xmlschema("1999-12-31T23:00:00Z"))
619
- assert_equal(Time.local(2000, 1, 16, 12, 0, 0),
620
- Time.xmlschema("2000-01-16T12:00:00"))
621
- assert_equal(Time.local(2000, 1, 16, 0, 0, 0),
622
- Time.xmlschema("2000-01-16T00:00:00"))
623
- assert_equal(Time.utc(2000, 1, 12, 12, 13, 14),
624
- Time.xmlschema("2000-01-12T12:13:14Z"))
625
- assert_equal(Time.utc(2001, 4, 17, 19, 23, 17, 300000),
626
- Time.xmlschema("2001-04-17T19:23:17.3Z"))
627
- assert_raise(ArgumentError) { Time.xmlschema("2000-01-01T00:00:00.+00:00") }
628
- end
629
-
630
- def test_encode_xmlschema
631
- t = Time.utc(2001, 4, 17, 19, 23, 17, 300000)
632
- assert_equal("2001-04-17T19:23:17Z", t.xmlschema)
633
- assert_equal("2001-04-17T19:23:17.3Z", t.xmlschema(1))
634
- assert_equal("2001-04-17T19:23:17.300000Z", t.xmlschema(6))
635
- assert_equal("2001-04-17T19:23:17.3000000Z", t.xmlschema(7))
636
-
637
- t = Time.utc(2001, 4, 17, 19, 23, 17, 123456)
638
- assert_equal("2001-04-17T19:23:17.1234560Z", t.xmlschema(7))
639
- assert_equal("2001-04-17T19:23:17.123456Z", t.xmlschema(6))
640
- assert_equal("2001-04-17T19:23:17.12345Z", t.xmlschema(5))
641
- assert_equal("2001-04-17T19:23:17.1Z", t.xmlschema(1))
642
-
643
- begin
644
- Time.at(-1)
645
- rescue ArgumentError
646
- # ignore
647
- else
648
- t = Time.utc(1960, 12, 31, 23, 0, 0, 123456)
649
- assert_equal("1960-12-31T23:00:00.123456Z", t.xmlschema(6))
650
- end
651
-
652
- assert_equal(249, Time.xmlschema("2008-06-05T23:49:23.000249+09:00").usec)
653
- end
654
-
655
- def test_completion
656
- now = Time.local(2001,11,29,21,26,35)
657
- assert_equal(Time.local( 2001,11,29,21,12),
658
- Time.parse("2001/11/29 21:12", now))
659
- assert_equal(Time.local( 2001,11,29),
660
- Time.parse("2001/11/29", now))
661
- assert_equal(Time.local( 2001,11,29),
662
- Time.parse( "11/29", now))
663
- #assert_equal(Time.local(2001,11,1), Time.parse("Nov", now))
664
- assert_equal(Time.local( 2001,11,29,10,22),
665
- Time.parse( "10:22", now))
666
- end
667
-
668
- def test_invalid
669
- # They were actually used in some web sites.
670
- assert_raise(ArgumentError) { Time.httpdate("1 Dec 2001 10:23:57 GMT") }
671
- assert_raise(ArgumentError) { Time.httpdate("Sat, 1 Dec 2001 10:25:42 GMT") }
672
- assert_raise(ArgumentError) { Time.httpdate("Sat, 1-Dec-2001 10:53:55 GMT") }
673
- assert_raise(ArgumentError) { Time.httpdate("Saturday, 01-Dec-2001 10:15:34 GMT") }
674
- assert_raise(ArgumentError) { Time.httpdate("Saturday, 01-Dec-101 11:10:07 GMT") }
675
- assert_raise(ArgumentError) { Time.httpdate("Fri, 30 Nov 2001 21:30:00 JST") }
676
-
677
- # They were actually used in some mails.
678
- assert_raise(ArgumentError) { Time.rfc2822("01-5-20") }
679
- assert_raise(ArgumentError) { Time.rfc2822("7/21/00") }
680
- assert_raise(ArgumentError) { Time.rfc2822("2001-8-28") }
681
- assert_raise(ArgumentError) { Time.rfc2822("00-5-6 1:13:06") }
682
- assert_raise(ArgumentError) { Time.rfc2822("2001-9-27 9:36:49") }
683
- assert_raise(ArgumentError) { Time.rfc2822("2000-12-13 11:01:11") }
684
- assert_raise(ArgumentError) { Time.rfc2822("2001/10/17 04:29:55") }
685
- assert_raise(ArgumentError) { Time.rfc2822("9/4/2001 9:23:19 PM") }
686
- assert_raise(ArgumentError) { Time.rfc2822("01 Nov 2001 09:04:31") }
687
- assert_raise(ArgumentError) { Time.rfc2822("13 Feb 2001 16:4 GMT") }
688
- assert_raise(ArgumentError) { Time.rfc2822("01 Oct 00 5:41:19 PM") }
689
- assert_raise(ArgumentError) { Time.rfc2822("2 Jul 00 00:51:37 JST") }
690
- assert_raise(ArgumentError) { Time.rfc2822("01 11 2001 06:55:57 -0500") }
691
- assert_raise(ArgumentError) { Time.rfc2822("18 \343\366\356\341\370 2000") }
692
- assert_raise(ArgumentError) { Time.rfc2822("Fri, Oct 2001 18:53:32") }
693
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 2 Nov 2001 03:47:54") }
694
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 27 Jul 2001 11.14.14 +0200") }
695
- assert_raise(ArgumentError) { Time.rfc2822("Thu, 2 Nov 2000 04:13:53 -600") }
696
- assert_raise(ArgumentError) { Time.rfc2822("Wed, 5 Apr 2000 22:57:09 JST") }
697
- assert_raise(ArgumentError) { Time.rfc2822("Mon, 11 Sep 2000 19:47:33 00000") }
698
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 28 Apr 2000 20:40:47 +-900") }
699
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 19 Jan 2001 8:15:36 AM -0500") }
700
- assert_raise(ArgumentError) { Time.rfc2822("Thursday, Sep 27 2001 7:42:35 AM EST") }
701
- assert_raise(ArgumentError) { Time.rfc2822("3/11/2001 1:31:57 PM Pacific Daylight Time") }
702
- assert_raise(ArgumentError) { Time.rfc2822("Mi, 28 Mrz 2001 11:51:36") }
703
- assert_raise(ArgumentError) { Time.rfc2822("P, 30 sept 2001 23:03:14") }
704
- assert_raise(ArgumentError) { Time.rfc2822("fr, 11 aug 2000 18:39:22") }
705
- assert_raise(ArgumentError) { Time.rfc2822("Fr, 21 Sep 2001 17:44:03 -1000") }
706
- assert_raise(ArgumentError) { Time.rfc2822("Mo, 18 Jun 2001 19:21:40 -1000") }
707
- assert_raise(ArgumentError) { Time.rfc2822("l\366, 12 aug 2000 18:53:20") }
708
- assert_raise(ArgumentError) { Time.rfc2822("l\366, 26 maj 2001 00:15:58") }
709
- assert_raise(ArgumentError) { Time.rfc2822("Dom, 30 Sep 2001 17:36:30") }
710
- assert_raise(ArgumentError) { Time.rfc2822("%&, 31 %2/ 2000 15:44:47 -0500") }
711
- assert_raise(ArgumentError) { Time.rfc2822("dom, 26 ago 2001 03:57:07 -0300") }
712
- assert_raise(ArgumentError) { Time.rfc2822("ter, 04 set 2001 16:27:58 -0300") }
713
- assert_raise(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
714
- assert_raise(ArgumentError) { Time.rfc2822("Wen, 3 oct 2001 23:17:49 -0400") }
715
- assert_raise(ArgumentError) { Time.rfc2822("ele, 11 h: 2000 12:42:15 -0500") }
716
- assert_raise(ArgumentError) { Time.rfc2822("Tue, 14 Aug 2001 3:55:3 +0200") }
717
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 25 Aug 2000 9:3:48 +0800") }
718
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 1 Dec 2000 0:57:50 EST") }
719
- assert_raise(ArgumentError) { Time.rfc2822("Mon, 7 May 2001 9:39:51 +0200") }
720
- assert_raise(ArgumentError) { Time.rfc2822("Wed, 1 Aug 2001 16:9:15 +0200") }
721
- assert_raise(ArgumentError) { Time.rfc2822("Wed, 23 Aug 2000 9:17:36 +0800") }
722
- assert_raise(ArgumentError) { Time.rfc2822("Fri, 11 Aug 2000 10:4:42 +0800") }
723
- assert_raise(ArgumentError) { Time.rfc2822("Sat, 15 Sep 2001 13:22:2 +0300") }
724
- assert_raise(ArgumentError) { Time.rfc2822("Wed,16 \276\305\324\302 2001 20:06:25 +0800") }
725
- assert_raise(ArgumentError) { Time.rfc2822("Wed,7 \312\256\322\273\324\302 2001 23:47:22 +0800") }
726
- assert_raise(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=C5=DA),?= 10 2 2001 23:32:26 +0900 (JST)") }
727
- assert_raise(ArgumentError) { Time.rfc2822("\307\341\314\343\332\311, 30 \344\346\335\343\310\321 2001 10:01:06") }
728
- assert_raise(ArgumentError) { Time.rfc2822("=?iso-8859-1?Q?(=BF=E5),?= 12 =?iso-8859-1?Q?9=B7=EE?= 2001 14:52:41\n+0900 (JST)") }
729
- end
730
-
731
- def test_zone_0000
732
- assert_equal(true, Time.parse("2000-01-01T00:00:00Z").utc?)
733
- assert_equal(true, Time.parse("2000-01-01T00:00:00-00:00").utc?)
734
- assert_equal(false, Time.parse("2000-01-01T00:00:00+00:00").utc?)
735
- assert_equal(false, Time.parse("Sat, 01 Jan 2000 00:00:00 GMT").utc?)
736
- assert_equal(true, Time.parse("Sat, 01 Jan 2000 00:00:00 -0000").utc?)
737
- assert_equal(false, Time.parse("Sat, 01 Jan 2000 00:00:00 +0000").utc?)
738
- assert_equal(false, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 GMT").utc?)
739
- assert_equal(true, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 -0000").utc?)
740
- assert_equal(false, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 +0000").utc?)
741
- assert_equal(true, Time.rfc2822("Sat, 01 Jan 2000 00:00:00 UTC").utc?)
742
- end
743
-
744
- def test_parse_leap_second
745
- t = Time.utc(1998,12,31,23,59,59)
746
- assert_equal(t, Time.parse("Thu Dec 31 23:59:59 UTC 1998"))
747
- assert_equal(t, Time.parse("Fri Dec 31 23:59:59 -0000 1998"));t.localtime
748
- assert_equal(t, Time.parse("Fri Jan 1 08:59:59 +0900 1999"))
749
- assert_equal(t, Time.parse("Fri Jan 1 00:59:59 +0100 1999"))
750
- assert_equal(t, Time.parse("Fri Dec 31 23:59:59 +0000 1998"))
751
- assert_equal(t, Time.parse("Fri Dec 31 22:59:59 -0100 1998"));t.utc
752
- t += 1
753
- assert_equal(t, Time.parse("Thu Dec 31 23:59:60 UTC 1998"))
754
- assert_equal(t, Time.parse("Fri Dec 31 23:59:60 -0000 1998"));t.localtime
755
- assert_equal(t, Time.parse("Fri Jan 1 08:59:60 +0900 1999"))
756
- assert_equal(t, Time.parse("Fri Jan 1 00:59:60 +0100 1999"))
757
- assert_equal(t, Time.parse("Fri Dec 31 23:59:60 +0000 1998"))
758
- assert_equal(t, Time.parse("Fri Dec 31 22:59:60 -0100 1998"));t.utc
759
- t += 1 if t.sec == 60
760
- assert_equal(t, Time.parse("Thu Jan 1 00:00:00 UTC 1999"))
761
- assert_equal(t, Time.parse("Fri Jan 1 00:00:00 -0000 1999"));t.localtime
762
- assert_equal(t, Time.parse("Fri Jan 1 09:00:00 +0900 1999"))
763
- assert_equal(t, Time.parse("Fri Jan 1 01:00:00 +0100 1999"))
764
- assert_equal(t, Time.parse("Fri Jan 1 00:00:00 +0000 1999"))
765
- assert_equal(t, Time.parse("Fri Dec 31 23:00:00 -0100 1998"))
766
- end
767
-
768
- def test_rfc2822_leap_second
769
- t = Time.utc(1998,12,31,23,59,59)
770
- assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:59 UTC"))
771
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 -0000"));t.localtime
772
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:59 +0900"))
773
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:59 +0100"))
774
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 +0000"))
775
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:59 -0100"));t.utc
776
- t += 1
777
- assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:60 UTC"))
778
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 -0000"));t.localtime
779
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:60 +0900"))
780
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:60 +0100"))
781
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 +0000"))
782
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:60 -0100"));t.utc
783
- t += 1 if t.sec == 60
784
- assert_equal(t, Time.rfc2822("Thu, 1 Jan 1999 00:00:00 UTC"))
785
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 -0000"));t.localtime
786
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 09:00:00 +0900"))
787
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 01:00:00 +0100"))
788
- assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 +0000"))
789
- assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:00:00 -0100"))
790
- end
791
-
792
- def test_xmlschema_leap_second
793
- t = Time.utc(1998,12,31,23,59,59)
794
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:59Z"))
795
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:59-00:00"));t.localtime
796
- assert_equal(t, Time.xmlschema("1999-01-01T08:59:59+09:00"))
797
- assert_equal(t, Time.xmlschema("1999-01-01T00:59:59+01:00"))
798
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:59+00:00"))
799
- assert_equal(t, Time.xmlschema("1998-12-31T22:59:59-01:00"));t.utc
800
- t += 1
801
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:60Z"))
802
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:60-00:00"));t.localtime
803
- assert_equal(t, Time.xmlschema("1999-01-01T08:59:60+09:00"))
804
- assert_equal(t, Time.xmlschema("1999-01-01T00:59:60+01:00"))
805
- assert_equal(t, Time.xmlschema("1998-12-31T23:59:60+00:00"))
806
- assert_equal(t, Time.xmlschema("1998-12-31T22:59:60-01:00"));t.utc
807
- t += 1 if t.sec == 60
808
- assert_equal(t, Time.xmlschema("1999-01-01T00:00:00Z"))
809
- assert_equal(t, Time.xmlschema("1999-01-01T00:00:00-00:00"));t.localtime
810
- assert_equal(t, Time.xmlschema("1999-01-01T09:00:00+09:00"))
811
- assert_equal(t, Time.xmlschema("1999-01-01T01:00:00+01:00"))
812
- assert_equal(t, Time.xmlschema("1999-01-01T00:00:00+00:00"))
813
- assert_equal(t, Time.xmlschema("1998-12-31T23:00:00-01:00"))
814
- end
815
-
816
- def test_xmlschema_fraction
817
- assert_equal(500000, Time.xmlschema("2000-01-01T00:00:00.5+00:00").tv_usec)
818
- end
819
-
820
- def test_ruby_talk_152866
821
- t = Time::xmlschema('2005-08-30T22:48:00-07:00')
822
- assert_equal(31, t.day)
823
- assert_equal(8, t.mon)
824
- end
825
-
826
- def test_parse_fraction
827
- assert_equal(500000, Time.parse("2000-01-01T00:00:00.5+00:00").tv_usec)
828
- end
829
-
830
- def test_strptime
831
- assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z"))
832
- end
833
-
834
- def test_nsec
835
- assert_equal(123456789, Time.xmlschema("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
836
- assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
837
- end
838
- end
839
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhomobile Dev
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-23 00:00:00 -08:00
12
+ date: 2009-01-26 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -74,13 +74,13 @@ dependencies:
74
74
  version:
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: newgem
77
- type: :development
77
+ type: :runtime
78
78
  version_requirement:
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 1.2.3
83
+ version: "0"
84
84
  version:
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: hoe