multi_ruby_runner 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06e774088593a5de42c26d7f5bbe79ed84abc733
4
- data.tar.gz: 12eda98207469cf116b07a995642daa0c8d30895
3
+ metadata.gz: 00aac72c6817d6c81473fa843b131158bee18e96
4
+ data.tar.gz: ca7ba7076db13897eaba56b3626aad9cfca9ab70
5
5
  SHA512:
6
- metadata.gz: 085ffae8976d313d0162ac727337e13bf65fe8d1d02a73835772862e7370358cbdb44f5bf5d65f4ccd188ced3a2721aa6334c9daa1f46fd72937c32572e15ca6
7
- data.tar.gz: c0ef1590d62d9962940a7fac1c231575d2944234e6715dbe691110498ffe3ace37f457a9dbcf3b48cb9075495e620ee977ecddcdb74b13bfced231b052426a09
6
+ metadata.gz: f760bbcf644e2d854366a74001da0cb75d261f81dd9d548b881414ba44eead2bdc52d7501e478252a6f05a6d90a6c03db1ac9f130e3cee3b67a78dacf924820f
7
+ data.tar.gz: 8fcfe77dc5102c2737d010fa89d8dafd9c9bce1d00b5f5558f78f015050e0edca4658287895d28aedd366597318b9f12ea760e76e7105645f5708d6666bb4e21
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.0.3
2
+
3
+ * Added option to pass in a ruby engine invocation for scenarios where no ruby version manager is present (e.g., in Docker)
4
+
1
5
  ### 1.0.2
2
6
 
3
7
  * Fixed rbenv implementation
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 `:fork` option to true. 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`.
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.
@@ -1,3 +1,3 @@
1
1
  class MultiRubyRunner
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -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 MultiRubyRunner won't work and will raise errors instead.
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
@@ -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, defaults to true.
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.2
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: 2016-03-17 00:00:00.000000000 Z
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.5.1
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.