Class: Diffend::LocalContext::Packages
- Inherits:
-
Object
- Object
- Diffend::LocalContext::Packages
- Defined in:
- lib/diffend/local_context/packages.rb
Overview
Module responsible for building packages information from local context
Constant Summary collapse
- ME_PATH =
Definition of a local path, if it matches it means that we are the source
'.'- ME_SOURCES =
Sources that we expect to match ourselves too
[ Bundler::Source::Gemspec, Bundler::Source::Path ].freeze
- DEPENDENCIES_TYPES =
List of dependency types
{ direct: 0, dependency: 1 }.freeze
- SOURCES_TYPES =
List of sources types
{ valid: 0, multiple_primary: 1 }.freeze
- GEM_SOURCES_TYPES =
List of gem sources types
{ local: 0, gemfile_source: 1, gemfile_git: 2, gemfile_path: 3 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#build_install ⇒ Hash
Build install specification.
-
#build_update ⇒ Hash
Build update specification.
-
#initialize(definition) ⇒ Hash
constructor
Local dependencies.
Constructor Details
#initialize(definition) ⇒ Hash
Returns local dependencies.
53 54 55 56 57 58 |
# File 'lib/diffend/local_context/packages.rb', line 53 def initialize(definition) @definition = definition @direct_dependencies = Hash[definition.dependencies.map { |val| [val.name, val] }] # Support case without Gemfile.lock @locked_specs = @definition.locked_gems ? @definition.locked_gems.specs : [] end |
Class Method Details
.call(command, definition) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/diffend/local_context/packages.rb', line 36 def call(command, definition) Bundler.ui.silence { definition.resolve_remotely! } instance = new(definition) case command when Commands::INSTALL, Commands::EXEC then instance.build_install when Commands::UPDATE then instance.build_update else raise ArgumentError, "invalid command: #{command}" end end |
Instance Method Details
#build_install ⇒ Hash
Build install specification
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/diffend/local_context/packages.rb', line 63 def build_install hash = build_main @definition.specs.each do |spec| next if skip?(spec.source) locked_spec = @locked_specs.find { |s| s.name == spec.name } hash['dependencies'][spec.name] = { 'platform' => build_spec_platform(spec, locked_spec), 'source' => build_spec_source(spec), 'type' => build_dependency_type(spec.name), 'versions' => build_versions(spec, locked_spec) } end hash end |
#build_update ⇒ Hash
Build update specification
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/diffend/local_context/packages.rb', line 85 def build_update hash = build_main @definition.specs.each do |spec| next if skip?(spec.source) locked_spec = @locked_specs.find { |s| s.name == spec.name } hash['dependencies'][spec.name] = { 'platform' => build_spec_platform(spec, locked_spec), 'source' => build_spec_source(spec), 'type' => build_dependency_type(spec.name), 'versions' => build_versions(spec, locked_spec) } end hash end |