ropen3 0.1.0

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: 186a968f0d3e3b87eb02414ce826e149ea1211d97354e43d66f440648512208e
4
+ data.tar.gz: 16fecda647917417fb01dd6914bbbf321bb2f7b84d50a2dd816c71054fc3e6e9
5
+ SHA512:
6
+ metadata.gz: 8cd757560e330a09d5e8836668cc818cdc4c767d17d373ea2f2b36687cea117980af323a05c109335d4640bed1f19df388f6371652eb15e9dfec1cc6fc31a247
7
+ data.tar.gz: 75e843d22af6e3b420dd65e513808c44a0d6eae3b7b693aa57353755d93d6be22ec427439366ab4230a5f02c8cbf9e73b6d4cb1d5b365aae7b0bd9d862e3c47d
data/.gitignore ADDED
@@ -0,0 +1,16 @@
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
12
+
13
+ .DS_Store
14
+ *.swp
15
+ /.vscode
16
+ .env
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 tadman@postageapp.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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'dotenv-rails'
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ropen3 (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (6.1.3.1)
10
+ actionview (= 6.1.3.1)
11
+ activesupport (= 6.1.3.1)
12
+ rack (~> 2.0, >= 2.0.9)
13
+ rack-test (>= 0.6.3)
14
+ rails-dom-testing (~> 2.0)
15
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
16
+ actionview (6.1.3.1)
17
+ activesupport (= 6.1.3.1)
18
+ builder (~> 3.1)
19
+ erubi (~> 1.4)
20
+ rails-dom-testing (~> 2.0)
21
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
22
+ activesupport (6.1.3.1)
23
+ concurrent-ruby (~> 1.0, >= 1.0.2)
24
+ i18n (>= 1.6, < 2)
25
+ minitest (>= 5.1)
26
+ tzinfo (~> 2.0)
27
+ zeitwerk (~> 2.3)
28
+ builder (3.2.4)
29
+ concurrent-ruby (1.1.8)
30
+ crass (1.0.6)
31
+ diff-lcs (1.4.4)
32
+ dotenv (2.7.6)
33
+ dotenv-rails (2.7.6)
34
+ dotenv (= 2.7.6)
35
+ railties (>= 3.2)
36
+ erubi (1.10.0)
37
+ i18n (1.8.10)
38
+ concurrent-ruby (~> 1.0)
39
+ loofah (2.9.1)
40
+ crass (~> 1.0.2)
41
+ nokogiri (>= 1.5.9)
42
+ method_source (1.0.0)
43
+ minitest (5.14.4)
44
+ nokogiri (1.11.3-x86_64-darwin)
45
+ racc (~> 1.4)
46
+ racc (1.5.2)
47
+ rack (2.2.3)
48
+ rack-test (1.1.0)
49
+ rack (>= 1.0, < 3)
50
+ rails-dom-testing (2.0.3)
51
+ activesupport (>= 4.2.0)
52
+ nokogiri (>= 1.6)
53
+ rails-html-sanitizer (1.3.0)
54
+ loofah (~> 2.3)
55
+ railties (6.1.3.1)
56
+ actionpack (= 6.1.3.1)
57
+ activesupport (= 6.1.3.1)
58
+ method_source
59
+ rake (>= 0.8.7)
60
+ thor (~> 1.0)
61
+ rake (13.0.3)
62
+ rspec (3.10.0)
63
+ rspec-core (~> 3.10.0)
64
+ rspec-expectations (~> 3.10.0)
65
+ rspec-mocks (~> 3.10.0)
66
+ rspec-core (3.10.1)
67
+ rspec-support (~> 3.10.0)
68
+ rspec-expectations (3.10.1)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-mocks (3.10.2)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-support (3.10.2)
75
+ thor (1.1.0)
76
+ tzinfo (2.0.4)
77
+ concurrent-ruby (~> 1.0)
78
+ zeitwerk (2.4.2)
79
+
80
+ PLATFORMS
81
+ x86_64-darwin-20
82
+
83
+ DEPENDENCIES
84
+ dotenv-rails
85
+ rake
86
+ ropen3!
87
+ rspec
88
+
89
+ BUNDLED WITH
90
+ 2.2.16
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 PostageApp Ltd., Scott Tadman
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,87 @@
1
+ # ROpen3
2
+
3
+ Adds [`rbenv`](https://github.com/sstephenson/rbenv) compatibility to the
4
+ `Open3` suite of process tools for easier instantiation of alternate Ruby
5
+ versions from a Ruby parent process.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ropen3'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```shell
18
+ bundle install
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```gem
24
+ gem install ropen3
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ To use ROpen3, establish the required version and `Gemfile` parameters, then
30
+ issue one or more `popen3` operations:
31
+
32
+ ```ruby
33
+ ro = ROpen3.new(version: '2.3.3')
34
+
35
+ ro.popen3('gem env') do |_sin, sout, serr, proc|
36
+ print sout.read
37
+ end
38
+ ```
39
+
40
+ This can also be done using a block style:
41
+
42
+ ```ruby
43
+ ROpen3.new(version: '2.3.3') do |ro|
44
+ ro.popen3('gem env') do |_sin, sout, serr, proc|
45
+ print sout.read
46
+ end
47
+ end
48
+ ```
49
+
50
+ All [`popen3`](https://rubyapi.org/3.0/o/open3#method-i-popen3) options,
51
+ including environment variable overrides, are supported as these are forwarded
52
+ through:
53
+
54
+ ```ruby
55
+ ROpen3.new(version: '2.3.3') do |ro|
56
+ ro.popen3({ 'VERBOSE' => '1' }, 'example', binmode: true) do |_sin, sout, serr, proc|
57
+ print sout.read
58
+ end
59
+ end
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
65
+ run `rake spec` to run the tests. You can also run `bin/console` for an
66
+ interactive prompt that will allow you to experiment.
67
+
68
+ 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
69
+ run `bundle exec rake release`, which will create a git tag for the version,
70
+ push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at
75
+ https://github.com/postageapp/ropen3. This project is intended to be
76
+ a safe, welcoming space for collaboration, and contributors are expected to
77
+ adhere to the [code of conduct](https://github.com/tadman/rbenv_popen3/blob/master/CODE_OF_CONDUCT.md).
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
82
+
83
+ ## Code of Conduct
84
+
85
+ Everyone interacting in the ROpen3 project's codebases, issue trackers,
86
+ chat rooms and mailing lists is expected to follow the
87
+ [code of conduct](https://github.com/tadman/rbenv_popen3/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
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
+ task default: :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rbenv_popen3"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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
data/lib/ropen3.rb ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'ropen3/version'
4
+
5
+ require 'open3'
6
+
7
+ class ROpen3
8
+ attr_reader :version
9
+ attr_reader :gemfile
10
+
11
+ def initialize(version:, gemfile: nil)
12
+ @version = version
13
+ @gemfile = gemfile
14
+
15
+ @env = ROpen3::Environment.env(version: version, gemfile: gemfile)
16
+
17
+ yield(self) if (block_given?)
18
+ end
19
+
20
+ def popen3(*cmd, &block)
21
+ env_arg = @env.merge(
22
+ # Pull off optional environment argument
23
+ case (cmd.first)
24
+ when Hash
25
+ cmd.shift
26
+ else
27
+ { }
28
+ end
29
+ )
30
+
31
+ if (defined?(Bundler))
32
+ Bundler.with_unbundled_env do
33
+ Open3.popen3(env_arg, *cmd, &block)
34
+ end
35
+ else
36
+ Open3.popen3(env_arg, *cmd, &block)
37
+ end
38
+ end
39
+ end
40
+
41
+ require_relative './ropen3/environment'
@@ -0,0 +1,25 @@
1
+ module ROpen3::Environment
2
+ def env(version:, gemfile: nil, env: ENV)
3
+ {
4
+ 'RBENV_VERSION' => version,
5
+ 'BUNDLE_GEMFILE' => gemfile,
6
+ 'PATH' => path(version: version, env: env)
7
+ }.compact.freeze
8
+ end
9
+
10
+ def rbenv_version_path(version:)
11
+ File.expand_path('~/.rbenv/versions/%s/bin' % version)
12
+ end
13
+
14
+ def path(version:, env: ENV)
15
+ (
16
+ [
17
+ rbenv_version_path(version: version)
18
+ ] + env['PATH'].split(/:/).reject do |path|
19
+ path.include?('.rbenv')
20
+ end
21
+ ).join(':')
22
+ end
23
+
24
+ extend self
25
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ROpen3
4
+ VERSION = File.read(File.expand_path('../../VERSION', __dir__)).chomp.freeze
5
+
6
+ def self.version
7
+ VERSION
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './lib/ropen3/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'ropen3'
7
+ spec.version = ROpen3.version
8
+ spec.authors = [ 'Scott Tadman' ]
9
+ spec.email = %w[ tadman@postageapp.com ]
10
+
11
+ spec.summary = 'Run commands in an rbenv environment'
12
+ spec.description = 'Wrapper around Open3.popen3 with rbenv support'
13
+ spec.homepage = 'https://github.com/postageapp/ropen3'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = spec.homepage
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = %w[ lib ]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency 'example-gem', '~> 1.0'
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ropen3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Scott Tadman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Wrapper around Open3.popen3 with rbenv support
14
+ email:
15
+ - tadman@postageapp.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.md
26
+ - README.md
27
+ - Rakefile
28
+ - VERSION
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/ropen3.rb
32
+ - lib/ropen3/environment.rb
33
+ - lib/ropen3/version.rb
34
+ - rbenv_open3.gemspec
35
+ homepage: https://github.com/postageapp/ropen3
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ allowed_push_host: https://rubygems.org/
40
+ homepage_uri: https://github.com/postageapp/ropen3
41
+ source_code_uri: https://github.com/postageapp/ropen3
42
+ changelog_uri: https://github.com/postageapp/ropen3
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 2.4.0
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.2.15
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Run commands in an rbenv environment
62
+ test_files: []