Class: Gem::Tasks::Project Private
- Inherits:
-
Object
- Object
- Gem::Tasks::Project
- Defined in:
- lib/rubygems/tasks/project.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SCM_DIRS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Supported SCMs and their control directories.
{ git: '.git', hg: '.hg', svn: '.svn' }
- PKG_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The
pkg/directory. 'pkg'
Instance Attribute Summary collapse
-
#builds ⇒ Hash{String => Hash{String => String}}
readonly
private
The builds and their packages.
-
#gemspecs ⇒ Hash{String => Gem::Specification}
readonly
private
The builds and gemspecs of the project.
-
#name ⇒ String
readonly
private
The name of the project.
-
#primary_gemspec ⇒ String
readonly
private
The name of the primary gemspec.
-
#root ⇒ String
readonly
private
The project directory.
-
#scm ⇒ Symbol?
readonly
private
The SCM the project is using.
Class Method Summary collapse
-
.directories ⇒ Hash{String => Project}
private
Maps project directories to projects.
Instance Method Summary collapse
-
#bundler? ⇒ Boolean
private
Specifies whether the project uses Bundler.
-
#gemspec(name = nil) ⇒ Gem::Specification
private
Retrieves a gemspec for the project.
-
#initialize(root = Dir.pwd) ⇒ Project
constructor
private
Initializes the project.
Constructor Details
#initialize(root = Dir.pwd) ⇒ Project
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the project.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rubygems/tasks/project.rb', line 74 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 |
Instance Attribute Details
#builds ⇒ Hash{String => Hash{String => String}} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The builds and their packages.
58 59 60 |
# File 'lib/rubygems/tasks/project.rb', line 58 def builds @builds end |
#gemspecs ⇒ Hash{String => Gem::Specification} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The builds and gemspecs of the project.
50 51 52 |
# File 'lib/rubygems/tasks/project.rb', line 50 def gemspecs @gemspecs end |
#name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The name of the project.
36 37 38 |
# File 'lib/rubygems/tasks/project.rb', line 36 def name @name end |
#primary_gemspec ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The name of the primary gemspec.
66 67 68 |
# File 'lib/rubygems/tasks/project.rb', line 66 def primary_gemspec @primary_gemspec end |
#root ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The project directory.
28 29 30 |
# File 'lib/rubygems/tasks/project.rb', line 28 def root @root end |
#scm ⇒ Symbol? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The SCM the project is using.
42 43 44 |
# File 'lib/rubygems/tasks/project.rb', line 42 def scm @scm end |
Class Method Details
.directories ⇒ Hash{String => Project}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Maps project directories to projects.
130 131 132 133 134 |
# File 'lib/rubygems/tasks/project.rb', line 130 def self.directories @@directories ||= Hash.new do |hash,key| hash[key] = new(key) end end |
Instance Method Details
#bundler? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Specifies whether the project uses Bundler.
141 142 143 |
# File 'lib/rubygems/tasks/project.rb', line 141 def bundler? @bundler end |
#gemspec(name = nil) ⇒ Gem::Specification
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieves a gemspec for the project.
114 115 116 117 118 119 120 121 122 |
# File 'lib/rubygems/tasks/project.rb', line 114 def gemspec(name=nil) name ||= @primary_gemspec unless @gemspecs.has_key?(name) raise(ArgumentError,"unknown gemspec: #{name}") end return @gemspecs[name] end |