Class: Gem::Tasks::Project
- Inherits:
-
Object
- Object
- Gem::Tasks::Project
- Defined in:
- lib/rubygems/tasks/project.rb
Constant Summary collapse
- SCM_DIRS =
Supported SCMs and their control directories.
{ git: '.git', hg: '.hg', svn: '.svn' }
- PKG_DIR =
The
pkg/
directory. 'pkg'
Instance Attribute Summary collapse
-
#builds ⇒ Hash{String => Hash{String => String}}
readonly
The builds and their packages.
-
#gemspecs ⇒ Hash{String => Gem::Specification}
readonly
The builds and gemspecs of the project.
-
#name ⇒ String
readonly
The name of the project.
-
#primary_gemspec ⇒ String
readonly
The name of the primary gemspec.
-
#root ⇒ String
readonly
The project directory.
-
#scm ⇒ Symbol?
readonly
The SCM the project is using.
Class Method Summary collapse
-
.directories ⇒ Hash{String => Project}
Maps project directories to projects.
Instance Method Summary collapse
-
#bundler? ⇒ Boolean
Specifies whether the project uses Bundler.
-
#gemspec(name = nil) ⇒ Gem::Specification
Retrieves a gemspec for the project.
-
#initialize(root = Dir.pwd) ⇒ Project
constructor
Initializes the project.
Constructor Details
#initialize(root = Dir.pwd) ⇒ Project
Initializes the project.
72 73 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 |
# 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 |
Instance Attribute Details
#builds ⇒ Hash{String => Hash{String => String}} (readonly)
The builds and their packages.
56 57 58 |
# File 'lib/rubygems/tasks/project.rb', line 56 def builds @builds end |
#gemspecs ⇒ Hash{String => Gem::Specification} (readonly)
The builds and gemspecs of the project.
48 49 50 |
# File 'lib/rubygems/tasks/project.rb', line 48 def gemspecs @gemspecs end |
#name ⇒ String (readonly)
The name of the project.
34 35 36 |
# File 'lib/rubygems/tasks/project.rb', line 34 def name @name end |
#primary_gemspec ⇒ String (readonly)
The name of the primary gemspec.
64 65 66 |
# File 'lib/rubygems/tasks/project.rb', line 64 def primary_gemspec @primary_gemspec end |
#root ⇒ String (readonly)
The project directory.
26 27 28 |
# File 'lib/rubygems/tasks/project.rb', line 26 def root @root end |
#scm ⇒ Symbol? (readonly)
Returns The SCM the project is using.
40 41 42 |
# File 'lib/rubygems/tasks/project.rb', line 40 def scm @scm end |
Class Method Details
.directories ⇒ Hash{String => Project}
Maps project directories to projects.
128 129 130 131 132 |
# File 'lib/rubygems/tasks/project.rb', line 128 def self.directories @@directories ||= Hash.new do |hash,key| hash[key] = new(key) end end |
Instance Method Details
#bundler? ⇒ Boolean
Specifies whether the project uses Bundler.
139 140 141 |
# File 'lib/rubygems/tasks/project.rb', line 139 def bundler? @bundler end |
#gemspec(name = nil) ⇒ Gem::Specification
Retrieves a gemspec for the project.
112 113 114 115 116 117 118 119 120 |
# 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 |