mdhost 0.4 → 0.4.1

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: 3a8134394649ff658a0481ef6c3e320f778e560154f4d07e873c3f56d28b1f77
4
- data.tar.gz: 40438e7e07e3de5b341c05ee553f14d554329a51c8f688b2326ea63dabb4935d
3
+ metadata.gz: 62280fb528dd0907b39a1031ff4f42d63d18502897c22df0a95702d9a09760df
4
+ data.tar.gz: 53793a87bdca36b8aec9680b5bf4365072d3d291641de33452881cd37ab513ac
5
5
  SHA512:
6
- metadata.gz: 60b49b4c61d662da9335cfd1413b7aedd99e90f624ae0424d99444f0e1a1acea3bf336d660c54fd3237cc9ba20c2b37ddfe98783df63c83a5baf2ac63e3a47da
7
- data.tar.gz: 3c8ecc633e616d5c1863e2a3dceaac95a53c5a270fb51b3c13d8e9af65c29c6b9c9e138eb04da04e1b2834c577df9f55417a66f8fee68232632c2c3cbc2ec48a
6
+ metadata.gz: d047182f45d558bf47f6c91ae9214ebf3a9780390889fc6feefa4bc03afbeb9aec286154c6cdde1297de282fe1c20574498470bd1cefcf0360809e0e3fca0d0d
7
+ data.tar.gz: 38a81dc6b74c659ba06eb11a9d512dee04e7d8b9327b6d913505031cb985af207f0a34eb176f972c79188aba05b83602d7253dedfa8b87591854a8b9f75ff331
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ require:
2
+ - rubocop-rspec
3
+
1
4
  AllCops:
2
5
  NewCops: enable
3
6
  TargetRubyVersion: 3.2
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.4
1
+ 0.4.1
data/lib/mdhost.rb CHANGED
@@ -66,11 +66,11 @@ module MDHost
66
66
  end
67
67
 
68
68
  def display_table(input)
69
- system("eshost", "-h", "JavaScriptCore,SpiderMonkey,V8", "-te", input)
69
+ system("eshost", "-g", "jsc,jsshell,d8", "-te", input)
70
70
  end
71
71
 
72
72
  def results_for(escaped_input)
73
- result = `eshost -e #{escaped_input}`.split(/\n+/)
73
+ result = `eshost -g jsc,jsshell,d8 -e #{escaped_input}`.split(/\n+/)
74
74
 
75
75
  # We can't just #each_slice by 2, because sometimes an engine acts up and
76
76
  # produces no output, which would mess up the grouping. So, we need to
@@ -78,8 +78,12 @@ module MDHost
78
78
  # line as the result.
79
79
  table = {}
80
80
  result.each_with_index do |line, i|
81
- if %w[JavaScriptCore SpiderMonkey V8].any? { |e| line.end_with? e }
82
- table[line.match(/\w+/).to_s.to_sym] = result[i + 1]
81
+ engine_name = %w[JavaScriptCore SpiderMonkey V8].find do |engine|
82
+ line.downcase.end_with?(engine.downcase)
83
+ end
84
+
85
+ if engine_name
86
+ table[engine_name.to_sym] = result[i + 1]
83
87
  end
84
88
  end
85
89
 
data/mdhost.gemspec CHANGED
@@ -22,5 +22,8 @@ Gem::Specification.new do |gem|
22
22
  gem.add_dependency "clipboard", "~> 1.1"
23
23
  gem.add_dependency "optimist", "~> 3.1"
24
24
 
25
+ gem.add_development_dependency "fuubar", "~> 2.0"
26
+ gem.add_development_dependency "rspec", "~> 3.12"
25
27
  gem.add_development_dependency "rubocop", "~> 1.54"
28
+ gem.add_development_dependency "rubocop-rspec", "~> 2.22"
26
29
  end
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'
4
+ version: 0.4.1
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-25 00:00:00.000000000 Z
11
+ date: 2023-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fuubar
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rubocop
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +80,20 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '1.54'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.22'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.22'
55
97
  description: Runs eshost in table mode, copying a Markdown version of the table to
56
98
  your clipboard.
57
99
  email: vinny.diehl@gmail.com