1

Rails 3のアップグレード(ruby 1.9.3)でrunt gemを使用していますが、nil:NilClass`に対して次のエラーが発生ますundefined method

これは、irb/pryでそれを複製する方法です。

> require 'runt'
=> true
> start_at = Runt::PDate.min(2009,1,1, 0, 0)
=> #<Runt::PDate: 2009-01-01T00:00:00+00:00 ((2454833j,0s,0n),+0s,2299161j)>
> end_at = Runt::PDate.min(2009,1,1, 1, 30)
=> #<Runt::PDate: 2009-01-01T01:30:00+00:00 ((2454833j,5400s,0n),+0s,2299161j)>
> runt_pattern = Runt::EveryTE.new(start_at, 600)
=> every 600 minutes starting Thu Jan  1 00:00:00 2009
> date_range = Runt::DateRange.new(start_at, end_at)
=> #<Runt::PDate: 2009-01-01T00:00:00+00:00 ((2454833j,0s,0n),+0s,2299161j)>
..
#<Runt::PDate: 2009-01-01T01:30:00+00:00 ((2454833j,5400s,0n),+0s,2299161j)>
> schedule = Runt::Schedule.new
=> #<Runt::Schedule:0x007fd46cad56b8 @elems={}>
> schedule.add 'events', runt_pattern
=> every 600 minutes starting Thu Jan  1 00:00:00 2009
> schedule.dates('events', date_range)
NoMethodError: undefined method `precision' for nil:NilClass
from /Users/ttt/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/runt-0.7.0/lib/runt/dprecision.rb:121:in `<=>'

誰かがこれについて何か知っていますか?

https://github.com/texel/runt/blob/master/lib/runt/schedule.rb#L28の行によってトリガーされているようですが、それでもコードをさらに掘り下げる方法を見つけようとしています。

https://github.com/craigw/runtなど、さらに更新されたラントバージョンがあることに気づきましたが、それらも問題を修正していないようです。

ree-1.8.7-2011.03のrails2で動作し、を返します[Thu, 01 Jan 2009 00:00:00 +0000]

編集:rails2が返すものを追加しました。

4

1 に答える 1

0

あなたの問題はEveryTE クラスにあるようです。初期化メソッドには、オプションの精度パラメーターがあります。

class EveryTE

  include TExpr

  def initialize(start,n,precision=nil)
    @start=start
    @interval=n
    # Use the precision of the start date by default
    @precision=precision || @start.date_precision
  end

  def include?(date)
    i=DPrecision.to_p(@start,@precision)
    d=DPrecision.to_p(date,@precision)
    while i<=d
      return true if i.eql?(d)
      i=i+@interval
    end
    false
  end

  def to_s
    "every #{@interval} #{@precision.label.downcase}s starting #{Runt.format_date(@start)}"
  end

end

デフォルトの nil を受け入れるのではなく、精度を提供しようとします。

> runt_pattern = Runt::EveryTE.new(start_at, 600,Runt::DPrecision::Precision.sec)

精度の完全なリストは次のとおりです ( DPrecision クラス内):

Precision.year
Precision.month
Precision.week
Precision.day
Precision.hour
Precision.min
Precision.sec
Precision.millisec
于 2013-02-14T01:48:22.627 に答える