double_take 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eb8186c5d898a2e6550db26a607b2d4f09145719c28886834a6ad2167ba2f36
4
- data.tar.gz: c05ccc9225617434b6840361516c7c51aabc8ca2fa9b55e9392cd8117f398dcd
3
+ metadata.gz: 9597d31af06477de2ac02b29a24fc6f99bde3ba1cb83ac030f66eef2c608ec30
4
+ data.tar.gz: 364983fc62bc579cbde20b80d6694f58daf76fe182c1544b8a83ecae28df3068
5
5
  SHA512:
6
- metadata.gz: 3dc20a938039245f9e7372ffa238131ee1eef66e2837f192a7c443818b04638f741aec6c20d2619a19dd09d5347f9c1d70930494b09429a70506a26ad7ca3e9e
7
- data.tar.gz: 0636f9ed64f7e537bbfbd56596db2129be64dd60f172cf270723f0813176e4998e4fac04af52ab9a9efcda6bcea6e3cccf4b534144cbfd2426ba9b38822afffe
6
+ metadata.gz: 251a382afd4ff42b5f28a8e02491feeae5bf6d98793a5a41d5c8f88347a99c74d983dadcd00662022b6324f11ff5032eaf68d0f3ab018a3a4cc9098c3fd240ff
7
+ data.tar.gz: e95acc20e76bb6dc5f48f287ad767c62582dcf4b68b617014cd5f8a3e1c40034d0e62b1af28cd349ee5869a4682bdb5ffad7f6f14fad5f42b05ceb42edcfec66
@@ -1,5 +1,10 @@
1
1
  # double_take
2
2
 
3
+ ## 0.2.0
4
+ - Remove registering command and hooks at file loadtime
5
+ - Create method for loading and registering command and hooks and add to `plugins.rb`
6
+ - Bundle "next" lockfile on plugin install, removing the need to `bundle` twice
7
+
3
8
  ## 0.1.2
4
9
  - Fix helper method
5
10
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- double_take (0.1.2)
4
+ double_take (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -20,7 +20,7 @@ And then execute:
20
20
 
21
21
  ## Usage
22
22
 
23
- The plugin is installed with an initial `bundle`. Then, every subsequent `bundle` will install all gems from both `Gemfile.lock` and `Gemfile_next.lock`.
23
+ The plugin is installed with `bundle install`. It will also install all gems from both `Gemfile.lock` and `Gemfile_next.lock` on the initial `bundle` and every subsequent one as well.
24
24
 
25
25
  _NOTE_: This plugin does not generate a `Gemfile_next.lock`, keep both lockfiles in sync over gem bumps, nor does it implement any strategy for bifurcating the `Gemfile` to load different gems. For those reasons, this plugin pairs really well with [`bootboot`](https://github.com/Shopify/bootboot). For more info on dual booting I recommend reading its `README`.
26
26
 
@@ -18,7 +18,11 @@ module DoubleTake
18
18
  ensure
19
19
  ENV.delete("DEPENDENCIES_NEXT")
20
20
  end
21
- end
22
21
 
23
- DoubleTake::Clean.new.register_command
24
- DoubleTake::Hook.new.register
22
+ def self.load
23
+ DoubleTake::Clean.new.register_command
24
+ hook = DoubleTake::Hook.new
25
+ hook.bundle_next unless Bundler::Plugin.installed?("double_take")
26
+ hook.register
27
+ end
28
+ end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module DoubleTake
4
4
  class Hook < Bundler::Plugin::API
5
+ EMPTY_ARRAY = [].freeze
6
+ EMPTY_UNLOCK = { gems: EMPTY_ARRAY, sources: EMPTY_ARRAY, ruby: false }.freeze
7
+
5
8
  def register
6
9
  self.class.hook("before-install-all") do
7
10
  next if !GEMFILE_NEXT_LOCK.file?
@@ -15,17 +18,27 @@ module DoubleTake
15
18
  current_definition = Bundler.definition
16
19
  unlock = current_definition.instance_variable_get(:@unlock)
17
20
 
18
- DoubleTake.with_dependency_next do
19
- next_definition = Bundler::Definition
20
- .build(GEMFILE, GEMFILE_NEXT_LOCK, unlock)
21
+ if current_definition.to_lock == @previous_lockfile
22
+ bundle_next(unlock)
23
+ end
24
+ end
25
+ end
26
+
27
+ def bundle_next(unlock = EMPTY_UNLOCK)
28
+ return if ENV["DEPENDENCIES_NEXT"] || !GEMFILE_NEXT_LOCK.file?
21
29
 
22
- if current_definition.to_lock == @previous_lockfile
23
- Bundler.ui.confirm("Installing bundle for NEXT")
30
+ # this method memoizes an instance of the current definition
31
+ # so we need to fill that cache for other bundler internals to use
32
+ Bundler.definition
24
33
 
25
- # TODO: pass options parameter to installer
26
- Bundler::Installer.new(Bundler.root, next_definition).run({})
27
- end
28
- end
34
+ DoubleTake.with_dependency_next do
35
+ next_definition = Bundler::Definition
36
+ .build(GEMFILE, GEMFILE_NEXT_LOCK, unlock)
37
+
38
+ Bundler.ui.confirm("Installing bundle for NEXT")
39
+
40
+ # TODO: pass options parameter to installer
41
+ Bundler::Installer.new(Bundler.root, next_definition).run({})
29
42
  end
30
43
  end
31
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DoubleTake
2
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
3
5
  end
data/plugins.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lib/double_take"
4
+
5
+ DoubleTake.load
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_take
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Ewing
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler