spellr 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/.spellr.yml +1 -0
- data/lib/spellr/file.rb +18 -19
- data/lib/spellr/interactive_add.rb +1 -1
- data/lib/spellr/language.rb +7 -21
- data/lib/spellr/line_location.rb +9 -11
- data/lib/spellr/tokenizer.rb +3 -2
- data/lib/spellr/version.rb +1 -1
- data/spellr.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52262546809e049a6c04f71c067d895e2cd83b865bc1371a4c9c489ca8b8b5b7
|
4
|
+
data.tar.gz: c75f1e3037419fb9e917cac1d808fa3f32a882f0c76bb2a871ddca8ac8b33ea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12771b2588b7b8e2bfdfadec6c78cf4dd5f90000730451f8f8f7f066de77aba171a6227fa9c3a0ea914fb3dd7f33cd975b9dcfb2d73d0fb11a03898e460ed489
|
7
|
+
data.tar.gz: bfa05561e73da2b21fe6d2e7a138c8dfae8eda29dcadb83dd5c10e31b5d7b525b18161f8f9cd944b1d58ae1b46022ca2a4e4d05c7efad68d3363540714ca6b16
|
data/CHANGELOG.md
CHANGED
data/lib/.spellr.yml
CHANGED
data/lib/spellr/file.rb
CHANGED
@@ -4,25 +4,6 @@ require 'pathname'
|
|
4
4
|
|
5
5
|
module Spellr
|
6
6
|
class File < Pathname
|
7
|
-
def self.wrap(file)
|
8
|
-
file.is_a?(Spellr::File) ? file : Spellr::File.new(file)
|
9
|
-
end
|
10
|
-
|
11
|
-
# don't use FastIgnore shebang handling
|
12
|
-
# because i use lots of different FastIgnore instances and each would to open the files.
|
13
|
-
def hashbang
|
14
|
-
@hashbang ||= begin
|
15
|
-
return if extname != ''
|
16
|
-
return unless first_line&.start_with?('#!')
|
17
|
-
|
18
|
-
first_line
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def first_line
|
23
|
-
@first_line ||= each_line.first
|
24
|
-
end
|
25
|
-
|
26
7
|
def relative_path
|
27
8
|
@relative_path ||= relative_path_from(Spellr.pwd)
|
28
9
|
end
|
@@ -34,6 +15,24 @@ module Spellr
|
|
34
15
|
end
|
35
16
|
end
|
36
17
|
|
18
|
+
# the bulk of this method is copied from fast_ignore
|
19
|
+
def first_line # rubocop:disable Metrics/MethodLength
|
20
|
+
return @first_line if defined?(@first_line)
|
21
|
+
|
22
|
+
@first_line = nil
|
23
|
+
|
24
|
+
file = ::File.new(to_s)
|
25
|
+
@first_line = file.sysread(25)
|
26
|
+
@first_line += file.sysread(50) until @first_line.include?("\n")
|
27
|
+
file.close
|
28
|
+
@first_line
|
29
|
+
rescue ::EOFError, ::SystemCallError
|
30
|
+
# :nocov:
|
31
|
+
file&.close
|
32
|
+
# :nocov:
|
33
|
+
@first_line
|
34
|
+
end
|
35
|
+
|
37
36
|
def read_write
|
38
37
|
write(yield read)
|
39
38
|
end
|
data/lib/spellr/language.rb
CHANGED
@@ -10,14 +10,10 @@ module Spellr
|
|
10
10
|
attr_reader :name
|
11
11
|
attr_reader :key
|
12
12
|
|
13
|
-
def initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) # rubocop:disable Metrics/ParameterLists
|
13
|
+
def initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) # rubocop:disable Metrics/ParameterLists
|
14
14
|
@name = name
|
15
15
|
@key = key
|
16
|
-
@includes = includes
|
17
|
-
@hashbangs = hashbangs
|
18
|
-
@hashbang_pattern = unless hashbangs.empty?
|
19
|
-
/\A#!.*\b(?:#{hashbangs.map { |s| Regexp.escape(s) }.join('|')})\b/
|
20
|
-
end
|
16
|
+
@includes = includes + hashbangs.map { |h| "#!:#{h}" }
|
21
17
|
@locales = Array(locale)
|
22
18
|
@addable = addable
|
23
19
|
end
|
@@ -26,10 +22,6 @@ module Spellr
|
|
26
22
|
@addable
|
27
23
|
end
|
28
24
|
|
29
|
-
def matches?(file)
|
30
|
-
matches_includes?(file) || matches_hashbangs?(file)
|
31
|
-
end
|
32
|
-
|
33
25
|
def wordlists
|
34
26
|
default_wordlists.select(&:exist?)
|
35
27
|
end
|
@@ -41,24 +33,18 @@ module Spellr
|
|
41
33
|
)
|
42
34
|
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
def matches_hashbangs?(file)
|
47
|
-
return @includes.empty? unless @hashbang_pattern
|
48
|
-
|
49
|
-
file = Spellr::File.wrap(file)
|
50
|
-
return unless file.hashbang
|
36
|
+
def matches?(file)
|
37
|
+
return true if @includes.empty?
|
51
38
|
|
52
|
-
|
39
|
+
fast_ignore.allowed?(file.to_s, directory: false, content: file.first_line)
|
53
40
|
end
|
54
41
|
|
55
|
-
|
56
|
-
return @hashbangs.empty? if @includes.empty?
|
42
|
+
private
|
57
43
|
|
44
|
+
def fast_ignore
|
58
45
|
@fast_ignore ||= FastIgnore.new(
|
59
46
|
include_rules: @includes, gitignore: false, root: Spellr.pwd_s
|
60
47
|
)
|
61
|
-
@fast_ignore.allowed?(file.to_s)
|
62
48
|
end
|
63
49
|
|
64
50
|
def gem_wordlist
|
data/lib/spellr/line_location.rb
CHANGED
@@ -7,24 +7,22 @@ module Spellr
|
|
7
7
|
attr_reader :line_number
|
8
8
|
attr_reader :char_offset
|
9
9
|
attr_reader :byte_offset
|
10
|
+
attr_reader :file
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
|
12
|
+
def initialize(
|
13
|
+
file = ::Spellr::File.new('[string]'),
|
14
|
+
line_number = 1,
|
15
|
+
char_offset: 0,
|
16
|
+
byte_offset: 0
|
17
|
+
)
|
18
|
+
@file = file
|
13
19
|
@line_number = line_number
|
14
20
|
@char_offset = char_offset
|
15
21
|
@byte_offset = byte_offset
|
16
22
|
end
|
17
23
|
|
18
24
|
def to_s
|
19
|
-
"#{
|
20
|
-
end
|
21
|
-
|
22
|
-
def file_relative_path
|
23
|
-
file.relative_path
|
24
|
-
end
|
25
|
-
|
26
|
-
def file
|
27
|
-
@file ||= Spellr::File.wrap(@filename)
|
25
|
+
"#{file.relative_path}:#{line_number}"
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
data/lib/spellr/tokenizer.rb
CHANGED
@@ -7,9 +7,10 @@ require_relative 'line_tokenizer'
|
|
7
7
|
|
8
8
|
module Spellr
|
9
9
|
class Tokenizer
|
10
|
-
attr_reader :file
|
10
|
+
attr_reader :file, :filename
|
11
11
|
|
12
12
|
def initialize(file, start_at: nil, skip_key: true)
|
13
|
+
@filename = file
|
13
14
|
@start_at = start_at || ColumnLocation.new(line_location: LineLocation.new(file))
|
14
15
|
@file = file.is_a?(StringIO) || file.is_a?(IO) ? file : ::File.new(file)
|
15
16
|
@file.pos = @start_at.line_location.byte_offset
|
@@ -45,7 +46,7 @@ module Spellr
|
|
45
46
|
|
46
47
|
def prepare_line(line, line_number, char_offset, byte_offset)
|
47
48
|
line_location = LineLocation.new(
|
48
|
-
|
49
|
+
filename, line_number, char_offset: char_offset, byte_offset: byte_offset
|
49
50
|
)
|
50
51
|
column_location = ColumnLocation.new(line_location: line_location)
|
51
52
|
Token.new(line, location: column_location)
|
data/lib/spellr/version.rb
CHANGED
data/spellr.gemspec
CHANGED
@@ -41,6 +41,6 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'tty_string', '>= 0.2.1'
|
42
42
|
spec.add_development_dependency 'webmock', '~> 3.8'
|
43
43
|
|
44
|
-
spec.add_dependency 'fast_ignore', '>= 0.
|
44
|
+
spec.add_dependency 'fast_ignore', '>= 0.11.0'
|
45
45
|
spec.add_dependency 'parallel', '~> 1.0'
|
46
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spellr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dana Sherson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0.
|
201
|
+
version: 0.11.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 0.
|
208
|
+
version: 0.11.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: parallel
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -315,7 +315,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
- !ruby/object:Gem::Version
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
|
-
|
318
|
+
rubyforge_project:
|
319
|
+
rubygems_version: 2.7.10
|
319
320
|
signing_key:
|
320
321
|
specification_version: 4
|
321
322
|
summary: Spell check your source code
|