Class: EacRubyUtils::GemsRegistry::Gem
- Defined in:
- lib/eac_ruby_utils/gems_registry/gem.rb
Instance Attribute Summary collapse
-
#gemspec ⇒ Object
readonly
Returns the value of attribute gemspec.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #found? ⇒ Boolean
-
#initialize(registry, gemspec) ⇒ Gem
constructor
A new instance of Gem.
- #lib_file_found? ⇒ Boolean
- #path_to_require ⇒ String
- #registered_module ⇒ Object
Constructor Details
#initialize(registry, gemspec) ⇒ Gem
Returns a new instance of Gem.
10 11 12 13 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 10 def initialize(registry, gemspec) @registry = registry @gemspec = gemspec end |
Instance Attribute Details
#gemspec ⇒ Object (readonly)
Returns the value of attribute gemspec.
8 9 10 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 8 def gemspec @gemspec end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
8 9 10 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 8 def registry @registry end |
Instance Method Details
#found? ⇒ Boolean
15 16 17 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 15 def found? lib_file_found? && registered_module.is_a?(::Module) end |
#lib_file_found? ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 19 def lib_file_found? gemspec.require_paths.any? do |require_path| ::Pathname.new(require_path).(gemspec.gem_dir).join(path_to_require + '.rb') .file? end end |
#path_to_require ⇒ String
34 35 36 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 34 def path_to_require gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore end |
#registered_module ⇒ Object
26 27 28 29 30 31 |
# File 'lib/eac_ruby_utils/gems_registry/gem.rb', line 26 def registered_module return nil unless lib_file_found? require path_to_require path_to_require.classify.constantize end |