rexe 0.15.1 → 1.0.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: 1e109ac92787742884d19056f18b7b6cc36bd93f017f8e06857b733c6532f607
4
- data.tar.gz: b1eb347fee1f87826f73f3afb246de542ee145b484b1497cc5f2ff29eada7265
3
+ metadata.gz: ad9ebb60746e9796db2a6f284cf0d0aee226db27e665710cdfc18714ec0e6363
4
+ data.tar.gz: f2cbb93e42bca15ffab3d9b240785427c70a6ed507b33c9673eb9536d0a0a343
5
5
  SHA512:
6
- metadata.gz: f7a5886ca0a29bc61bdd37cb27ecb8e328aeed12aa7dcf4c3c4a7bb15bf8d2009d8b2ffab45f334f7e5b50fe8ca9ea30dd4ef02448077acaab935ee33671b52b
7
- data.tar.gz: 4567e8126e315260b9c07583f0c7a028ce237b83e634103552b08a0d43f240271ebed5c49d13f2dee29256201f8a88d632fae2a0761c612816e764d3a70c5ec3
6
+ metadata.gz: 17a9cf1e2ece63be47427236a3803ff2ddd7bf144774755c567e7074ad43c6aff19799a2e3651bc8a81fcc7a7550eae3968e9525942f4d4bccb4127e0c481fe4
7
+ data.tar.gz: 484af00828303109e4b9904316700f25340cee8314e0a4e038b5166b2b5410c8e5731b0b6bb6ab91414b03c1bf709d532048d2cf975fcffac782d47db07c0209
@@ -1,4 +1,14 @@
1
- ## rexe -- Ruby Command Line Executor
1
+ ## rexe -- Ruby Command Line Executor/Filter
2
+
3
+
4
+ ### 1.0.0
5
+
6
+ * Suppress help message on SystemExit.
7
+ * Eliminate stack trace from all error messages.
8
+ * Fix Awesome Print output to have a "\n" at the end of it.
9
+ * Add eur_rates.json sample data.
10
+ * Remove gem post-commit message.
11
+
2
12
 
3
13
  ### 0.15.1
4
14
 
data/README.md CHANGED
@@ -1,28 +1,32 @@
1
- ---
2
- title: The `rexe` Command Line Executor and Filter
3
- date: 2019-02-15
4
- ---
1
+ # Rexe
5
2
 
6
- [Caution: This is a long article!
7
- You might want to skim the section headings and source code first.
8
- Many sections can be skipped without sacrificing comprehensibility of the rest of them.
9
- ]
3
+ __Rexe__ is a Ruby script and gem that multiplies Ruby's usefulness and conciseness on the command line by:
4
+
5
+ * automating parsing and formatting using JSON, YAML, Ruby marshalling, Awesome Print, and others
6
+ * simplifying the use of Ruby as a shell filter, optionally predigesting input as lines, an enumerator, or one big string
7
+ * extracting the plumbing from the command line; requires and other options can be set in an environment variable
8
+ * enabling the loading of Ruby helper files to keep your code DRY and your command line code high level
9
+ * reading and evaluating a ~/.rexerc file on startup for your shared custom code and common requires
10
10
 
11
11
  ----
12
12
 
13
13
  Shell scripting is great for simple tasks but for anything nontrivial
14
14
  it can easily get cryptic and awkward (pun intended!).
15
-
16
- Often, I solve this problem by writing a Ruby script instead. Ruby gives me fine
15
+
16
+ This problem can often be solved by writing a Ruby script instead. Ruby provides fine
17
17
  grained control in a language that is all about clarity, conciseness, and expressiveness.
18
18
 
19
19
  Unfortunately, when there are multiple OS commands to be called, then Ruby can be
20
20
  awkward too.
21
21
 
22
+ Sometimes a good solution is to combine Ruby and shell scripting on the same
23
+ command line. Rexe multiplies your power to do so.
24
+
25
+
22
26
  ### Using the Ruby Interpreter on the Command Line
23
27
 
24
- Sometimes a good solution is to combine Ruby and shell scripting on the same
25
- command line. Here's an example, using an intermediate environment variable to
28
+ Let's start by seeing what the Ruby interpreter already provides.
29
+ Here we use `ruby` on the command line, using an intermediate environment variable to
26
30
  simplify the logic and save the data for use by future commands.
27
31
  An excerpt of the output follows the code:
28
32
 
@@ -39,13 +43,13 @@ base: EUR
39
43
  date: '2019-03-08'
40
44
  ```
41
45
 
42
- However, the configuration setup (the `require`s) along with the reading, parsing, and formatting
46
+ Unfortunately, the configuration setup (the `require`s) along with the reading, parsing, and formatting
43
47
  make the command long and tedious, discouraging this approach.
44
48
 
45
49
  ### Rexe
46
50
 
47
- The `rexe` script [see footnote ^1] can simplify such commands.
48
- Among other things, `rexe` provides switch-activated input parsing and output formatting so that converting
51
+ Rexe [see footnote ^1 regarding its origin] can simplify such commands.
52
+ Among other things, rexe provides switch-activated input parsing and output formatting so that converting
49
53
  from one format to another is trivial.
50
54
  The previous `ruby` command can be expressed in `rexe` as:
51
55
 
@@ -53,27 +57,40 @@ The previous `ruby` command can be expressed in `rexe` as:
53
57
  ➜ ~  echo $EUR_RATES_JSON | rexe -mb -ij -oy self
54
58
  ```
55
59
 
60
+ Or, even more concisely (`self` is the default Ruby source code for rexe commands):
61
+
62
+ ```
63
+ ➜ ~  echo $EUR_RATES_JSON | rexe -mb -ij -oy
64
+ ```
65
+
56
66
  The command options may seem cryptic, but they're logical so it shouldn't take long to learn them:
57
67
 
58
68
  * `-mb` - __mode__ to consume all standard input as a single __big__ string
59
69
  * `-ij` - parse that __input__ with __JSON__; `self` will be the parsed object
60
70
  * `-oy` - __output__ the final value as __YAML__
61
71
 
62
- `rexe` is at https://github.com/keithrbennett/rexe and can be installed with
63
- `gem install rexe`. `rexe` provides several ways to simplify Ruby on the command
72
+ If input comes from a JSON or YAML file, rexe determines the input format from the file's extension,
73
+ and it's even simpler:
74
+
75
+ ```
76
+ ➜ ~  rexe -f eur_rates.json -oy
77
+ ```
78
+
79
+ Rexe is at https://github.com/keithrbennett/rexe and can be installed with
80
+ `gem install rexe`. Rexe provides several ways to simplify Ruby on the command
64
81
  line, tipping the scale so that it is practical to do it more often.
65
82
 
66
83
  ----
67
84
 
68
- Here is `rexe`'s help text as of the time of this writing:
85
+ Here is rexe's help text as of the time of this writing:
69
86
 
70
87
  ```
71
- rexe -- Ruby Command Line Executor/Filter -- v0.15.1 -- https://github.com/keithrbennett/rexe
88
+ rexe -- Ruby Command Line Executor/Filter -- v1.0.0 -- https://github.com/keithrbennett/rexe
72
89
 
73
90
  Executes Ruby code on the command line, optionally automating management of standard input
74
91
  and standard output, and optionally parsing input and formatting output with YAML, JSON, etc.
75
92
 
76
- rexe [options] 'Ruby source code'
93
+ rexe [options] [Ruby source code]
77
94
 
78
95
  Options:
79
96
 
@@ -108,29 +125,34 @@ Options:
108
125
  -r, --require REQUIRE(S) Gems and built-in libraries to require, comma separated;
109
126
  ! to clear all, or precede a name with '-' to remove
110
127
 
111
- If source code is not specified, it will default to 'self', which is most likely useful
112
- only in a filter mode (-ml, -me, -mb).
128
+ ---------------------------------------------------------------------------------------
129
+
130
+ In many cases you will need to enclose your source code in single or double quotes.
131
+
132
+ If source code is not specified, it will default to 'self',
133
+ which is most likely useful only in a filter mode (-ml, -me, -mb).
113
134
 
114
135
  If there is an .rexerc file in your home directory, it will be run as Ruby code
115
136
  before processing the input.
116
137
 
117
- If there is a REXE_OPTIONS environment variable, its content will be prepended to the command line
118
- so that you can specify options implicitly (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
138
+ If there is a REXE_OPTIONS environment variable, its content will be prepended
139
+ to the command line so that you can specify options implicitly
140
+ (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
119
141
  ```
120
142
 
121
143
  ### Simplifying the Rexe Invocation
122
144
 
123
- There are two main ways we can make the `rexe` command line even more concise:
145
+ There are two main ways we can make the rexe command line even more concise:
124
146
 
125
147
  * by extracting configuration into the `REXE_OPTIONS` environment variable
126
- * by extracting low level and/or shared code into files that are loaded using `-l`,
148
+ * by extracting low level and/or shared code into helper files that are loaded using `-l`,
127
149
  or implicitly with `~/.rexerc`
128
150
 
129
151
 
130
152
  ### The REXE_OPTIONS Environment Variable
131
153
 
132
154
  The `REXE_OPTIONS` environment variable can contain command line options that would otherwise
133
- be specified on the `rexe` command line:
155
+ be specified on the rexe command line:
134
156
 
135
157
  Instead of this:
136
158
 
@@ -147,16 +169,17 @@ you can do this:
147
169
  ```
148
170
 
149
171
  Putting configuration options in `REXE_OPTIONS` effectively creates custom defaults,
150
- and is useful when you use options in most or all of your commands. Any options specified on the `rexe`
172
+ and is useful when you use the same options in most or all of your commands.
173
+ Any options specified on the rexe
151
174
  command line will override the environment variable options.
152
175
 
153
176
  Like any environment variable, `REXE_OPTIONS` could also be set in your startup script, input on a command line using `export`, or in another script loaded with `source` or `.`.
154
177
 
155
178
  ### Loading Files
156
179
 
157
- The environment variable approach works well for command line _options_, but what if we want to specify Ruby _code_ (e.g. methods) that can be used by your `rexe` code?
180
+ The environment variable approach works well for command line _options_, but what if we want to specify Ruby _code_ (e.g. methods) that can be used by your rexe code?
158
181
 
159
- For this, `rexe` lets you _load_ Ruby files, using the `-l` option, or implicitly (without your specifying it) in the case of the `~/.rexerc` file. Here is an example of something you might include in such a file:
182
+ For this, rexe lets you _load_ Ruby files, using the `-l` option, or implicitly (without your specifying it) in the case of the `~/.rexerc` file. Here is an example of something you might include in such a file:
160
183
 
161
184
  ```
162
185
  # Open YouTube to Wagner's "Ride of the Valkyries"
@@ -165,7 +188,13 @@ def valkyries
165
188
  end
166
189
  ```
167
190
 
168
- To digress a bit, why would you want this? You might want to be able to go to another room until a long job completes, and be notified when it is done. The `valkyries` method will launch a browser window pointed to Richard Wagner's "Ride of the Valkyries" starting at a lively point in the music. (The `open` command is Mac specific and could be replaced with `start` on Windows, a browser command name, etc.) [see footnote ^2]
191
+ To digress a bit, why would you want this? You might want to be able to go to another room
192
+ until a long job completes, and be notified when it is done.
193
+ The `valkyries` method will launch a browser window pointed
194
+ to Richard Wagner's "Ride of the Valkyries"
195
+ starting at a lively point in the music [see footnote ^2 regarding autoplay].
196
+ (The `open` command is Mac specific and could be replaced with `start` on Windows,
197
+ a browser command name, etc.) [see footnote ^3 regarding OS portability].
169
198
 
170
199
  If you like this kind of audio notification, you could download public domain audio files and use a command like player like `afplay` on Mac OS, or `mpg123` or `ogg123` on Linux. This approach is lighter weight, requires no network access, and will not leave an open browser window for you to close.
171
200
 
@@ -178,9 +207,12 @@ is loaded from your `~/.rexerc` file or an explicitly loaded file:
178
207
 
179
208
  (Note that `;` is used rather than `&&` because we want to hear the music whether or not the command succeeds.)
180
209
 
181
- You might be thinking that creating an alias or a minimal shell script for this `open` would be a simpler and more natural
210
+ You might be thinking that creating an alias or a minimal shell script (instead of a Ruby script)
211
+ for this `open` would be a simpler and more natural
182
212
  approach, and I would agree with you. However, over time the number of these could become unmanageable, whereas using Ruby
183
- you could build a pretty extensive and well organized library of functionality. Moreover, that functionality could be made available to _all_ your Ruby code (for example, by putting it in a gem), and not just command line one liners.
213
+ you could build a pretty extensive and well organized library of functionality.
214
+ Moreover, that functionality could be made available to _all_ your Ruby code
215
+ (for example, by putting it in a gem), and not just command line one liners.
184
216
 
185
217
  For example, you could have something like this in a gem or loaded file:
186
218
 
@@ -220,29 +252,30 @@ and the execution time of your Ruby code:
220
252
  ➜ ~  echo $EUR_RATES_JSON | rexe -gy -ij -mb -oa self
221
253
  ...
222
254
  ---
223
- :count: 0
224
- :rexe_version: 0.13.0
225
- :start_time: '2019-03-21T20:58:51+08:00'
226
- :source_code: ap JSON.parse(STDIN.read)
255
+ :count: 1
256
+ :rexe_version: 1.0.0
257
+ :start_time: '2019-04-14T19:15:50+08:00'
258
+ :source_code: self
227
259
  :options:
228
- :input_format: :none
229
- :input_mode: :no_input
260
+ :input_filespec:
261
+ :input_format: :json
262
+ :input_mode: :one_big_string
230
263
  :loads: []
231
- :output_format: :puts
264
+ :output_format: :awesome_print
232
265
  :requires:
233
266
  - awesome_print
234
267
  - json
235
268
  - yaml
236
269
  :log_format: :yaml
237
270
  :noop: false
238
- :duration_secs: 0.070381
271
+ :duration_secs: 0.064798
239
272
  ```
240
273
 
241
274
  We specified `-gy` for YAML format; there are other formats as well (see the help output or this document)
242
275
  and the default is `-gn`, which means don't output the log entry at all.
243
276
 
244
277
  The requires you see were not explicitly specified but were automatically added because
245
- `rexe` will add any requires needed for automatic parsing and formatting, and
278
+ Rexe will add any requires needed for automatic parsing and formatting, and
246
279
  we specified those formats in the command line options `-gy -ij -oa`.
247
280
 
248
281
  This extra output is sent to standard error (_stderr_) instead of standard output
@@ -258,15 +291,15 @@ If you would like to append this informational output to a file(e.g. `rexe.log`)
258
291
 
259
292
  ### Input Modes
260
293
 
261
- `rexe` tries to make it simple and convenient for you to handle standard input,
294
+ Rexe tries to make it simple and convenient for you to handle standard input,
262
295
  and in different ways. Here is the help text relating to input modes:
263
296
 
264
297
  ```
265
298
  -m, --input_mode MODE Mode with which to handle input (i.e. what `self` will be in your code):
266
- -ml line mode; each line is ingested as a separate string
267
- -me enumerator mode
268
- -mb big string mode; all lines combined into single multiline string
269
- -mn (default) no input mode; no special handling of input; self is not input
299
+ -ml line mode; each line is ingested as a separate string
300
+ -me enumerator mode
301
+ -mb big string mode; all lines combined into single multiline string
302
+ -mn (default) no input mode; no special handling of input; self is an Object.new
270
303
  ```
271
304
 
272
305
  The first three are _filter_ modes; they make standard input available
@@ -320,7 +353,7 @@ files in the directory listing:
320
353
  2 Desktop
321
354
  ```
322
355
 
323
- Since `self` is an enumerable, we can call `first` and then `each_with_index`.
356
+ Since `self` is an enumerable, we can call `first` on it.
324
357
  We've used the default output mode `-on` (_no output_ mode), which says don't do any automatic output,
325
358
  just the output explicitly specified by `puts` in the source code.
326
359
 
@@ -328,11 +361,11 @@ just the output explicitly specified by `puts` in the source code.
328
361
  #### -mb "Big String" Filter Mode
329
362
 
330
363
  In this mode, all standard input is combined into a single (possibly
331
- large) string, with newline characters joining the lines in the string.
364
+ large and possibly multiline) string.
332
365
 
333
366
  A good example of when you would use this is when you need to parse a multiline JSON or YAML representation of an object;
334
- you need to pass the entire (probably) multiline string to the parse method.
335
- This is the mode that was used in the first `rexe` example in this article.
367
+ you need to pass all the standard input to the parse method.
368
+ This is the mode that was used in the first rexe example in this article.
336
369
 
337
370
 
338
371
  #### -mn "No Input" Executor Mode -- The Default
@@ -359,7 +392,7 @@ you can do one of the following:
359
392
 
360
393
  ### Input Formats
361
394
 
362
- `rexe` can parse your input in any of several formats if you like.
395
+ Rexe can parse your input in any of several formats if you like.
363
396
  You would request this in the _input format_ (`-i`) option.
364
397
  Legal values are:
365
398
 
@@ -389,6 +422,9 @@ Several output formats are provided for your convenience:
389
422
 
390
423
  All formats will implicitly `require` anything needed to accomplish their task (e.g. `require 'yaml'`).
391
424
 
425
+ The default is `-on` to produce no output at all (unless explicitly coded to do so). If you prefer a different
426
+ default such as `-op` for _puts_ mode, you can specify that in your `REXE_OPTIONS` environment variable.
427
+
392
428
  You may wonder why these formats are provided, given that their functionality
393
429
  could be included in the custom code instead. Here's why:
394
430
 
@@ -399,7 +435,7 @@ could be included in the custom code instead. Here's why:
399
435
 
400
436
  ### Reading Input from a File
401
437
 
402
- `rexe` also simplifies getting input from a file rather than standard input. The `-f` option takes a filespec
438
+ Rexe also simplifies getting input from a file rather than standard input. The `-f` option takes a filespec
403
439
  and does with its content exactly what it would have done with standard input. This shortens:
404
440
 
405
441
  ```
@@ -433,12 +469,21 @@ So the example we gave above:
433
469
  Another possible win for using `-f` is that since it is a command line option, it could be specified in `REXE_OPTIONS`.
434
470
  This could be useful if you are doing many operations on the same file.
435
471
 
472
+ If you need to override the input mode and format automatically configured for file input, you can simply specify
473
+ the desired options on the command line _after_ the `-f`:
474
+
475
+ ```
476
+ ➜ ~  rexe -f eur_rates.json -mb -in 'puts self.class, self[0..20]'
477
+ String
478
+ {"base":"EUR","rates"
479
+ ```
480
+
436
481
 
437
482
  ### 'self' as Default Source Code
438
483
 
439
- To make `rexe` even more concise, you do not need to specify any source code when you want that source code
440
- to be `self`. This would be the case for simple format conversions, such as the following JSON to YAML conversion
441
- of the currency coversion rates:
484
+ To make rexe even more concise, you do not need to specify any source code when you want that source code
485
+ to be `self`. This would be the case for simple format conversions, as in JSON to YAML conversion
486
+ mentioned above:
442
487
 
443
488
  ```
444
489
  ➜ ~  rexe -f eur_rates.json -oy
@@ -465,19 +510,20 @@ by accessing the `$RC` global variable, which contains an OpenStruct. Let's prin
465
510
  ➜ ~  rexe -oa '$RC'
466
511
  OpenStruct {
467
512
  :count => 0,
468
- :rexe_version => "0.13.0",
469
- :start_time => "2019-03-23T20:17:59+08:00",
513
+ :rexe_version => "1.0.0",
514
+ :start_time => "2019-04-14T19:16:26+08:00",
470
515
  :source_code => "$RC",
471
516
  :options => {
472
- :input_format => :none,
473
- :input_mode => :no_input,
474
- :loads => [],
475
- :output_format => :awesome_print,
476
- :requires => [
517
+ :input_filespec => nil,
518
+ :input_format => :none,
519
+ :input_mode => :none,
520
+ :loads => [],
521
+ :output_format => :awesome_print,
522
+ :requires => [
477
523
  [0] "awesome_print"
478
524
  ],
479
- :log_format => :none,
480
- :noop => false
525
+ :log_format => :none,
526
+ :noop => false
481
527
  }
482
528
  }
483
529
  ```
@@ -508,13 +554,13 @@ Defining methods in your loaded files enables you to effectively define a
508
554
  [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) for your command line use.
509
555
  You could use different load files for different projects, domains, or contexts,
510
556
  and define aliases or one line scripts to give them meaningful names.
511
- For example, if I wrote code to work with Ansible and put it in `~/projects/ansible-tools/rexe-ansible.rb`,
512
- I could define an alias in my startup script:
557
+ For example, if you had Ansible helper code in `~/projects/ansible-tools/rexe-ansible.rb`,
558
+ you could define an alias in your startup script:
513
559
 
514
560
  ```
515
561
  ➜ ~  alias rxans="rexe -l ~/projects/ansible-tools/rexe-ansible.rb $*"
516
562
  ```
517
- ...and then I would have an Ansible DSL available for me to use by calling `rxans`.
563
+ ...and then you would have an Ansible DSL available for me to use by calling `rxans`.
518
564
 
519
565
  In addition, since you can also call `pry` on the context of any object, you
520
566
  can provide a DSL in a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) (shell)
@@ -555,7 +601,7 @@ so calls to your custom methods _look_ like built in language commands and keywo
555
601
 
556
602
  ### Quotation Marks and Quoting Strings in Your Ruby Code
557
603
 
558
- One complication of using utilities like `rexe` where Ruby code is specified on the command line is that
604
+ One complication of using utilities like rexe where Ruby code is specified on the command line is that
559
605
  you need to be careful about the shell's special treatment of certain characters. For this reason, it is often
560
606
  necessary to quote the Ruby code. You can use single or double quotes to have the shell treat your source code
561
607
  as a single argument. An excellent reference for how they differ is on StackOverflow at
@@ -573,7 +619,7 @@ hello
573
619
  hello
574
620
  ```
575
621
 
576
- We can also use `%q` or `%Q`, and sometimes this eliminates the needs for the outer quotes:
622
+ We can also use `%q` or `%Q`, and sometimes this eliminates the needs for the outer quotes altogether:
577
623
 
578
624
  ```
579
625
  ➜ ~  rexe puts %q{hello}
@@ -606,8 +652,7 @@ We can eliminate the need for any quotes in the Ruby code using `%Q{}`:
606
652
  The time is now 2019-03-29 17:06:13 +0800
607
653
  ```
608
654
 
609
- Of course you can always escape the quotes with backslashes instead, but in my experience
610
- that becomes difficult to read.
655
+ Of course you can always escape the quotes with backslashes instead, but that is probably more difficult to read.
611
656
 
612
657
 
613
658
 
@@ -621,8 +666,8 @@ want to inspect the configuration options before executing the Ruby code.
621
666
 
622
667
  ### Mimicking Method Arguments
623
668
 
624
- You may want to support arguments in your `rexe` commands.
625
- You could do this by piping in the arguments as `rexe`'s stdin.
669
+ You may want to support arguments in your rexe commands.
670
+ It's a little kludgy, but you could do this by piping in the arguments as rexe's stdin.
626
671
 
627
672
  One of the previous examples downloaded currency conversion rates.
628
673
  To prepare for an example of how to do this, let's find out the available currency codes:
@@ -633,7 +678,7 @@ rexe -ij -mb -op "self['rates'].keys.sort.join(' ')"
633
678
  AUD BGN BRL CAD CHF CNY CZK DKK GBP HKD HRK HUF IDR ILS INR ISK JPY KRW MXN MYR NOK NZD PHP PLN RON RUB SEK SGD THB TRY USD ZAR
634
679
  ```
635
680
 
636
- The codes output are the legal arguments that could be sent to `rexe`'s stdin as an argument in the command below.
681
+ The codes output are the legal arguments that could be sent to rexe's stdin as an argument in the command below.
637
682
  Let's find out the Euro exchange rate for _PHP_, Philippine Pesos:
638
683
 
639
684
  ```
@@ -644,42 +689,42 @@ Let's find out the Euro exchange rate for _PHP_, Philippine Pesos:
644
689
  1 EUR = 58.986 PHP
645
690
  ```
646
691
 
647
- In this code, `self` is the currency code `PHP` (Philippine Peso). We have accessed the JSON text to parse from the environment variable we previously populated.
692
+ In this code, `self` is the currency code `PHP` (Philippine Peso).
693
+ We have accessed the JSON text to parse from the environment variable we previously populated.
648
694
 
649
- Because we "used up" stdin for the argument, we could not make use of automatic parsing
650
- of the currency exchange data (using the `-ij` option),
651
- which would have greatly simplified the command. One possible solution to this would be
652
- to pipe in the JSON or YAML representation of a hash
653
- with entries for both the argument and the currency exchange data...but this might
654
- make the command line too complex to be practical.
695
+ Because we "used up" stdin for the `PHP` argument, we needed to read the JSON data explicitly from
696
+ the environment variable, and that made the command more complex. A regular Ruby script would handle this more nicely.
697
+
655
698
 
656
699
  ### Using the Clipboard for Text Processing
657
700
 
658
- Sometimes when editing text I need to do some one off text manipulation.
659
- Using the system's commands for pasting to and copying from the clipboard,
660
- this can easily be done. On the Mac, we have the following commands:
701
+ For editing text in an editor,
702
+ rexe can be used for text transformations that would otherwise need to be done manually.
703
+
704
+ The system's commands for pasting to and copying from the clipboard can handle the moving of the text
705
+ between the editor and rexe. On the Mac, we have the following commands:
661
706
 
662
- * `pbcopy` - copies the content of stdin _to_ the clipboard
663
- * `pbpaste` - copies the content _from_ the clipboard to stdout
707
+ * `pbcopy` - copies the content of its stdin _to_ the clipboard
708
+ * `pbpaste` - copies the content _from_ the clipboard to its stdout
664
709
 
665
- Let's say I have the following currency codes displayed on the screen
710
+ Let's say we have the following currency codes displayed on the screen
666
711
  (data abridged for brevity):
667
712
 
668
713
  ```
669
714
  AUD BGN BRL PHP TRY USD ZAR
670
715
  ```
671
716
 
672
- ...and I want to turn them into Ruby symbols for inclusion in Ruby source code as keys in a hash
717
+ ...and we want to turn them into Ruby symbols for inclusion in Ruby source code as keys in a hash
673
718
  whose values will be the display names of the currencies, e.g "Australian Dollar").
674
719
 
675
- I could manually select that text and use system menu commands or keys to copy it to the clipboard,
676
- or I could do this:
720
+ We could manually select that text and use system menu commands or keys to copy it to the clipboard,
721
+ or we could do this:
677
722
 
678
723
  ```
679
724
  ➜ ~  echo AUD BGN BRL PHP TRY USD ZAR | pbcopy
680
725
  ```
681
726
 
682
- After copying this line to the clipboard, I could run this:
727
+ After copying this line to the clipboard, we could run this:
683
728
 
684
729
  ```
685
730
  ➜ ~  pbpaste | rexe -ml -op "split.map(&:downcase).map { |s| %Q{ #{s}: '',} }.join(%Q{\n})"
@@ -694,12 +739,12 @@ displayed in the terminal, and I could then paste it into my editor.
694
739
 
695
740
  Using the clipboard in manual operations is handy, but using it in automated scripts is a very bad idea, since
696
741
  there is only one clipboard per user session. If you use the clipboard in an automated script you risk
697
- an error situation if its content is changed by others, or, conversely, you could mess up another task
742
+ an error situation if its content is changed by another process, or, conversely, you could mess up another process
698
743
  when you change the content of the clipboard.
699
744
 
700
745
  ### Multiline Ruby Commands
701
746
 
702
- Although `rexe` is cleanest with short one liners, you may want to use it to include nontrivial Ruby code
747
+ Although rexe is cleanest with short one liners, you may want to use it to include nontrivial Ruby code
703
748
  in your shell script as well. If you do this, you may need to add trailing backslashes to the lines of Ruby code.
704
749
 
705
750
  What might not be so obvious is that you will often need to use semicolons as statement separators.
@@ -709,8 +754,7 @@ For example, here is an example without a semicolon:
709
754
  ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m} \
710
755
  puts to_a"
711
756
 
712
- /Users/kbennett/.rvm/gems/ruby-2.6.0/gems/rexe-0.10.1/exe/rexe:256:in `eval':
713
- (eval):1: syntax error, unexpected tIDENTIFIER, expecting '}' (SyntaxError)
757
+ rexe: (eval):1: syntax error, unexpected tIDENTIFIER, expecting '}'
714
758
  ...new { print %Q{\u001b[33m} puts to_a }
715
759
  ... ^~~~
716
760
  ```
@@ -776,7 +820,7 @@ and want to ignore all of them.
776
820
 
777
821
  ### Comma Separated Requires and Loads
778
822
 
779
- For consistency with the `ruby` interpreter, `rexe` supports requires with the `-r` option, but
823
+ For consistency with the `ruby` interpreter, rexe supports requires with the `-r` option, but
780
824
  also allows grouping them together using commas:
781
825
 
782
826
  ```
@@ -790,12 +834,12 @@ Files loaded with the `-l` option are treated the same way.
790
834
 
791
835
  ### Beware of Configured Requires
792
836
 
793
- Requiring gems and modules for _all_ invocations of `rexe` will make your commands simpler and more concise, but will be a waste of execution time if they are not needed. You can inspect the execution times to see just how much time is being wasted. For example, we can find out that rails takes about 0.63 seconds to load on my laptop by observing and comparing the execution times with and without the require (output has been abbreviated using `grep`):
837
+ Requiring gems and modules for _all_ invocations of rexe will make your commands simpler and more concise, but will be a waste of execution time if they are not needed. You can inspect the execution times to see just how much time is being consumed. For example, we can find out that rails takes about 0.63 seconds to load on one system by observing and comparing the execution times with and without the require (output has been abbreviated using `grep`):
794
838
 
795
839
  ```
796
- ➜ ~  rexe -gy -r rails 123 2>&1 | grep duration
840
+ ➜ ~  rexe -gy -r rails 2>&1 | grep duration
797
841
  :duration_secs: 0.660138
798
- ➜ ~  rexe -gy 123 2>&1 | grep duration
842
+ ➜ ~  rexe -gy 2>&1 | grep duration
799
843
  :duration_secs: 0.027781
800
844
  ```
801
845
  (For the above to work, the `rails` gem and its dependencies need to be installed.)
@@ -803,21 +847,55 @@ Requiring gems and modules for _all_ invocations of `rexe` will make your comman
803
847
 
804
848
  ### Operating System Support
805
849
 
806
- `rexe` has been tested successfully on Mac OS, Linux, and Windows Subsystem for Linux (WSL).
850
+ Rexe has been tested successfully on Mac OS, Linux, and Windows Subsystem for Linux (WSL).
807
851
  It is intended as a tool for the Unix shell, and, as such, no attempt is made to support
808
852
  Windows non-Unix shells.
809
853
 
810
854
 
811
855
  ### More Examples
812
856
 
813
- Here are some more examples to illustrate the use of `rexe`.
857
+ Here are some more examples to illustrate the use of rexe.
858
+
859
+ ----
860
+
861
+ #### Using Rexe as a Simple Calculator
862
+
863
+ To output the result to stdout, you can either call `puts` or specify the `-op` option:
864
+
865
+ ```
866
+ ➜ ~  rexe puts 1 / 3.0
867
+ 0.3333333333333333
868
+ ```
869
+
870
+ or:
871
+
872
+ ```
873
+ ➜ ~  rexe -op 1 / 3.0
874
+ 0.3333333333333333
875
+ ```
876
+
877
+ Since `*` is interpreted by the shell, if we do multiplication, we need to quote the expression:
878
+
879
+ ```
880
+ ➜ ~  rexe -op '2 * 7'
881
+ 14
882
+ ```
883
+
884
+ Of course, if you put the `-op` in the `REXE_OPTIONS` environment variable,
885
+ you don't need to be explicit about the output:
886
+
887
+ ```
888
+ ➜ ~  export REXE_OPTIONS=-op
889
+ ➜ ~  rexe '2 * 7'
890
+ 14
891
+ ```
814
892
 
815
893
  ----
816
894
 
817
895
 
818
896
  #### Outputting ENV
819
897
 
820
- Output the contents of `ENV` using AwesomePrint [see footnote ^3]:
898
+ Output the contents of `ENV` using AwesomePrint [see footnote ^4 regarding ENV.to_s]:
821
899
 
822
900
  ```
823
901
  ➜ ~  rexe -oa ENV
@@ -864,6 +942,9 @@ alphabetically will result in sorting them numerically as well.
864
942
 
865
943
  #### Print yellow (trust me!):
866
944
 
945
+ This uses an [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code)
946
+ to output text to the terminal in yellow:
947
+
867
948
  ```
868
949
  ➜ ~  cowsay hello | rexe -me "print %Q{\u001b[33m}; puts to_a"
869
950
  ➜ ~  # or
@@ -889,7 +970,7 @@ Let's take the YouTube example from the "Loading Files" section further.
889
970
  Let's have the video that loads be different for the success or failure
890
971
  of the command.
891
972
 
892
- If I put this in a load file (such as ~/.rexerc):
973
+ If we put this in a load file (such as ~/.rexerc):
893
974
 
894
975
  ```
895
976
  def play(piece_code)
@@ -909,14 +990,14 @@ end
909
990
 
910
991
 
911
992
  # Must pipe the exit code into this Ruby process,
912
- # e.g. using `echo $? | rexe play_result_by_exit_code
993
+ # e.g. using `echo $? | rexe play_result_by_exit_code`
913
994
  def play_result_by_exit_code
914
995
  play_result(STDIN.read.chomp == '0')
915
996
  end
916
997
 
917
998
  ```
918
999
 
919
- Then when I issue a command that succeeds, the Hallelujah Chorus is played:
1000
+ Then when we issue a command that succeeds, the Hallelujah Chorus is played [see footnote ^2]:
920
1001
 
921
1002
  ```
922
1003
  ➜ ~  uname; echo $? | rexe play_result_by_exit_code
@@ -962,6 +1043,35 @@ copying the original text to the clipboard:
962
1043
  ```
963
1044
 
964
1045
 
1046
+ ----
1047
+
1048
+ #### Currency Conversion
1049
+
1050
+ I travel a lot, and when I visit a country for the first time I often get confused by the exchange rate.
1051
+ I put this in my `~/.rexerc`:
1052
+
1053
+ ```
1054
+ # Conversion rate to US Dollars
1055
+ module Curr
1056
+ module_function
1057
+ def myr; 4.08 end # Malaysian Ringits
1058
+ def thb; 31.72 end # Thai Baht
1059
+ def usd; 1.00 end # US Dollars
1060
+ def vnd; 23199.50 end # Vietnamese Dong
1061
+ end
1062
+ ```
1063
+
1064
+ If I'm lucky enough to be at my computer when I need to do a conversion,
1065
+ for example, to find the value of 150 Malaysian ringits in US dollars, I can do this:
1066
+
1067
+ ```
1068
+ ➜ rexe git:(master) ✗  rexe puts 150 / Curr.myr
1069
+ 36.76470588235294
1070
+ ```
1071
+
1072
+ Obviously rates will change over time, but this will give me a general idea, which is usually all I need.
1073
+
1074
+
965
1075
  ----
966
1076
 
967
1077
  #### Reformatting Grep Output
@@ -983,13 +1093,13 @@ So this is what worked well for me:
983
1093
 
984
1094
  ```
985
1095
  ➜ ~  grep Struct **/*.rb | grep -v OpenStruct | rexe -ml -op \
986
- "a = \
987
- gsub('lib/rock_books/', '')\
988
- .gsub('< Struct.new', '')\
989
- .gsub('; end', '')\
990
- .split('.rb:')\
991
- .map(&:strip);\
992
- \
1096
+ "a = \
1097
+ gsub('lib/rock_books/', '') \
1098
+ .gsub('< Struct.new', '') \
1099
+ .gsub('; end', '') \
1100
+ .split('.rb:') \
1101
+ .map(&:strip); \
1102
+ \
993
1103
  %q{%-40s %-s} % [a[0] + %q{.rb}, a[1]]"
994
1104
  ```
995
1105
 
@@ -1024,23 +1134,23 @@ straightforward to follow. Here's what it does:
1024
1134
 
1025
1135
  ### Conclusion
1026
1136
 
1027
- `rexe` is not revolutionary technology, it's just plumbing that removes parsing,
1137
+ Rexe is not revolutionary technology, it's just plumbing that removes parsing,
1028
1138
  formatting, and low level
1029
1139
  configuration from your command line so that you can focus on the high level
1030
1140
  task at hand.
1031
1141
 
1032
1142
  When we consider a new piece of software, we usually think "what would this be
1033
- helpful with now?". However, for me, the power of `rexe` is not so much what I can do
1143
+ helpful with now?". However, for me, the power of rexe is not so much what I can do
1034
1144
  with it in a single use case now, but rather what will I be able to do over time
1035
1145
  as I accumulate more experience and expertise with it.
1036
1146
 
1037
- I suggest starting to use `rexe` even for modest improvements in workflow, even
1147
+ I suggest starting to use rexe even for modest improvements in workflow, even
1038
1148
  if it doesn't seem compelling. There's a good chance that as you use it over
1039
1149
  time, new ideas will come to you and the workflow improvements will increase
1040
1150
  exponentially.
1041
1151
 
1042
1152
  A word of caution though --
1043
- the complexity and difficulty of _sharing_ your `rexe` scripts across systems
1153
+ the complexity and difficulty of _sharing_ your rexe scripts across systems
1044
1154
  will be proportional to the extent to which you use environment variables
1045
1155
  and loaded files for configuration and shared code.
1046
1156
  Be responsible and disciplined in making this configuration and code as clean and organized as possible.
@@ -1049,11 +1159,17 @@ Be responsible and disciplined in making this configuration and code as clean an
1049
1159
 
1050
1160
  #### Footnotes
1051
1161
 
1052
- [^1]: `rexe` is an embellishment of the minimal but excellent `rb` script at
1162
+ [^1]: Rexe is an embellishment of the minimal but excellent `rb` script at
1053
1163
  https://github.com/thisredone/rb. I started using `rb` and thought of lots of
1054
- other features I would like to have, so I started working on `rexe`.
1164
+ other features I would like to have, so I started working on rexe.
1055
1165
 
1056
- [^2]: Making this truly OS-portable is a lot more complex than it looks on the surface.
1166
+ [^2]: It's possible that when this page opens in your browser it will not play automatically.
1167
+ You may need to change your default browser, or change the code that opens the URL.
1168
+ Firefox's new (as of March 2019) version 66 suppresses autoplay; you can register
1169
+ exceptions to this policy: open Firefox Preferences, search for "autoplay" and add
1170
+ "https://www.youtube.com".
1171
+
1172
+ [^3]: Making this truly OS-portable is a lot more complex than it looks on the surface.
1057
1173
  On Linux, `xdg-open` may not be installed by default. Also, Windows Subsystem for Linux (WSL)
1058
1174
  out of the box is not able to launch graphical applications.
1059
1175
 
@@ -1074,7 +1190,4 @@ Here is a _start_ at a method that opens a resource portably across operating sy
1074
1190
  end
1075
1191
  ```
1076
1192
 
1077
- [^3]: It is an interesting quirk of the Ruby language that `ENV.to_s` returns `"ENV"` and not the contents of the `ENV` object. As a result, many of the other output formats will also return some form of `"ENV"`. You can handle this by specifying `ENV.to_h`.
1078
-
1079
- - Keith Bennett (@keithrbennett on Github and Twitter)
1080
-
1193
+ [^4]: It is an interesting quirk of the Ruby language that `ENV.to_s` returns `"ENV"` and not the contents of the `ENV` object. As a result, many of the other output formats will also return some form of `"ENV"`. You can handle this by specifying `ENV.to_h`.
data/exe/rexe CHANGED
@@ -12,16 +12,24 @@ require 'shellwords'
12
12
 
13
13
  class Rexe
14
14
 
15
- VERSION = '0.15.1'
15
+ VERSION = '1.0.0'
16
16
 
17
17
  PROJECT_URL = 'https://github.com/keithrbennett/rexe'
18
18
 
19
19
 
20
20
  module Helpers
21
- def error_exit(message)
22
- $stderr.puts(message)
23
- $stderr.puts("Use the -h option to get help.")
24
- exit(-1)
21
+
22
+ # Try executing code. If error raised, print message (but not stack trace) & exit -1.
23
+ def try
24
+ begin
25
+ yield
26
+ rescue Exception => e
27
+ unless e.class == SystemExit
28
+ $stderr.puts('rexe: ' << e.class.to_s)
29
+ $stderr.puts("Use the -h option to get help.")
30
+ exit(-1)
31
+ end
32
+ end
25
33
  end
26
34
  end
27
35
 
@@ -82,10 +90,10 @@ class Rexe
82
90
 
83
91
  def input_parsers
84
92
  @input_parsers ||= {
85
- json: ->(obj) { JSON.parse(obj) },
86
- marshal: ->(obj) { Marshal.load(obj) },
87
- none: ->(obj) { obj },
88
- yaml: ->(obj) { YAML.load(obj) },
93
+ json: ->(string) { JSON.parse(string) },
94
+ marshal: ->(string) { Marshal.load(string) },
95
+ none: ->(string) { string },
96
+ yaml: ->(string) { YAML.load(string) },
89
97
  }
90
98
  end
91
99
 
@@ -108,7 +116,7 @@ class Rexe
108
116
 
109
117
  def formatters
110
118
  @formatters ||= {
111
- awesome_print: ->(obj) { obj.ai },
119
+ awesome_print: ->(obj) { obj.ai << "\n" },
112
120
  inspect: ->(obj) { obj.inspect + "\n" },
113
121
  json: ->(obj) { obj.to_json },
114
122
  marshal: ->(obj) { Marshal.dump(obj) },
@@ -121,6 +129,7 @@ class Rexe
121
129
  }
122
130
  end
123
131
 
132
+
124
133
  def format_requires
125
134
  @format_requires ||= {
126
135
  json: 'json',
@@ -156,14 +165,14 @@ class Rexe
156
165
  end
157
166
 
158
167
 
159
- def add_format_requires_to_requires_list
168
+ private def add_format_requires_to_requires_list
160
169
  formats = [options.input_format, options.output_format, options.log_format]
161
170
  requires = formats.map { |format| lookups.format_requires[format] }.uniq.compact
162
171
  requires.each { |r| options.requires << r }
163
172
  end
164
173
 
165
174
 
166
- def help_text
175
+ private def help_text
167
176
  <<~HEREDOC
168
177
 
169
178
  rexe -- Ruby Command Line Executor/Filter -- v#{VERSION} -- #{PROJECT_URL}
@@ -171,7 +180,7 @@ class Rexe
171
180
  Executes Ruby code on the command line, optionally automating management of standard input
172
181
  and standard output, and optionally parsing input and formatting output with YAML, JSON, etc.
173
182
 
174
- rexe [options] 'Ruby source code'
183
+ rexe [options] [Ruby source code]
175
184
 
176
185
  Options:
177
186
 
@@ -206,21 +215,26 @@ class Rexe
206
215
  -r, --require REQUIRE(S) Gems and built-in libraries to require, comma separated;
207
216
  ! to clear all, or precede a name with '-' to remove
208
217
 
209
- If source code is not specified, it will default to 'self', which is most likely useful
210
- only in a filter mode (-ml, -me, -mb).
218
+ ---------------------------------------------------------------------------------------
219
+
220
+ In many cases you will need to enclose your source code in single or double quotes.
221
+
222
+ If source code is not specified, it will default to 'self',
223
+ which is most likely useful only in a filter mode (-ml, -me, -mb).
211
224
 
212
225
  If there is an .rexerc file in your home directory, it will be run as Ruby code
213
226
  before processing the input.
214
227
 
215
- If there is a REXE_OPTIONS environment variable, its content will be prepended to the command line
216
- so that you can specify options implicitly (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
228
+ If there is a REXE_OPTIONS environment variable, its content will be prepended
229
+ to the command line so that you can specify options implicitly
230
+ (e.g. `export REXE_OPTIONS="-r awesome_print,yaml"`)
217
231
 
218
232
  HEREDOC
219
233
  end
220
234
 
221
235
 
222
236
  # File file input mode; detects the input mode (JSON, YAML, or None) from the extension.
223
- def autodetect_file_format(filespec)
237
+ private def autodetect_file_format(filespec)
224
238
  extension = File.extname(filespec).downcase
225
239
  if extension == '.json'
226
240
  :json
@@ -232,7 +246,7 @@ class Rexe
232
246
  end
233
247
 
234
248
 
235
- def open_resource(resource_identifier)
249
+ private def open_resource(resource_identifier)
236
250
  command = case (`uname`.chomp)
237
251
  when 'Darwin'
238
252
  'open'
@@ -258,7 +272,7 @@ class Rexe
258
272
  parser.on('-f', '--input_file FILESPEC',
259
273
  'Use this file instead of stdin; autodetects YAML and JSON file extensions') do |v|
260
274
  unless File.exist?(v)
261
- error_exit "File #{v} does not exist."
275
+ raise "File #{v} does not exist."
262
276
  end
263
277
  options.input_filespec = v
264
278
  options.input_format = autodetect_file_format(v)
@@ -270,7 +284,7 @@ class Rexe
270
284
  parser.on('-g', '--log_format FORMAT', 'Log format, logs to stderr, defaults to none (see -o for format options)') do |v|
271
285
  options.log_format = lookups.output_formats[v]
272
286
  if options.log_format.nil?
273
- error_exit("Output mode was '#{v}' but must be one of #{lookups.output_formats.keys}.")
287
+ raise("Output mode was '#{v}' but must be one of #{lookups.output_formats.keys}.")
274
288
  end
275
289
  end
276
290
 
@@ -284,7 +298,7 @@ class Rexe
284
298
 
285
299
  options.input_format = lookups.input_formats[v]
286
300
  if options.input_format.nil?
287
- error_exit("Input mode was '#{v}' but must be one of #{lookups.input_formats.keys}.")
301
+ raise("Input mode was '#{v}' but must be one of #{lookups.input_formats.keys}.")
288
302
  end
289
303
  end
290
304
 
@@ -297,7 +311,7 @@ class Rexe
297
311
 
298
312
  existent, nonexistent = adds.partition { |filespec| File.exists?(filespec) }
299
313
  if nonexistent.any?
300
- error_exit("\nDid not find the following files to load: #{nonexistent}\n\n")
314
+ raise("\nDid not find the following files to load: #{nonexistent}\n\n")
301
315
  else
302
316
  existent.each { |filespec| options.loads << filespec }
303
317
  end
@@ -311,7 +325,7 @@ class Rexe
311
325
 
312
326
  options.input_mode = lookups.input_modes[v]
313
327
  if options.input_mode.nil?
314
- error_exit("Input mode was '#{v}' but must be one of #{lookups.input_modes.keys}.")
328
+ raise("Input mode was '#{v}' but must be one of #{lookups.input_modes.keys}.")
315
329
  end
316
330
  end
317
331
 
@@ -320,7 +334,7 @@ class Rexe
320
334
 
321
335
  options.output_format = lookups.output_formats[v]
322
336
  if options.output_format.nil?
323
- error_exit("Output mode was '#{v}' but must be one of #{lookups.output_formats.keys}.")
337
+ raise("Output mode was '#{v}' but must be one of #{lookups.output_formats.keys}.")
324
338
  end
325
339
  end
326
340
 
@@ -353,7 +367,7 @@ class Rexe
353
367
 
354
368
  parser.on('-v', '--version', 'Print version') do
355
369
  puts VERSION
356
- exit
370
+ exit(0)
357
371
  end
358
372
 
359
373
  # Undocumented feature
@@ -484,24 +498,27 @@ class Rexe
484
498
  # This class' entry point.
485
499
  def call
486
500
 
487
- @options = CommandLineParser.new.parse
501
+ try do
488
502
 
489
- options.requires.each { |r| require!(r) }
490
- load_global_config_if_exists
491
- options.loads.each { |file| load(file) }
503
+ @options = CommandLineParser.new.parse
492
504
 
493
- @user_source_code = ARGV.join(' ')
494
- @user_source_code = 'self' if @user_source_code == ''
505
+ options.requires.each { |r| require!(r) }
506
+ load_global_config_if_exists
507
+ options.loads.each { |file| load(file) }
495
508
 
496
- @callable = create_callable
509
+ @user_source_code = ARGV.join(' ')
510
+ @user_source_code = 'self' if @user_source_code == ''
497
511
 
498
- init_rexe_context
499
- init_parser_and_formatters
512
+ @callable = create_callable
500
513
 
501
- # This is where the user's source code will be executed; the action will in turn call `execute`.
502
- lookup_action(options.input_mode).call unless options.noop
514
+ init_rexe_context
515
+ init_parser_and_formatters
503
516
 
504
- output_log_entry
517
+ # This is where the user's source code will be executed; the action will in turn call `execute`.
518
+ lookup_action(options.input_mode).call unless options.noop
519
+
520
+ output_log_entry
521
+ end
505
522
  end
506
523
  end
507
524
  end
@@ -45,18 +45,4 @@ Gem::Specification.new do |spec|
45
45
  spec.add_development_dependency "rake", "~> 12.3"
46
46
  spec.add_development_dependency "rspec", "~> 3.0"
47
47
 
48
- spec.post_install_message =
49
- <<~HEREDOC
50
-
51
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
52
-
53
- WARNING!
54
-
55
- The default output format has been changed from -op (:puts) to -on (:none)
56
- in version 0.14.0.
57
-
58
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
59
-
60
- HEREDOC
61
-
62
48
  end
@@ -0,0 +1,38 @@
1
+ {
2
+ "base": "EUR",
3
+ "rates": {
4
+ "BGN": 1.9558,
5
+ "NZD": 1.6748,
6
+ "ILS": 4.0389,
7
+ "RUB": 72.6133,
8
+ "CAD": 1.5082,
9
+ "USD": 1.1321,
10
+ "PHP": 58.553,
11
+ "CHF": 1.1326,
12
+ "ZAR": 15.7631,
13
+ "AUD": 1.5771,
14
+ "JPY": 126.76,
15
+ "TRY": 6.535,
16
+ "HKD": 8.8788,
17
+ "MYR": 4.658,
18
+ "THB": 35.955,
19
+ "HRK": 7.435,
20
+ "NOK": 9.602,
21
+ "IDR": 15954.12,
22
+ "DKK": 7.4643,
23
+ "CZK": 25.623,
24
+ "HUF": 321.9,
25
+ "GBP": 0.8629,
26
+ "MXN": 21.236,
27
+ "KRW": 1283.0,
28
+ "ISK": 135.2,
29
+ "SGD": 1.5318,
30
+ "BRL": 4.3884,
31
+ "PLN": 4.2796,
32
+ "INR": 78.2915,
33
+ "RON": 4.7598,
34
+ "CNY": 7.5939,
35
+ "SEK": 10.4788
36
+ },
37
+ "date": "2019-04-12"
38
+ }
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.15.1
4
+ version: 1.0.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-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - exe/rexe
102
102
  - rexe.gemspec
103
+ - sample-data/eur_rates.json
103
104
  homepage: https://github.com/keithrbennett/rexe
104
105
  licenses:
105
106
  - MIT
@@ -108,17 +109,7 @@ metadata:
108
109
  homepage_uri: https://github.com/keithrbennett/rexe
109
110
  source_code_uri: https://github.com/keithrbennett/rexe
110
111
  changelog_uri: https://github.com/keithrbennett/rexe/blob/master/README.md
111
- post_install_message: |2+
112
-
113
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
114
-
115
- WARNING!
116
-
117
- The default output format has been changed from -op (:puts) to -on (:none)
118
- in version 0.14.0.
119
-
120
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
121
-
112
+ post_install_message:
122
113
  rdoc_options: []
123
114
  require_paths:
124
115
  - lib