lib/diffend/local_context/packages.rb in diffend-monitor-0.2.35 vs lib/diffend/local_context/packages.rb in diffend-monitor-0.2.36
- old
+ new
@@ -32,33 +32,41 @@
class << self
# @param command [String] command executed via bundler
# @param definition [Bundler::Definition] definition for your source
def call(command, definition)
- Bundler.ui.silence { definition.resolve_remotely! }
+ instance = new(command, definition)
- instance = new(definition)
+ Bundler.ui.silence { instance.resolve }
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
end
+ # @param command [String] command executed via bundler
# @param definition [Bundler::Definition] definition for your source
#
# @return [Hash] local dependencies
- def initialize(definition)
+ 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
+ # Resolve definition
+ def resolve
+ @cached ? @definition.resolve_with_cache! : @definition.resolve_remotely!
+ end
+
# Build install specification
#
# @return [Hash]
def build_install
hash = build_main
@@ -207,15 +215,10 @@
def source_for_spec(spec)
return spec.remote if spec.remote
case spec.source
when Bundler::Source::Rubygems
- spec
- .source
- .send(:remote_specs)
- .search(Bundler::Dependency.new(spec.name, spec.version))
- .last
- .remote
+ Bundler::Source::Rubygems::Remote.new(spec.source.remotes.last)
when Bundler::Source::Metadata, Bundler::Source::Git, Bundler::Source::Path
spec.source
else
raise ArgumentError, "unknown source #{spec.source.class}"
end