ruby_npm 0.1.0.pre.1

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: 1e881cd3e037d19933e854ea4ded7e72a6bb69b661c78dc9fcf51e4b4645c47f
4
+ data.tar.gz: dcf5758ec3746447abab1ac2e8aa880cba531c8e61b1dd24e7791a194ed9a4d8
5
+ SHA512:
6
+ metadata.gz: bf28ec38e38ffbcfcd9c622cd61cf846a4fc0a82b2848bd07ffc6732b111e08c463b5b6777107576b75209b3d1fc5b3ba5a1f5a1e085918c0e21d8a2e4cfadac
7
+ data.tar.gz: 79cdf3fa9bf80081bb0e6fec3063c923d33ae6b6be4090e9751ffc3837b69fb89c40dbf57b62fd6bb4bdeb4fe8d91a3181d67dd4a4daba4c75c7666abc74d2a9
@@ -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 maintainers@infrablocks.io. 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
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in ruby_npm.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,185 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby_npm (0.1.0.pre.1)
5
+ immutable-struct (~> 2.4)
6
+ lino (~> 3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (7.0.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ addressable (2.8.1)
17
+ public_suffix (>= 2.0.2, < 6.0)
18
+ ast (2.4.2)
19
+ coderay (1.1.3)
20
+ colored2 (3.1.2)
21
+ concurrent-ruby (1.1.10)
22
+ diff-lcs (1.5.0)
23
+ docile (1.4.0)
24
+ excon (0.95.0)
25
+ faker (3.1.0)
26
+ i18n (>= 1.8.11, < 2)
27
+ faraday (2.7.2)
28
+ faraday-net_http (>= 2.0, < 3.1)
29
+ ruby2_keywords (>= 0.0.4)
30
+ faraday-net_http (3.0.2)
31
+ ffi (1.15.5)
32
+ formatador (1.1.0)
33
+ gem-release (2.2.2)
34
+ guard (2.18.0)
35
+ formatador (>= 0.2.4)
36
+ listen (>= 2.7, < 4.0)
37
+ lumberjack (>= 1.0.12, < 2.0)
38
+ nenv (~> 0.1)
39
+ notiffany (~> 0.0)
40
+ pry (>= 0.13.0)
41
+ shellany (~> 0.0)
42
+ thor (>= 0.18.1)
43
+ guard-compat (1.2.1)
44
+ guard-rspec (4.7.3)
45
+ guard (~> 2.1)
46
+ guard-compat (~> 1.1)
47
+ rspec (>= 2.99.0, < 4.0)
48
+ hamster (3.0.0)
49
+ concurrent-ruby (~> 1.0)
50
+ i18n (1.12.0)
51
+ concurrent-ruby (~> 1.0)
52
+ immutable-struct (2.4.1)
53
+ json (2.6.3)
54
+ lino (3.1.0)
55
+ hamster (~> 3.0)
56
+ open4 (~> 1.3)
57
+ listen (3.7.1)
58
+ rb-fsevent (~> 0.10, >= 0.10.3)
59
+ rb-inotify (~> 0.9, >= 0.9.10)
60
+ lumberjack (1.2.8)
61
+ method_source (1.0.0)
62
+ minitest (5.16.3)
63
+ nenv (0.3.0)
64
+ notiffany (0.1.3)
65
+ nenv (~> 0.1)
66
+ shellany (~> 0.0)
67
+ octokit (4.25.1)
68
+ faraday (>= 1, < 3)
69
+ sawyer (~> 0.9)
70
+ open4 (1.3.4)
71
+ parallel (1.22.1)
72
+ parser (3.1.3.0)
73
+ ast (~> 2.4.1)
74
+ pry (0.14.1)
75
+ coderay (~> 1.1)
76
+ method_source (~> 1.0)
77
+ public_suffix (5.0.1)
78
+ rainbow (3.1.1)
79
+ rake (13.0.6)
80
+ rake_circle_ci (0.11.0)
81
+ colored2 (~> 3.1)
82
+ excon (~> 0.72)
83
+ rake_factory (~> 0.23)
84
+ sshkey (~> 2.0)
85
+ rake_factory (0.31.0)
86
+ activesupport (>= 4)
87
+ rake (~> 13.0)
88
+ rake_github (0.9.0)
89
+ colored2 (~> 3.1)
90
+ octokit (~> 4.16)
91
+ rake_factory (~> 0.23)
92
+ sshkey (~> 2.0)
93
+ rake_gpg (0.16.0)
94
+ rake_factory (>= 0.23, < 1)
95
+ ruby_gpg2 (>= 0.6, < 1)
96
+ rake_ssh (0.6.0)
97
+ colored2 (~> 3.1)
98
+ rake_factory (~> 0.23)
99
+ sshkey (~> 2.0)
100
+ rb-fsevent (0.11.2)
101
+ rb-inotify (0.10.1)
102
+ ffi (~> 1.0)
103
+ regexp_parser (2.6.1)
104
+ rexml (3.2.5)
105
+ rspec (3.12.0)
106
+ rspec-core (~> 3.12.0)
107
+ rspec-expectations (~> 3.12.0)
108
+ rspec-mocks (~> 3.12.0)
109
+ rspec-core (3.12.0)
110
+ rspec-support (~> 3.12.0)
111
+ rspec-expectations (3.12.1)
112
+ diff-lcs (>= 1.2.0, < 2.0)
113
+ rspec-support (~> 3.12.0)
114
+ rspec-mocks (3.12.1)
115
+ diff-lcs (>= 1.2.0, < 2.0)
116
+ rspec-support (~> 3.12.0)
117
+ rspec-support (3.12.0)
118
+ rubocop (1.41.1)
119
+ json (~> 2.3)
120
+ parallel (~> 1.10)
121
+ parser (>= 3.1.2.1)
122
+ rainbow (>= 2.2.2, < 4.0)
123
+ regexp_parser (>= 1.8, < 3.0)
124
+ rexml (>= 3.2.5, < 4.0)
125
+ rubocop-ast (>= 1.23.0, < 2.0)
126
+ ruby-progressbar (~> 1.7)
127
+ unicode-display_width (>= 1.4.0, < 3.0)
128
+ rubocop-ast (1.24.0)
129
+ parser (>= 3.1.1.0)
130
+ rubocop-rake (0.6.0)
131
+ rubocop (~> 1.0)
132
+ rubocop-rspec (2.16.0)
133
+ rubocop (~> 1.33)
134
+ ruby-progressbar (1.11.0)
135
+ ruby2_keywords (0.0.5)
136
+ ruby_gpg2 (0.10.0)
137
+ lino (~> 3.0)
138
+ sawyer (0.9.2)
139
+ addressable (>= 2.3.5)
140
+ faraday (>= 0.17.3, < 3)
141
+ shellany (0.0.1)
142
+ simplecov (0.22.0)
143
+ docile (~> 1.1)
144
+ simplecov-html (~> 0.11)
145
+ simplecov_json_formatter (~> 0.1)
146
+ simplecov-html (0.12.3)
147
+ simplecov_json_formatter (0.1.4)
148
+ sshkey (2.0.0)
149
+ terminal-notifier-guard (1.7.0)
150
+ thor (1.2.1)
151
+ tzinfo (2.0.5)
152
+ concurrent-ruby (~> 1.0)
153
+ unicode-display_width (2.3.0)
154
+ webrick (1.7.0)
155
+ yard (0.9.28)
156
+ webrick (~> 1.7.0)
157
+
158
+ PLATFORMS
159
+ arm64-darwin-21
160
+ ruby
161
+ x86_64-darwin-19
162
+ x86_64-linux
163
+
164
+ DEPENDENCIES
165
+ bundler
166
+ faker
167
+ gem-release
168
+ guard
169
+ guard-rspec
170
+ rake
171
+ rake_circle_ci
172
+ rake_github
173
+ rake_gpg
174
+ rake_ssh
175
+ rspec
176
+ rubocop
177
+ rubocop-rake
178
+ rubocop-rspec
179
+ ruby_npm!
180
+ simplecov
181
+ terminal-notifier-guard
182
+ yard
183
+
184
+ BUNDLED WITH
185
+ 2.4.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 InfraBlocks Maintainers
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,99 @@
1
+ # RubyNPM
2
+
3
+ A simple wrapper around the `npm` binary to allow execution from within
4
+ a Ruby program, RSpec test or Rakefile.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'ruby_npm'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install ruby_npm
21
+
22
+ ## Usage
23
+
24
+ To require `RubyNPM`:
25
+
26
+ ```ruby
27
+ require 'ruby_npm'
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ * [API docs](https://infrablocks.github.io/ruby_npm/index.html)
33
+
34
+ ## Development
35
+
36
+ To install dependencies and run the build, run the pre-commit build:
37
+
38
+ ```shell
39
+ ./go
40
+ ```
41
+
42
+ This runs all unit tests and other checks including coverage and code linting /
43
+ formatting.
44
+
45
+ To run only the unit tests, including coverage:
46
+
47
+ ```shell
48
+ ./go test:unit
49
+ ```
50
+
51
+ To attempt to fix any code linting / formatting issues:
52
+
53
+ ```shell
54
+ ./go library:fix
55
+ ```
56
+
57
+ To check for code linting / formatting issues without fixing:
58
+
59
+ ```shell
60
+ ./go library:check
61
+ ```
62
+
63
+ You can also run `bin/console` for an interactive prompt that will allow you to
64
+ experiment.
65
+
66
+ ### Managing CircleCI keys
67
+
68
+ To encrypt a GPG key for use by CircleCI:
69
+
70
+ ```shell
71
+ openssl aes-256-cbc \
72
+ -e \
73
+ -md sha1 \
74
+ -in ./config/secrets/ci/gpg.private \
75
+ -out ./.circleci/gpg.private.enc \
76
+ -k "<passphrase>"
77
+ ```
78
+
79
+ To check decryption is working correctly:
80
+
81
+ ```shell
82
+ openssl aes-256-cbc \
83
+ -d \
84
+ -md sha1 \
85
+ -in ./.circleci/gpg.private.enc \
86
+ -k "<passphrase>"
87
+ ```
88
+
89
+ ## Contributing
90
+
91
+ Bug reports and pull requests are welcome on GitHub at
92
+ https://github.com/infrablocks/ruby_npm. This project is intended to be a
93
+ safe, welcoming space for collaboration, and contributors are expected to adhere
94
+ to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
95
+
96
+ ## License
97
+
98
+ The gem is available as open source under the terms of the
99
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'yard'
5
+ require 'rake_circle_ci'
6
+ require 'rake_github'
7
+ require 'rake_ssh'
8
+ require 'rake_gpg'
9
+ require 'securerandom'
10
+ require 'rspec/core/rake_task'
11
+ require 'rubocop/rake_task'
12
+
13
+ task default: %i[
14
+ library:fix
15
+ test:unit
16
+ ]
17
+
18
+ namespace :encryption do
19
+ namespace :directory do
20
+ desc 'Ensure CI secrets directory exists.'
21
+ task :ensure do
22
+ FileUtils.mkdir_p('config/secrets/ci')
23
+ end
24
+ end
25
+
26
+ namespace :passphrase do
27
+ desc 'Generate encryption passphrase used by CI.'
28
+ task generate: ['directory:ensure'] do
29
+ File.write('config/secrets/ci/encryption.passphrase',
30
+ SecureRandom.base64(36))
31
+ end
32
+ end
33
+ end
34
+
35
+ namespace :keys do
36
+ namespace :deploy do
37
+ RakeSSH.define_key_tasks(
38
+ path: 'config/secrets/ci/',
39
+ comment: 'maintainers@infrablocks.io'
40
+ )
41
+ end
42
+
43
+ namespace :gpg do
44
+ RakeGPG.define_generate_key_task(
45
+ output_directory: 'config/secrets/ci',
46
+ name_prefix: 'gpg',
47
+ owner_name: 'InfraBlocks Maintainers',
48
+ owner_email: 'maintainers@infrablocks.io',
49
+ owner_comment: 'ruby_npm CI Key'
50
+ )
51
+ end
52
+ end
53
+
54
+ namespace :secrets do
55
+ desc 'Regenerate all generatable secrets.'
56
+ task regenerate: %w[
57
+ encryption:passphrase:generate
58
+ keys:deploy:generate
59
+ keys:gpg:generate
60
+ ]
61
+ end
62
+
63
+ RuboCop::RakeTask.new
64
+
65
+ YARD::Rake::YardocTask.new do |t|
66
+ t.files = ['lib/**/*.rb']
67
+ t.options = %w[--embed-mixins --output-dir docs]
68
+ end
69
+
70
+ namespace :library do
71
+ desc 'Run all checks of the library'
72
+ task check: [:rubocop]
73
+
74
+ desc 'Attempt to automatically fix issues with the library'
75
+ task fix: [:'rubocop:autocorrect_all']
76
+ end
77
+
78
+ namespace :documentation do
79
+ desc 'Generate documentation'
80
+ task generate: [:yard]
81
+
82
+ desc 'Commit documentation'
83
+ task :commit, [:skip] do |_, args|
84
+ args.with_defaults(skip: 'true')
85
+
86
+ skip_ci = args.skip == 'true'
87
+
88
+ sh('git', 'commit',
89
+ '-a',
90
+ '-m', "Generate latest documentation#{skip_ci ? ' [ci skip]' : ''}")
91
+ end
92
+
93
+ desc 'Update documentation'
94
+ task update: %i[generate commit]
95
+ end
96
+
97
+ namespace :test do
98
+ RSpec::Core::RakeTask.new(:unit)
99
+ end
100
+
101
+ RakeCircleCI.define_project_tasks(
102
+ namespace: :circle_ci,
103
+ project_slug: 'github/infrablocks/ruby_npm'
104
+ ) do |t|
105
+ circle_ci_config =
106
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
107
+
108
+ t.api_token = circle_ci_config['circle_ci_api_token']
109
+ t.environment_variables = {
110
+ ENCRYPTION_PASSPHRASE:
111
+ File.read('config/secrets/ci/encryption.passphrase')
112
+ .chomp
113
+ }
114
+ t.checkout_keys = []
115
+ t.ssh_keys = [
116
+ {
117
+ hostname: 'github.com',
118
+ private_key: File.read('config/secrets/ci/ssh.private')
119
+ }
120
+ ]
121
+ end
122
+
123
+ RakeGithub.define_repository_tasks(
124
+ namespace: :github,
125
+ repository: 'infrablocks/ruby_npm'
126
+ ) do |t, args|
127
+ github_config =
128
+ YAML.load_file('config/secrets/github/config.yaml')
129
+
130
+ t.access_token = github_config['github_personal_access_token']
131
+ t.deploy_keys = [
132
+ {
133
+ title: 'CircleCI',
134
+ public_key: File.read('config/secrets/ci/ssh.public')
135
+ }
136
+ ]
137
+ t.branch_name = args.branch_name
138
+ t.commit_message = args.commit_message
139
+ end
140
+
141
+ namespace :pipeline do
142
+ desc 'Prepare CircleCI Pipeline'
143
+ task prepare: %i[
144
+ circle_ci:env_vars:ensure
145
+ circle_ci:checkout_keys:ensure
146
+ circle_ci:ssh_keys:ensure
147
+ github:deploy_keys:ensure
148
+ ]
149
+ end
150
+
151
+ namespace :version do
152
+ desc 'Bump version for specified type (pre, major, minor, patch)'
153
+ task :bump, [:type] do |_, args|
154
+ bump_version_for(args.type)
155
+ end
156
+ end
157
+
158
+ desc 'Release gem'
159
+ task :release do
160
+ sh 'gem release --tag --push'
161
+ end
162
+
163
+ def bump_version_for(version_type)
164
+ sh "gem bump --version #{version_type} " \
165
+ '&& bundle install ' \
166
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
167
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
168
+ end
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 'ruby_npm'
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
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lino'
4
+
5
+ require_relative '../errors'
6
+
7
+ module RubyNPM
8
+ module Commands
9
+ class Base
10
+ # rubocop:disable Metrics/AbcSize
11
+
12
+ # Constructs an instance of the command.
13
+ #
14
+ def initialize(**opts)
15
+ @binary = opts[:binary] || RubyNPM.configuration.binary
16
+ @logger = opts[:logger] || RubyNPM.configuration.logger
17
+ @options = opts[:options] || RubyNPM.configuration.options
18
+ @stdin = opts[:stdin] || RubyNPM.configuration.stdin
19
+ @stdout = opts[:stdout] || RubyNPM.configuration.stdout
20
+ @stderr = opts[:stderr] || RubyNPM.configuration.stderr
21
+ end
22
+
23
+ # rubocop:enable Metrics/AbcSize
24
+
25
+ # Executes the command instance.
26
+ #
27
+ # @param [Hash<String, Object>] parameters The parameters used to
28
+ # invoke the command. See subclass documentation for details of
29
+ # supported options.
30
+ # @param [Hash<String, Object>] invocation_options Additional options
31
+ # controlling the invocation of the command.
32
+ # @option invocation_options [Hash<String, String>] :environment A map
33
+ # of environment variables to expose at command invocation time.
34
+ def execute(parameters = {}, invocation_options = {})
35
+ do_before(parameters)
36
+ build_and_execute_command(parameters, invocation_options)
37
+ do_after(parameters)
38
+ rescue Open4::SpawnError
39
+ message = "Failed while running '#{command_name}'."
40
+ logger.error(message)
41
+ raise Errors::ExecutionError, message
42
+ end
43
+
44
+ protected
45
+
46
+ attr_reader :binary, :logger, :stdin, :stdout, :stderr
47
+
48
+ def build_and_execute_command(parameters, invocation_options)
49
+ command = build_command(parameters, invocation_options)
50
+
51
+ logger.debug("Running '#{command}'.")
52
+ command.execute(
53
+ stdin: stdin,
54
+ stdout: stdout,
55
+ stderr: stderr
56
+ )
57
+ end
58
+
59
+ def command_name
60
+ self.class.to_s.split('::')[-1].downcase
61
+ end
62
+
63
+ def do_before(_parameters); end
64
+
65
+ def do_after(_parameters); end
66
+
67
+ private
68
+
69
+ def build_command(parameters, invocation_options)
70
+ parameters = resolve_parameters(parameters)
71
+ environment = invocation_options[:environment] || {}
72
+
73
+ Lino::CommandLineBuilder
74
+ .for_command(@binary)
75
+ .with_environment_variables(environment)
76
+ .with_options_after_subcommands
77
+ .with_option_separator('=')
78
+ .with_appliables(@options.resolve(options, parameters))
79
+ .with_subcommands(subcommands)
80
+ .with_arguments(arguments(parameters).compact.flatten).build
81
+ end
82
+
83
+ def resolve_parameters(parameters)
84
+ parameter_defaults(parameters)
85
+ .merge(parameters)
86
+ .merge(parameter_overrides(parameters))
87
+ end
88
+
89
+ def parameter_defaults(_parameters)
90
+ {}
91
+ end
92
+
93
+ def parameter_overrides(_parameters)
94
+ {}
95
+ end
96
+
97
+ def subcommands
98
+ []
99
+ end
100
+
101
+ def options
102
+ []
103
+ end
104
+
105
+ def arguments(_parameters)
106
+ []
107
+ end
108
+ end
109
+ end
110
+ end