Class: Source::Gem
Defined Under Namespace
Classes: Factory, FilesFromGemProvider
Constant Summary
Constants inherited
from Base
Base::DEFAULTS
Instance Attribute Summary collapse
Attributes inherited from Base
#files_provider
#options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
constant_field, #contains_file?, #file_contents, #files, #maintainer
included
Constructor Details
#initialize(metadata, files_provider = nil, options = {}) ⇒ Gem
Returns a new instance of Gem.
87
88
89
90
|
# File 'lib/gpm/source/gem.rb', line 87
def initialize(metadata, files_provider = nil, options = {})
@metadata = metadata
super(files_provider, options)
end
|
Instance Attribute Details
Returns the value of attribute metadata.
86
87
88
|
# File 'lib/gpm/source/gem.rb', line 86
def metadata
@metadata
end
|
Class Method Details
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/gpm/source/gem.rb', line 34
def self.read_metadata(gem_file)
metadata = nil
Dir.chdir(File.dirname(gem_file)) do
if gem_file.end_with?('.gem')
contents = nil
File.open(gem_file, 'r') do |f|
::Gem::Package.open(f, 'r') do |gem|
metadata = gem.metadata
end
end
elsif gem_file.end_with?('.gemspec')
metadata = ::Gem::Specification.load(gem_file)
else
raise "Unknown file type of #{gem_file}. Need a .gem or .gemspec file"
end
end
raise "Could not read metadata for #{gem_file.inspect}" unless metadata
metadata
end
|
Instance Method Details
#architecture ⇒ Object
119
120
121
122
123
124
125
126
|
# File 'lib/gpm/source/gem.rb', line 119
def architecture
if !metadata.extensions.empty?
"native"
else
"all"
end
end
|
#dependencies ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/gpm/source/gem.rb', line 128
def dependencies
dependencies = []
metadata.runtime_dependencies.map do |dep|
if dep.respond_to?(:requirement)
reqs = dep.requirement.to_s.gsub(/,/, '')
else
reqs = dep.version_requirements
end
reqs.to_s.split(/, */).each do |req|
dependencies << "#{name(dep)} #{req}"
end
end
return dependencies + ["libc6", "ruby"]
end
|
113
114
115
116
|
# File 'lib/gpm/source/gem.rb', line 113
def email
result = metadata.email
return result.kind_of?(Array) ? result.first : result
end
|
#name(name_provider = nil) ⇒ Object
104
105
106
107
|
# File 'lib/gpm/source/gem.rb', line 104
def name(name_provider=nil)
name_provider ||= metadata
"rubygem-#{name_provider.name}"
end
|