autocorrect-rb 2.1.2.beta1-arm64-darwin → 2.1.2.beta4-arm64-darwin

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: d783c8f798207868dd343de68b239e5e5c51317c39cda2e71aafc90bd18cf3b3
4
- data.tar.gz: e20d333ce6aad66377d598edf9187ae263a953e02bcc9fe94f5fb5e1dcfd2af2
3
+ metadata.gz: 49f2cc6ec1cacd4ae9f78c8eb49eb79e6f601ea61ef9bb3f92bfefbb19157720
4
+ data.tar.gz: 04b62477401cfe22a1a7679f30a8787273b449f53296d2804bc7c9ce49a5104b
5
5
  SHA512:
6
- metadata.gz: be27eda0b92c3f5c35eb57a7fc9af8785e64cbf744931f79ddda44183f6ef99ba0472c70f43b245c481f8d2f30cbbc6c058de76d1b91b7eea75a33764fcb2e2b
7
- data.tar.gz: 6f9e44526a52a1865e20ec6a1a2bba898b946929b540fec405ffa6818c912bffcdd997ddcc7c1152a2a3425c78ce5ec48a49cb8433b8bdc9ee01da2aa5c43fa5
6
+ metadata.gz: b7a82ee2c926636b218df74b271bb83c458410e2decbade5eefb90726abd20d1de7b95ecc9c429a71d1f106a75fe3ab0cc70e05fef287f4aead9cbd77ee60cc6
7
+ data.tar.gz: 7468ce5e0a0733d05b234db4b7db769be1a889839d33b9a51edd3eb85b3146235690c2ed7dffc6ad0661bc2e9695b9fb5b3b99ca3b439dfc7161c2c873ffff16
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  require "bundler/gem_tasks"
10
+ require "rubygems/package_task"
10
11
  require "rake/testtask"
11
12
  require "rake/extensiontask"
12
13
  require "bundler"
@@ -19,16 +20,22 @@ CROSS_PLATFORMS = %w[
19
20
  x86_64-linux
20
21
  ]
21
22
 
22
- spec = Bundler.load_gemspec("autocorrect-rb.gemspec")
23
-
24
23
  Rake::TestTask.new(:test) do |t|
25
24
  t.libs << "test"
26
25
  t.libs << "lib"
27
26
  t.test_files = FileList["test/**/*_test.rb"]
28
27
  end
29
28
 
29
+ spec = Bundler.load_gemspec("autocorrect-rb.gemspec")
30
+
31
+ # Make a autocorrect-rb-0.0.0.gem
32
+ # Disable release gem for platform: ruby, because autocorrect rust source build is complex.
33
+ # Gem::PackageTask.new(spec).define
34
+
35
+ # Make a native gem, eg. autocorrect-rb-0.0.0-x86_64-linux.gem
30
36
  Rake::ExtensionTask.new("autocorrect", spec) do |ext|
31
- # ext.lib_dir = "lib/autocorrect"
37
+ # Compile output autocorrect.so into lib/autocorrect/autocorrect.so
38
+ ext.lib_dir = "lib/autocorrect"
32
39
  ext.source_pattern = "*.{rs,toml}"
33
40
  ext.cross_compile = true
34
41
  ext.cross_platform = CROSS_PLATFORMS
@@ -65,6 +72,5 @@ task :bench do
65
72
  end
66
73
  end
67
74
 
68
- task build: :compile
69
75
  task test: :compile
70
- task default: %i[compile test]
76
+ task default: %i[test]
@@ -0,0 +1,13 @@
1
+ [package]
2
+ edition = "2021"
3
+ name = "autocorrect-rb"
4
+ version = "2.1.1"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+ [lib]
8
+ crate-type = ["cdylib"]
9
+ name = "autocorrect"
10
+
11
+ [dependencies]
12
+ autocorrect = {path = "../../../autocorrect", version = ">=1.0.0"}
13
+ magnus = "0.3"
@@ -1,4 +1,4 @@
1
1
  require "mkmf"
2
2
  require "rb_sys/mkmf"
3
3
 
4
- create_rust_makefile("autocorrect")
4
+ create_rust_makefile("autocorrect/autocorrect")
@@ -0,0 +1,125 @@
1
+ use magnus::{define_class, function, Error, Object};
2
+
3
+ #[derive(Debug, Clone)]
4
+ pub struct LineResult {
5
+ line: usize,
6
+ col: usize,
7
+ new: String,
8
+ old: String,
9
+ severity: usize,
10
+ }
11
+
12
+ impl LineResult {
13
+ pub fn line(&self) -> usize {
14
+ self.line
15
+ }
16
+
17
+ pub fn col(&self) -> usize {
18
+ self.col
19
+ }
20
+
21
+ pub fn get_new(&self) -> String {
22
+ self.new.clone()
23
+ }
24
+
25
+ pub fn old(&self) -> String {
26
+ self.old.clone()
27
+ }
28
+
29
+ pub fn severity(&self) -> usize {
30
+ self.severity
31
+ }
32
+
33
+ pub fn inspect(&self) -> String {
34
+ format!("{:?}", self)
35
+ }
36
+
37
+ pub fn to_hash(&self) -> Result<magnus::RHash, Error> {
38
+ let hash = magnus::RHash::new();
39
+ hash.aset("line", self.line())?;
40
+ hash.aset("col", self.col())?;
41
+ hash.aset("new", self.get_new())?;
42
+ hash.aset("old", self.old())?;
43
+ hash.aset("severity", self.severity())?;
44
+ Ok(hash)
45
+ }
46
+ }
47
+
48
+ #[derive(Debug, Clone)]
49
+ pub struct LintResult {
50
+ pub filepath: String,
51
+ pub lines: Vec<LineResult>,
52
+ pub error: String,
53
+ }
54
+
55
+ impl LintResult {
56
+ pub fn filepath(&self) -> String {
57
+ self.filepath.clone()
58
+ }
59
+
60
+ pub fn lines(&self) -> Vec<LineResult> {
61
+ self.lines.clone()
62
+ }
63
+
64
+ pub fn error(&self) -> String {
65
+ self.error.clone()
66
+ }
67
+
68
+ pub fn inspect(&self) -> String {
69
+ format!("{:?}", self)
70
+ }
71
+
72
+ pub fn to_hash(&self) -> Result<magnus::RHash, Error> {
73
+ let hash = magnus::RHash::new();
74
+ hash.aset("filepath", self.filepath())?;
75
+ hash.aset(
76
+ "lines",
77
+ self.lines()
78
+ .iter()
79
+ .map(|l| l.to_hash().unwrap())
80
+ .collect::<Vec<magnus::RHash>>(),
81
+ )?;
82
+ hash.aset("error", self.error())?;
83
+ Ok(hash)
84
+ }
85
+ }
86
+
87
+ pub fn format(input: String) -> String {
88
+ autocorrect::format(&input)
89
+ }
90
+
91
+ pub fn format_for(input: String, filename_or_ext: String) -> String {
92
+ autocorrect::format_for(&input, &filename_or_ext).out
93
+ }
94
+
95
+ pub fn lint_for(input: String, filename_or_ext: String) -> magnus::RHash {
96
+ let result = autocorrect::lint_for(&input, &filename_or_ext);
97
+
98
+ LintResult {
99
+ filepath: filename_or_ext,
100
+ lines: result
101
+ .lines
102
+ .iter()
103
+ .map(|l| LineResult {
104
+ line: l.line,
105
+ col: l.col,
106
+ new: l.new.clone(),
107
+ old: l.old.clone(),
108
+ severity: l.severity.clone() as usize,
109
+ })
110
+ .collect::<_>(),
111
+ error: result.error,
112
+ }
113
+ .to_hash()
114
+ .unwrap()
115
+ }
116
+
117
+ #[magnus::init(name = "autocorrect")]
118
+ fn init() -> Result<(), Error> {
119
+ let class = define_class("AutoCorrect", Default::default())?;
120
+ class.define_singleton_method("format", function!(format, 1))?;
121
+ class.define_singleton_method("format_for", function!(format_for, 2))?;
122
+ class.define_singleton_method("lint_for", function!(lint_for, 2))?;
123
+
124
+ Ok(())
125
+ }
File without changes
File without changes
File without changes
@@ -3,10 +3,5 @@ begin
3
3
  ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
4
4
  require_relative "autocorrect/#{ruby_version}/autocorrect"
5
5
  rescue LoadError
6
- # fall back to the extension compiled upon installation.
7
- # use "require" instead of "require_relative" because non-native gems will place C extension files
8
- # in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
9
- # is in $LOAD_PATH but not necessarily relative to this file
10
- # (see https://github.com/sparklemotion/nokogiri/issues/2300 for more)
11
6
  require "autocorrect/autocorrect"
12
7
  end
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.1.2.beta1
4
+ version: 2.1.2.beta4
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -34,11 +34,13 @@ extra_rdoc_files: []
34
34
  files:
35
35
  - README.md
36
36
  - Rakefile
37
+ - ext/autocorrect/Cargo.toml
37
38
  - ext/autocorrect/extconf.rb
38
- - lib/2.7/autocorrect.bundle
39
- - lib/3.0/autocorrect.bundle
40
- - lib/3.1/autocorrect.bundle
39
+ - ext/autocorrect/src/lib.rs
41
40
  - lib/autocorrect-rb.rb
41
+ - lib/autocorrect/2.7/autocorrect.bundle
42
+ - lib/autocorrect/3.0/autocorrect.bundle
43
+ - lib/autocorrect/3.1/autocorrect.bundle
42
44
  homepage: https://github.com/huacnlee/autocorrect
43
45
  licenses:
44
46
  - MIT