fast_ignore 0.10.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FastIgnore
4
+ class ShebangRule
5
+ attr_reader :negation
6
+ alias_method :negation?, :negation
7
+ undef :negation
8
+
9
+ attr_reader :rule
10
+ alias_method :shebang, :rule
11
+
12
+ attr_reader :type
13
+
14
+ def initialize(rule, negation)
15
+ @rule = rule
16
+ @negation = negation
17
+
18
+ @type = negation ? 3 : 2
19
+
20
+ freeze
21
+ end
22
+
23
+ def file_only?
24
+ true
25
+ end
26
+
27
+ def dir_only?
28
+ false
29
+ end
30
+
31
+ def unanchored?
32
+ true
33
+ end
34
+
35
+ # :nocov:
36
+ def inspect
37
+ "#<ShebangRule #{'allow ' if @negation}#!:#{@rule.to_s[15..-4]}>"
38
+ end
39
+ # :nocov:
40
+
41
+ def match?(_, full_path, filename, content)
42
+ return false if filename.include?('.')
43
+
44
+ (content || first_line(full_path))&.match?(@rule)
45
+ end
46
+
47
+ private
48
+
49
+ def first_line(path)
50
+ file = ::File.new(path)
51
+ first_line = file.sysread(25)
52
+ first_line += file.sysread(50) until first_line.include?("\n")
53
+ file.close
54
+ first_line
55
+ rescue ::EOFError, ::SystemCallError
56
+ # :nocov:
57
+ file&.close
58
+ # :nocov:
59
+ first_line
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- VERSION = '0.10.1'
4
+ VERSION = '0.13.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_ignore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.8.1
131
+ version: 0.8.3
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.8.1
138
+ version: 0.8.3
139
139
  description:
140
140
  email:
141
141
  - robot@dana.sh
@@ -143,34 +143,17 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".gitignore"
147
- - ".leftovers.yml"
148
- - ".rspec"
149
- - ".rubocop.yml"
150
- - ".simplecov"
151
- - ".spellr.yml"
152
- - ".spellr_wordlists/english.txt"
153
- - ".spellr_wordlists/ruby.txt"
154
- - ".spellr_wordlists/shell.txt"
155
- - ".travis.yml"
156
146
  - CHANGELOG.md
157
- - Gemfile
158
147
  - LICENSE.txt
159
148
  - README.md
160
- - Rakefile
161
- - bin/console
162
- - bin/ls
163
- - bin/setup
164
- - bin/time
165
- - fast_ignore.gemspec
166
149
  - lib/fast_ignore.rb
167
150
  - lib/fast_ignore/backports.rb
168
- - lib/fast_ignore/backports/delete_prefix_suffix.rb
169
- - lib/fast_ignore/backports/dir_each_child.rb
151
+ - lib/fast_ignore/fn_match_to_re.rb
170
152
  - lib/fast_ignore/rule.rb
171
153
  - lib/fast_ignore/rule_builder.rb
172
154
  - lib/fast_ignore/rule_set.rb
173
155
  - lib/fast_ignore/rule_set_builder.rb
156
+ - lib/fast_ignore/shebang_rule.rb
174
157
  - lib/fast_ignore/version.rb
175
158
  homepage: https://github.com/robotdana/fast_ignore
176
159
  licenses:
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- /.bundle/
2
- /coverage/
3
- /pkg/
4
- .rspec_status
5
- *.gem
6
- Gemfile.lock
@@ -1,5 +0,0 @@
1
- exclude_paths:
2
- - vendor
3
- rules:
4
- - names: allowed? # public api
5
- skip: true
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,216 +0,0 @@
1
- require: rubocop-rspec
2
-
3
- # Reference:
4
- # https://rubocop.readthedocs.io/en/latest/
5
-
6
- # Keep this in alphabetical order.
7
- # Each override should have a comment (even if it's just "default is bad")
8
-
9
- AllCops:
10
- NewCops: enable
11
- Exclude:
12
- - db/schema*
13
- - .bundle/**/*
14
- - tmp/**/*
15
- - vendor/**/*
16
- DisplayCopNames: true
17
- DisplayStyleGuide: true
18
- TargetRubyVersion: 2.4
19
-
20
- # all of our layout customisations are because we prefer indentation to be
21
- # always consistently 2 spaces, for blocks, scopes, multiline expressions, etc
22
- # e.g.
23
- # class Klass
24
- # def method(arg1,
25
- # arg2)
26
- # value = if arg1 == 'value' && arg2 == 'value'
27
- # method2
28
- # .method(arg_a, arg_b,
29
- # arg_c, arg_d, keyword1: true,
30
- # keyword2: true) do
31
- # @last = [
32
- # arg_a, arg_b,
33
- # arg_c, arg_d
34
- # ]
35
- # end
36
- # end
37
- # value
38
- # end
39
- # end
40
-
41
- # to match our preference for consistent indentation
42
- Layout/HashAlignment:
43
- EnforcedLastArgumentHashStyle: always_ignore
44
-
45
- # to match our preference for consistent indentation
46
- Layout/ParameterAlignment:
47
- EnforcedStyle: with_fixed_indentation
48
-
49
- # to match our preference for consistent indentation
50
- Layout/BlockAlignment:
51
- EnforcedStyleAlignWith: start_of_block
52
-
53
- # to match our preference for consistent indentation
54
- Layout/CaseIndentation:
55
- EnforcedStyle: end
56
-
57
- # to match our preference for consistent indentation
58
- Layout/EndAlignment:
59
- EnforcedStyleAlignWith: start_of_line
60
-
61
- # Aligning Assignments, etc makes diffs noisy
62
- Layout/ExtraSpacing:
63
- AllowForAlignment: false
64
-
65
- # to match our preference for consistent indentation
66
- Layout/FirstArrayElementLineBreak:
67
- Enabled: true
68
-
69
- # to match our preference for consistent indentation
70
- Layout/FirstHashElementLineBreak:
71
- Enabled: true
72
-
73
- # to match our preference for consistent indentation
74
- Layout/FirstArgumentIndentation:
75
- EnforcedStyle: consistent
76
-
77
- # to match our preference for consistent indentation
78
- Layout/FirstArrayElementIndentation:
79
- EnforcedStyle: consistent
80
-
81
- # to match our preference for consistent indentation
82
- Layout/FirstHashElementIndentation:
83
- EnforcedStyle: consistent
84
-
85
- Layout/LineLength:
86
- Max: 120
87
-
88
- # to match our preference for consistent indentation
89
- # and hanging assignment looks lost
90
- Layout/MultilineAssignmentLayout:
91
- EnforcedStyle: same_line
92
-
93
- # this changes our preferred:
94
- # value = if thing1 &&
95
- # thing2
96
- # to:
97
- # value = if thing1 &&
98
- # thing2
99
- # even though the IndentationWidth is 2
100
- # but it's right most of the time so I put up with it
101
- Layout/MultilineOperationIndentation:
102
- EnforcedStyle: indented
103
-
104
- Layout/MultilineMethodCallIndentation:
105
- EnforcedStyle: indented
106
-
107
- # Temporarily disable this spec as a recent change has broken it for us:
108
- # https://github.com/rubocop-hq/rubocop/issues/6254
109
- Layout/RescueEnsureAlignment:
110
- Enabled: false
111
-
112
- Metrics:
113
- CountComments: false
114
-
115
- Metrics/BlockLength:
116
- ExcludedMethods:
117
- - configure
118
- - describe
119
- - context
120
- - shared_examples
121
-
122
- Metrics/CyclomaticComplexity:
123
- Enabled: false
124
-
125
- Metrics/PerceivedComplexity:
126
- Enabled: false
127
-
128
- RSpec:
129
- Enabled: true
130
- Include:
131
- - 'spec/**/*.rb'
132
-
133
- RSpec/DescribeClass:
134
- Enabled: false
135
-
136
- # I misuse matchers often
137
- RSpec/ExpectActual:
138
- Enabled: false
139
-
140
- RSpec/FilePath:
141
- Enabled: false
142
-
143
- # Multiple expectations are useful
144
- # checking you've partially achieved something on the way to completely achieving it is useful for debugging failures
145
- RSpec/MultipleExpectations:
146
- Enabled: false
147
-
148
- # It should be obvious from context. Chill out rubocop
149
- RSpec/NamedSubject:
150
- Enabled: false
151
-
152
- RSpec/NestedGroups:
153
- Max: 7
154
-
155
- # This matches the style we've been using all along (ever so slightly more frequently)
156
- Style/Alias:
157
- EnforcedStyle: prefer_alias_method
158
-
159
- Style/CollectionMethods:
160
- Enabled: true
161
-
162
- # we don't rdoc
163
- Style/Documentation:
164
- Enabled: false
165
-
166
- # this can mess with the balance of symmetric cases
167
- Style/IfInsideElse:
168
- Enabled: false
169
-
170
- # [a, b].include?(x) is more unclear than a == x || b == x
171
- Style/MultipleComparison:
172
- Enabled: false
173
-
174
- # it's microscopically faster
175
- Style/Not:
176
- Enabled: false
177
-
178
- # we use %w{} pretty frequently
179
- Style/PercentLiteralDelimiters:
180
- PreferredDelimiters:
181
- default: '{}'
182
- '%w': '{}'
183
- '%W': '{}'
184
- '%i': '{}'
185
- '%I': '{}'
186
- '%r': '{}'
187
-
188
- # We want this to warn to force consistency within the codebase.
189
- Style/SafeNavigation:
190
- Enabled: true
191
-
192
- # different methods calls that do exactly the same thing are a smell, regardless of semantics
193
- Style/SignalException:
194
- EnforcedStyle: only_raise
195
-
196
- # this wants less descriptive names
197
- Style/SingleLineBlockParams:
198
- Enabled: false
199
-
200
- Style/SymbolArray:
201
- Enabled: false
202
-
203
- Style/WordArray:
204
- Enabled: false
205
-
206
- Style/HashEachMethods:
207
- Enabled: true
208
-
209
- Style/HashTransformKeys:
210
- Enabled: true
211
-
212
- Style/HashTransformValues:
213
- Enabled: true
214
-
215
- Style/CommentedKeyword:
216
- Enabled: false
data/.simplecov DELETED
@@ -1,10 +0,0 @@
1
- SimpleCov.start do
2
- add_filter '/backports'
3
- add_filter '/spec/'
4
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5')
5
- enable_coverage(:branch)
6
- minimum_coverage line: 100, branch: 100
7
- else
8
- minimum_coverage 100
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- excludes:
2
- - vendor
3
- languages:
4
- english:
5
- locale: [US, AU]
@@ -1,50 +0,0 @@
1
- argv
2
- backports
3
- baz
4
- changelog
5
- codebase
6
- config
7
- cov
8
- cyclomatic
9
- enoent
10
- enumerables
11
- env
12
- errno
13
- extensionless
14
- fancyignore
15
- frotz
16
- gemfile
17
- github
18
- gitignore
19
- gitkeep
20
- hashbang
21
- includefile
22
- janky
23
- klass
24
- llo
25
- nocov
26
- noninfringement
27
- params
28
- pathspec
29
- pwd
30
- rdoc
31
- regexp
32
- rspec
33
- rubo
34
- rubocop
35
- rubygems
36
- rulesets
37
- rvm
38
- sherson
39
- simplecov
40
- stdin
41
- substring
42
- sudo
43
- symlinks
44
- tmp
45
- toplevel
46
- txt
47
- unrecursive
48
- upcase
49
- usr
50
- zsh
@@ -1 +0,0 @@
1
- rspec