bundler-fastupdate 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/bundle +6 -0
- data/bundler-fastupdate.gemspec +24 -0
- data/lib/.bundler_fastupdate.rb.swp +0 -0
- data/lib/bundler/fast_updater.rb +80 -0
- data/lib/bundler-fastupdate/version.rb +5 -0
- data/lib/bundler-fastupdate.rb +7 -0
- data/lib/bundler_fastupdate.rb +22 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/bundle
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "bundler-fastupdate/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bundler-fastupdate"
|
7
|
+
s.version = Bundler::Fastupdate::VERSION
|
8
|
+
s.authors = ["David McCullars"]
|
9
|
+
s.email = ["dmccullars@ePublishing.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Provide a significantly faster update under certain circumstances}
|
12
|
+
s.description = %q{Provide a significantly faster update under certain circumstances}
|
13
|
+
|
14
|
+
s.rubyforge_project = "bundler-fastupdate"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_runtime_dependency "bundler", "~> 1.0.17"
|
24
|
+
end
|
Binary file
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'bundler/environment'
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class FastUpdater < Environment
|
5
|
+
|
6
|
+
def initialize(root, definition, name, options={})
|
7
|
+
super(root, definition)
|
8
|
+
@name = name or raise CanNotFastUpdate.new('missing name')
|
9
|
+
@dependency = dependencies.detect { |d| d.name == @name } or raise CanNotFastUpdate.new("can't find depdenency")
|
10
|
+
@locked_version = specs.detect { |d| d.name == @name } or raise CanNotFastUpdate.new("can't find locked_version")
|
11
|
+
@source = @locked_version.source or raise CanNotFastUpdate.new("can't find source")
|
12
|
+
@installed_specs = @source.send(:installed_specs) or raise CanNotFastUpdate.new("can't find installed_specs")
|
13
|
+
(@latest_version, @latest_version_uri = fetch_latest_version_from_first_source) or raise CanNotFastUpdate.new("can't find latest_version")
|
14
|
+
rescue GemNotFound => e
|
15
|
+
raise CanNotFastUpdate.new("#{e.message} (#{e.class})")
|
16
|
+
end
|
17
|
+
|
18
|
+
def fastupdate
|
19
|
+
Bundler.bundle_path.exist? or raise CanNotFastUpdate.new('Bundle path does not exist')
|
20
|
+
dependencies_match? or raise CanNotFastUpdate.new('Dependencies mismatch')
|
21
|
+
meets_all_dependencies? or raise CanNotFastUpdate.new('Dependencies not met')
|
22
|
+
|
23
|
+
if latest_version_installed?
|
24
|
+
Bundler.ui.info "Using #{@latest_version.name} (#{@latest_version.version}) "
|
25
|
+
else
|
26
|
+
install_latest_version
|
27
|
+
end
|
28
|
+
Bundler.ui.info ""
|
29
|
+
|
30
|
+
update_resolve!
|
31
|
+
lock
|
32
|
+
end
|
33
|
+
|
34
|
+
CanNotFastUpdate = Class.new(StandardError)
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def fetch_latest_version_from_first_source
|
39
|
+
old = Bundler.rubygems.sources
|
40
|
+
@source.remotes.each do |uri|
|
41
|
+
Gem.sources = [uri.to_s]
|
42
|
+
spec = Gem::SpecFetcher.fetcher.fetch(@dependency).first
|
43
|
+
return spec if spec
|
44
|
+
end
|
45
|
+
nil
|
46
|
+
ensure
|
47
|
+
Bundler.rubygems.sources = old
|
48
|
+
end
|
49
|
+
|
50
|
+
def latest_version_installed?
|
51
|
+
@installed_specs[@name].include? @latest_version
|
52
|
+
end
|
53
|
+
|
54
|
+
def install_latest_version
|
55
|
+
Bundler.rubygems.with_build_args [Bundler.settings["build.#{@name}"]] do
|
56
|
+
rem_spec = RemoteSpecification.new(@latest_version.name, @latest_version.version, @latest_version.platform, @latest_version_uri)
|
57
|
+
@source.send(:download_gem_from_uri, rem_spec, @latest_version_uri)
|
58
|
+
@source.install(@latest_version)
|
59
|
+
end
|
60
|
+
FileUtils.rm_rf(Bundler.tmp)
|
61
|
+
end
|
62
|
+
|
63
|
+
def dependencies_match?
|
64
|
+
@locked_version.dependencies == @latest_version.dependencies
|
65
|
+
end
|
66
|
+
|
67
|
+
def meets_all_dependencies?
|
68
|
+
@latest_version.dependencies.none? do |dep|
|
69
|
+
@installed_specs[dep].empty?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_resolve!
|
74
|
+
# NOTE: This is a nasty little hack. Surely there is a better way to ask Bundler
|
75
|
+
# to just re-resolve itself. Alas, I had little luck ...
|
76
|
+
@definition.resolve[@name].first.instance_variable_set(:@version, @latest_version.version)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bundler/vendored_thor'
|
2
|
+
require 'bundler/cli'
|
3
|
+
require 'bundler/fast_updater'
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc "fastupdate", "update a given gem much, much faster"
|
10
|
+
long_desc <<-D
|
11
|
+
Update is slow, very slow. This is a faster alternative when you don't
|
12
|
+
care about upgrading dependencies that still meet the requirements.
|
13
|
+
D
|
14
|
+
def fastupdate(name)
|
15
|
+
Bundler::FastUpdater.new(Bundler.root, Bundler.definition, name, options).fastupdate
|
16
|
+
rescue Bundler::FastUpdater::CanNotFastUpdate => e
|
17
|
+
Bundler.ui.info "Can not fast update: #{e.message}"
|
18
|
+
update(name)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-fastupdate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David McCullars
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-29 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.17
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
description: Provide a significantly faster update under certain circumstances
|
38
|
+
email:
|
39
|
+
- dmccullars@ePublishing.com
|
40
|
+
executables:
|
41
|
+
- bundle
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- Rakefile
|
50
|
+
- bin/bundle
|
51
|
+
- bundler-fastupdate.gemspec
|
52
|
+
- lib/.bundler_fastupdate.rb.swp
|
53
|
+
- lib/bundler-fastupdate.rb
|
54
|
+
- lib/bundler-fastupdate/version.rb
|
55
|
+
- lib/bundler/fast_updater.rb
|
56
|
+
- lib/bundler_fastupdate.rb
|
57
|
+
homepage: ""
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: -1164039447894484443
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: -1164039447894484443
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: bundler-fastupdate
|
86
|
+
rubygems_version: 1.7.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Provide a significantly faster update under certain circumstances
|
90
|
+
test_files: []
|
91
|
+
|