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(command, definition) ⇒ Hash
constructor
Local dependencies.
-
#resolve ⇒ Object
Resolve definition.
Constructor Details
#initialize(command, definition) ⇒ Hash
Returns local dependencies.
54 55 56 57 58 59 60 61 |
# File 'lib/diffend/local_context/packages.rb', line 54 def initialize(command, definition) @command = command @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 : [] @cached = command == Commands::EXEC 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) instance = new(command, definition) ::Bundler.ui.silence { instance.resolve } case command when Commands::INSTALL, Commands::EXEC, Commands::SECURE 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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/diffend/local_context/packages.rb', line 71 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
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/diffend/local_context/packages.rb', line 93 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 |
#resolve ⇒ Object
Resolve definition
64 65 66 |
# File 'lib/diffend/local_context/packages.rb', line 64 def resolve @cached ? @definition.resolve_with_cache! : @definition.resolve_remotely! end |