Module: FlossFunding::Rakelib::GemSpecReader
- Defined in:
- lib/floss_funding/rakelib/gem_spec_reader.rb
Class Method Summary collapse
-
.read(library_root) ⇒ Hash
Reads gemspec data from the first *.gemspec in library_root using RubyGems API, and extracts fields of interest.
Class Method Details
.read(library_root) ⇒ Hash
Reads gemspec data from the first *.gemspec in library_root using
RubyGems API, and extracts fields of interest.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/floss_funding/rakelib/gem_spec_reader.rb', line 8 def read(library_root) gemspec_path = Dir.glob(File.join(library_root, "*.gemspec")).first return {} unless gemspec_path begin spec = Gem::Specification.load(gemspec_path) return {} unless spec puts "Loaded gemspec: #{spec}" if DEBUG = spec. || {} puts "metadata: #{.inspect}" if DEBUG extracted = { :library_name => spec.name, :homepage => spec.homepage, :authors => spec., :email => spec.email, } # Gemspec metadata is keyed exactly the gem author keyed it. # Thus, support both symbol and string keys. extracted[:funding_uri] = ["funding_uri"] extracted[:funding_uri] ||= [:funding_uri] puts "extracted: #{extracted.inspect}" if DEBUG extracted rescue StandardError => error warn("[floss_funding] Error reading gemspec in #{library_root}:\n #{error.class}:\n #{error.}") {} end end |