| @@ -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 | # |
38 | require 'rubygems' | | 38 | require 'rubygems' |
39 | require 'yaml' | | | |
40 | require 'fileutils' | | 39 | require 'fileutils' |
41 | require 'optparse' | | 40 | require 'optparse' |
42 | | | 41 | |
| | | 42 | begin |
| | | 43 | # Since newer rubygems load psych instead of syck, don't load yaml directly. |
| | | 44 | Gem.load_yaml |
| | | 45 | rescue NoMethodError |
| | | 46 | # Older rubygems don't have load_yaml() and don't know about psych. |
| | | 47 | end |
| | | 48 | |
43 | class GemSpecUpdater | | 49 | class 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: |