elelem-tools 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10d95e567040251074141f329ea4f0e1400a866715c8ca6b3c5c58f61136576a
4
- data.tar.gz: 135c83d3d9945b31555a28012a5b0e9d91260d4d8e2e984de42f71461e8f76dc
3
+ metadata.gz: 76ec7a010fbd709f164dbf2ac05b85bd60187e1451a6505726fc7f35dbd9d7eb
4
+ data.tar.gz: 74de74a8b6add422ef3db5ade2bb9f3eec63eb1373687e324145b2cd09de48c8
5
5
  SHA512:
6
- metadata.gz: c7026b46f8b420cb9be98b16282dda7a0048b909057b7c945e76df481a5b7139846ffe3f12239868c3829d43e45bc5da2a0f2e8155caa5b90f73001841ae6741
7
- data.tar.gz: fb44a774890cafa5d26cf14eb8d5d7b117a73cd56bd8190c49cef711e7611aa7c431faf95b0b8b4ed0be399a65fb61a818bf7a76e66a73877bd36bdc4b4e410e
6
+ metadata.gz: 49fd1c98c79f4d45d6039d71347b6d96268a6bc10b594b96e9e4a24d54f863c4e0091fd457dfbd7e6bb3caca22bfda71b3c82c350cea2390b14173b81b271124
7
+ data.tar.gz: 8049db48ab2f0c0ca92b5db290e8827f2bc2f0f5eef144407872a4bd4f0ebe4850621610abf865ce0161e813edfb427a8a0a64e842fdc33c0027f4bb15c221db
@@ -1,13 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Elelem::Plugins.register(:verify) do |agent|
4
+ class Verifiers
5
+ SYNTAX = {
6
+ ".rb" => "ruby -c %{path}",
7
+ ".erb" => "erb -x %{path} | ruby -c",
8
+ ".py" => "python -m py_compile %{path}",
9
+ ".go" => "go vet %{path}",
10
+ ".rs" => "cargo check --quiet",
11
+ ".ts" => "npx tsc --noEmit %{path}",
12
+ ".js" => "node --check %{path}",
13
+ }.freeze
14
+
15
+ def self.for(path)
16
+ return [] unless path
17
+
18
+ cmds = []
19
+ ext = File.extname(path)
20
+ cmds << (SYNTAX[ext] % { path: path }) if SYNTAX[ext]
21
+ cmds << test_runner
22
+ cmds.compact
23
+ end
24
+
25
+ def self.test_runner
26
+ %w[bin/test script/test].find { |s| File.executable?(s) }
27
+ end
28
+ end
29
+
4
30
  agent.toolbox.add("verify",
5
31
  description: "Verify file syntax and run tests",
6
32
  params: { path: { type: "string" } },
7
33
  required: ["path"]
8
34
  ) do |args|
9
35
  path = args["path"]
10
- Elelem::Plugins::Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
36
+ Verifiers.for(path).inject({ verified: [] }) do |memo, cmd|
11
37
  agent.terminal.say agent.toolbox.header("execute", { "command" => cmd })
12
38
  v = agent.toolbox.run("execute", { "command" => cmd })
13
39
  break v.merge(path: path, command: cmd) if v[:exit_status] != 0
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Elelem
4
4
  module Tools
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elelem-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan