mdhost 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +85 -0
- data/VERSION +1 -1
- data/lib/mdhost.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46252ce5e38effe36d8920e2737cedf6fcb53bd3536d3b9d60c4696e1c2cd8f2
|
4
|
+
data.tar.gz: ab71ddc064792091175d0fe2160bf49d84ba6790ab1c9e4ad3834cc580969b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 460436997058ddbbee346cc12156cec627dd965121e219d46537791d5fe89ccaca5a9b03a00cb397207fada340591dc975345b3ae813fa7b0e9c077cdcf1ef99
|
7
|
+
data.tar.gz: 757a7c9ae0e18b9a71c0f0b4383dfe88525c1833d8fbf7c6960ee9e088aee5b0fc2380fb8d0f0c0d65fc9a66c0c0ce567bbc9f04137b6a04171d6e10d4c9a7f3
|
data/README.md
CHANGED
@@ -3,3 +3,88 @@
|
|
3
3
|
Runs `eshost`, displays the table output in the terminal, and generates a
|
4
4
|
Markdown table of a few of the results (JavaScriptCore, SpiderMonkey, and V8),
|
5
5
|
copying it to your clipboard.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install via [RubyGems](https://rubygems.org/gems/mdhost):
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install mdhost
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### Single input
|
18
|
+
|
19
|
+
Given a single input, `mdhost` will output the table from `eshost -t` to your
|
20
|
+
terminal, and will copy to your clipboard a markdown code block containing the
|
21
|
+
relevant `eshost` command, followed by a markdown table of the results. For
|
22
|
+
example, running this:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
mdhost 'Date.parse("0")'
|
26
|
+
```
|
27
|
+
|
28
|
+
Will output the following markdown to your clipboard:
|
29
|
+
|
30
|
+
```
|
31
|
+
> eshost -te 'Date.parse("0")'
|
32
|
+
```
|
33
|
+
|Engine |Result |
|
34
|
+
|--------------|---------------|
|
35
|
+
|JavaScriptCore|-62167219200000|
|
36
|
+
|SpiderMonkey |NaN |
|
37
|
+
|V8 |946710000000 |
|
38
|
+
|
39
|
+
### Multiple inputs
|
40
|
+
|
41
|
+
You can have multiple unrelated inputs at once, and a more complex table will
|
42
|
+
be generated. For example, running this:
|
43
|
+
|
44
|
+
```sh
|
45
|
+
mdhost '"hello"' "42"
|
46
|
+
```
|
47
|
+
|
48
|
+
Will output the following markdown to your clipboard:
|
49
|
+
|
50
|
+
|Input|JavaScriptCore|SpiderMonkey|V8
|
51
|
+
|---|---|---|---
|
52
|
+
|`"hello"`|hello|hello|hello
|
53
|
+
|`42`|42|42|42
|
54
|
+
|
55
|
+
### Format inputs
|
56
|
+
|
57
|
+
If you have multiple similar inputs, for example arguments to a function, you
|
58
|
+
can format them into a string passed into the `--format` or `-f` parameter. The
|
59
|
+
substring `#{}` in the format string will be replaced by each of the multiple
|
60
|
+
arguments that follow and arranged into a table. For example, running this:
|
61
|
+
|
62
|
+
```sh
|
63
|
+
mdhost -f 'Date.parse("#{}")' "1970-01-01" "Thu 1970-01-01" "Thu Jan.01.1970"
|
64
|
+
```
|
65
|
+
|
66
|
+
Will output the following markdown to your clipboard:
|
67
|
+
|
68
|
+
|Input|JavaScriptCore|SpiderMonkey|V8
|
69
|
+
|---|---|---|---
|
70
|
+
|`Date.parse("1970-01-01")`|0|0|0
|
71
|
+
|`Date.parse("Thu 1970-01-01")`|NaN|25200000|25200000
|
72
|
+
|`Date.parse("Thu Jan.01.1970")`|NaN|25200000|25200000
|
73
|
+
|
74
|
+
You can also use the `--table-format` or `-t` parameter to specify a different
|
75
|
+
format string for the "Input" column of the table. For example, if you wanted
|
76
|
+
the inputs to the function in the previous example to simply be displayed
|
77
|
+
surrounded by quotation marks, you could run:
|
78
|
+
|
79
|
+
```sh
|
80
|
+
mdhost -f 'Date.parse("#{}")' -t '"#{}"' "1970-01-01" "Thu 1970-01-01" "Thu Jan.01.1970"
|
81
|
+
Date.parse("1970-01-01")
|
82
|
+
```
|
83
|
+
|
84
|
+
And the following markdown would be output to your clipboard:
|
85
|
+
|
86
|
+
|Input|JavaScriptCore|SpiderMonkey|V8
|
87
|
+
|---|---|---|---
|
88
|
+
|`"1970-01-01"`|0|0|0
|
89
|
+
|`"Thu 1970-01-01"`|NaN|25200000|25200000
|
90
|
+
|`"Thu Jan.01.1970"`|NaN|25200000|25200000
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5
|
data/lib/mdhost.rb
CHANGED
@@ -24,6 +24,7 @@ module MDHost
|
|
24
24
|
Options:
|
25
25
|
BANNER
|
26
26
|
|
27
|
+
opt :execute, "Execute the input using `eshost -x`", short: :x
|
27
28
|
opt :format, "Format string to compose multiple inputs into", type: :string
|
28
29
|
opt :table_format, 'Format string to use for the table "Input" column', type: :string
|
29
30
|
|
@@ -38,6 +39,7 @@ module MDHost
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def run
|
42
|
+
@eshost_mode = @options.execute ? "x" : "e"
|
41
43
|
@format_string = @options.format
|
42
44
|
|
43
45
|
if !@format_string && ARGV.length > 1
|
@@ -66,11 +68,11 @@ module MDHost
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def display_table(input)
|
69
|
-
system("eshost", "-
|
71
|
+
system("eshost", "-g", "jsc,jsshell,d8", "-t#{@eshost_mode}", input)
|
70
72
|
end
|
71
73
|
|
72
74
|
def results_for(escaped_input)
|
73
|
-
result = `eshost -
|
75
|
+
result = `eshost -g jsc,jsshell,d8 -#{@eshost_mode} #{escaped_input}`.split(/\n+/)
|
74
76
|
|
75
77
|
# We can't just #each_slice by 2, because sometimes an engine acts up and
|
76
78
|
# produces no output, which would mess up the grouping. So, we need to
|
@@ -78,8 +80,12 @@ module MDHost
|
|
78
80
|
# line as the result.
|
79
81
|
table = {}
|
80
82
|
result.each_with_index do |line, i|
|
81
|
-
|
82
|
-
|
83
|
+
engine_name = %w[JavaScriptCore SpiderMonkey V8].find do |engine|
|
84
|
+
line.downcase.end_with?(engine.downcase)
|
85
|
+
end
|
86
|
+
|
87
|
+
if engine_name
|
88
|
+
table[engine_name.to_sym] = result[i + 1]
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
@@ -104,7 +110,7 @@ module MDHost
|
|
104
110
|
|
105
111
|
output = <<~EOS
|
106
112
|
```
|
107
|
-
> eshost -
|
113
|
+
> eshost -t#{@eshost_mode} #{escaped_input}
|
108
114
|
```
|
109
115
|
|Engine#{' ' * (engine_length - 6)}|Result#{' ' * (result_length - 6)}|
|
110
116
|
|#{'-' * engine_length}|#{'-' * result_length}|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdhost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinny Diehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|