binbundle 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d503eb5e3d329154c4b8134337701a6dcdf2b10548750603cce3e7689d7249bf
4
+ data.tar.gz: 6265a9d0df9271d3c77d6619e048a3a18f29b19e31d3381a724b246313acc882
5
+ SHA512:
6
+ metadata.gz: 4d1ba6cbdde6132a8775bc6f4d8041d0c580351a330db2cf561de3c39ecc12cd77132c60e903fcd1cfd2875cfb0fd2c684fb18521983921a56b098fe2bde32bf
7
+ data.tar.gz: a5f3262d2de2caf4a16840c1a2eb86f96d10a49b23ebcf0aaa258774840a860086d7e45fad367431a25767f4b6c0daa20f4c712fca9776b9d19e94bdfb4190f7
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: single_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: single_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 1.0.6
2
+
3
+ - Add spinners
4
+
5
+ ## [0.1.0] - 2024-08-01
6
+
7
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at brett.terpstra@oracle.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in binbundle.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ binbundle (1.0.5)
5
+ tty-spinner (~> 0.9)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.1)
12
+ json (2.7.2)
13
+ language_server-protocol (3.17.0.3)
14
+ parallel (1.25.1)
15
+ parser (3.3.4.0)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ racc (1.8.1)
19
+ rainbow (3.1.1)
20
+ rake (13.2.1)
21
+ regexp_parser (2.9.2)
22
+ rexml (3.3.4)
23
+ strscan
24
+ rspec (3.13.0)
25
+ rspec-core (~> 3.13.0)
26
+ rspec-expectations (~> 3.13.0)
27
+ rspec-mocks (~> 3.13.0)
28
+ rspec-core (3.13.0)
29
+ rspec-support (~> 3.13.0)
30
+ rspec-expectations (3.13.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.13.0)
33
+ rspec-mocks (3.13.1)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-support (3.13.1)
37
+ rubocop (1.65.1)
38
+ json (~> 2.3)
39
+ language_server-protocol (>= 3.17.0)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.3.0.2)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 2.4, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.31.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.31.3)
49
+ parser (>= 3.3.1.0)
50
+ ruby-progressbar (1.13.0)
51
+ strscan (3.1.0)
52
+ tty-cursor (0.7.1)
53
+ tty-spinner (0.9.3)
54
+ tty-cursor (~> 0.7)
55
+ unicode-display_width (2.5.0)
56
+
57
+ PLATFORMS
58
+ x86_64-darwin-20
59
+
60
+ DEPENDENCIES
61
+ binbundle!
62
+ rake (~> 13.0)
63
+ rspec (~> 3.0)
64
+ rubocop (~> 1.21)
65
+
66
+ BUNDLED WITH
67
+ 2.2.29
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Brett Terpstra
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.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Binbundle
2
+
3
+ Creates a "bundle" file of all installed gems with executables. The resulting file is an executable script that can be run standalone, or in combination with this script to add options like `sudo` or `--user-install` to the `gem install` commands. These options can be specified when creating the file as well. A file created with `sudo` or `--user-install` commands can still be overridden when running via this script and `--install`.
4
+
5
+ Created file is called `Binfile` in the current directory unless another path is specified with `--file`.
6
+
7
+ ## Installation
8
+
9
+ Install with:
10
+
11
+ $ gem install binbundle
12
+
13
+ If this causes errors, use:
14
+
15
+ $ gem install --user-install binbundle
16
+
17
+ ## Usage
18
+
19
+ Run `binbundle` to create a Binfile in the current directory. That file can optionally be made executable (you'll be prompted). In the future when doing a clean install or using a new system, you can just run that file as a standalone to reinstall all of your gem binaries.
20
+
21
+ Using this script with the `--install` flag will read the Binfile and execute it line by line, adding options like version numbers, sudo, or the `--user-install` flag.
22
+
23
+ You can also run with subcommands `bundle` or `install`, e.g. `bundle_gem_bins install`.
24
+
25
+ ```
26
+ Usage: binbundle [options] [bundle|install]
27
+ --[no-]versions Include version info in output (default true)
28
+ --dry-run Output to STDOUT instead of file
29
+ -s, --sudo Install gems with sudo
30
+ -u, --user-install Use --user-install to install gems
31
+ -f, --file FILE Output to alternative filename (default Binfile)
32
+ -v, --version Display version
33
+ --install Run bundle script
34
+ -h, --help Display this screen
35
+ ```
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
40
+
41
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/ttscoff/binbundle>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ttscoff/binbundle/blob/main/CODE_OF_CONDUCT.md).
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the Binbundle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ttscoff/binbundle/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/binbundle ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/binbundle'
5
+
6
+ options = {
7
+ dry_run: false,
8
+ file: 'Binfile',
9
+ include_version: true,
10
+ sudo: false,
11
+ user_install: false
12
+ }
13
+
14
+ optparse = OptionParser.new do |opts|
15
+ opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
16
+
17
+ opts.on('--[no-]versions', 'Include version info in output (default true)') do |opt|
18
+ options[:include_version] = opt
19
+ end
20
+
21
+ opts.on('--dry-run', 'Output to STDOUT instead of file') do
22
+ options[:dry_run] = true
23
+ end
24
+
25
+ opts.on('-s', '--sudo', 'Install gems with sudo') do
26
+ options[:sudo] = true
27
+ end
28
+
29
+ opts.on('-u', '--user-install', 'Use --user-install to install gems') do
30
+ options[:user_install] = true
31
+ end
32
+
33
+ opts.on('-f', '--file FILE', 'Output to alternative filename (default Binfile)') do |opt|
34
+ options[:file] = opt
35
+ end
36
+
37
+ opts.on('-v', '--version', 'Display version') do
38
+ puts "#{File.basename(__FILE__)} v#{Binbundle::VERSION}"
39
+ Process.exit 0
40
+ end
41
+
42
+ opts.on('--install', 'Run bundle script') do
43
+ options[:install] = true
44
+ end
45
+
46
+ opts.on('-h', '--help', 'Display this screen') do
47
+ puts opts
48
+ exit
49
+ end
50
+ end
51
+
52
+ optparse.parse!
53
+
54
+ if options[:sudo] && options[:user_install]
55
+ puts 'Error: --sudo and --user-install cannot be used together'
56
+ Process.exit 1
57
+ end
58
+
59
+ gb = Binbundle::GemBins.new(options)
60
+
61
+ options[:install] = true if ARGV.count.positive? && ARGV[0] =~ /^inst/
62
+
63
+ if options[:install]
64
+ gb.install
65
+ else
66
+ gb.generate
67
+ end
data/binbundle.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/binbundle/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'binbundle'
7
+ spec.version = Binbundle::VERSION
8
+ spec.authors = ['Brett Terpstra']
9
+ spec.email = ['me@brettterpstra.com']
10
+
11
+ spec.summary = 'Bundle all your gem binaries.'
12
+ spec.description = 'Easily take a snapshot of all binaries installed with Gem and restore on a fresh system.'
13
+ spec.homepage = 'https://github.com/ttscoff/binbundle'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/ttscoff/binbundle'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/ttscoff/binbundle/CHANGELOG.md'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = 'bin'
29
+ spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_runtime_dependency('tty-spinner', '~> 0.9')
33
+ end
@@ -0,0 +1,120 @@
1
+ module Binbundle
2
+ # Main class
3
+ class GemBins
4
+ def local_gems
5
+ Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name)
6
+ end
7
+
8
+ def initialize(options = {})
9
+ @include_version = options[:include_version] || false
10
+ @user_install = options[:user_install]
11
+ @sudo = options[:sudo]
12
+ @dry_run = options[:dry_run]
13
+ @file = File.expand_path(options[:file])
14
+
15
+ @local_gems = local_gems.delete_if { |_, specs| specs.delete_if { |spec| spec.executables.empty? }.empty? }
16
+ end
17
+
18
+ def install
19
+ unless File.exist?(@file)
20
+ puts "File #{@file} not found"
21
+ Process.exit 1
22
+ end
23
+
24
+ res = Prompt.yn("Install gems from #{File.basename(@file)}", default_response: true)
25
+
26
+ Process.exit 0 unless res
27
+
28
+ puts "Installing gems from #{@file}"
29
+
30
+ contents = IO.read(@file)
31
+ gem_list = GemList.new(contents, include_version: @include_version)
32
+ lines = if @sudo
33
+ gem_list.sudo
34
+ elsif @user_install
35
+ gem_list.user_install
36
+ else
37
+ gem_list.normal_install
38
+ end
39
+
40
+ if @dry_run
41
+ puts lines.join("\n")
42
+ Process.exit 0
43
+ end
44
+
45
+ `sudo echo -n ''` if @sudo
46
+
47
+ @errors = []
48
+
49
+ lines.each do |cmd|
50
+ spinner = TTY::Spinner.new("[:spinner] #{cmd} ...", hide_cursor: true, format: :dots_2)
51
+
52
+ spinner.auto_spin
53
+
54
+ output = `/bin/bash -c '#{cmd}' 2>&1`
55
+ result = $?.success?
56
+
57
+ if result
58
+ spinner.success
59
+ spinner.stop
60
+ else
61
+ spinner.error
62
+ spinner.stop
63
+ @errors << output
64
+ end
65
+ end
66
+
67
+ unless @errors.empty?
68
+ puts "ERRORS:"
69
+ puts @errors.join("\n")
70
+ end
71
+ end
72
+
73
+ def gem_command(gem, attrs)
74
+ ver = @include_version ? " -v '#{attrs[:version]}'" : ''
75
+ ui = @user_install ? '--user-install ' : ''
76
+ sudo = @sudo ? 'sudo ' : ''
77
+ "# Executables: #{attrs[:bins].join(', ')}\n#{sudo}gem install #{ui}#{gem}#{ver}"
78
+ end
79
+
80
+ def generate
81
+ gems_with_bins = {}
82
+
83
+ @local_gems.each do |g, specs|
84
+ versions = specs.map { |spec| spec.version.to_s }
85
+ bins = specs.map(&:executables)
86
+ gems_with_bins[g] = { version: versions.max, bins: bins.sort.uniq }
87
+ end
88
+
89
+ output = gems_with_bins.map { |gem, attrs| gem_command(gem, attrs) }.join("\n\n")
90
+
91
+ if @dry_run
92
+ puts output
93
+ else
94
+ write_file(output)
95
+ end
96
+ end
97
+
98
+ def write_file(output)
99
+ if File.exist?(@file)
100
+ res = Prompt.yn("#{@file} already exists, overwrite", default_response: false)
101
+ Process.exit 1 unless res
102
+ end
103
+
104
+ File.open(@file, 'w') do |f|
105
+ f.puts '#!/bin/bash'
106
+ f.puts
107
+ f.puts output
108
+ end
109
+
110
+ puts "Wrote list to #{@file}"
111
+
112
+ res = Prompt.yn('Make file executable', default_response: true)
113
+
114
+ return unless res
115
+
116
+ FileUtils.chmod 0o777, @file
117
+ puts 'Made file executable'
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binbundle
4
+ # String helpers
5
+ class GemList
6
+ attr_writer :include_version
7
+
8
+ attr_reader :gem_list
9
+
10
+ def initialize(contents, include_version: true)
11
+ @contents = contents
12
+ @include_version = include_version
13
+ @gem_list = gem_list
14
+ end
15
+
16
+ def gem_list
17
+ @gem_list ||= @contents.split("\n").delete_if { |line| line.strip.empty? || line =~ /^#/ }.each_with_object([]) do |l, arr|
18
+ m = l.match(/^(?:sudo )?gem install (?:--user-install )?(?<gem>\S+)(?: (?:-v|--version) '(?<version>[0-9.]+)')?/)
19
+ arr << { gem: m['gem'], version: m['version'] }
20
+ end
21
+ end
22
+
23
+ def sudo
24
+ @gem_list.map do |gem|
25
+ version = @include_version && gem[:version] ? " -v '#{gem[:version]}'" : ''
26
+ "sudo gem install #{gem[:gem]}#{version}"
27
+ end
28
+ end
29
+
30
+ def user_install
31
+ @gem_list.map do |gem|
32
+ version = @include_version && gem[:version] ? " -v '#{gem[:version]}'" : ''
33
+ "gem install --user-install #{gem[:gem]}#{version}"
34
+ end
35
+ end
36
+
37
+ def normal_install
38
+ @gem_list.map do |gem|
39
+ version = @include_version && gem[:version] ? " -v '#{gem[:version]}'" : ''
40
+ "gem install #{gem[:gem]}#{version}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binbundle
4
+ # Command line prompts
5
+ module Prompt
6
+ ##
7
+ ## Ask a yes or no question in the terminal
8
+ ##
9
+ ## @param question [String] The question
10
+ ## to ask
11
+ ## @param default_response [Boolean] default
12
+ ## response if no input
13
+ ##
14
+ ## @return [Boolean] yes or no
15
+ ##
16
+ def self.yn(question, default_response: nil)
17
+ $stdin.reopen('/dev/tty')
18
+
19
+ default = if default_response.is_a?(String)
20
+ default_response =~ /y/i ? true : false
21
+ else
22
+ default_response
23
+ end
24
+
25
+ # if this isn't an interactive shell, answer default
26
+ return default unless $stdout.isatty
27
+
28
+ # clear the buffer
29
+ if ARGV&.length
30
+ ARGV.length.times do
31
+ ARGV.shift
32
+ end
33
+ end
34
+ system 'stty cbreak'
35
+
36
+ options = if default.nil?
37
+ '[y/n]'
38
+ else
39
+ "[#{default ? 'Y/n' : 'y/N'}]"
40
+ end
41
+ $stdout.syswrite "#{question.sub(/\?$/, '')} #{options}? "
42
+ res = $stdin.sysread 1
43
+ puts
44
+ system 'stty cooked'
45
+
46
+ res.chomp!
47
+ res.downcase!
48
+
49
+ return default if res.empty?
50
+
51
+ res =~ /y/i ? true : false
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binbundle
4
+ VERSION = '1.0.5'
5
+ end
data/lib/binbundle.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+ require 'fileutils'
5
+ require 'tty-spinner'
6
+ require_relative 'binbundle/version'
7
+ require_relative 'binbundle/prompt'
8
+ require_relative 'binbundle/gem_list'
9
+ require_relative 'binbundle/gem_bins'
10
+
11
+ module Binbundle
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binbundle
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Brett Terpstra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-spinner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ description: Easily take a snapshot of all binaries installed with Gem and restore
28
+ on a fresh system.
29
+ email:
30
+ - me@brettterpstra.com
31
+ executables:
32
+ - binbundle
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - bin/binbundle
46
+ - binbundle.gemspec
47
+ - lib/binbundle.rb
48
+ - lib/binbundle/gem_bins.rb
49
+ - lib/binbundle/gem_list.rb
50
+ - lib/binbundle/prompt.rb
51
+ - lib/binbundle/version.rb
52
+ homepage: https://github.com/ttscoff/binbundle
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/ttscoff/binbundle
57
+ source_code_uri: https://github.com/ttscoff/binbundle
58
+ changelog_uri: https://github.com/ttscoff/binbundle/CHANGELOG.md
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.2.15
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Bundle all your gem binaries.
78
+ test_files: []