Mon Nov 7 11:56:26 2011 UTC ()
Don't require 'yaml' unconditionaly but try to call Gem.load_yaml.
Avoid possible problem of ruby192-base with ruby-psych installed.


(taca)
diff -r1.2 -r1.3 pkgsrc/lang/ruby/files/update-gemspec.rb

cvs diff -r1.2 -r1.3 pkgsrc/lang/ruby/files/update-gemspec.rb (expand / switch to unified diff)

--- pkgsrc/lang/ruby/files/update-gemspec.rb 2011/09/13 03:18:29 1.2
+++ pkgsrc/lang/ruby/files/update-gemspec.rb 2011/11/07 11:56:25 1.3
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1#!/usr/pkg/bin/ruby 1#!/usr/pkg/bin/ruby
2# -*- coding: utf-8 -*- 2# -*- coding: utf-8 -*-
3# 3#
4# $NetBSD: update-gemspec.rb,v 1.2 2011/09/13 03:18:29 taca Exp $ 4# $NetBSD: update-gemspec.rb,v 1.3 2011/11/07 11:56:25 taca Exp $
5# 5#
6# Copyright (c) 2011 The NetBSD Foundation, Inc. 6# Copyright (c) 2011 The NetBSD Foundation, Inc.
7# All rights reserved. 7# All rights reserved.
8# 8#
9# This code is derived from software contributed to The NetBSD Foundation 9# This code is derived from software contributed to The NetBSD Foundation
10# by Takahiro Kambe. 10# by Takahiro Kambe.
11# 11#
12# Redistribution and use in source and binary forms, with or without 12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions 13# modification, are permitted provided that the following conditions
14# are met: 14# are met:
15# 15#
16# 1. Redistributions of source code must retain the above copyright 16# 1. Redistributions of source code must retain the above copyright
17# notice, this list of conditions and the following disclaimer. 17# notice, this list of conditions and the following disclaimer.
@@ -26,30 +26,36 @@ @@ -26,30 +26,36 @@
26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32# SUCH DAMAGE. 32# SUCH DAMAGE.
33# 33#
34 34
35# 35#
36# This is a quick and dirty tool which updates gemspec file: 36# This is a quick and dirty tool which updates gemspec file:
37# 37#
38require 'rubygems' 38require 'rubygems'
39require 'yaml' 
40require 'fileutils' 39require 'fileutils'
41require 'optparse' 40require 'optparse'
42 41
 42begin
 43 # Since newer rubygems load psych instead of syck, don't load yaml directly.
 44 Gem.load_yaml
 45rescue NoMethodError
 46 # Older rubygems don't have load_yaml() and don't know about psych.
 47end
 48
43class GemSpecUpdater 49class GemSpecUpdater
44 OrigSuffix = '.orig_gemspec' 50 OrigSuffix = '.orig_gemspec'
45 51
46 def initialize(file) 52 def initialize(file)
47 @file = file 53 @file = file
48 open(file) { |f| 54 open(file) { |f|
49 @spec = Gem::Specification.from_yaml(f) 55 @spec = Gem::Specification.from_yaml(f)
50 } 56 }
51 @requirements = {} 57 @requirements = {}
52 end 58 end
53 59
54 # 60 #
55 # rule should be: 61 # rule should be: