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

Instance Method Details

#gem_nameObject



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_gemspecObject



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_pathObject



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_partsObject



23
24
25
# File 'lib/avm/eac_ruby_base1/sources/base/rubygems.rb', line 23

def gem_namespace_parts
  gem_name.split('-')
end

#gemspecGem::Specification

Returns:

  • (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_pathPathname

Returns:

  • (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_directoryPathname

Returns:

  • (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_filePathname

Returns:

  • (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