晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/source/ |
| Current File : //opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/source/git.rb |
require 'digest'
require 'rubygems/util'
##
# A git gem for use in a gem dependencies file.
#
# Example:
#
# source =
# Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false
#
# source.specs
class Gem::Source::Git < Gem::Source
##
# The name of the gem created by this git gem.
attr_reader :name
##
# The commit reference used for checking out this git gem.
attr_reader :reference
##
# When false the cache for this repository will not be updated.
attr_accessor :remote
##
# The git repository this gem is sourced from.
attr_reader :repository
##
# The directory for cache and git gem installation
attr_accessor :root_dir
##
# Does this repository need submodules checked out too?
attr_reader :need_submodules
##
# Creates a new git gem source for a gems from loaded from +repository+ at
# the given +reference+. The +name+ is only used to track the repository
# back to a gem dependencies file, it has no real significance as a git
# repository may contain multiple gems. If +submodules+ is true, submodules
# will be checked out when the gem is installed.
def initialize name, repository, reference, submodules = false
super(nil)
@name = name
@repository = repository
@reference = reference
@need_submodules = submodules
@remote = true
@root_dir = Gem.dir
@git = ENV['git'] || 'git'
end
def <=> other
case other
when Gem::Source::Git then
0
when Gem::Source::Installed,
Gem::Source::Lock then
-1
when Gem::Source then
1
else
nil
end
end
def == other # :nodoc:
super and
@name == other.name and
@repository == other.repository and
@reference == other.reference and
@need_submodules == other.need_submodules
end
##
# Checks out the files for the repository into the install_dir.
def checkout # :nodoc:
cache
return false unless File.exist? repo_cache_dir
unless File.exist? install_dir then
system @git, 'clone', '--quiet', '--no-checkout',
repo_cache_dir, install_dir
end
Dir.chdir install_dir do
system @git, 'fetch', '--quiet', '--force', '--tags', install_dir
success = system @git, 'reset', '--quiet', '--hard', @reference
success &&=
Gem::Util.silent_system @git, 'submodule', 'update',
'--quiet', '--init', '--recursive' if @need_submodules
success
end
end
##
# Creates a local cache repository for the git gem.
def cache # :nodoc:
return unless @remote
if File.exist? repo_cache_dir then
Dir.chdir repo_cache_dir do
system @git, 'fetch', '--quiet', '--force', '--tags',
@repository, 'refs/heads/*:refs/heads/*'
end
else
system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',
@repository, repo_cache_dir
end
end
##
# Directory where git gems get unpacked and so-forth.
def base_dir # :nodoc:
File.join @root_dir, 'bundler'
end
##
# A short reference for use in git gem directories
def dir_shortref # :nodoc:
rev_parse[0..11]
end
##
# Nothing to download for git gems
def download full_spec, path # :nodoc:
end
##
# The directory where the git gem will be installed.
def install_dir # :nodoc:
return unless File.exist? repo_cache_dir
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
end
def pretty_print q # :nodoc:
q.group 2, '[Git: ', ']' do
q.breakable
q.text @repository
q.breakable
q.text @reference
end
end
##
# The directory where the git gem's repository will be cached.
def repo_cache_dir # :nodoc:
File.join @root_dir, 'cache', 'bundler', 'git', "#{@name}-#{uri_hash}"
end
##
# Converts the git reference for the repository into a commit hash.
def rev_parse # :nodoc:
Dir.chdir repo_cache_dir do
Gem::Util.popen(@git, 'rev-parse', @reference).strip
end
end
##
# Loads all gemspecs in the repository
def specs
checkout
return [] unless install_dir
Dir.chdir install_dir do
Dir['{,*,*/*}.gemspec'].map do |spec_file|
directory = File.dirname spec_file
file = File.basename spec_file
Dir.chdir directory do
spec = Gem::Specification.load file
if spec then
spec.base_dir = base_dir
spec.extension_dir =
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version, "#{name}-#{dir_shortref}"
spec.full_gem_path = File.dirname spec.loaded_from if spec
end
spec
end
end.compact
end
end
##
# A hash for the git gem based on the git repository URI.
def uri_hash # :nodoc:
normalized =
if @repository =~ %r%^\w+://(\w+@)?% then
uri = URI(@repository).normalize.to_s.sub %r%/$%,''
uri.sub(/\A(\w+)/) { $1.downcase }
else
@repository
end
Digest::SHA1.hexdigest normalized
end
end
|