Module: Avm::EacRubyBase1::Sources::Base::Rubygems
- Defined in:
- lib/avm/eac_ruby_base1/sources/base/rubygems.rb
Constant Summary collapse
- GEMSPEC_EXTNAME =
'.gemspec'
Instance Method Summary collapse
- #gem_name ⇒ Object
- #gem_name_by_gemspec ⇒ Object
- #gem_name_by_path ⇒ Object
- #gem_namespace_parts ⇒ Object
- #gemspec ⇒ Gem::Specification
- #gemspec_path ⇒ Pathname
- #root_module_directory ⇒ Pathname
- #root_module_file ⇒ Pathname
Instance Method Details
#gem_name ⇒ Object
10 11 12 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 10 def gem_name gem_name_by_gemspec || gem_name_by_path end |
#gem_name_by_gemspec ⇒ Object
14 15 16 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 14 def gem_name_by_gemspec gemspec_path.if_present { |v| v.basename(GEMSPEC_EXTNAME).to_path } end |
#gem_name_by_path ⇒ Object
18 19 20 21 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 18 def gem_name_by_path fullname = path.basename.to_s /\A(.+)(?:-\d+(?:\.\d+)*)\z/.if_match(fullname, false) { |m| m[1] }.if_present(fullname) end |
#gem_namespace_parts ⇒ Object
23 24 25 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 23 def gem_namespace_parts gem_name.split('-') end |
#gemspec ⇒ Gem::Specification
28 29 30 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 28 def gemspec ::Gem::Specification.load(gemspec_path.to_path) end |
#gemspec_path ⇒ Pathname
33 34 35 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 33 def gemspec_path path.glob("*#{GEMSPEC_EXTNAME}").first end |
#root_module_directory ⇒ Pathname
38 39 40 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 38 def root_module_directory path.join('lib', *gem_namespace_parts) end |
#root_module_file ⇒ Pathname
43 44 45 |
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 43 def root_module_file root_module_directory.dirname.join("#{root_module_directory.basename}.rb") end |