1 Star 0 Fork 5

zhangwenlong01/ruby

forked from OpenCloudOS Stream/ruby 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rubygems.con 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
nilusyi 提交于 2023-03-09 15:19 . OCS package init
#!/usr/bin/ruby
require 'rubygems/package'
module RubyGemsReq
module Helpers
# Keep only '!=' requirements.
def self.conflicts(requirements)
conflicts = requirements.select {|r| r.first == '!='}
end
# Converts Gem::Requirement into array of requirements strings compatible
# with RPM .spec file.
def self.requirement_versions_to_rpm(requirement)
self.conflicts(requirement.requirements).map do |op, version|
version == Gem::Version.new(0) ? "" : "= #{version}"
end
end
end
# Report conflicting gem dependencies including their version.
def self.gem_depenencies(specification)
specification.runtime_dependencies.each do |dependency|
conflict_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement|
requirement_string = "rubygem(#{dependency.name}) #{requirement}"
end
if conflict_strings.length > 0
conflict_string = conflict_strings.join(' with ')
conflict_string.prepend('(').concat(')') if conflict_strings.length > 1
puts conflict_string
end
end
end
# Reports all conflicts specified by all provided .gemspec files.
def self.conflicts
while filename = gets
filename.strip!
begin
specification = Gem::Specification.load filename
gem_depenencies(specification)
rescue => e
# Ignore all errors.
end
end
end
end
if __FILE__ == $0
RubyGemsReq::conflicts
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangwenlong01/ruby.git
git@gitee.com:zhangwenlong01/ruby.git
zhangwenlong01
ruby
ruby
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385