Class: Bundler::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.



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

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

Instance Attribute Details

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#post_install_messageObject

Returns the value of attribute post_install_message.



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

def post_install_message
  @post_install_message
end

#specObject

Returns the value of attribute spec.



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

def spec
  @spec
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#all_dependenciesObject

Represents all dependencies



68
69
70
# File 'lib/bundler/installer/parallel_installer.rb', line 68

def all_dependencies
  @spec.dependencies
end

#dependenciesObject

Represents only the non-development dependencies, the ones that are itself and are in the total list.



56
57
58
59
60
# File 'lib/bundler/installer/parallel_installer.rb', line 56

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

#dependencies_installed?(all_specs) ⇒ Boolean

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

Returns:

  • (Boolean)


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

def dependencies_installed?(all_specs)
  installed_specs = all_specs.select(&:installed?).map(&:name)
  dependencies.all? {|d| installed_specs.include? d.name }
end

#enqueued?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bundler/installer/parallel_installer.rb', line 22

def enqueued?
  state == :enqueued
end

#failed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bundler/installer/parallel_installer.rb', line 26

def failed?
  state == :failed
end

#has_post_install_message?Boolean

Returns:

  • (Boolean)


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

def has_post_install_message?
  !post_install_message.empty?
end

#ignorable_dependency?(dep) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/bundler/installer/parallel_installer.rb', line 43

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

#installation_attempted?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/bundler/installer/parallel_installer.rb', line 30

def installation_attempted?
  installed? || failed?
end

#installed?Boolean

Returns:

  • (Boolean)


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

def installed?
  state == :installed
end

#missing_lockfile_dependencies(all_spec_names) ⇒ Object



62
63
64
65
# File 'lib/bundler/installer/parallel_installer.rb', line 62

def missing_lockfile_dependencies(all_spec_names)
  deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
  deps.reject {|dep| all_spec_names.include? dep.name }
end

#ready_to_enqueue?Boolean

Only true when spec in neither installed nor already enqueued

Returns:

  • (Boolean)


35
36
37
# File 'lib/bundler/installer/parallel_installer.rb', line 35

def ready_to_enqueue?
  !enqueued? && !installation_attempted?
end

#to_sObject



72
73
74
# File 'lib/bundler/installer/parallel_installer.rb', line 72

def to_s
  "#<#{self.class} #{@spec.full_name} (#{state})>"
end