commit-meat 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/TODO.md +2 -0
- data/lib/commit-meat.rb +14 -10
- data/lib/commit-meat/config/bad_words_whitelist.yml +4 -0
- data/lib/commit-meat/tester.rb +36 -12
- data/lib/commit-meat/version.rb +1 -1
- metadata +4 -2
data/CHANGELOG.md
CHANGED
data/TODO.md
ADDED
data/lib/commit-meat.rb
CHANGED
@@ -8,22 +8,26 @@ require 'yaml'
|
|
8
8
|
module CommitMeat
|
9
9
|
|
10
10
|
def self.run
|
11
|
-
|
12
|
-
message = File.read(message_file).strip
|
13
|
-
|
14
|
-
tester = Tester.new(message)
|
15
|
-
|
11
|
+
tester = Tester.new(commit_message)
|
16
12
|
tester.test
|
17
|
-
|
18
|
-
|
13
|
+
|
14
|
+
if tester.has_failures? || tester.has_warnings?
|
15
|
+
puts "There's NO MEAT - did not commit.".magenta.bold
|
16
|
+
tester.warning_messages.each { |message| puts message.yellow }
|
17
|
+
tester.failure_messages.each { |message| puts message.red }
|
19
18
|
end
|
19
|
+
|
20
|
+
stop_commit if tester.has_failures?
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
23
24
|
|
24
|
-
def self.
|
25
|
-
|
26
|
-
|
25
|
+
def self.commit_message
|
26
|
+
message_file = ARGV[0]
|
27
|
+
File.read(message_file).strip
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.stop_commit
|
27
31
|
exit 1
|
28
32
|
end
|
29
33
|
|
data/lib/commit-meat/tester.rb
CHANGED
@@ -2,28 +2,48 @@ module CommitMeat
|
|
2
2
|
|
3
3
|
class Tester
|
4
4
|
|
5
|
-
attr_reader :failure_messages
|
5
|
+
attr_reader :failure_messages, :warning_messages
|
6
6
|
|
7
7
|
def initialize(message)
|
8
8
|
@message = message
|
9
9
|
@failure_messages = []
|
10
|
+
@warning_messages = []
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
+
def has_messages?
|
14
|
+
has_warnings? || has_failures?
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_warnings?
|
18
|
+
@warning_messages.any?
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_failures?
|
13
22
|
@failure_messages.any?
|
14
23
|
end
|
15
24
|
|
16
25
|
def test
|
17
|
-
|
18
|
-
|
26
|
+
fail_if :has_only_one_word, "A single word commit message? really?"
|
27
|
+
warn_if :includes_bad_words, "$@#! - [gets shocked by a V-chip]"
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fail_if(test, failure_message)
|
33
|
+
test_if(test, failure_message, @failure_messages)
|
34
|
+
end
|
35
|
+
|
36
|
+
def warn_if(test, warning_message)
|
37
|
+
test_if(test, warning_message, @warning_messages)
|
19
38
|
end
|
20
39
|
|
21
|
-
def
|
22
|
-
if send(
|
23
|
-
|
40
|
+
def test_if(test, message, message_box)
|
41
|
+
if send(test)
|
42
|
+
message_box << message
|
24
43
|
end
|
25
44
|
end
|
26
45
|
|
46
|
+
|
27
47
|
## tests
|
28
48
|
|
29
49
|
def has_only_one_word
|
@@ -32,15 +52,19 @@ module CommitMeat
|
|
32
52
|
|
33
53
|
def includes_bad_words
|
34
54
|
bad_words = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'config/bad_words.yml'))
|
35
|
-
|
55
|
+
bad_words_whitelist = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'config/bad_words_whitelist.yml'))
|
56
|
+
|
57
|
+
words_in_message = @message.split
|
36
58
|
|
37
|
-
bad_words.
|
38
|
-
|
59
|
+
bad_words.any? do |bad_word|
|
60
|
+
words_in_message.any? do |word|
|
61
|
+
if word.include?(bad_word)
|
62
|
+
!bad_words_whitelist.any? { |whitelist_word| word.include?(whitelist_word) }
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
40
66
|
|
41
|
-
bad_words_found.any?
|
42
67
|
end
|
43
68
|
|
44
69
|
end
|
45
|
-
|
46
70
|
end
|
data/lib/commit-meat/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commit-meat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colored
|
@@ -56,11 +56,13 @@ files:
|
|
56
56
|
- CHANGELOG.md
|
57
57
|
- LICENSE
|
58
58
|
- README.md
|
59
|
+
- TODO.md
|
59
60
|
- bin/commit-meat
|
60
61
|
- commit-meat.gemspec
|
61
62
|
- gemfile
|
62
63
|
- lib/commit-meat.rb
|
63
64
|
- lib/commit-meat/config/bad_words.yml
|
65
|
+
- lib/commit-meat/config/bad_words_whitelist.yml
|
64
66
|
- lib/commit-meat/installation.rb
|
65
67
|
- lib/commit-meat/tester.rb
|
66
68
|
- lib/commit-meat/version.rb
|