pronto-blacklist 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: ce4d1ccba021e9f675d3b06ef0b7a697a14cb6fb
4
- data.tar.gz: 044345d7ec7aa46e89d4b30c4173b825b5bb3646
2
+ SHA256:
3
+ metadata.gz: 507e0f87c659e44e2fd599adfb5aec8d0127805cd88388456994e95e651c3289
4
+ data.tar.gz: ae2cc5ac22913d1475116a5410f8a216ffc73613a9d88546ba93804674fca60d
5
5
  SHA512:
6
- metadata.gz: 7a4e82dc235bf84fb6e95c827e98f0fd039b04f2c319dfae5dce17032f7ba4f24497d3e100a806f9b03f702d18b98bcfe8871f3fb06b36ad7a53e8a3ea63222b
7
- data.tar.gz: 3f83dc5e8b6c196bf5414bc45029bb408de1dc114887e62de7b1c67538196f32452b2809f511cf828cce8bd727f79de3b7f404e105d804f242e22a77bdb25d56
6
+ metadata.gz: 10249768505a075ce8d662fe3b048e4c23d5a5dd4d60fe64c82e83fb2e352f1e1302a5b516675c617687584597eba6e74e37d4baef9b1751cd05770173209557
7
+ data.tar.gz: 073605f619614fd3a776876c71b896247d0095b8ebb88c260f30444f4bc3e87620994a2a4e73eb1498a99af0803b3ce35569cb6aeb346aa7fac063b31ac04b05
@@ -0,0 +1,112 @@
1
+ version: 2
2
+ references:
3
+ cache_repo: &cache_repo
4
+ save_cache:
5
+ key: v1-repo-{{ .Branch }}-{{ .Revision }}
6
+ paths:
7
+ - .
8
+
9
+ restore_repo: &restore_repo
10
+ restore_cache:
11
+ key: v1-repo-{{ .Branch }}-{{ .Revision }}
12
+
13
+ bundle: &bundle
14
+ run:
15
+ name: Bundle Install
16
+ command: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle
17
+
18
+ run_tests: &run_tests
19
+ run:
20
+ name: run tests
21
+ command: bundle exec rake spec
22
+
23
+ jobs:
24
+ build:
25
+ docker:
26
+ - image: circleci/ruby:2.2
27
+ working_directory: ~/pronto-blacklist
28
+ steps:
29
+ - checkout
30
+ - *cache_repo
31
+ ruby_2.2:
32
+ docker:
33
+ - image: circleci/ruby:2.2
34
+ working_directory: ~/pronto-blacklist
35
+ steps:
36
+ - *restore_repo
37
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
38
+ - restore_cache:
39
+ key: v1-dependencies-2.2-{{ checksum "pronto-blacklist.gemspec" }}
40
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
41
+ - *bundle
42
+ - save_cache:
43
+ key: v1-dependencies-2.2-{{ checksum "pronto-blacklist.gemspec" }}
44
+ paths:
45
+ - ./vendor/bundle
46
+ - *run_tests
47
+ ruby_2.3:
48
+ docker:
49
+ - image: circleci/ruby:2.3
50
+ working_directory: ~/pronto-blacklist
51
+ steps:
52
+ - *restore_repo
53
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake libssl-dev
54
+ - restore_cache:
55
+ key: v1-dependencies-2.3-{{ checksum "pronto-blacklist.gemspec" }}
56
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
57
+ - *bundle
58
+ - save_cache:
59
+ key: v1-dependencies-2.3-{{ checksum "pronto-blacklist.gemspec" }}
60
+ paths:
61
+ - ./vendor/bundle
62
+ - *run_tests
63
+ ruby_2.4:
64
+ docker:
65
+ - image: circleci/ruby:2.4
66
+ working_directory: ~/pronto-blacklist
67
+ steps:
68
+ - *restore_repo
69
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
70
+ - restore_cache:
71
+ key: v1-dependencies-2.4-{{ checksum "pronto-blacklist.gemspec" }}
72
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
73
+ - *bundle
74
+ - save_cache:
75
+ key: v1-dependencies-2.4-{{ checksum "pronto-blacklist.gemspec" }}
76
+ paths:
77
+ - ./vendor/bundle
78
+ - *run_tests
79
+ ruby_2.5:
80
+ docker:
81
+ - image: circleci/ruby:2.5
82
+ working_directory: ~/pronto-blacklist
83
+ steps:
84
+ - *restore_repo
85
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
86
+ - restore_cache:
87
+ key: v1-dependencies-2.5-{{ checksum "pronto-blacklist.gemspec" }}
88
+ - run: sudo apt-get update -qq && sudo apt-get install -y cmake
89
+ - *bundle
90
+ - save_cache:
91
+ key: v1-dependencies-2.5-{{ checksum "pronto-blacklist.gemspec" }}
92
+ paths:
93
+ - ./vendor/bundle
94
+ - *run_tests
95
+
96
+ workflows:
97
+ version: 2
98
+ test_supported_ruby_versions:
99
+ jobs:
100
+ - build
101
+ - ruby_2.2:
102
+ requires:
103
+ - build
104
+ - ruby_2.3:
105
+ requires:
106
+ - build
107
+ - ruby_2.4:
108
+ requires:
109
+ - build
110
+ - ruby_2.5:
111
+ requires:
112
+ - build
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.2.0] - 2018-11-12
6
+
7
+ ### Added
8
+
9
+ * [#3](https://github.com/pbstriker38/pronto-blacklist/pull/3): Add options to exclude files and ignore case.
10
+
11
+ ### Changed
12
+
13
+ * [#3](https://github.com/pbstriker38/pronto-blacklist/pull/3): Format of .pronto-blacklist.yml changed
14
+
15
+ ## [0.1.0] - 2018-11-07
16
+
17
+ ### Added
18
+
19
+ * [#3](https://github.com/pbstriker38/pronto-blacklist/pull/1): First release
data/README.md CHANGED
@@ -1,15 +1,18 @@
1
+ [![Gem Version](https://badge.fury.io/rb/pronto-blacklist.svg)](https://badge.fury.io/rb/pronto-blacklist)
2
+ [![CircleCI](https://circleci.com/gh/pbstriker38/pronto-blacklist.svg?style=svg)](https://circleci.com/gh/pbstriker38/pronto-blacklist)
3
+
1
4
  # Pronto::Blacklist
2
5
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pronto/blacklist`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ Pronto runner to flag strings from a blacklist. [What is Pronto?](https://github.com/prontolabs/pronto)
4
7
 
5
- TODO: Delete this and the text above, and describe your gem
8
+ This is useful for preventing use of deprecated classes.
6
9
 
7
10
  ## Installation
8
11
 
9
12
  Add this line to your application's Gemfile:
10
13
 
11
14
  ```ruby
12
- gem 'pronto-blacklist'
15
+ gem 'pronto-blacklist', require: false
13
16
  ```
14
17
 
15
18
  And then execute:
@@ -22,7 +25,27 @@ Or install it yourself as:
22
25
 
23
26
  ## Usage
24
27
 
25
- TODO: Write usage instructions here
28
+ Create the following yaml file in the root of your codebase
29
+
30
+ `.pronto-blacklist.yml`
31
+ ```yaml
32
+ blacklist:
33
+ - DeprecatedClass
34
+ - cancelled
35
+ - some other string
36
+ options:
37
+ DeprecatedClass:
38
+ exclude:
39
+ - '**/*_spec.rb'
40
+ cancelled:
41
+ case_sensitive: false
42
+ ```
43
+
44
+ ### Options
45
+
46
+ `exclude`: Accepts an array of paths in .gitignore format. It will not blacklist the string in matching files.
47
+
48
+ `case_sensitive`: Defaults to `true` if not set.
26
49
 
27
50
  ## Development
28
51
 
@@ -32,4 +55,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
55
 
33
56
  ## Contributing
34
57
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pronto-blacklist.
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pbstriker38/pronto-blacklist.
@@ -1,5 +1,6 @@
1
1
  require 'pronto/blacklist/version'
2
2
  require 'pronto'
3
+ require 'pathspec'
3
4
 
4
5
  module Pronto
5
6
  class Blacklist < Runner
@@ -15,31 +16,53 @@ module Pronto
15
16
  private
16
17
 
17
18
  def inspect(patch)
19
+ return if patch.delta.new_file[:path] == '.pronto-blacklist.yml'
20
+
18
21
  patch.added_lines.map do |line|
19
- blacklist_words.map do |blacklist_word|
20
- new_message(line, blacklist_word) if line.content.include?(blacklist_word)
22
+ blacklist_strings.map do |blacklist_string|
23
+ new_message(line, blacklist_string) if match?(line, blacklist_string)
21
24
  end
22
25
  end
23
26
  end
24
27
 
28
+ def match?(line, blacklist_string)
29
+ options = options_for(blacklist_string)
30
+
31
+ if options['exclude'] && options['exclude'].any?
32
+ return false if PathSpec.new(options['exclude']).match(line.patch.new_file_full_path)
33
+ end
34
+
35
+
36
+ if options['case_sensitive'] == false
37
+ return line.content.downcase.include?(blacklist_string.downcase)
38
+ end
39
+
40
+ line.content.include?(blacklist_string)
41
+ end
42
+
25
43
  def new_message(line, word)
26
44
  path = line.patch.delta.new_file[:path]
27
45
 
28
46
  Message.new(path, line, :error, "Do not use #{word}", nil, self.class)
29
47
  end
30
48
 
31
- def blacklist_words
32
- @blacklist_words ||= begin
49
+ def blacklist_strings
50
+ @blacklist_strings ||= config_hash['blacklist'] || []
51
+ end
52
+
53
+ def options_for(blacklist_string)
54
+ config_hash['options'][blacklist_string] || {}
55
+ end
56
+
57
+ def config_hash
58
+ @config_hash ||= begin
59
+ config_path = File.expand_path(File.join('./', '.pronto-blacklist.yml'))
33
60
  if File.exist?(config_path)
34
- YAML.load_file(config_path)['blacklist'] || []
61
+ YAML.load_file(config_path)
35
62
  else
36
- []
63
+ {}
37
64
  end
38
65
  end
39
66
  end
40
-
41
- def config_path
42
- File.expand_path(File.join('./', '.pronto-blacklist.yml'))
43
- end
44
67
  end
45
68
  end
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module BlacklistVersion
3
- VERSION = "0.1.0"
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'pronto-blacklist'
7
7
  spec.version = Pronto::BlacklistVersion::VERSION
8
8
  spec.authors = ['Daniel Alfaro']
9
- spec.email = ['daniel@fair.com']
9
+ spec.email = ['pbstriker38@gmail.com']
10
10
 
11
11
  spec.summary = %q{Detects additions of items on blacklist.}
12
12
  spec.description = %q{Detects additions of items on blacklist.}
@@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency 'pronto', '~> 0.9'
34
+ spec.add_dependency 'pathspec', '~> 0.2'
34
35
 
35
- spec.add_development_dependency 'bundler', '~> 1.17'
36
+ spec.add_development_dependency 'bundler', '~> 1.16'
36
37
  spec.add_development_dependency 'rake', '~> 10.0'
37
38
  spec.add_development_dependency 'rspec', '~> 3.0'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-blacklist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Alfaro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto
@@ -24,20 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pathspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.17'
47
+ version: '1.16'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.17'
54
+ version: '1.16'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -68,15 +82,16 @@ dependencies:
68
82
  version: '3.0'
69
83
  description: Detects additions of items on blacklist.
70
84
  email:
71
- - daniel@fair.com
85
+ - pbstriker38@gmail.com
72
86
  executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".circleci/config.yml"
76
91
  - ".gitignore"
77
92
  - ".rspec"
93
+ - CHANGELOG.md
78
94
  - Gemfile
79
- - Gemfile.lock
80
95
  - LICENSE
81
96
  - README.md
82
97
  - Rakefile
@@ -106,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
121
  version: '0'
107
122
  requirements: []
108
123
  rubyforge_project:
109
- rubygems_version: 2.5.1
124
+ rubygems_version: 2.7.8
110
125
  signing_key:
111
126
  specification_version: 4
112
127
  summary: Detects additions of items on blacklist.
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pronto-blacklist (0.1.0)
5
- pronto (~> 0.9)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- addressable (2.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- diff-lcs (1.3)
13
- faraday (0.15.3)
14
- multipart-post (>= 1.2, < 3)
15
- gitlab (4.6.1)
16
- httparty (>= 0.14.0)
17
- terminal-table (>= 1.5.1)
18
- httparty (0.16.2)
19
- multi_xml (>= 0.5.2)
20
- multi_xml (0.6.0)
21
- multipart-post (2.0.0)
22
- octokit (4.13.0)
23
- sawyer (~> 0.8.0, >= 0.5.3)
24
- pronto (0.9.5)
25
- gitlab (~> 4.0, >= 4.0.0)
26
- httparty (>= 0.13.7)
27
- octokit (~> 4.7, >= 4.7.0)
28
- rainbow (~> 2.1)
29
- rugged (~> 0.24, >= 0.23.0)
30
- thor (~> 0.19.0)
31
- public_suffix (3.0.3)
32
- rainbow (2.2.2)
33
- rake
34
- rake (10.5.0)
35
- rspec (3.8.0)
36
- rspec-core (~> 3.8.0)
37
- rspec-expectations (~> 3.8.0)
38
- rspec-mocks (~> 3.8.0)
39
- rspec-core (3.8.0)
40
- rspec-support (~> 3.8.0)
41
- rspec-expectations (3.8.2)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.8.0)
44
- rspec-mocks (3.8.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.8.0)
47
- rspec-support (3.8.0)
48
- rugged (0.27.5)
49
- sawyer (0.8.1)
50
- addressable (>= 2.3.5, < 2.6)
51
- faraday (~> 0.8, < 1.0)
52
- terminal-table (1.8.0)
53
- unicode-display_width (~> 1.1, >= 1.1.1)
54
- thor (0.19.4)
55
- unicode-display_width (1.4.0)
56
-
57
- PLATFORMS
58
- ruby
59
-
60
- DEPENDENCIES
61
- bundler (~> 1.17)
62
- pronto-blacklist!
63
- rake (~> 10.0)
64
- rspec (~> 3.0)
65
-
66
- BUNDLED WITH
67
- 1.17.1