【问题标题】:invalid date format in specification when trying to build gem尝试构建 gem 时规范中的无效日期格式
【发布时间】:2011-12-07 04:19:24
【问题描述】:

我正在编写一个 gem,我想构建它:

$ gem build llrb.gemspec

gemspec 包含:

s.date = %q{2011-12-5}

但我收到此错误:

[llrb.gemspec] 中的无效 gemspec:规范中的无效日期格式:“2011-12-5”

gemspec 的正确日期格式是什么?我的 RubyGems 安装有问题吗?


我正在运行 RubyGems 1.8.12。使用 ruby​​ 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]。

【问题讨论】:

    标签: ruby build gem


    【解决方案1】:

    我认为它只是一个缺失的 0。(至少对于 ruby​​ 1.9.2 这将是解决方案)。

    require 'rubygems'
    
    spec = Gem::Specification.new do |s|
      s.name = 'example'
      s.version = '1.0'
      s.summary = 'Example gem specification'
      s.date = %q{2011-12-05}
    end
    
    p spec.date #2011-12-05 00:00:00 UTC
    

    或者尝试一下

      s.date = Date.new(2011,12,5)
    

    【讨论】:

      猜你喜欢
      • 2011-11-09
      • 2011-08-11
      • 1970-01-01
      • 2015-02-07
      • 2020-04-14
      • 1970-01-01
      • 2016-11-24
      • 2021-11-24
      • 1970-01-01
      相关资源
      最近更新 更多