wielder_of_anor 0.3.2 → 0.4.0
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.
- checksums.yaml +4 -4
- data/.gitignore +5 -5
- data/LICENSE.txt +21 -21
- data/README.md +114 -114
- data/bin/wielder_of_anor +17 -17
- data/lib/wielder_of_anor.rb +388 -382
- data/lib/wielder_of_anor/version.rb +2 -2
- data/wielder_of_anor.gemspec +26 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f95532e9ef0f162cee99d705e5ff57d76e603f
|
4
|
+
data.tar.gz: 19b253f236f65500cc08ed86a79b4292d2e7ad1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7b6cdaeaf0762b20bdb52bf95d0129ff7b61060859f2b6872c8ba913c6bbc087777cf95ced720bdd2e2cf66ff4671711ca6d04034886d24ea14dc45b58caf4
|
7
|
+
data.tar.gz: f7aadde722183cd655b094feaee85aa976a24ad2bbdaa75eab375ddb5f3d05ec096d8eca3993f61a6057a1cf4fa9a0f913636fd0b3e7d2129c992f854218dd02
|
data/.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
docs/forbidden_words
|
2
|
-
docs/files_changed
|
3
|
-
config/config.yaml
|
4
|
-
Gemfile.lock
|
5
|
-
.idea
|
1
|
+
docs/forbidden_words
|
2
|
+
docs/files_changed
|
3
|
+
config/config.yaml
|
4
|
+
Gemfile.lock
|
5
|
+
.idea
|
6
6
|
.bundle
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 iamsellek
|
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 all
|
13
|
-
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 THE
|
21
|
-
SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 iamsellek
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,115 +1,115 @@
|
|
1
|
-
# Wielder of Anor
|
2
|
-
Checks a user's staged files for "forbidden" words (as determined by the user)
|
3
|
-
and, if any are found, alerts the user to the locations of said words.
|
4
|
-
|
5
|
-
## Longer Description
|
6
|
-
I am absent-minded. Very absent-minded. Absent-minded to the point that I'll
|
7
|
-
throw some "puts" or "console.log" commands into my code for debugging purposes
|
8
|
-
only to completely forget about them and then happily push all my code to
|
9
|
-
master branch without a care in the world. This...is not okay. Yet despite my
|
10
|
-
constant reminders to my brain that it most certainly is not okay, it keeps
|
11
|
-
quite happily forgetting everything about everything when it's time to commit
|
12
|
-
my code. And since I (apparently) can't magically fix the way my brain works, I
|
13
|
-
figured I'd make my computer double-check me since, you know, that is the entire
|
14
|
-
reason we invented computers to begin with. Enter Wielder of Anor.
|
15
|
-
|
16
|
-
Wielder of Anor is a quick and easy way to ensure that you aren't pushing your
|
17
|
-
code to production (or anywhere else it shouldn't be) with "forbidden words" you
|
18
|
-
don't want there. You yourself determine which words are forbidden, so this app
|
19
|
-
should be helpful to anyone wanting to prevent certain text from making it past
|
20
|
-
your dev environment. Maybe you're like me and you can never remember to pull
|
21
|
-
your debugging commands out of your code before committing. Maybe you're a code
|
22
|
-
master and commit swaths of code at a time, laughing at the mere mortals around
|
23
|
-
you who commit smaller chunks of work several times a day, and you can't be
|
24
|
-
bothered to check through your tens of thousands of lines of code to ensure you
|
25
|
-
didn't leave some debugging command in there somewhere. Or maybe your code gets
|
26
|
-
more and more filled with swear words the more frustrating a problem gets and
|
27
|
-
you just can't let one of those slip to production again because seriously it'd
|
28
|
-
be like the third or fourth time and you like working here and can't imagine
|
29
|
-
staying here if you slip up another time or two and...
|
30
|
-
|
31
|
-
Ahem. Sorry.
|
32
|
-
|
33
|
-
So. If you need to prevent anything in your code from making it past your dev
|
34
|
-
environment and need a reliable way to do this, use Wielder of Anor.
|
35
|
-
|
36
|
-
## Installation
|
37
|
-
Installation is simple! Just run a `gem install wielder_of_anor`, then run
|
38
|
-
`wielder_of_anor` and follow the instructions. You're now good to go!
|
39
|
-
|
40
|
-
## Use/What It Does
|
41
|
-
To use Wielder of Anor, just run it *from within the code directory you want to
|
42
|
-
run the forbidden words checks against* (this is important). From your code
|
43
|
-
directory, just type `wielder_of_anor` followed by your arguments. You can pass
|
44
|
-
in a couple of arguments here.
|
45
|
-
|
46
|
-
The first argument can be:
|
47
|
-
|
48
|
-
* Your eventual commit message (in quotes), if you've chosen to allow Wielder
|
49
|
-
of Anor itself to run your commits for you. If you've chosen to *not* allow it
|
50
|
-
to run your commits for you, this argument will be ignored.
|
51
|
-
* 'help' - This will simply print out shorter versions of the options you are
|
52
|
-
currently reading.
|
53
|
-
* 'config' - This will re-run the configuration process. IF YOU SET ANY OF YOUR
|
54
|
-
FILE LOCATIONS TO POINT TO PREVIOUSLY EXISTING FILES, THOSE FILES *WILL* BE
|
55
|
-
OVERWRITTEN.
|
56
|
-
* 'words' - This will spit out all of the forbidden words that you currently
|
57
|
-
are checking for.
|
58
|
-
|
59
|
-
There is currently only one option for the second argument:
|
60
|
-
|
61
|
-
* The second argument can only be '1' and will be ignored unless there is a
|
62
|
-
commit message as the first argument. If this argument is passed, Wielder of
|
63
|
-
Anor will skip checking for any forbidden words whatsoever and jump straight
|
64
|
-
to the commit portion of the app. This is mainly here so that you can easily
|
65
|
-
force a commit after Wielder of Anor tells you of some forbidden words that
|
66
|
-
you've decided to allow for whatever reason. For instance, say 'puts' is one
|
67
|
-
of your forbidden words and there's a commented-out puts statement in your
|
68
|
-
code that you didn't put there and that, as such, you don't want to delete.
|
69
|
-
It's the only forbidden word showing up, so the rest of your code is clean.
|
70
|
-
So, instead of now having to type out a full git commit command, you can now
|
71
|
-
just hit your up arrow, hit the spacebar, type a '1' and hit enter.
|
72
|
-
|
73
|
-
Once run, Wielder of Anor will run a bash command that'll export the result of a
|
74
|
-
`git diff HEAD --staged --name-only` (so all files that you have 'git add'ed
|
75
|
-
since git HEAD) to a file. It'll then check every line in every one of those
|
76
|
-
files for any of your forbidden words and print out the locations of any and
|
77
|
-
every one it finds.
|
78
|
-
|
79
|
-
If it found none (or if you've skipped the search and are forcing a commit), you
|
80
|
-
are good to go and can tell the app to then run the git commit command, if
|
81
|
-
you've opted to allow it to do so. At this point, Wielder of Anor will run a
|
82
|
-
`git commit -m` followed by your commit message (your first argument when
|
83
|
-
running the app). Once it prints out "COMMITTED.", execution will end. Don't
|
84
|
-
forget to run your git push!
|
85
|
-
|
86
|
-
## Wielder of Anor? Wut.
|
87
|
-
You know, the thing Gandalf calls himself to the Balrog as he's all "YOU SHALL
|
88
|
-
NOT PASS!" over and over? When he's, you know, preventing the Balrog from
|
89
|
-
getting past him? He...he prevents a *forbidden* thing from...
|
90
|
-
|
91
|
-
A gatekeeper. This app is a gatekeeper. Gandalf was a Gatekeeper that one
|
92
|
-
time. It's artistic. Or something.
|
93
|
-
|
94
|
-
## License
|
95
|
-
The MIT License (MIT)
|
96
|
-
|
97
|
-
Copyright (c) 2016 Chris Sellek
|
98
|
-
|
99
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
100
|
-
of this software and associated documentation files (the "Software"), to deal
|
101
|
-
in the Software without restriction, including without limitation the rights
|
102
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
103
|
-
copies of the Software, and to permit persons to whom the Software is
|
104
|
-
furnished to do so, subject to the following conditions:
|
105
|
-
|
106
|
-
The above copyright notice and this permission notice shall be included in all
|
107
|
-
copies or substantial portions of the Software.
|
108
|
-
|
109
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
110
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
111
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
112
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
113
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
114
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
1
|
+
# Wielder of Anor
|
2
|
+
Checks a user's staged files for "forbidden" words (as determined by the user)
|
3
|
+
and, if any are found, alerts the user to the locations of said words.
|
4
|
+
|
5
|
+
## Longer Description
|
6
|
+
I am absent-minded. Very absent-minded. Absent-minded to the point that I'll
|
7
|
+
throw some "puts" or "console.log" commands into my code for debugging purposes
|
8
|
+
only to completely forget about them and then happily push all my code to
|
9
|
+
master branch without a care in the world. This...is not okay. Yet despite my
|
10
|
+
constant reminders to my brain that it most certainly is not okay, it keeps
|
11
|
+
quite happily forgetting everything about everything when it's time to commit
|
12
|
+
my code. And since I (apparently) can't magically fix the way my brain works, I
|
13
|
+
figured I'd make my computer double-check me since, you know, that is the entire
|
14
|
+
reason we invented computers to begin with. Enter Wielder of Anor.
|
15
|
+
|
16
|
+
Wielder of Anor is a quick and easy way to ensure that you aren't pushing your
|
17
|
+
code to production (or anywhere else it shouldn't be) with "forbidden words" you
|
18
|
+
don't want there. You yourself determine which words are forbidden, so this app
|
19
|
+
should be helpful to anyone wanting to prevent certain text from making it past
|
20
|
+
your dev environment. Maybe you're like me and you can never remember to pull
|
21
|
+
your debugging commands out of your code before committing. Maybe you're a code
|
22
|
+
master and commit swaths of code at a time, laughing at the mere mortals around
|
23
|
+
you who commit smaller chunks of work several times a day, and you can't be
|
24
|
+
bothered to check through your tens of thousands of lines of code to ensure you
|
25
|
+
didn't leave some debugging command in there somewhere. Or maybe your code gets
|
26
|
+
more and more filled with swear words the more frustrating a problem gets and
|
27
|
+
you just can't let one of those slip to production again because seriously it'd
|
28
|
+
be like the third or fourth time and you like working here and can't imagine
|
29
|
+
staying here if you slip up another time or two and...
|
30
|
+
|
31
|
+
Ahem. Sorry.
|
32
|
+
|
33
|
+
So. If you need to prevent anything in your code from making it past your dev
|
34
|
+
environment and need a reliable way to do this, use Wielder of Anor.
|
35
|
+
|
36
|
+
## Installation
|
37
|
+
Installation is simple! Just run a `gem install wielder_of_anor`, then run
|
38
|
+
`wielder_of_anor` and follow the instructions. You're now good to go!
|
39
|
+
|
40
|
+
## Use/What It Does
|
41
|
+
To use Wielder of Anor, just run it *from within the code directory you want to
|
42
|
+
run the forbidden words checks against* (this is important). From your code
|
43
|
+
directory, just type `wielder_of_anor` followed by your arguments. You can pass
|
44
|
+
in a couple of arguments here.
|
45
|
+
|
46
|
+
The first argument can be:
|
47
|
+
|
48
|
+
* Your eventual commit message (in quotes), if you've chosen to allow Wielder
|
49
|
+
of Anor itself to run your commits for you. If you've chosen to *not* allow it
|
50
|
+
to run your commits for you, this argument will be ignored.
|
51
|
+
* 'help' - This will simply print out shorter versions of the options you are
|
52
|
+
currently reading.
|
53
|
+
* 'config' - This will re-run the configuration process. IF YOU SET ANY OF YOUR
|
54
|
+
FILE LOCATIONS TO POINT TO PREVIOUSLY EXISTING FILES, THOSE FILES *WILL* BE
|
55
|
+
OVERWRITTEN.
|
56
|
+
* 'words' - This will spit out all of the forbidden words that you currently
|
57
|
+
are checking for.
|
58
|
+
|
59
|
+
There is currently only one option for the second argument:
|
60
|
+
|
61
|
+
* The second argument can only be '1' and will be ignored unless there is a
|
62
|
+
commit message as the first argument. If this argument is passed, Wielder of
|
63
|
+
Anor will skip checking for any forbidden words whatsoever and jump straight
|
64
|
+
to the commit portion of the app. This is mainly here so that you can easily
|
65
|
+
force a commit after Wielder of Anor tells you of some forbidden words that
|
66
|
+
you've decided to allow for whatever reason. For instance, say 'puts' is one
|
67
|
+
of your forbidden words and there's a commented-out puts statement in your
|
68
|
+
code that you didn't put there and that, as such, you don't want to delete.
|
69
|
+
It's the only forbidden word showing up, so the rest of your code is clean.
|
70
|
+
So, instead of now having to type out a full git commit command, you can now
|
71
|
+
just hit your up arrow, hit the spacebar, type a '1' and hit enter.
|
72
|
+
|
73
|
+
Once run, Wielder of Anor will run a bash command that'll export the result of a
|
74
|
+
`git diff HEAD --staged --name-only` (so all files that you have 'git add'ed
|
75
|
+
since git HEAD) to a file. It'll then check every line in every one of those
|
76
|
+
files for any of your forbidden words and print out the locations of any and
|
77
|
+
every one it finds.
|
78
|
+
|
79
|
+
If it found none (or if you've skipped the search and are forcing a commit), you
|
80
|
+
are good to go and can tell the app to then run the git commit command, if
|
81
|
+
you've opted to allow it to do so. At this point, Wielder of Anor will run a
|
82
|
+
`git commit -m` followed by your commit message (your first argument when
|
83
|
+
running the app). Once it prints out "COMMITTED.", execution will end. Don't
|
84
|
+
forget to run your git push!
|
85
|
+
|
86
|
+
## Wielder of Anor? Wut.
|
87
|
+
You know, the thing Gandalf calls himself to the Balrog as he's all "YOU SHALL
|
88
|
+
NOT PASS!" over and over? When he's, you know, preventing the Balrog from
|
89
|
+
getting past him? He...he prevents a *forbidden* thing from...
|
90
|
+
|
91
|
+
A gatekeeper. This app is a gatekeeper. Gandalf was a Gatekeeper that one
|
92
|
+
time. It's artistic. Or something.
|
93
|
+
|
94
|
+
## License
|
95
|
+
The MIT License (MIT)
|
96
|
+
|
97
|
+
Copyright (c) 2016 Chris Sellek
|
98
|
+
|
99
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
100
|
+
of this software and associated documentation files (the "Software"), to deal
|
101
|
+
in the Software without restriction, including without limitation the rights
|
102
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
103
|
+
copies of the Software, and to permit persons to whom the Software is
|
104
|
+
furnished to do so, subject to the following conditions:
|
105
|
+
|
106
|
+
The above copyright notice and this permission notice shall be included in all
|
107
|
+
copies or substantial portions of the Software.
|
108
|
+
|
109
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
110
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
111
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
112
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
113
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
114
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
115
115
|
SOFTWARE.
|
data/bin/wielder_of_anor
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'wielder_of_anor'
|
4
|
-
|
5
|
-
woa = WielderOfAnor::WielderOfAnor.new
|
6
|
-
|
7
|
-
woa.help if ARGV[0] == 'help'
|
8
|
-
|
9
|
-
woa.first_run if ARGV[0] == 'config'
|
10
|
-
|
11
|
-
woa.output_forbidden_words if ARGV[0] == 'words'
|
12
|
-
|
13
|
-
woa.add_forbidden_word(ARGV[1]) if ARGV[0] == 'add'
|
14
|
-
|
15
|
-
woa.prepare(ARGV[0], ARGV[1])
|
16
|
-
|
17
|
-
woa.wielder_of_anor
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'wielder_of_anor'
|
4
|
+
|
5
|
+
woa = WielderOfAnor::WielderOfAnor.new
|
6
|
+
|
7
|
+
woa.help if ARGV[0] == 'help'
|
8
|
+
|
9
|
+
woa.first_run if ARGV[0] == 'config'
|
10
|
+
|
11
|
+
woa.output_forbidden_words if ARGV[0] == 'words'
|
12
|
+
|
13
|
+
woa.add_forbidden_word(ARGV[1]) if ARGV[0] == 'add'
|
14
|
+
|
15
|
+
woa.prepare(ARGV[0], ARGV[1])
|
16
|
+
|
17
|
+
woa.wielder_of_anor
|
data/lib/wielder_of_anor.rb
CHANGED
@@ -1,383 +1,389 @@
|
|
1
|
-
require 'shellwords'
|
2
|
-
require 'yaml'
|
3
|
-
require 'rainbow'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
require_relative 'wielder_of_anor/version'
|
7
|
-
|
8
|
-
module WielderOfAnor
|
9
|
-
class WielderOfAnor
|
10
|
-
include WielderOfAnorVersion
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
set_app_directory
|
14
|
-
|
15
|
-
@forbidden_words = []
|
16
|
-
end
|
17
|
-
|
18
|
-
##############################################################################
|
19
|
-
##############################################################################
|
20
|
-
## ##
|
21
|
-
## commit_message is the git commit message the user would like to send ##
|
22
|
-
## once we have verified that there are no forbidden words present in their ##
|
23
|
-
## code. ##
|
24
|
-
## ##
|
25
|
-
## force_commit is either '1' or nil. If it's 1, we will commit later even ##
|
26
|
-
## if there are forbidden words present. ##
|
27
|
-
## ##
|
28
|
-
##############################################################################
|
29
|
-
##############################################################################
|
30
|
-
|
31
|
-
def prepare(commit_message, force_commit)
|
32
|
-
# If there's just one, it's the current version. Don't run if the current config is present.
|
33
|
-
restore_settings if Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*").length > 1 &&
|
34
|
-
!(File.exists?("#{@app_directory}/lib/config.yaml"))
|
35
|
-
first_run unless File.exists?("#{@app_directory}/lib/config.yaml")
|
36
|
-
|
37
|
-
config = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
38
|
-
@commit_message = commit_message
|
39
|
-
@force_commit = force_commit
|
40
|
-
@current_directory = Dir.pwd
|
41
|
-
@files_changed_file_location = config['files_changed_file_location']
|
42
|
-
@commit_for_user = config['commit_for_user']
|
43
|
-
|
44
|
-
# Don't want to use a previous version.
|
45
|
-
File.delete(@files_changed_file_location) if File.exists?(@files_changed_file_location)
|
46
|
-
|
47
|
-
git_diff
|
48
|
-
|
49
|
-
@files_changed_file = File.open(@files_changed_file_location, "r")
|
50
|
-
@forbidden_words = config['forbidden_words']
|
51
|
-
end
|
52
|
-
|
53
|
-
def help
|
54
|
-
lines_pretty_print 'Wielder of Anor can accept up to two parameters on run. The first parameter can be:'
|
55
|
-
|
56
|
-
single_space
|
57
|
-
|
58
|
-
lines_pretty_print '- Your eventual commit message (in quotes). This is ignored if you have not allowed '\
|
59
|
-
'Wielder of Anor to commit for you.'
|
60
|
-
lines_pretty_print '- help - You should already know what this does :).'
|
61
|
-
lines_pretty_print '- config - Re-runs the initial set up.'
|
62
|
-
|
63
|
-
single_space
|
64
|
-
|
65
|
-
lines_pretty_print 'And your second parameter can only be \'1\', and it\'ll be ignored unless all of the '\
|
66
|
-
'following is true:'
|
67
|
-
|
68
|
-
single_space
|
69
|
-
|
70
|
-
lines_pretty_print '- You have allowed Wielder of Anor to run commits for you.'
|
71
|
-
lines_pretty_print '- Your first parameter is your commit message.'
|
72
|
-
|
73
|
-
abort
|
74
|
-
end
|
75
|
-
|
76
|
-
def output_forbidden_words
|
77
|
-
set_app_directory
|
78
|
-
config = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
79
|
-
|
80
|
-
unless config && config['forbidden_words']
|
81
|
-
lines_pretty_print Rainbow('You have yet to set your forbidden words! Please run the app with the parameter '\
|
82
|
-
'\'config\' to set up your configurations and forbidden words.').red
|
83
|
-
|
84
|
-
abort
|
85
|
-
end
|
86
|
-
|
87
|
-
lines_pretty_print Rainbow('Your forbidden words are:').yellow
|
88
|
-
|
89
|
-
single_space
|
90
|
-
|
91
|
-
config['forbidden_words'].each do |word|
|
92
|
-
lines_pretty_print Rainbow(word).yellow
|
93
|
-
end
|
94
|
-
|
95
|
-
single_space
|
96
|
-
|
97
|
-
abort
|
98
|
-
end
|
99
|
-
|
100
|
-
# Attempt to restore settings from previous version.
|
101
|
-
def restore_settings
|
102
|
-
lines_pretty_print 'I see that you have a previous wielder_of_anor installation on this machine.'
|
103
|
-
lines_pretty_print Rainbow('Would you like to restore its settings?').yellow
|
104
|
-
|
105
|
-
answered = false
|
106
|
-
|
107
|
-
until answered
|
108
|
-
answer = STDIN.gets.strip!
|
109
|
-
|
110
|
-
single_space
|
111
|
-
|
112
|
-
if answer == 'yes' || answer == 'y' || answer == 'no' || answer == 'n'
|
113
|
-
answered = true
|
114
|
-
else
|
115
|
-
lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
return if answer == 'no' || answer == 'n'
|
120
|
-
|
121
|
-
lines_pretty_print 'One moment, please.'
|
122
|
-
|
123
|
-
single_space
|
124
|
-
|
125
|
-
all_gems = Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*")
|
126
|
-
|
127
|
-
# glob orders things in the array alphabetically, so the second-to-last one in the array is the
|
128
|
-
# most recent version that is not the current version.
|
129
|
-
previous_config_file = "#{all_gems[-2]}/lib/config.yaml"
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
def
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
single_space
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
end
|
364
|
-
|
365
|
-
def
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
end
|
374
|
-
|
375
|
-
def
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
1
|
+
require 'shellwords'
|
2
|
+
require 'yaml'
|
3
|
+
require 'rainbow'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
require_relative 'wielder_of_anor/version'
|
7
|
+
|
8
|
+
module WielderOfAnor
|
9
|
+
class WielderOfAnor
|
10
|
+
include WielderOfAnorVersion
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
set_app_directory
|
14
|
+
|
15
|
+
@forbidden_words = []
|
16
|
+
end
|
17
|
+
|
18
|
+
##############################################################################
|
19
|
+
##############################################################################
|
20
|
+
## ##
|
21
|
+
## commit_message is the git commit message the user would like to send ##
|
22
|
+
## once we have verified that there are no forbidden words present in their ##
|
23
|
+
## code. ##
|
24
|
+
## ##
|
25
|
+
## force_commit is either '1' or nil. If it's 1, we will commit later even ##
|
26
|
+
## if there are forbidden words present. ##
|
27
|
+
## ##
|
28
|
+
##############################################################################
|
29
|
+
##############################################################################
|
30
|
+
|
31
|
+
def prepare(commit_message, force_commit)
|
32
|
+
# If there's just one, it's the current version. Don't run if the current config is present.
|
33
|
+
restore_settings if Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*").length > 1 &&
|
34
|
+
!(File.exists?("#{@app_directory}/lib/config.yaml"))
|
35
|
+
first_run unless File.exists?("#{@app_directory}/lib/config.yaml")
|
36
|
+
|
37
|
+
config = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
38
|
+
@commit_message = commit_message
|
39
|
+
@force_commit = force_commit
|
40
|
+
@current_directory = Dir.pwd
|
41
|
+
@files_changed_file_location = config['files_changed_file_location']
|
42
|
+
@commit_for_user = config['commit_for_user']
|
43
|
+
|
44
|
+
# Don't want to use a previous version.
|
45
|
+
File.delete(@files_changed_file_location) if File.exists?(@files_changed_file_location)
|
46
|
+
|
47
|
+
git_diff
|
48
|
+
|
49
|
+
@files_changed_file = File.open(@files_changed_file_location, "r")
|
50
|
+
@forbidden_words = config['forbidden_words']
|
51
|
+
end
|
52
|
+
|
53
|
+
def help
|
54
|
+
lines_pretty_print 'Wielder of Anor can accept up to two parameters on run. The first parameter can be:'
|
55
|
+
|
56
|
+
single_space
|
57
|
+
|
58
|
+
lines_pretty_print '- Your eventual commit message (in quotes). This is ignored if you have not allowed '\
|
59
|
+
'Wielder of Anor to commit for you.'
|
60
|
+
lines_pretty_print '- help - You should already know what this does :).'
|
61
|
+
lines_pretty_print '- config - Re-runs the initial set up.'
|
62
|
+
|
63
|
+
single_space
|
64
|
+
|
65
|
+
lines_pretty_print 'And your second parameter can only be \'1\', and it\'ll be ignored unless all of the '\
|
66
|
+
'following is true:'
|
67
|
+
|
68
|
+
single_space
|
69
|
+
|
70
|
+
lines_pretty_print '- You have allowed Wielder of Anor to run commits for you.'
|
71
|
+
lines_pretty_print '- Your first parameter is your commit message.'
|
72
|
+
|
73
|
+
abort
|
74
|
+
end
|
75
|
+
|
76
|
+
def output_forbidden_words
|
77
|
+
set_app_directory
|
78
|
+
config = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
79
|
+
|
80
|
+
unless config && config['forbidden_words']
|
81
|
+
lines_pretty_print Rainbow('You have yet to set your forbidden words! Please run the app with the parameter '\
|
82
|
+
'\'config\' to set up your configurations and forbidden words.').red
|
83
|
+
|
84
|
+
abort
|
85
|
+
end
|
86
|
+
|
87
|
+
lines_pretty_print Rainbow('Your forbidden words are:').yellow
|
88
|
+
|
89
|
+
single_space
|
90
|
+
|
91
|
+
config['forbidden_words'].each do |word|
|
92
|
+
lines_pretty_print Rainbow(word).yellow
|
93
|
+
end
|
94
|
+
|
95
|
+
single_space
|
96
|
+
|
97
|
+
abort
|
98
|
+
end
|
99
|
+
|
100
|
+
# Attempt to restore settings from previous version.
|
101
|
+
def restore_settings
|
102
|
+
lines_pretty_print 'I see that you have a previous wielder_of_anor installation on this machine.'
|
103
|
+
lines_pretty_print Rainbow('Would you like to restore its settings?').yellow
|
104
|
+
|
105
|
+
answered = false
|
106
|
+
|
107
|
+
until answered
|
108
|
+
answer = STDIN.gets.strip!
|
109
|
+
|
110
|
+
single_space
|
111
|
+
|
112
|
+
if answer == 'yes' || answer == 'y' || answer == 'no' || answer == 'n'
|
113
|
+
answered = true
|
114
|
+
else
|
115
|
+
lines_pretty_print Rainbow('Please input either \'yes\' or \'no\'.').yellow
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
return if answer == 'no' || answer == 'n'
|
120
|
+
|
121
|
+
lines_pretty_print 'One moment, please.'
|
122
|
+
|
123
|
+
single_space
|
124
|
+
|
125
|
+
all_gems = Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*")
|
126
|
+
|
127
|
+
# glob orders things in the array alphabetically, so the second-to-last one in the array is the
|
128
|
+
# most recent version that is not the current version.
|
129
|
+
previous_config_file = "#{all_gems[-2]}/lib/config.yaml"
|
130
|
+
config = YAML.load_file(previous_config_file)
|
131
|
+
new_config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
|
132
|
+
|
133
|
+
YAML.dump(config, new_config_file)
|
134
|
+
new_config_file.close
|
135
|
+
|
136
|
+
lines_pretty_print 'Done! Please run me again when you\'re ready.'
|
137
|
+
|
138
|
+
abort
|
139
|
+
end
|
140
|
+
|
141
|
+
def first_run
|
142
|
+
lines_pretty_print 'Thanks for downloading Wielder of Anor! Let\'s run through the '\
|
143
|
+
'initial setup!'
|
144
|
+
|
145
|
+
STDIN.gets
|
146
|
+
|
147
|
+
files_changed_file_location = "#{@app_directory}/lib/files_changed"
|
148
|
+
|
149
|
+
commit_for_user = set_commit_for_user
|
150
|
+
|
151
|
+
single_space
|
152
|
+
|
153
|
+
forbidden_words = set_forbidden_words
|
154
|
+
|
155
|
+
set_configs(files_changed_file_location, forbidden_words, commit_for_user)
|
156
|
+
end
|
157
|
+
|
158
|
+
def set_commit_for_user
|
159
|
+
lines_pretty_print 'Would you like Wielder of Anor to run your commits for you once you'\
|
160
|
+
' have verified that your code is free of forbidden words?'
|
161
|
+
lines_pretty_print Rainbow('(Type \'yes\' or \'no\'. Just hitting enter defaults to no.)').yellow
|
162
|
+
|
163
|
+
commit_for_user = STDIN.gets.strip!.downcase
|
164
|
+
commit_for_user = 'no' if commit_for_user == ''
|
165
|
+
|
166
|
+
until commit_for_user == 'yes' || commit_for_user =='y' || commit_for_user == 'no' || commit_for_user == 'n' do
|
167
|
+
lines_pretty_print Rainbow('Please type either \'yes\' or \'no\'.').yellow
|
168
|
+
commit_for_user = STDIN.gets.strip!.downcase
|
169
|
+
end
|
170
|
+
|
171
|
+
commit_for_user
|
172
|
+
end
|
173
|
+
|
174
|
+
def set_configs(files_changed_file_location, forbidden_words, commit_for_user)
|
175
|
+
config = {}
|
176
|
+
config['files_changed_file_location'] = files_changed_file_location
|
177
|
+
|
178
|
+
if commit_for_user == 'yes' || commit_for_user == 'y'
|
179
|
+
config['commit_for_user'] = true
|
180
|
+
else
|
181
|
+
config['commit_for_user'] = false
|
182
|
+
end
|
183
|
+
|
184
|
+
config['forbidden_words'] = forbidden_words
|
185
|
+
|
186
|
+
file = File.open("#{@app_directory}/lib/config.yaml", 'w')
|
187
|
+
YAML.dump(config, file)
|
188
|
+
file.close
|
189
|
+
|
190
|
+
lines_pretty_print 'And with that, we\'re done! Feel free to run Wielder of Anor again if'\
|
191
|
+
' you\'d like to check your code now!'
|
192
|
+
|
193
|
+
abort
|
194
|
+
end
|
195
|
+
|
196
|
+
def set_forbidden_words
|
197
|
+
forbidden_words = []
|
198
|
+
|
199
|
+
done = false
|
200
|
+
|
201
|
+
lines_pretty_print 'Great! Now that we\'re done with the files, let\'s add your forbidden '\
|
202
|
+
'words from here!'
|
203
|
+
single_space
|
204
|
+
|
205
|
+
until done do
|
206
|
+
lines_pretty_print Rainbow('Enter a forbidden word and hit enter. If you are done entering '\
|
207
|
+
'forbidden words, type \'x211\' and hit enter instead.').yellow unless forbidden_words.count > 0
|
208
|
+
|
209
|
+
lines_pretty_print Rainbow('Added! Enter another forbidden word and hit enter. If you are done '\
|
210
|
+
'entering forbidden words, type \'x211\' and hit enter instead.').yellow unless forbidden_words.count == 0
|
211
|
+
word = STDIN.gets.strip!
|
212
|
+
|
213
|
+
single_space
|
214
|
+
|
215
|
+
if word == 'x211'
|
216
|
+
done = true
|
217
|
+
else
|
218
|
+
forbidden_words << word
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
forbidden_words
|
223
|
+
end
|
224
|
+
|
225
|
+
def git_diff
|
226
|
+
bash("git diff HEAD --name-only --staged > #{@files_changed_file_location}")
|
227
|
+
end
|
228
|
+
|
229
|
+
def add_forbidden_word(word)
|
230
|
+
set_app_directory
|
231
|
+
config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
232
|
+
config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
|
233
|
+
|
234
|
+
if word.nil?
|
235
|
+
lines_pretty_print Rainbow('Please submit your word as a second parameter.').red
|
236
|
+
|
237
|
+
abort
|
238
|
+
end
|
239
|
+
|
240
|
+
if config_yaml['forbidden_words'].include?(word)
|
241
|
+
lines_pretty_print Rainbow("''#{word}'' is already a forbidden word!").red
|
242
|
+
|
243
|
+
abort
|
244
|
+
end
|
245
|
+
|
246
|
+
config_yaml['forbidden_words'] << word
|
247
|
+
|
248
|
+
YAML.dump(config_yaml, config_file)
|
249
|
+
|
250
|
+
lines_pretty_print 'Added!'
|
251
|
+
|
252
|
+
abort
|
253
|
+
end
|
254
|
+
|
255
|
+
def wielder_of_anor
|
256
|
+
found_forbidden = false
|
257
|
+
count = File.foreach(@files_changed_file).inject(0) {|c, line| c+1}
|
258
|
+
|
259
|
+
if count == 0
|
260
|
+
single_space
|
261
|
+
|
262
|
+
lines_pretty_print Rainbow('No files have been added. Please use the git add command to add files to your '\
|
263
|
+
'commit.').red
|
264
|
+
|
265
|
+
single_space
|
266
|
+
|
267
|
+
abort
|
268
|
+
end
|
269
|
+
|
270
|
+
# If we're forcing the commit, don't bother checking for forbidden words.
|
271
|
+
unless @force_commit
|
272
|
+
single_space
|
273
|
+
|
274
|
+
print_header_footer
|
275
|
+
|
276
|
+
single_space
|
277
|
+
|
278
|
+
@files_changed_file.each_line do |files_changed_line|
|
279
|
+
file_path = "#{@current_directory}/#{files_changed_line.strip}"
|
280
|
+
code_file = File.open(file_path, "r") if File.exists?(file_path)
|
281
|
+
index = 0
|
282
|
+
next unless code_file
|
283
|
+
|
284
|
+
code_file.each_line do |line|
|
285
|
+
index += 1
|
286
|
+
@forbidden_words.each do |word|
|
287
|
+
if line.include?(word)
|
288
|
+
found_forbidden = true
|
289
|
+
lines_pretty_print Rainbow("-- FORBIDDEN WORD FOUND ON LINE #{index} IN #{files_changed_line.strip}: --").red
|
290
|
+
lines_pretty_print Rainbow(" #{line}").yellow
|
291
|
+
double_space
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
code_file.close
|
297
|
+
end
|
298
|
+
|
299
|
+
single_space
|
300
|
+
|
301
|
+
print_header_footer
|
302
|
+
|
303
|
+
single_space
|
304
|
+
else
|
305
|
+
lines_pretty_print Rainbow('NOT SEARCHING FOR FORBIDDEN WORDS, PER USER INPUT.').red
|
306
|
+
single_space
|
307
|
+
end
|
308
|
+
|
309
|
+
@files_changed_file.close
|
310
|
+
|
311
|
+
results(found_forbidden)
|
312
|
+
end
|
313
|
+
|
314
|
+
def results(found_forbidden)
|
315
|
+
if found_forbidden
|
316
|
+
single_space
|
317
|
+
lines_pretty_print 'Remove offending line(s) and re-run commit statement or run this '\
|
318
|
+
'app again with \'1\' as your second argument to force the commit.'
|
319
|
+
|
320
|
+
single_space
|
321
|
+
lines_pretty_print Rainbow('**ONLY FORCE THE COMMIT IF YOU ARE SURE YOU ARE 100% SURE YOU WANT '\
|
322
|
+
'TO COMMIT THE ABOVE LINES TO YOUR BRANCH!!**').red
|
323
|
+
File.delete(@files_changed_file)
|
324
|
+
abort
|
325
|
+
else
|
326
|
+
unless @force_commit
|
327
|
+
lines_pretty_print Rainbow('Found 0 forbidden words!').green
|
328
|
+
|
329
|
+
single_space
|
330
|
+
end
|
331
|
+
|
332
|
+
File.delete(@files_changed_file)
|
333
|
+
commit if @commit_for_user
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def print_header_footer
|
338
|
+
puts '***************************************************************************'
|
339
|
+
end
|
340
|
+
|
341
|
+
def commit
|
342
|
+
if @force_commit
|
343
|
+
lines_pretty_print 'Skipped checking for forbidden words. Ready to commit now?'
|
344
|
+
lines_pretty_print Rainbow('**WARNING: YOU ARE FORCING THE COMMIT WITHOUT CHECKING FOR FORBIDDEN WORDS.**').red
|
345
|
+
|
346
|
+
single_space
|
347
|
+
else
|
348
|
+
lines_pretty_print 'Okay to commit! Should I go ahead and run the actual commit now?'
|
349
|
+
end
|
350
|
+
|
351
|
+
lines_pretty_print 'Please type \'yes\' OR \'y\' to continue. Any other input will be treated as a \'no\'.'
|
352
|
+
|
353
|
+
input = STDIN.gets.chomp.downcase
|
354
|
+
|
355
|
+
single_space
|
356
|
+
|
357
|
+
if input == 'yes' || input == 'y'
|
358
|
+
bash(%Q[git commit -m "#{@commit_message}"])
|
359
|
+
single_space
|
360
|
+
lines_pretty_print 'Committed.'
|
361
|
+
single_space
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
def bash(command)
|
366
|
+
# Dir.chdir ensures all bash commands are being run from the correct
|
367
|
+
# directory.
|
368
|
+
Dir.chdir(@current_directory) { system "#{command}" }
|
369
|
+
end
|
370
|
+
|
371
|
+
def set_app_directory
|
372
|
+
@app_directory = File.expand_path(File.dirname(__FILE__)).chomp('/lib')
|
373
|
+
end
|
374
|
+
|
375
|
+
def lines_pretty_print(string)
|
376
|
+
lines = string.scan(/\S.{0,70}\S(?=\s|$)|\S+/)
|
377
|
+
|
378
|
+
lines.each { |line| puts line }
|
379
|
+
end
|
380
|
+
|
381
|
+
def single_space
|
382
|
+
puts ''
|
383
|
+
end
|
384
|
+
|
385
|
+
def double_space
|
386
|
+
puts "\n\n"
|
387
|
+
end
|
388
|
+
end
|
383
389
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module WielderOfAnorVersion
|
2
|
-
VERSION = "0.
|
1
|
+
module WielderOfAnorVersion
|
2
|
+
VERSION = "0.4.0"
|
3
3
|
end
|
data/wielder_of_anor.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'wielder_of_anor/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'wielder_of_anor'
|
8
|
-
spec.version = WielderOfAnorVersion::VERSION
|
9
|
-
spec.authors = ['Chris Sellek']
|
10
|
-
spec.email = ['iamsellek@gmail.com']
|
11
|
-
|
12
|
-
spec.summary = 'Checks a user\'s staged files for \'forbidden\' words (as determined by the user) '\
|
13
|
-
'and, if any are found, alerts the user to the locations of said words.'
|
14
|
-
spec.description = 'See GitHub page for longer description.'
|
15
|
-
spec.homepage = 'https://github.com/iamsellek/wielder_of_anor'
|
16
|
-
spec.license = 'MIT'
|
17
|
-
|
18
|
-
spec.files = `git ls-files`.split($/)
|
19
|
-
spec.executables = ['wielder_of_anor']
|
20
|
-
spec.test_files = []
|
21
|
-
spec.require_paths = ['lib']
|
22
|
-
|
23
|
-
spec.add_dependency 'rainbow'
|
24
|
-
|
25
|
-
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wielder_of_anor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'wielder_of_anor'
|
8
|
+
spec.version = WielderOfAnorVersion::VERSION
|
9
|
+
spec.authors = ['Chris Sellek']
|
10
|
+
spec.email = ['iamsellek@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Checks a user\'s staged files for \'forbidden\' words (as determined by the user) '\
|
13
|
+
'and, if any are found, alerts the user to the locations of said words.'
|
14
|
+
spec.description = 'See GitHub page for longer description.'
|
15
|
+
spec.homepage = 'https://github.com/iamsellek/wielder_of_anor'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = ['wielder_of_anor']
|
20
|
+
spec.test_files = []
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'rainbow'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wielder_of_anor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Sellek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.5.2
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Checks a user's staged files for 'forbidden' words (as determined by the
|