rexe 0.4.1 → 0.5.0
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 +7 -0
- data/README.md +5 -5
- data/exe/rexe +37 -20
- data/rexe.gemspec +8 -4
- metadata +16 -4
- data/lib/rexe.rb +0 -6
- data/lib/rexe/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9f5d21ea46dc4d71386e6611f07fa8a5471728c23733fa6cbee7251efe12cdc
|
4
|
+
data.tar.gz: 61a166a3a08214863854eb8d9276aa3b65048d6ae956a835bb6d468e64b05df2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b58224490be5b8b63a094a522ba318a4827762cab34e39c6f8831daa5a0f4f9d5c8cd373daf5f5df2affecea5701e7d7f7568f625d7eaaa0722a570bc769bac
|
7
|
+
data.tar.gz: f097725d076854d4fcd3c38f81d44222e0b3641e7cb8c996e9b6c3520b4fff82cbc9fc75ae70a071a63c173a99c5db44ddbd81c8b18a389d34406e0c989cdfab
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
## rexe -- Ruby Command Line Executor
|
2
2
|
|
3
3
|
|
4
|
+
### v0.5.0
|
5
|
+
|
6
|
+
* Add '!' to require and load command options to clear respective file lists.
|
7
|
+
* In 'no input' mode (-mn), fix so that only output explicitly sent to stdout is output (unlike other modes).
|
8
|
+
* Gemspec now parses version from text instead of loading the script.
|
9
|
+
* Add tests.
|
10
|
+
|
4
11
|
### v0.4.1
|
5
12
|
|
6
13
|
* Fix -r (require) bug.
|
data/README.md
CHANGED
@@ -26,21 +26,21 @@ rexe is a _filter_ in that it can consume standard input and emit standard outpu
|
|
26
26
|
As a summary, here is the help text printed out by the application:
|
27
27
|
|
28
28
|
```
|
29
|
-
rexe -- Ruby Command Line Filter -- v0.
|
29
|
+
rexe -- Ruby Command Line Filter/Executor -- v0.5.0 -- https://github.com/keithrbennett/rexe
|
30
30
|
|
31
|
-
|
31
|
+
Executes Ruby code on the command line, optionally taking standard input and writing to standard output.
|
32
32
|
|
33
33
|
Options:
|
34
34
|
|
35
35
|
-h, --help Print help and exit
|
36
|
-
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated
|
37
|
-
-u, --load-up RUBY_FILE(S) Ruby file(s) to load, searching up tree, comma separated
|
36
|
+
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated, or ! to clear
|
37
|
+
-u, --load-up RUBY_FILE(S) Ruby file(s) to load, searching up tree, comma separated, or ! to clear
|
38
38
|
-m, --mode MODE Mode with which to handle input (i.e. what `self` will be in the code):
|
39
39
|
-ms for each line to be handled separately as a string (default)
|
40
40
|
-me for an enumerator of lines (least memory consumption for big data)
|
41
41
|
-mb for 1 big string (all lines combined into single multiline string)
|
42
42
|
-mn to execute the specified Ruby code on no input at all
|
43
|
-
-r, --require REQUIRES Gems and built-in libraries
|
43
|
+
-r, --require REQUIRES Gems and built-in libraries to require, comma separated, or ! to clear
|
44
44
|
-v, --[no-]verbose Verbose mode (logs to stderr) Verbose off short options: -v n, -v false
|
45
45
|
|
46
46
|
If there is an .rexerc file in your home directory, it will be run as Ruby code
|
data/exe/rexe
CHANGED
@@ -7,10 +7,9 @@
|
|
7
7
|
require 'optparse'
|
8
8
|
require 'shellwords'
|
9
9
|
|
10
|
-
|
11
10
|
class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
12
11
|
|
13
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.5.0'
|
14
13
|
|
15
14
|
def initialize
|
16
15
|
self.input_mode = :string
|
@@ -23,21 +22,21 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
23
22
|
def help_text
|
24
23
|
<<~HEREDOC
|
25
24
|
|
26
|
-
rexe -- Ruby Command Line Filter -- v#{VERSION} -- https://github.com/keithrbennett/rexe
|
25
|
+
rexe -- Ruby Command Line Filter/Executor -- v#{VERSION} -- https://github.com/keithrbennett/rexe
|
27
26
|
|
28
|
-
|
27
|
+
Executes Ruby code on the command line, optionally taking standard input and writing to standard output.
|
29
28
|
|
30
29
|
Options:
|
31
30
|
|
32
31
|
-h, --help Print help and exit
|
33
|
-
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated
|
34
|
-
-u, --load-up RUBY_FILE(S) Ruby file(s) to load, searching up tree, comma separated
|
32
|
+
-l, --load RUBY_FILE(S) Ruby file(s) to load, comma separated, or ! to clear
|
33
|
+
-u, --load-up RUBY_FILE(S) Ruby file(s) to load, searching up tree, comma separated, or ! to clear
|
35
34
|
-m, --mode MODE Mode with which to handle input (i.e. what `self` will be in the code):
|
36
35
|
-ms for each line to be handled separately as a string (default)
|
37
36
|
-me for an enumerator of lines (least memory consumption for big data)
|
38
37
|
-mb for 1 big string (all lines combined into single multiline string)
|
39
38
|
-mn to execute the specified Ruby code on no input at all
|
40
|
-
-r, --require REQUIRES Gems and built-in libraries
|
39
|
+
-r, --require REQUIRES Gems and built-in libraries to require, comma separated, or ! to clear
|
41
40
|
-v, --[no-]verbose Verbose mode (logs to stderr) Verbose off short options: -v n, -v false
|
42
41
|
|
43
42
|
If there is an .rexerc file in your home directory, it will be run as Ruby code
|
@@ -69,18 +68,26 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
69
68
|
exit
|
70
69
|
end
|
71
70
|
|
72
|
-
parser.on('-l', '--load RUBY_FILE(S)', 'Ruby file(s) to load, comma separated') do |v|
|
73
|
-
v
|
71
|
+
parser.on('-l', '--load RUBY_FILE(S)', 'Ruby file(s) to load, comma separated, or ! to clear') do |v|
|
72
|
+
if v == '!'
|
73
|
+
self.loads.clear
|
74
|
+
else
|
75
|
+
v.split(',').map(&:strip).each { |r| self.loads << r }
|
76
|
+
end
|
74
77
|
end
|
75
78
|
|
76
|
-
parser.on('-u', '--load_up RUBY_FILE(S)', 'Ruby file(s) to load, searching up tree, comma separated') do |v|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
parser.on('-u', '--load_up RUBY_FILE(S)', 'Ruby file(s) to load, searching up tree, comma separated, or ! to clear') do |v|
|
80
|
+
if v == '!'
|
81
|
+
self.loads.clear
|
82
|
+
else
|
83
|
+
filespecs = v.split(',').map(&:strip)
|
84
|
+
filespecs.each do |filespec|
|
85
|
+
found_file = find_file_up_tree(filespec)
|
86
|
+
if found_file
|
87
|
+
self.loads << found_file
|
88
|
+
else
|
89
|
+
log_if_verbose("Did not find load file #{filespec} in this directory or higher.")
|
90
|
+
end
|
84
91
|
end
|
85
92
|
end
|
86
93
|
end
|
@@ -103,8 +110,12 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
103
110
|
end
|
104
111
|
|
105
112
|
parser.on('-r', '--require REQUIRE(S)',
|
106
|
-
'Gems and built-in libraries (e.g. shellwords, yaml) to require, comma separated') do |v|
|
107
|
-
v
|
113
|
+
'Gems and built-in libraries (e.g. shellwords, yaml) to require, comma separated, or ! to clear') do |v|
|
114
|
+
if v == '!'
|
115
|
+
self.requires.clear
|
116
|
+
else
|
117
|
+
v.split(',').map(&:strip).each { |r| self.requires << r }
|
118
|
+
end
|
108
119
|
end
|
109
120
|
|
110
121
|
# See https://stackoverflow.com/questions/54576873/ruby-optionparser-short-code-for-boolean-option
|
@@ -114,6 +125,12 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
114
125
|
parser.on('-v', '--[no-]verbose [FLAG]', TrueClass, 'Verbose mode (logs to stderr)') do |v|
|
115
126
|
self.verbose = (v.nil? ? true : v)
|
116
127
|
end
|
128
|
+
|
129
|
+
|
130
|
+
parser.on('', '--version', 'Print version') do
|
131
|
+
puts VERSION
|
132
|
+
exit
|
133
|
+
end
|
117
134
|
end.parse!
|
118
135
|
end
|
119
136
|
|
@@ -148,7 +165,7 @@ class Rexe < Struct.new(:input_mode, :loads, :requires, :verbose)
|
|
148
165
|
if eval_context_object
|
149
166
|
puts eval_context_object.instance_eval(&code)
|
150
167
|
else
|
151
|
-
|
168
|
+
code.call
|
152
169
|
end
|
153
170
|
rescue Errno::EPIPE
|
154
171
|
exit(-13)
|
data/rexe.gemspec
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
# lib = File.expand_path("../exe", __FILE__)
|
2
|
-
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
load File.expand_path(File.join(File.dirname(__FILE__), 'exe', 'rexe'))
|
4
1
|
|
5
2
|
Gem::Specification.new do |spec|
|
6
3
|
spec.name = "rexe"
|
7
|
-
|
4
|
+
|
5
|
+
spec.version = -> do
|
6
|
+
rexe_file = File.join(File.dirname(__FILE__), 'exe', 'rexe')
|
7
|
+
version_line = File.readlines(rexe_file).grep(/\s*VERSION\s*=\s*'/).first.chomp
|
8
|
+
version_line.match(/'(.+)'/)[0].gsub("'", '')
|
9
|
+
end.()
|
10
|
+
|
8
11
|
spec.authors = ["Keith Bennett"]
|
9
12
|
spec.email = ["keithrbennett@gmail.com"]
|
10
13
|
|
@@ -36,6 +39,7 @@ Gem::Specification.new do |spec|
|
|
36
39
|
spec.require_paths = ["lib"]
|
37
40
|
|
38
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
42
|
+
spec.add_development_dependency "os"
|
39
43
|
spec.add_development_dependency "rake", "~> 12.3"
|
40
44
|
spec.add_development_dependency "rspec", "~> 3.0"
|
41
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: os
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,8 +85,6 @@ files:
|
|
71
85
|
- bin/console
|
72
86
|
- bin/setup
|
73
87
|
- exe/rexe
|
74
|
-
- lib/rexe.rb
|
75
|
-
- lib/rexe/version.rb
|
76
88
|
- rexe.gemspec
|
77
89
|
homepage: https://github.com/keithrbennett/rexe
|
78
90
|
licenses:
|
data/lib/rexe.rb
DELETED
data/lib/rexe/version.rb
DELETED