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 ⇒ Hash
Build specification.
-
#initialize(command, definition) ⇒ Hash
constructor
Local dependencies.
-
#resolve ⇒ Object
Resolve definition.
Constructor Details
#initialize(command, definition) ⇒ Hash
Returns local dependencies.
53 54 55 56 57 58 59 60 |
# File 'lib/diffend/local_context/packages.rb', line 53 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 |
# 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, Commands::UPDATE, Commands::ADD then instance.build else raise ArgumentError, "invalid command: #{command}" end end |
Instance Method Details
#build ⇒ Hash
Build specification
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/diffend/local_context/packages.rb', line 74 def build hash = build_main @definition.resolve.each do |spec| # Skip metadata next if spec.instance_variable_get(:@specification).nil? 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
63 64 65 66 67 68 69 |
# File 'lib/diffend/local_context/packages.rb', line 63 def resolve @cached ? @definition.resolve_with_cache! : @definition.resolve_remotely! # Despite bundler not materializing resolution, we always need to do so to get all the # gems details @definition.specs end |