double_take 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2e2037b165cc3f52fede20413444872ccdb8597ca263292342181e5930223ab5
4
+ data.tar.gz: 510d3837c8e0d5ec56a28228d770e81d77b6bfbff87f94cf09b33f51652fcf54
5
+ SHA512:
6
+ metadata.gz: 61a531a8c25d7086e2340324bd5ad9bc0246a58ee86ba9e98e3dc9507b9c0ecbe3e1364bb98a522a1335e5568c2e2e5b49110a0f8f823a1589001d5d93aeeb7d
7
+ data.tar.gz: 6efb8b2174ec4e4efc122abcc586bb98432e78d07aab207bc784c82001fc228aab84fff22f5c876ffac1c5eb190d9fd664abd75191e27d0eaaac094f7685f750
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.6
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,4 @@
1
+ # double_take
2
+
3
+ ## 0.1.0 (unreleased)
4
+ - Initial version
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tewing10@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in double_take.gemspec
6
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ double_take (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (12.3.3)
11
+ rspec (3.9.0)
12
+ rspec-core (~> 3.9.0)
13
+ rspec-expectations (~> 3.9.0)
14
+ rspec-mocks (~> 3.9.0)
15
+ rspec-core (3.9.2)
16
+ rspec-support (~> 3.9.3)
17
+ rspec-expectations (3.9.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.9.0)
20
+ rspec-mocks (3.9.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-support (3.9.3)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (>= 1.17.0, < 2.2)
30
+ double_take!
31
+ rake (~> 12.3.3)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Tyler Ewing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # DoubleTake
2
+
3
+ DoubleTake is a [bundler plugin](https://bundler.io/v2.0/guides/bundler_plugins.html) that doubly bundles gems from multiple lockfiles for projects that are using a [dual boot strategy](https://www.youtube.com/watch?v=I-2Xy3RS1ns&t=368s).
4
+
5
+ The motivation for this tool was for instances where both sets of gems are needed and the gems are decided at boot time. For example: docker images that are built with the gem bundle in a pipeline and can't determine which gem set to use until the docker image is run. A single docker image is useful for debugging as you don't have to guess which image had which gem set.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ plugin "double_take"
13
+ ```
14
+
15
+ _NOTE_: We use the `plugin` method, not `gem`.
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ ## Usage
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`.
24
+
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
+
27
+ As mentioned in the `bootboot` plugin the `Gemfile` needs to be bifurcated with the environment variable `DEPENDENCIES_NEXT`.
28
+
29
+
30
+ ### Clean
31
+ The `bundle clean` command is useful for removing unused gems on your system. The problem is that the default `bundle clean` only respects the gem set in `Gemfile.lock` which will remove any differing gems in `Gemfile_next.lock`. To avoid this, you can use the command:
32
+
33
+ $ bundle double_take clean
34
+
35
+ It accepts all options that bundler's clean command does:
36
+
37
+ $ bundle double_take clean --help
38
+ $ bundle double_take clean --dry-run
39
+ $ bundle double_take clean --force
40
+
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zoso10/double_take. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
55
+
56
+ ## Code of Conduct
57
+
58
+ Everyone interacting in the DoubleTake project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/double_take/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "double_take"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "double_take/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "double_take"
9
+ spec.version = DoubleTake::VERSION
10
+ spec.authors = ["Tyler Ewing"]
11
+ spec.email = ["tewing10@gmail.com"]
12
+
13
+ spec.summary = %q{A bundler plugin to install multiple sets of dependencies.}
14
+ spec.homepage = "https://github.com/zoso10/double_take"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "https://github.com/zoso10/double_take/blob/master/CHANGELOG.md"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", ">= 1.17.0", "< 2.2"
35
+ spec.add_development_dependency "rake", "~> 12.3.3"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ require "pathname"
5
+
6
+ require "double_take/clean"
7
+ require "double_take/hook"
8
+ require "double_take/version"
9
+
10
+ module DoubleTake
11
+ GEMFILE = Bundler.default_gemfile
12
+ GEMFILE_NEXT_LOCK = Pathname("#{GEMFILE}_next.lock")
13
+
14
+ def with_dependency_next_override
15
+ ENV["DEPENDENCIES_NEXT"] = "1"
16
+
17
+ yield
18
+ ensure
19
+ ENV.delete("DEPENDENCIES_NEXT")
20
+ end
21
+ end
22
+
23
+ DoubleTake::Clean.new.register_command
24
+ DoubleTake::Hook.new.register
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoubleTake
4
+ class Clean < Bundler::Plugin::API
5
+ module Patch
6
+ def next_specs
7
+ ENV["DEPENDENCIES_NEXT"] = "1"
8
+ deps = if Bundler.settings[:cache_all_platforms]
9
+ dependencies
10
+ else
11
+ requested_dependencies
12
+ end
13
+ next_specs = Bundler::Definition
14
+ .build(GEMFILE, GEMFILE_NEXT_LOCK, nil)
15
+ .resolve
16
+ .materialize(deps)
17
+ ensure
18
+ ENV.delete("DEPENDENCIES_NEXT")
19
+ end
20
+
21
+ def specs
22
+ super.merge(next_specs)
23
+ end
24
+ end
25
+
26
+ def register_command
27
+ self.class.command("double_take")
28
+ end
29
+
30
+ def exec(_command, args)
31
+ return if !GEMFILE_NEXT_LOCK.file?
32
+
33
+ if args.first != "clean"
34
+ Bundler.ui.error("Unknown subcommand: '#{args.first}'")
35
+ return
36
+ end
37
+
38
+ require "bundler/cli"
39
+ require "bundler/cli/clean"
40
+
41
+ Bundler::Definition.prepend(DoubleTake::Clean::Patch)
42
+
43
+ options = {
44
+ "dry-run": args.include?("--dry-run"),
45
+ "force": args.include?("--force"),
46
+ }
47
+ Bundler::CLI::Clean.new(options).run
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoubleTake
4
+ class Hook < Bundler::Plugin::API
5
+ def register
6
+ self.class.hook("before-install-all") do
7
+ next if !GEMFILE_NEXT_LOCK.file?
8
+
9
+ @previous_lockfile = Bundler.default_lockfile.read
10
+ end
11
+
12
+ self.class.hook("after-install-all") do
13
+ next if ENV["DEPENDENCIES_NEXT"] || !GEMFILE_NEXT_LOCK.file?
14
+
15
+ current_definition = Bundler.definition
16
+ unlock = current_definition.instance_variable_get(:@unlock)
17
+
18
+ with_dependency_next_override do
19
+ next_definition = Bundler::Definition
20
+ .build(GEMFILE, GEMFILE_NEXT_LOCK, unlock)
21
+
22
+ if current_definition.to_lock == @previous_lockfile
23
+ Bundler.ui.confirm("Installing bundle for NEXT")
24
+
25
+ # TODO: pass options parameter to installer
26
+ Bundler::Installer.new(Bundler.root, next_definition).run({})
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module DoubleTake
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: double_take
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Ewing
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.17.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.2'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.17.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 12.3.3
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 12.3.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ description:
62
+ email:
63
+ - tewing10@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - ".rspec"
70
+ - ".travis.yml"
71
+ - CHANGELOG.md
72
+ - CODE_OF_CONDUCT.md
73
+ - Gemfile
74
+ - Gemfile.lock
75
+ - LICENSE.txt
76
+ - README.md
77
+ - Rakefile
78
+ - bin/console
79
+ - bin/setup
80
+ - double_take.gemspec
81
+ - lib/double_take.rb
82
+ - lib/double_take/clean.rb
83
+ - lib/double_take/hook.rb
84
+ - lib/double_take/version.rb
85
+ homepage: https://github.com/zoso10/double_take
86
+ licenses:
87
+ - MIT
88
+ metadata:
89
+ homepage_uri: https://github.com/zoso10/double_take
90
+ source_code_uri: https://github.com/zoso10/double_take
91
+ changelog_uri: https://github.com/zoso10/double_take/blob/master/CHANGELOG.md
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubygems_version: 3.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A bundler plugin to install multiple sets of dependencies.
111
+ test_files: []