pronto-dirty_words 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab8140a1ed32f681e2c597b2be2165ff644cbf22
4
+ data.tar.gz: bd771c3975a89d21ef87ee0501678563b828350e
5
+ SHA512:
6
+ metadata.gz: 525d96aabf2d2cb950ff3bbdd49a2b4f768501acf6500e0dec98fb93c7b2fff2a4afed80f556670a14b87ab4465d33a49e7c0be7ea57a38a682d22f17f715e18
7
+ data.tar.gz: f9ab5036c4558239b20cefa1ee603fcf0dc2cbf79a56ab29cc27ac94e8e2d572d20585687c44452b2c5a970fbdb61a9ba03fc339518c419ad78acd410abb4a94
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2017 Kevin Jalbert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Pronto Dirty Words Runner
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pronto-dirty_words.svg)](http://badge.fury.io/rb/pronto-dirty_words)
4
+ [![Build Status](https://travis-ci.org/kevinjalbert/pronto-dirty_words.svg?branch=master)](https://travis-ci.org/kevinjalbert/pronto-dirty_words)
5
+ [![Code Climate](https://codeclimate.com/github/kevinjalbert/pronto-dirty_words/badges/gpa.svg)](https://codeclimate.com/github/kevinjalbert/pronto-dirty_words)
6
+ [![Test Coverage](https://codeclimate.com/github/kevinjalbert/pronto-dirty_words/badges/coverage.svg)](https://codeclimate.com/github/kevinjalbert/pronto-dirty_words/coverage)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/kevinjalbert/pronto-dirty_words.svg)](https://gemnasium.com/github.com/kevinjalbert/pronto-dirty_words)
8
+
9
+ Pronto runner for the [Seven Dirty Words](https://en.wikipedia.org/wiki/Seven_dirty_words). [What is Pronto?](https://github.com/mmozuras/pronto)
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module DirtyWordsVersion
3
+ VERSION = '0.9.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ require 'pronto'
2
+ require 'shellwords'
3
+
4
+ module Pronto
5
+ class DirtyWords < Runner
6
+ DIRTY_WORDS = ['shit', 'piss', 'fuck', 'cunt', 'cocksucker', 'motherfucker', 'tits']
7
+
8
+ def run
9
+ return [] if !@patches || @patches.count.zero?
10
+
11
+ @patches
12
+ .select { |patch| patch.additions > 0 }
13
+ .map { |patch| inspect(patch) }
14
+ .flatten.compact
15
+ end
16
+
17
+ private
18
+
19
+ def git_repo_path
20
+ @git_repo_path ||= Rugged::Repository.discover(File.expand_path(Dir.pwd)).workdir
21
+ end
22
+
23
+ def inspect(patch)
24
+ offending_line_numbers(patch).map do |line_number|
25
+ patch
26
+ .added_lines
27
+ .select { |line| line.new_lineno == line_number }
28
+ .map { |line| new_message('Avoid using one of the seven dirty words', line) }
29
+ end
30
+ end
31
+
32
+ def new_message(offence, line)
33
+ path = line.patch.delta.new_file[:path]
34
+ level = :warning
35
+
36
+ Message.new(path, line, level, offence, nil, self.class)
37
+ end
38
+
39
+ def offending_line_numbers(patch)
40
+ line_numbers = []
41
+
42
+ Dir.chdir(git_repo_path) do
43
+ escaped_file_path = Shellwords.escape(patch.new_file_full_path.to_s)
44
+
45
+ File.foreach(escaped_file_path).with_index do |line, line_num|
46
+ line_numbers << line_num + 1 if DIRTY_WORDS.any? { |word| line.downcase.include?(word) }
47
+ end
48
+
49
+ line_numbers
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-dirty_words
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Jalbert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.24'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.23.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.24'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.23.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '12.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '12.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.4'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.4'
75
+ description:
76
+ email: kevin.j.jalbert@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files:
80
+ - LICENSE
81
+ - README.md
82
+ files:
83
+ - LICENSE
84
+ - README.md
85
+ - lib/pronto/dirty_words.rb
86
+ - lib/pronto/dirty_words/version.rb
87
+ homepage: https://github.com/kevinjalbert/pronto-dirty_words
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 2.0.0
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.6.11
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Pronto runner for flagging the Seven Dirty Words
111
+ test_files: []