Sha256: 43131bc9def6815785ae0fd23b44aafc05c8e75b08851580fd79e63136d6c037

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

class Jeweler
  module Gemspec
    # Generates a date for stuffing in the gemspec
    def date
      date = DateTime.now
      "#{date.year}-#{date.month}-#{date.day}"
    end


    # Writes out the gemspec
    def write_gemspec
      @gemspec.date = self.date
      File.open(gemspec_path, 'w') do |f|
        f.write @gemspec.to_ruby
      end
      puts "Generated #{gemspec_path}."
    end
    
    # Validates the gemspec in an environment similar to how GitHub would build
    # it. See http://gist.github.com/16215
    def validate_gemspec
      begin
        # Snippet borrowed from http://gist.github.com/16215
        data = File.read(gemspec_path)
      
        spec = nil
        if data !~ %r{!ruby/object:Gem::Specification}
          Thread.new { spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path) }.join
        else
          spec = YAML.load(data)
        end
        
        puts "#{gemspec_path} is valid."
      rescue Exception => e
        puts "#{gemspec_path} is invalid. See the backtrace for more details."
        raise
      end
    end
    
  protected
    def gemspec_path
      File.join(@base_dir, "#{@gemspec.name}.gemspec")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
technicalpickles-jeweler-0.0.7 lib/jeweler/gemspec.rb