Class: ParallelInstaller::SpecInstallation

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/installer/parallel_installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ SpecInstallation

Returns a new instance of SpecInstallation.



9
10
11
12
13
# File 'lib/bundler/installer/parallel_installer.rb', line 9

def initialize(spec)
  @spec, @name = spec, spec.name
  @state = :none
  @post_install_message = ""
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/bundler/installer/parallel_installer.rb', line 8

def name
  @name
end

#post_install_messageObject

Returns the value of attribute post_install_message.



8
9
10
# File 'lib/bundler/installer/parallel_installer.rb', line 8

def post_install_message
  @post_install_message
end

#specObject

Returns the value of attribute spec.



8
9
10
# File 'lib/bundler/installer/parallel_installer.rb', line 8

def spec
  @spec
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/bundler/installer/parallel_installer.rb', line 8

def state
  @state
end

Instance Method Details

#all_dependenciesObject

Represents all dependencies



51
52
53
# File 'lib/bundler/installer/parallel_installer.rb', line 51

def all_dependencies
  @spec.dependencies
end

#dependenciesObject

Represents only the non-development dependencies and the ones that are itself.



46
47
48
# File 'lib/bundler/installer/parallel_installer.rb', line 46

def dependencies
  @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }
end

#dependencies_installed?(remaining_specs) ⇒ Boolean

Checks installed dependencies against spec’s dependencies to make sure needed dependencies have been installed.

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/bundler/installer/parallel_installer.rb', line 38

def dependencies_installed?(remaining_specs)
  installed_specs = remaining_specs.reject(&:installed?).map(&:name)
  already_installed = lambda {|dep| installed_specs.include? dep.name }
  dependencies.all? {|d| already_installed[d] }
end

#enqueued?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/bundler/installer/parallel_installer.rb', line 19

def enqueued?
  state == :enqueued
end

#has_post_install_message?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bundler/installer/parallel_installer.rb', line 28

def has_post_install_message?
  !post_install_message.empty?
end

#ignorable_dependency?(dep) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/bundler/installer/parallel_installer.rb', line 32

def ignorable_dependency?(dep)
  dep.type == :development || dep.name == @name
end

#installed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/bundler/installer/parallel_installer.rb', line 15

def installed?
  state == :installed
end

#ready_to_enqueue?Boolean

Only true when spec in neither installed nor already enqueued

Returns:

  • (Boolean)


24
25
26
# File 'lib/bundler/installer/parallel_installer.rb', line 24

def ready_to_enqueue?
  !installed? && !enqueued?
end