mdhost 0.2 → 0.3

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/VERSION +1 -1
  4. data/lib/mdhost.rb +25 -15
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5777cc6b150eb2b2d4fd99a8aa09b92d213b1c256bbebe84cb2e518f70c9a557
4
- data.tar.gz: 749f2a4656b9ab982676021c0a023172353244eda49923b5b51de42c197556f5
3
+ metadata.gz: dbad6d4cf0eee94afaf0fb0d3b4b4de4daaefce726b93d6286f7d53b078c4d23
4
+ data.tar.gz: 2b2c6e7f473c8dc01e786ef247d44ab49b73e9bfc0d17d6ad420c5e5735ad8b9
5
5
  SHA512:
6
- metadata.gz: 02f255490e30db071012c1a29ab94d10cb252396d5b5d64f064ffed44666263b80e0625fbe2c709399f10f450832a1a51a63e192205e5bba99190a5e522d4651
7
- data.tar.gz: b7bbb2a5feaae8386e8d85d423177d21fe7ee4700f63e747f3cab772811a8063decdf4e8adf4e1a577ab83bc354de3cc93a2e2b2a1245e4cd6d92d11e68b76cb
6
+ metadata.gz: d8db2ff43540427438950d1b1b3a1977b1774f86e44a9bad1cd1336d742dd44dd7c02de0d560a267e06e436ff9e5b02aaa4764467c9b71634d740f4b71cc15ec
7
+ data.tar.gz: 2a98c530ee577254a2e9c59f67e64e898fbbd258e3478a4519c19584ba2d77eb98e828c3037769063bee90a8a07b204bfdb0b85eb5771628ae0d21fca3e28c27
data/.rubocop.yml CHANGED
@@ -29,6 +29,10 @@ Layout/SpaceAroundEqualsInParameterDefault:
29
29
  Layout/TrailingWhitespace:
30
30
  AllowInHeredoc: false
31
31
 
32
+ Lint/InterpolationCheck:
33
+ Exclude:
34
+ - lib/mdhost.rb
35
+
32
36
  Lint/NonDeterministicRequireOrder:
33
37
  Enabled: false
34
38
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2
1
+ 0.3
data/lib/mdhost.rb CHANGED
@@ -25,18 +25,25 @@ module MDHost
25
25
  BANNER
26
26
 
27
27
  opt :format, "Format string to compose multiple inputs into", type: :string
28
+ opt :table_format, 'Format string to use for the table "Input" column', type: :string
28
29
 
29
30
  educate_on_error
30
31
  end
31
32
 
32
33
  if ARGV.empty?
33
- Optimist::educate
34
+ Optimist.educate
34
35
  end
35
36
  end
36
37
 
37
38
  def run
38
- if (@format_string = @options.format)
39
- Optimist::educate unless @format_string.include?(FORMAT_SPECIFIER)
39
+ @format_string = @options.format
40
+
41
+ if !@format_string && ARGV.length > 1
42
+ @format_string = FORMAT_SPECIFIER
43
+ end
44
+
45
+ if @format_string
46
+ Optimist.educate unless @format_string.include?(FORMAT_SPECIFIER)
40
47
  run_format
41
48
  else
42
49
  @input = ARGV.first
@@ -81,9 +88,6 @@ module MDHost
81
88
  display_table @input
82
89
 
83
90
  escaped_input = escape_input @input
84
-
85
- result = `eshost -e #{escaped_input}`.split(/\n+/)
86
-
87
91
  table = results_for escaped_input
88
92
 
89
93
  # We don't *need* to pretty format the table so precisely, but why not?
@@ -108,24 +112,30 @@ module MDHost
108
112
  Clipboard.copy(output)
109
113
  end
110
114
 
111
- def run_format
112
- inputs = ARGV.map { |s| @format_string.sub(FORMAT_SPECIFIER, s) }
113
- inputs.each do |input|
114
- puts input
115
- display_table input
116
- end
115
+ def format(format_string, input)
116
+ format_string.sub(FORMAT_SPECIFIER, input)
117
+ end
117
118
 
119
+ def run_format
118
120
  output = +<<~TABLE
119
121
  |Input|JavaScriptCore|SpiderMonkey|V8
120
122
  |-----|--------------|------------|--
121
123
  TABLE
122
124
 
123
- inputs.each do |input|
124
- escaped_input = escape_input input
125
+ ARGV.each do |input|
126
+ formatted_input = format(@format_string, input)
127
+
128
+ puts formatted_input
129
+ display_table formatted_input
130
+
131
+ escaped_input = escape_input formatted_input
125
132
  results = results_for escaped_input
126
133
 
134
+ display_input = @options.table_format ? format(@options.table_format, input)
135
+ : formatted_input
136
+
127
137
  output << <<~ROW
128
- |`#{input}`|#{results[:JavaScriptCore]}|#{results[:SpiderMonkey]}|#{results[:V8]}
138
+ |`#{display_input}`|#{results[:JavaScriptCore]}|#{results[:SpiderMonkey]}|#{results[:V8]}
129
139
  ROW
130
140
  end
131
141
 
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.2'
4
+ version: '0.3'
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-24 00:00:00.000000000 Z
11
+ date: 2023-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard