rexe 0.4.1 → 0.5.0

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
  SHA256:
3
- metadata.gz: 6499be319e24a076933f783ed75a150a8aaeb6ac94be679ef715a58cf326346d
4
- data.tar.gz: 59ddbcdc184f592c14cc61523efa7dc1d60e7383fa1566bc26426ec260b50ea8
3
+ metadata.gz: e9f5d21ea46dc4d71386e6611f07fa8a5471728c23733fa6cbee7251efe12cdc
4
+ data.tar.gz: 61a166a3a08214863854eb8d9276aa3b65048d6ae956a835bb6d468e64b05df2
5
5
  SHA512:
6
- metadata.gz: 830f180887f1b3743707fb563c88fc15d723b8d454729cbd38d363e915ba15f297a7b7b6dfd6d42ada06825ed4d45336e1ab8a1773d2908724d8962dbf84616b
7
- data.tar.gz: edccf4ff045bd38d4e97744cb091b07535babf07187d5327c26571b0144a816f98d89dacd46bf949fbe037d5b8a41e5db0ca794c1f1df9028ee90cc1788cb440
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.4.1 -- https://github.com/keithrbennett/rexe
29
+ rexe -- Ruby Command Line Filter/Executor -- v0.5.0 -- https://github.com/keithrbennett/rexe
30
30
 
31
- Optionally takes standard input and runs the specified code on it, sending the result to standard output.
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 (e.g. shellwords, yaml) to require, comma separated
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.4.1'
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
- Optionally takes standard input and runs the specified code on it, sending the result to standard output.
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 (e.g. shellwords, yaml) to require, comma separated
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.split(',').map(&:strip).each { |r| self.loads << r }
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
- filespecs = v.split(',').map(&:strip)
78
- filespecs.each do |filespec|
79
- found_file = find_file_up_tree(filespec)
80
- if found_file
81
- self.loads << found_file
82
- else
83
- log_if_verbose("Did not find load file #{filespec} in this directory or higher.")
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.split(',').map(&:strip).each { |r| self.requires << r }
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
- puts code.call
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
- spec.version = Rexe::VERSION
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.1
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-15 00:00:00.000000000 Z
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
@@ -1,6 +0,0 @@
1
- require "rexe/version"
2
-
3
- module Rexe
4
- class Error < StandardError; end
5
- # Your code goes here...
6
- end
data/lib/rexe/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Rexe
2
- VERSION = "0.1.0"
3
- end