class Gem::Tasks::Project
@api semipublic
Constants
- PKG_DIR
The `pkg/` directory.
- SCM_DIRS
Supported SCMs and their control directories.
Attributes
builds[R]
The builds and their packages.
@return [Hash{String => Hash{String => String}}]
The hash of builds and their respective packages.
gemspecs[R]
The builds and gemspecs of the project.
@return [Hash{String => Gem::Specification}]
The hash of builds and their gemspecs.
name[R]
The name of the project.
@return [String]
The project name.
primary_gemspec[R]
The name of the primary gemspec.
@return [String]
The gemspec name.
root[R]
The project directory.
@return [String]
The path to the project.
scm[R]
@return [Symbol, nil]
The SCM the project is using.
Public Class Methods
directories()
click to toggle source
Maps project directories to projects.
@return [Hash{String => Project}]
Project directories and project objects.
# File lib/rubygems/tasks/project.rb, line 128 def self.directories @@directories ||= Hash.new do |hash,key| hash[key] = new(key) end end
new(root=Dir.pwd)
click to toggle source
Initializes the project.
@param [String] root
The root directory of the project.
# File lib/rubygems/tasks/project.rb, line 72 def initialize(root=Dir.pwd) @root = root @name = File.basename(@root) @scm, _ = SCM_DIRS.find do |scm,dir| File.directory?(File.join(@root,dir)) end Dir.chdir(@root) do @gemspecs = Hash[Dir['*.gemspec'].map { |path| [File.basename(path,'.gemspec'), Specification.load(path)] }] end @primary_gemspec = if @gemspecs.has_key?(@name) @name else @gemspecs.keys.sort.first end @builds = {} @gemspecs.each do |name,gemspec| @builds[name] = Hash.new do |packages,format| packages[format] = File.join(PKG_DIR,"#{gemspec.full_name}.#{format}") end end @bundler = File.file?(File.join(@root,'Gemfile')) end
Public Instance Methods
bundler?()
click to toggle source
Specifies whether the project uses Bundler.
@return [Boolean]
# File lib/rubygems/tasks/project.rb, line 139 def bundler? @bundler end
gemspec(name=nil)
click to toggle source
Retrieves a gemspec for the project.
@param [String] name (@primary_gemspec)
The gemspec name to retrieve.
@return [Gem::Specification]
The requested gemspec.
# File lib/rubygems/tasks/project.rb, line 112 def gemspec(name=nil) name ||= @primary_gemspec unless @gemspecs.has_key?(name) raise(ArgumentError,"unknown gemspec: #{name}") end return @gemspecs[name] end