晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby26/lib64/ruby/2.6.0/bundler/ |
| Current File : //opt/alt/ruby26/lib64/ruby/2.6.0/bundler/ruby_version.rb |
# frozen_string_literal: true
module Bundler
class RubyVersion
attr_reader :versions,
:patchlevel,
:engine,
:engine_versions,
:gem_version,
:engine_gem_version
def initialize(versions, patchlevel, engine, engine_version)
# The parameters to this method must satisfy the
# following constraints, which are verified in
# the DSL:
#
# * If an engine is specified, an engine version
# must also be specified
# * If an engine version is specified, an engine
# must also be specified
# * If the engine is "ruby", the engine version
# must not be specified, or the engine version
# specified must match the version.
@versions = Array(versions).map do |v|
op, v = Gem::Requirement.parse(v)
op == "=" ? v.to_s : "#{op} #{v}"
end
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
@input_engine = engine && engine.to_s
@engine = engine && engine.to_s || "ruby"
@engine_versions = (engine_version && Array(engine_version)) || @versions
@engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
@patchlevel = patchlevel
end
def to_s(versions = self.versions)
output = String.new("ruby #{versions_string(versions)}")
output << "p#{patchlevel}" if patchlevel
output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
output
end
# @private
PATTERN = /
ruby\s
([\d.]+) # ruby version
(?:p(-?\d+))? # optional patchlevel
(?:\s\((\S+)\s(.+)\))? # optional engine info
/xo
# Returns a RubyVersion from the given string.
# @param [String] the version string to match.
# @return [RubyVersion,Nil] The version if the string is a valid RubyVersion
# description, and nil otherwise.
def self.from_string(string)
new($1, $2, $3, $4) if string =~ PATTERN
end
def single_version_string
to_s(gem_version)
end
def ==(other)
versions == other.versions &&
engine == other.engine &&
engine_versions == other.engine_versions &&
patchlevel == other.patchlevel
end
def host
@host ||= [
RbConfig::CONFIG["host_cpu"],
RbConfig::CONFIG["host_vendor"],
RbConfig::CONFIG["host_os"]
].join("-")
end
# Returns a tuple of these things:
# [diff, this, other]
# The priority of attributes are
# 1. engine
# 2. ruby_version
# 3. engine_version
def diff(other)
raise ArgumentError, "Can only diff with a RubyVersion, not a #{other.class}" unless other.is_a?(RubyVersion)
if engine != other.engine && @input_engine
[:engine, engine, other.engine]
elsif versions.empty? || !matches?(versions, other.gem_version)
[:version, versions_string(versions), versions_string(other.versions)]
elsif @input_engine && !matches?(engine_versions, other.engine_gem_version)
[:engine_version, versions_string(engine_versions), versions_string(other.engine_versions)]
elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
[:patchlevel, patchlevel, other.patchlevel]
end
end
def versions_string(versions)
Array(versions).join(", ")
end
def self.system
ruby_engine = if defined?(RUBY_ENGINE) && !RUBY_ENGINE.nil?
RUBY_ENGINE.dup
else
# not defined in ruby 1.8.7
"ruby"
end
# :sob: mocking RUBY_VERSION breaks stuff on 1.8.7
ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
ruby_engine_version = case ruby_engine
when "ruby"
ruby_version
when "rbx"
Rubinius::VERSION.dup
when "jruby"
JRUBY_VERSION.dup
else
RUBY_ENGINE_VERSION.dup
end
patchlevel = RUBY_PATCHLEVEL.to_s
@ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
end
def to_gem_version_with_patchlevel
@gem_version_with_patch ||= begin
Gem::Version.create("#{@gem_version}.#{@patchlevel}")
rescue ArgumentError
@gem_version
end
end
def exact?
return @exact if defined?(@exact)
@exact = versions.all? {|v| Gem::Requirement.create(v).exact? }
end
private
def matches?(requirements, version)
# Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
Array(requirements).all? do |requirement|
Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.create(version))
end
end
end
end
|