autocorrect-rb 2.3.2-x86_64-linux → 2.4.1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39952533dd61a1f8fabb56483fde72595ba0bfef3d3b9477e687610cea447bca
4
- data.tar.gz: 67e82178793b3fe6639c6a2d6bf2ba459e7466a5003aea13eca665ee19ade581
3
+ metadata.gz: d7a528df24cf085bf82dc288eb0983f5bb24df4a67ecbd24a2800c728c9fc262
4
+ data.tar.gz: f6844d3a5fcbab580b00c1e749a38b6ad511ff52351377fc52cc1ef04fe04272
5
5
  SHA512:
6
- metadata.gz: 6d1f8fe3bd8bf6d738e8226ec4dd4443281e10cfee084bce6c31d2e18a8eca74f29ed63432c3bd0ad464fb99b6c6e5a2b2ecdbbca4c7b3424ae6232438d7f24a
7
- data.tar.gz: fc8d884782faea06ddeb7d2aac1694d5fdd2a4a13227d6edb6f3e507c9f613ba805dbd22df9abd68e3644569e6dbae30d97294330a15743faef02c1791f95df1
6
+ metadata.gz: 0f99915353584365f75aa9d6eb08f0606acd49e0d935d3d51a9acca25658564d477852b3b0ef71f6a3b8d7c9b8075c23eec0e04bf9d0429093637269a83704cf
7
+ data.tar.gz: d2047ea6b82d99bee7ffcb5557a89ccaa06f8b142e3151936fd0230e4acc5a53eda97fa2bf9011a1f473389bd99e1e5a6c7b4fe8ac8ee410a1fa83f32bc538e0
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
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  edition = "2021"
3
3
  name = "autocorrect-rb"
4
- version = "2.3.2"
4
+ version = "2.4.1"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
  [lib]
@@ -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.clone() as usize,
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autocorrect-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-25 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys