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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c33e39f748febedd7e1ea79110660774025c46bd8a0a3a2dfbfe9b412ee851
4
- data.tar.gz: be3e631046aae5ba275e6c38e1e07d7d5d2c08de507d971fd4ef270a7520f4a6
3
+ metadata.gz: 52262546809e049a6c04f71c067d895e2cd83b865bc1371a4c9c489ca8b8b5b7
4
+ data.tar.gz: c75f1e3037419fb9e917cac1d808fa3f32a882f0c76bb2a871ddca8ac8b33ea3
5
5
  SHA512:
6
- metadata.gz: 80499ae58b56c094a94722a34bf4e71d1ff5f5d38338d67ddc26f35759d30182e27580bea0e915b7402019438efb7d52e78f0146663185b5cf58c2f9dc4676d1
7
- data.tar.gz: 9b99f2a650177b26e040c3e54aa6586d80175607e731564249edaa735ab23fa76867e86d1cdf9be869e22d375d694f2b0455e7f2a0a293ab3acb81ba99d2a1e4
6
+ metadata.gz: 12771b2588b7b8e2bfdfadec6c78cf4dd5f90000730451f8f8f7f066de77aba171a6227fa9c3a0ea914fb3dd7f33cd975b9dcfb2d73d0fb11a03898e460ed489
7
+ data.tar.gz: bfa05561e73da2b21fe6d2e7a138c8dfae8eda29dcadb83dd5c10e31b5d7b525b18161f8f9cd944b1d58ae1b46022ca2a4e4d05c7efad68d3363540714ca6b16
@@ -1,3 +1,6 @@
1
+ # v0.8.4
2
+ - Update fast_ignore dependency, it's faster now (about 0.5s faster on rails codebase)
3
+
1
4
  # v0.8.3
2
5
  - Update fast_ignore dependency fixing symlinks to directories handling.
3
6
 
@@ -44,6 +44,7 @@ languages:
44
44
  - Rakefile
45
45
  - config.ru
46
46
  - Capfile
47
+ - .simplecov
47
48
  hashbangs:
48
49
  - ruby
49
50
 
@@ -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
@@ -18,7 +18,7 @@ module Spellr
18
18
  end
19
19
 
20
20
  def languages
21
- @languages ||= Spellr.config.languages_for(token.location.file.to_path)
21
+ @languages ||= Spellr.config.languages_for(token.location.file)
22
22
  end
23
23
 
24
24
  def addable_languages
@@ -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, Metrics/MethodLength
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
- private
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
- @hashbang_pattern.match?(file.hashbang)
39
+ fast_ignore.allowed?(file.to_s, directory: false, content: file.first_line)
53
40
  end
54
41
 
55
- def matches_includes?(file)
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
@@ -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(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0)
12
- @filename = file
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
- "#{file_relative_path}:#{line_number}"
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
@@ -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
- file, line_number, char_offset: char_offset, byte_offset: byte_offset
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spellr
4
- VERSION = '0.8.3'
4
+ VERSION = '0.8.4'
5
5
  end
@@ -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.10.1'
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.3
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-04-22 00:00:00.000000000 Z
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.10.1
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.10.1
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
- rubygems_version: 3.0.3
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