slimembedcop 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codespellignore +0 -0
- data/CHANGELOG.md +4 -0
- data/README.md +96 -2
- data/lib/slimembedcop/ruby_offense_collector.rb +1 -1
- data/lib/slimembedcop/version.rb +1 -1
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 819399a1940beed5d69493debeb14cc9ca337274d4c94a015aa4fa7cb4a61576
|
4
|
+
data.tar.gz: a9513d7bcc2b2df861fa0b9509542ef83f2b7caa4757d9a986d626d2305ce5d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b193c4391dadc3d800d2a9b6ae62dad2d0ce3e52450e3c292a7f30971bc82b622ce268d7b5a15e59d36c9ab627d7b476971d5cf4158e7e4ede005e4458b50fbb
|
7
|
+
data.tar.gz: 38dec3b0af1d1d4702297a6f0cdb01732ff9075fa2aa48258c5588b8e0caffc4f1b493956a3c8d4efc71d70dae502fb9808aa7c1dcacea47cdf7c002fcc29521
|
data/.codespellignore
ADDED
File without changes
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,100 @@
|
|
1
|
-
#
|
1
|
+
# SlimEmbedCop
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/slimembedcop.svg)](https://badge.fury.io/rb/slimembedcop)
|
4
|
+
[![CI](https://github.com/ydah/slimembedcop/actions/workflows/ci.yml/badge.svg)](https://github.com/ydah/slimembedcop/actions/workflows/ci.yml)
|
5
|
+
[![RubyDoc](https://img.shields.io/badge/%F0%9F%93%9ARubyDoc-documentation-informational.svg)](https://www.rubydoc.info/gems/slimembedcop)
|
6
|
+
|
7
|
+
|
8
|
+
[RuboCop](https://github.com/rubocop/rubocop) runner for [Ruby code embedded in Slim](https://github.com/slim-template/slim#embedded-engines-markdown-).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
**SlimEmbedCop**'s installation is pretty standard:
|
13
|
+
|
14
|
+
```sh
|
15
|
+
% gem install slimembedcop
|
16
|
+
```
|
17
|
+
|
18
|
+
If you'd rather install SlimEmbedCop using `bundler`, add a line for it in your `Gemfile` (but set the `require` option to `false`, as it is a standalone tool):
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'slimembedcop', require: false
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Use `slimembedcop` executable to check offenses and autocorrect them.
|
27
|
+
[RuboCop's cop](https://docs.rubocop.org/rubocop/1.56/cops.html) or any [custom cop](https://docs.rubocop.org/rubocop/extensions.html#custom-cops) you create can also be used with `slimembedcop`.
|
28
|
+
|
29
|
+
```sh
|
30
|
+
% exe/slimembedcop --help
|
31
|
+
Usage: slimembedcop [options] [file1, file2, ...]
|
32
|
+
-v, --version Display version.
|
33
|
+
-a, --autocorrect Autocorrect offenses.
|
34
|
+
-c, --config= Specify configuration file.
|
35
|
+
--[no-]color Force color output on or off.
|
36
|
+
-d, --debug Display debug info.
|
37
|
+
```
|
38
|
+
|
39
|
+
### Example
|
40
|
+
|
41
|
+
You have a Slim file like this:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
ruby:
|
45
|
+
message = "world"
|
46
|
+
html
|
47
|
+
head
|
48
|
+
title Slim Samples
|
49
|
+
body
|
50
|
+
ruby:
|
51
|
+
if some_var = true
|
52
|
+
do_something
|
53
|
+
end
|
54
|
+
h1 Hello, #{message}
|
55
|
+
ruby:
|
56
|
+
do_something /pattern/i
|
57
|
+
```
|
58
|
+
|
59
|
+
When executed, it outputs the following offenses:
|
60
|
+
|
61
|
+
```sh
|
62
|
+
% slimembedcop dummy.slim
|
63
|
+
Inspecting 1 file
|
64
|
+
W
|
65
|
+
|
66
|
+
Offenses:
|
67
|
+
|
68
|
+
dummy.slim:2:13: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
|
69
|
+
message = "world"
|
70
|
+
^^^^^^^
|
71
|
+
dummy.slim:8:19: W: [Correctable] Lint/AssignmentInCondition: Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
|
72
|
+
if some_var = true
|
73
|
+
^
|
74
|
+
dummy.slim:13:16: W: [Correctable] Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
|
75
|
+
do_something /pattern/i
|
76
|
+
^
|
77
|
+
|
78
|
+
1 file inspected, 3 offenses detected, 3 offenses autocorrectable
|
79
|
+
```
|
80
|
+
|
81
|
+
## Configuration
|
82
|
+
|
83
|
+
The behavior of [RuboCop](https://github.com/rubocop/rubocop) can be controlled via the [.rubocop.yml](https://github.com/rubocop/rubocop/blob/master/.rubocop.yml) configuration file. The behavior of `SlimEmbedCop` can be controlled by the `.slimembedcop.yml` configuration file. It makes it possible to enable/disable certain cops (checks) and to alter their behavior if they accept any parameters. The file can be placed in your home directory, XDG config directory, or in some project directory.
|
84
|
+
|
85
|
+
The file has the following format:
|
86
|
+
|
87
|
+
```yaml
|
88
|
+
inherit_from: ../.rubocop.yml
|
89
|
+
|
90
|
+
Style/Encoding:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Layout/LineLength:
|
94
|
+
Max: 99
|
95
|
+
```
|
96
|
+
|
97
|
+
NOTE: It is basically the same as RuboCop's. Please check [Configuration](https://docs.rubocop.org/rubocop/configuration.html) for details.
|
4
98
|
|
5
99
|
## License
|
6
100
|
|
data/lib/slimembedcop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimembedcop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
|
+
original_platform: ''
|
6
7
|
authors:
|
7
8
|
- Yudai Takada
|
8
|
-
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -24,7 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
-
description:
|
28
27
|
email:
|
29
28
|
- t.yudai92@gmail.com
|
30
29
|
executables:
|
@@ -32,6 +31,7 @@ executables:
|
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files: []
|
34
33
|
files:
|
34
|
+
- ".codespellignore"
|
35
35
|
- ".rspec"
|
36
36
|
- ".rubocop.yml"
|
37
37
|
- CHANGELOG.md
|
@@ -61,7 +61,6 @@ metadata:
|
|
61
61
|
source_code_uri: https://github.com/ydah/slimembedcop
|
62
62
|
changelog_uri: https://github.com/ydah/slimembedcop/releases
|
63
63
|
rubygems_mfa_required: 'true'
|
64
|
-
post_install_message:
|
65
64
|
rdoc_options: []
|
66
65
|
require_paths:
|
67
66
|
- lib
|
@@ -76,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
75
|
- !ruby/object:Gem::Version
|
77
76
|
version: '0'
|
78
77
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
80
|
-
signing_key:
|
78
|
+
rubygems_version: 3.6.0.dev
|
81
79
|
specification_version: 4
|
82
80
|
summary: RuboCop runner for Ruby code embedded in Slim.
|
83
81
|
test_files: []
|