fast_ignore 0.10.2 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
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,52 +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
- memoize
26
- nocov
27
- noninfringement
28
- params
29
- pathspec
30
- pwd
31
- rdoc
32
- regexp
33
- rspec
34
- rubo
35
- rubocop
36
- rubygems
37
- rulesets
38
- rvm
39
- sherson
40
- simplecov
41
- stdin
42
- substring
43
- sudo
44
- symlinks
45
- tmp
46
- toplevel
47
- txt
48
- unrecursive
49
- upcase
50
- usr
51
- webpack
52
- zsh
@@ -1 +0,0 @@
1
- rspec
@@ -1,3 +0,0 @@
1
- env
2
- euo
3
- usr
@@ -1,9 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
- - 2.7
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in fast_ignore.gemspec
8
-
9
- gemspec
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
- require 'spellr/rake_task'
7
- require 'leftovers/rake_task'
8
-
9
- RuboCop::RakeTask.new
10
- RSpec::Core::RakeTask.new(:spec)
11
- Spellr::RakeTask.generate_task
12
- Leftovers::RakeTask.generate_task
13
-
14
- task default: [:spec, :rubocop, :spellr, :leftovers]
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'fast_ignore'
6
-
7
- require 'pry'
8
- Pry.start
data/bin/ls DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby --disable-all
2
- # frozen_string_literal: true
3
-
4
- require_relative '../lib/fast_ignore'
5
-
6
- puts FastIgnore.new(relative: true, argv_rules: ARGV).to_a
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/bin/time DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # use mac terminal not vs code terminal
5
- # ensure nothing else is watching that dir in the filesystem e.g. webpack
6
-
7
- require 'open3'
8
- RUNS = 30
9
- SCRIPT = "time #{__dir__}/ls"
10
- Dir.chdir ARGV[0] do
11
- times = Array.new(RUNS).map do
12
- run_times = Open3.capture3(SCRIPT)[1]
13
- puts run_times.lstrip
14
- run_times.scan(/(?:\d+(?:.\d+)?)/)
15
- end
16
-
17
- puts format(
18
- "\e[1mAverage:\n\e[32m%0.2f real %0.2f user %0.2f sys\e[0m", # rubocop:disable Style/FormatStringToken
19
- *times.transpose.map { |n| (n.map(&:to_f).sum / RUNS) }
20
- )
21
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'fast_ignore/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'fast_ignore'
9
- spec.version = FastIgnore::VERSION
10
- spec.authors = ['Dana Sherson']
11
- spec.email = ['robot@dana.sh']
12
-
13
- spec.summary = 'Parse gitignore files, quickly'
14
- spec.homepage = 'https://github.com/robotdana/fast_ignore'
15
- spec.license = 'MIT'
16
-
17
- spec.required_ruby_version = '~> 2.4'
18
-
19
- if spec.respond_to?(:metadata)
20
- spec.metadata['homepage_uri'] = spec.homepage
21
- spec.metadata['source_code_uri'] = 'https://github.com/robotdana/fast_ignore'
22
- spec.metadata['changelog_uri'] = 'https://github.com/robotdana/fast_ignore/blob/master/CHANGELOG.md'
23
- end
24
-
25
- # Specify which files should be added to the gem when it is released.
26
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
- end
30
- spec.require_paths = ['lib']
31
-
32
- spec.add_development_dependency 'bundler', '>= 1.17'
33
- spec.add_development_dependency 'leftovers', '>= 0.2.2'
34
- spec.add_development_dependency 'pry', '> 0'
35
- spec.add_development_dependency 'rake', '>= 12.3.3'
36
- spec.add_development_dependency 'rspec', '~> 3.0'
37
- spec.add_development_dependency 'rubocop', '>= 0.74.0'
38
- spec.add_development_dependency 'rubocop-rspec', '~> 1'
39
- spec.add_development_dependency 'simplecov', '~> 0.18.5'
40
- spec.add_development_dependency 'spellr', '>= 0.8.3'
41
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This is a backport of ruby 2.5's delete_prefix/delete_suffix methods
4
- class FastIgnore
5
- module Backports
6
- module DeletePrefixSuffix
7
- refine ::String do
8
- # delete_prefix!(prefix) -> self or nil
9
- # Deletes leading prefix from str, returning nil if no change was made.
10
- #
11
- # "hello".delete_prefix!("hel") #=> "lo"
12
- # "hello".delete_prefix!("llo") #=> nil
13
- def delete_prefix!(str)
14
- return unless start_with?(str)
15
-
16
- slice!(0..(str.length - 1))
17
- self
18
- end
19
-
20
- # delete_suffix!(suffix) -> self or nil
21
- # Deletes trailing suffix from str, returning nil if no change was made.
22
- #
23
- # "hello".delete_suffix!("llo") #=> "he"
24
- # "hello".delete_suffix!("hel") #=> nil
25
- def delete_suffix!(str)
26
- return unless end_with?(str)
27
-
28
- slice!(-str.length..-1)
29
- self
30
- end
31
-
32
- # delete_prefix(prefix) -> new_str click to toggle source
33
- # Returns a copy of str with leading prefix deleted.
34
- #
35
- # "hello".delete_prefix("hel") #=> "lo"
36
- # "hello".delete_prefix("llo") #=> "hello"
37
- def delete_prefix(str)
38
- s = dup
39
- s.delete_prefix!(str)
40
- s
41
- end
42
-
43
- # delete_suffix(suffix) -> new_str
44
- # Returns a copy of str with trailing suffix deleted.
45
- #
46
- # "hello".delete_suffix("llo") #=> "he"
47
- # "hello".delete_suffix("hel") #=> "hello"
48
- def delete_suffix(str) # leftovers:allowed
49
- s = dup
50
- s.delete_suffix!(str)
51
- s
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This is a backport of ruby 2.5's each_child method
4
- class FastIgnore
5
- module Backports
6
- module DirEachChild
7
- refine ::Dir.singleton_class do
8
- def each_child(path, &block)
9
- Dir.entries(path).each do |entry|
10
- next if entry == '.' || entry == '..'
11
-
12
- block.call entry
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class FastIgnore
4
- module RuleSetBuilder
5
- class << self
6
- # :nocov:
7
- if ::FastIgnore::Backports.ruby_version_less_than?(2, 5)
8
- require_relative 'backports/delete_prefix_suffix'
9
- using ::FastIgnore::Backports::DeletePrefixSuffix
10
- end
11
- # :nocov:
12
-
13
- def build( # rubocop:disable Metrics/ParameterLists
14
- root:,
15
- ignore_rules: nil,
16
- ignore_files: nil,
17
- gitignore: :auto,
18
- include_rules: nil,
19
- include_files: nil,
20
- argv_rules: nil
21
- )
22
- prepare [
23
- from_array(ignore_rules),
24
- *from_files(ignore_files, project_root: root),
25
- from_array('.git'),
26
- from_gitignore_arg(gitignore, project_root: root),
27
- from_array(include_rules, allow: true),
28
- *from_files(include_files, allow: true, project_root: root),
29
- from_array(argv_rules, allow: true, expand_path: root)
30
- ]
31
- end
32
-
33
- private
34
-
35
- def prepare(rule_sets)
36
- rule_sets.compact!
37
- rule_sets.reject!(&:empty?)
38
- rule_sets.sort_by!(&:weight)
39
- rule_sets
40
- end
41
-
42
- def from_file(filename, project_root:, allow: false)
43
- filename = ::File.expand_path(filename, project_root)
44
- raise FastIgnore::Error, "#{filename} is not within #{project_root}" unless filename.start_with?(project_root)
45
-
46
- file_root = "#{::File.dirname(filename)}/".delete_prefix(project_root)
47
- build_rule_set(::File.readlines(filename), allow, file_root: file_root)
48
- end
49
-
50
- def from_files(files, project_root:, allow: false)
51
- Array(files).map do |file|
52
- from_file(file, project_root: project_root, allow: allow)
53
- end
54
- end
55
-
56
- def from_gitignore_arg(gitignore, project_root:)
57
- default_path = ::File.join(project_root, '.gitignore')
58
- case gitignore
59
- when :auto
60
- from_file(default_path, project_root: project_root) if ::File.exist?(default_path)
61
- when true
62
- from_file(default_path, project_root: project_root)
63
- end
64
- end
65
-
66
- def from_array(rules, allow: false, expand_path: false)
67
- return unless rules
68
-
69
- rules = Array(rules)
70
-
71
- return if rules.empty?
72
-
73
- rules = rules.flat_map { |string| string.to_s.lines }
74
-
75
- build_rule_set(rules, allow, expand_path: expand_path)
76
- end
77
-
78
- def build_rule_set(rules, allow, expand_path: false, file_root: nil)
79
- rules = rules.flat_map do |rule|
80
- ::FastIgnore::RuleBuilder.build(rule, allow, expand_path, file_root)
81
- end
82
-
83
- ::FastIgnore::RuleSet.new(rules, allow).freeze
84
- end
85
- end
86
- end
87
- end