mdhost 0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b987e2d55ede53f92d2f8a49261cb1cc2555e0a6bcc4f47408b0e14145729054
4
+ data.tar.gz: 30fcf7b31833fe0a8b1c3ee33758597825c8fb1e227b1a58a54c35b054c52520
5
+ SHA512:
6
+ metadata.gz: 70bf37bbc9d5f04f6679fd4bdd930c8dba800f4d6e0bba90f878bbdbe0fe914a6e2cb72ca3a824713f68010858bcad967d8b9bcce9b43f5432f687f2a0e57d6c
7
+ data.tar.gz: e1fafa621015efc0658c0744bcaf4489c77b03e3f5d043090dc475dd1012683ca0c0e22c642412cf585bf8d236917b7cc3c6c30f79591d0a1dd59a0e07e30685
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ # Don't push Gemfile.lock on a RubyGem
21
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,87 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.2
4
+
5
+ Gemspec/DevelopmentDependencies:
6
+ EnforcedStyle: gemspec
7
+
8
+ Gemspec/RequiredRubyVersion:
9
+ Enabled: false
10
+
11
+ Layout/ArgumentAlignment:
12
+ Enabled: false
13
+
14
+ Layout/EndAlignment:
15
+ EnforcedStyleAlignWith: variable
16
+
17
+ Layout/ExtraSpacing:
18
+ Enabled: false
19
+
20
+ Layout/FirstHashElementIndentation:
21
+ EnforcedStyle: consistent
22
+
23
+ Layout/MultilineMethodCallIndentation:
24
+ EnforcedStyle: indented
25
+
26
+ Layout/SpaceAroundEqualsInParameterDefault:
27
+ Enabled: false
28
+
29
+ Layout/TrailingWhitespace:
30
+ AllowInHeredoc: false
31
+
32
+ Lint/NonDeterministicRequireOrder:
33
+ Enabled: false
34
+
35
+ Metrics:
36
+ Enabled: false
37
+
38
+ Naming/HeredocDelimiterNaming:
39
+ Enabled: false
40
+
41
+ Naming/MethodParameterName:
42
+ Enabled: false
43
+
44
+ Naming/VariableNumber:
45
+ Enabled: false
46
+
47
+ Style/ClassAndModuleChildren:
48
+ Enabled: false
49
+
50
+ Style/Documentation:
51
+ Enabled: false
52
+
53
+ Style/FormatString:
54
+ Enabled: false
55
+
56
+ Style/GuardClause:
57
+ Enabled: false
58
+
59
+ Style/IfUnlessModifier:
60
+ Enabled: false
61
+
62
+ Style/MultilineTernaryOperator:
63
+ Enabled: false
64
+
65
+ Style/NestedParenthesizedCalls:
66
+ Enabled: false
67
+
68
+ Style/NestedTernaryOperator:
69
+ Enabled: false
70
+
71
+ Style/Next:
72
+ Enabled: false
73
+
74
+ Style/NumericPredicate:
75
+ Enabled: false
76
+
77
+ Style/ParallelAssignment:
78
+ Enabled: false
79
+
80
+ Style/RequireOrder:
81
+ Enabled: true
82
+
83
+ Style/StderrPuts:
84
+ Enabled: false
85
+
86
+ Style/StringLiterals:
87
+ EnforcedStyle: double_quotes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright © 2023 Vinny Diehl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # `mdhost`
2
+
3
+ Runs `eshost`, displays the table output in the terminal, and generates a
4
+ Markdown table of a few of the results (JavaScriptCore, SpiderMonkey, and V8),
5
+ copying it to your clipboard.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ task dist: :build
7
+ task default: :build
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1
data/bin/mdhost ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "mdhost"
5
+
6
+ MDHost::CLI.new.run
data/lib/mdhost.rb ADDED
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clipboard"
4
+
5
+ VERSION = File.read(File.expand_path("../VERSION", __dir__)).strip.freeze
6
+
7
+ module MDHost
8
+ class CLI
9
+ def initialize
10
+ if ARGV.empty? || %w[--version -v].include?(ARGV.first)
11
+ puts "mdhost version #{VERSION}"
12
+ exit 0
13
+ end
14
+
15
+ @input = ARGV.first
16
+ end
17
+
18
+ def run
19
+ # Display table
20
+ system("eshost", "-h", "JavaScriptCore,SpiderMonkey,V8", "-te", @input)
21
+
22
+ # Pretty escape the input (we'll be using it in the markdown so we want
23
+ # it to look clean)
24
+ escaped_input = if @input.include?("'") && @input.include?('"')
25
+ "\"#{@input.gsub('"', '\"')}\""
26
+ elsif @input.include?('"')
27
+ "'#{@input}'"
28
+ else
29
+ "\"#{@input}\""
30
+ end
31
+
32
+ result = `eshost -e #{escaped_input}`.split(/\n+/)
33
+
34
+ # We can't just #each_slice by 2, because sometimes an engine acts up and
35
+ # produces no output, which would mess up the grouping. So, we need to
36
+ # look specifically for the engines that we want and then take the next
37
+ # line as the result.
38
+ table = {}
39
+ result.each_with_index do |line, i|
40
+ if %w[JavaScriptCore SpiderMonkey V8].any? { |e| line.end_with? e }
41
+ table[line.match(/\w+/).to_s.to_sym] = result[i + 1]
42
+ end
43
+ end
44
+
45
+ # We don't *need* to pretty format the table so precisely, but why not?
46
+ engine_length = table.keys.max_by(&:length).length
47
+ result_length = table.values.max_by(&:length).length
48
+
49
+ markdown_table = table.map do |e, r|
50
+ "|#{e}#{' ' * (engine_length - e.length)}|#{r}#{' ' * (result_length - r.length)}|"
51
+ end.join("\n")
52
+
53
+ output = <<~EOS
54
+ ```
55
+ > eshost -te #{escaped_input}
56
+ ```
57
+ |Engine#{' ' * (engine_length - 6)}|Result#{' ' * (result_length - 6)}|
58
+ |#{'-' * engine_length}|#{'-' * result_length}|
59
+ #{markdown_table}
60
+ EOS
61
+
62
+ Clipboard.copy(output)
63
+ end
64
+ end
65
+ end
data/mdhost.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "mdhost"
5
+ gem.version = File.read(File.expand_path("VERSION", __dir__)).strip
6
+
7
+ gem.author = "Vinny Diehl"
8
+ gem.email = "vinny.diehl@gmail.com"
9
+ gem.homepage = "https://github.com/vinnydiehl/mdhost"
10
+ gem.metadata["rubygems_mfa_required"] = "true"
11
+
12
+ gem.license = "MIT"
13
+
14
+ gem.summary = "Generate Markdown eshost tables"
15
+ gem.description = "Runs eshost in table mode, copying a Markdown version " \
16
+ "of the table to your clipboard."
17
+
18
+ gem.bindir = "bin"
19
+ gem.executables = %w[mdhost]
20
+ gem.files = `git ls-files -z`.split "\x0"
21
+
22
+ gem.add_dependency "clipboard", "~> 1.1"
23
+
24
+ gem.add_development_dependency "rubocop", "~> 1.54"
25
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mdhost
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Vinny Diehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: clipboard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.54'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.54'
41
+ description: Runs eshost in table mode, copying a Markdown version of the table to
42
+ your clipboard.
43
+ email: vinny.diehl@gmail.com
44
+ executables:
45
+ - mdhost
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rubocop.yml"
51
+ - Gemfile
52
+ - LICENSE.md
53
+ - README.md
54
+ - Rakefile
55
+ - VERSION
56
+ - bin/mdhost
57
+ - lib/mdhost.rb
58
+ - mdhost.gemspec
59
+ homepage: https://github.com/vinnydiehl/mdhost
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ rubygems_mfa_required: 'true'
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.4.20
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Generate Markdown eshost tables
83
+ test_files: []