rubygems 标准库使用

Gem::Version

用于操作版本号

Gem::Version.correct?(str) #如果版本号的字符串满足ruby gems的要求 => true
Gem.bin_path("railties", "rails", str) #找到相应的gem的可执行文件目录
Gem.activate_bin_path('rack', 'rackup', '2.0.3') #找到相应版本的gem的可执行文件

default_spec 在Specification类中被初始化
register_default_spec
find_unresolved_default_spec
remove_unresolved_default_spec
clear_default_specs

Gem::Specification

包含gem信息的一个类,如下

Gem::Specification.new do |s|
  s.name        = 'example'
  s.version     = '0.1.0'
  s.licenses    = ['MIT']
  s.summary     = "This is an example!"
  s.description = "Much longer explanation of the example!"
  s.authors     = ["Ruby Coder"]
  s.email       = '[email protected]'
  s.files       = ["lib/example.rb"]
  s.homepage    = 'https://rubygems.org/gems/example'
  s.metadata    = { "source_code_uri" => "https://github.com/example/example" }
end

你可能感兴趣的:(rubygems 标准库使用)