multi_ruby_runner 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -2
- data/lib/multi_ruby_runner/version.rb +1 -1
- data/lib/multi_ruby_runner/version_manager/none.rb +30 -1
- data/lib/multi_ruby_runner.rb +5 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00aac72c6817d6c81473fa843b131158bee18e96
|
4
|
+
data.tar.gz: ca7ba7076db13897eaba56b3626aad9cfca9ab70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f760bbcf644e2d854366a74001da0cb75d261f81dd9d548b881414ba44eead2bdc52d7501e478252a6f05a6d90a6c03db1ac9f130e3cee3b67a78dacf924820f
|
7
|
+
data.tar.gz: 8fcfe77dc5102c2737d010fa89d8dafd9c9bce1d00b5f5558f78f015050e0edca4658287895d28aedd366597318b9f12ea760e76e7105645f5708d6666bb4e21
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -66,12 +66,13 @@ Note that we’re passing `argument1` and `argument2` as positional arguments to
|
|
66
66
|
|
67
67
|
### Non blocking (with fork)
|
68
68
|
|
69
|
-
If you just want to start a process and return back to the caller right away, you can set the `:
|
69
|
+
If you just want to start a process and return back to the caller right away, you can set the `:blocking` option to false. In that case you will get the child process’ PID as return value. This is useful if you want to start a service and communicate with it e.g., via `Sockets`.
|
70
70
|
|
71
71
|
mrr = MultiRubyRunner.new
|
72
72
|
child_pid = mrr.execute_command_in_directory(
|
73
73
|
"./bin/ruby-script-to-execute argument1 argument2",
|
74
|
-
"/path/to/folder/that/sets/ruby/env"
|
74
|
+
"/path/to/folder/that/sets/ruby/env",
|
75
|
+
blocking: false
|
75
76
|
)
|
76
77
|
|
77
78
|
You can communicate with the child process via pipes or sockets.
|
@@ -2,8 +2,37 @@ class MultiRubyRunner
|
|
2
2
|
class VersionManager
|
3
3
|
|
4
4
|
# Represents a ruby environment without a version manager.
|
5
|
-
# In this case
|
5
|
+
# In this case the Ruby engine invocation must be given via the
|
6
|
+
# options[:ruby_engine_invocation_override]. Example: "jruby -S"
|
6
7
|
class None < VersionManager
|
8
|
+
|
9
|
+
# See MultiRubyRunner#execute_command_in_directory
|
10
|
+
# @return [Hash]
|
11
|
+
# {
|
12
|
+
# entire_command: includes shell invocation, ruby engine invocation,
|
13
|
+
# and command
|
14
|
+
# blocking: Boolean
|
15
|
+
# environment_overrides: {}
|
16
|
+
# }
|
17
|
+
def compute_process_args(command_string, directory, options)
|
18
|
+
if '' == options[:ruby_engine_invocation_override].to_s.strip
|
19
|
+
raise "No :ruby_engine_invocation_override given!"
|
20
|
+
end
|
21
|
+
ruby_command = [
|
22
|
+
options[:ruby_engine_invocation_override], # Example: "jruby -S"
|
23
|
+
command_string, # execute command
|
24
|
+
].join(' ')
|
25
|
+
shell_command_string = ["cd #{ directory }", ruby_command].join('; ')
|
26
|
+
{
|
27
|
+
entire_command: [
|
28
|
+
options[:shell_invocation],
|
29
|
+
shell_command_string,
|
30
|
+
].join(' '),
|
31
|
+
blocking: options[:blocking],
|
32
|
+
environment_overrides: {},
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
7
36
|
end
|
8
37
|
|
9
38
|
end
|
data/lib/multi_ruby_runner.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
1
|
require "multi_ruby_runner/version"
|
4
2
|
require 'multi_ruby_runner/version_manager'
|
5
3
|
require 'multi_ruby_runner/version_manager/none'
|
@@ -21,7 +19,10 @@ class MultiRubyRunner
|
|
21
19
|
# @param directory [String] the dir containing the ".ruby-version" file
|
22
20
|
# @param options [Hash, optional]
|
23
21
|
# @option options [String, optional] shell_invocation what shell to use, defaults to bash
|
24
|
-
# @option options [Boolean, optional] blocking
|
22
|
+
# @option options [Boolean, optional] blocking defaults to true.
|
23
|
+
# @option options [String, optional] ruby_engine_invocation_override
|
24
|
+
# Can be used when no Ruby version manager is present, e.g., in a docker install.
|
25
|
+
# Example: "jruby -S "
|
25
26
|
# @return [String, Integer, Nil] STDOUT output when blocking, pid when non-blocking.
|
26
27
|
def execute_command_in_directory(command_string, directory, options = {})
|
27
28
|
shell_path = ENV['SHELL'] || '/bin/bash'
|
@@ -75,7 +76,7 @@ protected
|
|
75
76
|
stdout_str
|
76
77
|
else
|
77
78
|
# Raise exception
|
78
|
-
raise "Command failed with status #{ status.inspect }. stderr: #{ stderr_str }"
|
79
|
+
raise "Command failed with status #{ status.inspect }. stderr: #{ stderr_str.inspect }"
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_ruby_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Hund
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.6.11
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Execute Ruby code in different Ruby environments.
|