Class: Solidus::InstallGenerator::BundlerContext Private

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/solidus/install/install_generator/bundler_context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Bundler context during the install process.

This class gives access to information about the bundler context in which the install generator is run. I.e., which solidus components are present in the user's Gemfile. It also allows modifying the Gemfile to add or remove gems.

Defined Under Namespace

Classes: InjectorWithPathSupport

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBundlerContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of BundlerContext.


51
52
53
54
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 51

def initialize
  @dependencies = Bundler.locked_gems.dependencies
  @injector = InjectorWithPathSupport
end

Instance Attribute Details

#dependenciesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


45
46
47
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 45

def dependencies
  @dependencies
end

#injectorObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


45
46
47
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 45

def injector
  @injector
end

Class Method Details

.bundle_cleanly(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


47
48
49
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 47

def self.bundle_cleanly(&block)
  Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&block) : Bundler.with_clean_env(&block)
end

Instance Method Details

#break_down_components(components) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


64
65
66
67
68
69
70
71
72
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 64

def break_down_components(components)
  raise <<~MSG  unless solidus_in_gemfile?
    solidus meta gem needs to be present in the Gemfile to build the component dependency
  MSG

  @injector.inject(
    components.map { |component| dependency_for_component(component) }
  )
end

#component_in_gemfile?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

60
61
62
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 60

def component_in_gemfile?(name)
  !@dependencies["solidus_#{name}"].nil?
end

#remove(*args, **kwargs, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


74
75
76
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 74

def remove(*args, **kwargs, &block)
  @injector.remove(*args, **kwargs, &block)
end

#solidus_in_gemfile?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

56
57
58
# File 'lib/generators/solidus/install/install_generator/bundler_context.rb', line 56

def solidus_in_gemfile?
  !solidus_dependency.nil?
end