mdhost 0.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
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 +30 -18
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5777cc6b150eb2b2d4fd99a8aa09b92d213b1c256bbebe84cb2e518f70c9a557
4
- data.tar.gz: 749f2a4656b9ab982676021c0a023172353244eda49923b5b51de42c197556f5
3
+ metadata.gz: 3a8134394649ff658a0481ef6c3e320f778e560154f4d07e873c3f56d28b1f77
4
+ data.tar.gz: 40438e7e07e3de5b341c05ee553f14d554329a51c8f688b2326ea63dabb4935d
5
5
  SHA512:
6
- metadata.gz: 02f255490e30db071012c1a29ab94d10cb252396d5b5d64f064ffed44666263b80e0625fbe2c709399f10f450832a1a51a63e192205e5bba99190a5e522d4651
7
- data.tar.gz: b7bbb2a5feaae8386e8d85d423177d21fe7ee4700f63e747f3cab772811a8063decdf4e8adf4e1a577ab83bc354de3cc93a2e2b2a1245e4cd6d92d11e68b76cb
6
+ metadata.gz: 60b49b4c61d662da9335cfd1413b7aedd99e90f624ae0424d99444f0e1a1acea3bf336d660c54fd3237cc9ba20c2b37ddfe98783df63c83a5baf2ac63e3a47da
7
+ data.tar.gz: 3c8ecc633e616d5c1863e2a3dceaac95a53c5a270fb51b3c13d8e9af65c29c6b9c9e138eb04da04e1b2834c577df9f55417a66f8fee68232632c2c3cbc2ec48a
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.4
data/lib/mdhost.rb CHANGED
@@ -25,18 +25,27 @@ 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
29
+
30
+ opt :browser_names, "Use browser names in output table"
28
31
 
29
32
  educate_on_error
30
33
  end
31
34
 
32
35
  if ARGV.empty?
33
- Optimist::educate
36
+ Optimist.educate
34
37
  end
35
38
  end
36
39
 
37
40
  def run
38
- if (@format_string = @options.format)
39
- Optimist::educate unless @format_string.include?(FORMAT_SPECIFIER)
41
+ @format_string = @options.format
42
+
43
+ if !@format_string && ARGV.length > 1
44
+ @format_string = FORMAT_SPECIFIER
45
+ end
46
+
47
+ if @format_string
48
+ Optimist.educate unless @format_string.include?(FORMAT_SPECIFIER)
40
49
  run_format
41
50
  else
42
51
  @input = ARGV.first
@@ -81,9 +90,6 @@ module MDHost
81
90
  display_table @input
82
91
 
83
92
  escaped_input = escape_input @input
84
-
85
- result = `eshost -e #{escaped_input}`.split(/\n+/)
86
-
87
93
  table = results_for escaped_input
88
94
 
89
95
  # We don't *need* to pretty format the table so precisely, but why not?
@@ -108,24 +114,30 @@ module MDHost
108
114
  Clipboard.copy(output)
109
115
  end
110
116
 
117
+ def format(format_string, input)
118
+ format_string.sub(FORMAT_SPECIFIER, input)
119
+ end
120
+
111
121
  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
122
+ output = +"|Input|"
123
+ output += @options.browser_names ? "Safari|Firefox|Chrome"
124
+ : "JavaScriptCore|SpiderMonkey|V8"
125
+ output += "\n|---|---|---|---\n"
126
+
127
+ ARGV.each do |input|
128
+ formatted_input = format(@format_string, input)
117
129
 
118
- output = +<<~TABLE
119
- |Input|JavaScriptCore|SpiderMonkey|V8
120
- |-----|--------------|------------|--
121
- TABLE
130
+ puts formatted_input
131
+ display_table formatted_input
122
132
 
123
- inputs.each do |input|
124
- escaped_input = escape_input input
133
+ escaped_input = escape_input formatted_input
125
134
  results = results_for escaped_input
126
135
 
136
+ display_input = @options.table_format ? format(@options.table_format, input)
137
+ : formatted_input
138
+
127
139
  output << <<~ROW
128
- |`#{input}`|#{results[:JavaScriptCore]}|#{results[:SpiderMonkey]}|#{results[:V8]}
140
+ |`#{display_input}`|#{results[:JavaScriptCore]}|#{results[:SpiderMonkey]}|#{results[:V8]}
129
141
  ROW
130
142
  end
131
143
 
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.4'
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
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.4.20
93
+ rubygems_version: 3.4.22
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Generate Markdown eshost tables