autocorrect-rb 2.4.0-arm64-darwin → 2.4.1-arm64-darwin
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 +4 -4
- data/README.md +13 -0
- data/ext/autocorrect/Cargo.toml +1 -1
- data/ext/autocorrect/src/lib.rs +28 -2
- data/lib/autocorrect/2.7/autocorrect.bundle +0 -0
- data/lib/autocorrect/3.0/autocorrect.bundle +0 -0
- data/lib/autocorrect/3.1/autocorrect.bundle +0 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c808d95b5c9ffcf3d242d540d2467cd87bcf12bb5a18aaa120243036e2e7e96
|
4
|
+
data.tar.gz: 9b2270b5cad333870040c8aedf2cbd86c0c931ee21edfb805363be7fc72399d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e295ca93c4e6fbf7dfc4ed37a8963b2b0f6465bfd27598ad9ea88b4f7de5e353269d83adc225052a2bac6d1731c950562cbc65aaf0ef547b6088a28eeb0eac
|
7
|
+
data.tar.gz: c744352f9a4c2ec5f38af9e51dac74b7ec8ffe2495b7dbd2b6bc0c5dd22e5091f0c435430072b3c44beae9b08b33b9ac78d6447851258101f78cdf257b430487
|
data/README.md
CHANGED
@@ -38,6 +38,19 @@ puts result
|
|
38
38
|
# ],
|
39
39
|
# error: ''
|
40
40
|
# }
|
41
|
+
|
42
|
+
config_str = %({ textRules: { "你好hello": 0 } })
|
43
|
+
AutoCorrect.load_config(config_str)
|
44
|
+
out = AutoCorrect.format('Hello你好.')
|
45
|
+
puts out
|
46
|
+
# Hello 你好。
|
47
|
+
out = AutoCorrect.format('你好hello')
|
48
|
+
puts out
|
49
|
+
# 你好hello
|
50
|
+
|
51
|
+
# Ignorer, if /path/to/workdir contains .autocorrectignore or .gitignore
|
52
|
+
ignorer = AutoCorrect::Ignorer.new("/path/to/")
|
53
|
+
ignorer.ignored?("README.md")
|
41
54
|
```
|
42
55
|
|
43
56
|
## Benchmarks
|
data/ext/autocorrect/Cargo.toml
CHANGED
data/ext/autocorrect/src/lib.rs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
use magnus::{define_class, function, Error, Object};
|
1
|
+
use magnus::{define_class, function, method, Error, Module, Object};
|
2
2
|
|
3
3
|
#[derive(Debug, Clone)]
|
4
4
|
pub struct LineResult {
|
@@ -84,6 +84,23 @@ impl LintResult {
|
|
84
84
|
}
|
85
85
|
}
|
86
86
|
|
87
|
+
#[magnus::wrap(class = "AutoCorrect::Ignorer")]
|
88
|
+
pub struct Ignorer {
|
89
|
+
core: autocorrect::ignorer::Ignorer,
|
90
|
+
}
|
91
|
+
|
92
|
+
impl Ignorer {
|
93
|
+
pub fn new(work_dir: String) -> Self {
|
94
|
+
Ignorer {
|
95
|
+
core: autocorrect::ignorer::Ignorer::new(&work_dir),
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
fn is_ignored(&self, path: String) -> bool {
|
100
|
+
self.core.is_ignored(&path)
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
87
104
|
pub fn format(input: String) -> String {
|
88
105
|
autocorrect::format(&input)
|
89
106
|
}
|
@@ -105,7 +122,7 @@ pub fn lint_for(input: String, filename_or_ext: String) -> magnus::RHash {
|
|
105
122
|
col: l.col,
|
106
123
|
new: l.new.clone(),
|
107
124
|
old: l.old.clone(),
|
108
|
-
severity: l.severity
|
125
|
+
severity: l.severity as usize,
|
109
126
|
})
|
110
127
|
.collect::<_>(),
|
111
128
|
error: result.error,
|
@@ -114,12 +131,21 @@ pub fn lint_for(input: String, filename_or_ext: String) -> magnus::RHash {
|
|
114
131
|
.unwrap()
|
115
132
|
}
|
116
133
|
|
134
|
+
pub fn load_config(config_str: String) {
|
135
|
+
autocorrect::config::load(&config_str).unwrap();
|
136
|
+
}
|
137
|
+
|
117
138
|
#[magnus::init(name = "autocorrect")]
|
118
139
|
fn init() -> Result<(), Error> {
|
119
140
|
let class = define_class("AutoCorrect", Default::default())?;
|
120
141
|
class.define_singleton_method("format", function!(format, 1))?;
|
121
142
|
class.define_singleton_method("format_for", function!(format_for, 2))?;
|
122
143
|
class.define_singleton_method("lint_for", function!(lint_for, 2))?;
|
144
|
+
class.define_singleton_method("load_config", function!(load_config, 1))?;
|
145
|
+
|
146
|
+
let ignorer_class = class.define_class("Ignorer", Default::default())?;
|
147
|
+
ignorer_class.define_singleton_method("new", function!(Ignorer::new, 1))?;
|
148
|
+
ignorer_class.define_method("ignored?", method!(Ignorer::is_ignored, 1))?;
|
123
149
|
|
124
150
|
Ok(())
|
125
151
|
}
|
Binary file
|
Binary file
|
Binary file
|