summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authortaca <taca@pkgsrc.org>2011-09-13 03:18:29 +0000
committertaca <taca@pkgsrc.org>2011-09-13 03:18:29 +0000
commit12503762af8ef248cb3c62283feab4d3e1d231bb (patch)
tree8d755f317ba0ef2b2330d7c4ac6d3b99d470186b /lang
parent516e32431b632c63b020cd1a842034c5df233b72 (diff)
downloadpkgsrc-12503762af8ef248cb3c62283feab4d3e1d231bb.tar.gz
* Remove unused codes.
* Add support for deleting dependency to a ruby gem.
Diffstat (limited to 'lang')
-rw-r--r--lang/ruby/files/update-gemspec.rb45
1 files changed, 24 insertions, 21 deletions
diff --git a/lang/ruby/files/update-gemspec.rb b/lang/ruby/files/update-gemspec.rb
index 73886faf9d2..77256a9ee85 100644
--- a/lang/ruby/files/update-gemspec.rb
+++ b/lang/ruby/files/update-gemspec.rb
@@ -1,7 +1,7 @@
#!/usr/pkg/bin/ruby
# -*- coding: utf-8 -*-
#
-# $NetBSD: update-gemspec.rb,v 1.1 2011/08/12 14:35:34 taca Exp $
+# $NetBSD: update-gemspec.rb,v 1.2 2011/09/13 03:18:29 taca Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -40,18 +40,6 @@ require 'yaml'
require 'fileutils'
require 'optparse'
-class Gem::Specification
- def get_dependencies
- return @dependencies
- end
-end
-
-class Gem::Requirement
- def get_requirement
- return @requirement
- end
-end
-
class GemSpecUpdater
OrigSuffix = '.orig_gemspec'
@@ -71,26 +59,36 @@ class GemSpecUpdater
def parse_rules(rules)
rules.each do |s|
s.split.each do |dep|
- names = op = ver = nil
+ method = names = op = ver = nil
if /([a-z0-9_:-]+)([=!><\~][=>]*)(.*)/ =~ dep
names = $1
op = $2
ver = $3
+ r = Gem::Version.new ver
+ name, new_name = names.split(/:/, 2)
+ @requirements[name] = {
+ :method => :update,
+ :op => op,
+ :version => r,
+ :name => new_name
+ }
+ elsif /([a-z0-9_-]+):$/ =~ dep
+ name = $1
+ @requirements[name] = {
+ :method => :delete,
+ }
end
- r = Gem::Version.new ver
- name, new_name = names.split(/:/, 2)
- @requirements[name] = { :op => op, :version => r, :name => new_name }
end
end
end
def modify
- dependencies = @spec.runtime_dependencies
+ dependencies = @spec.instance_variable_get(:@dependencies)
dependencies.each do |dep|
- name = dep.name
- update = @requirements[name]
- unless update.nil?
+ next if dep.type != :runtime
+ update = @requirements[dep.name]
+ if not update.nil? and update[:method] == :update
r = dep.requirement.requirements
r[0][0] = update[:op]
r[0][1] = update[:version]
@@ -99,6 +97,11 @@ class GemSpecUpdater
end
end
end
+ dependencies.delete_if { |dep|
+ next if dep.type != :runtime
+ update = @requirements[dep.name]
+ not update.nil? and update[:method] == :delete
+ }
end
def update