wielder_of_anor 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +2 -1
- data/lib/wielder_of_anor.rb +10 -54
- data/lib/wielder_of_anor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98ff99d194882de2e091e089a9185b491818c3df
|
4
|
+
data.tar.gz: eb20c71aa2dff09875da8db419955b2f96d2103e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eee1b20cc4cea88221cf2c3104e8de57f24aeca76ed93b682968f26da8d45c8bcfa8e33b0d5c72c8dc836a43a5dbfd8c794292bec82047864e25c41b2952854
|
7
|
+
data.tar.gz: 68573daf715a6e9967a223ab4a082a9a409de81d0ddbd72ce023e692badf2d89e18a020277d2dd9ce4821edd3fbf1e54330922f7b0e5c0191dd1aaaf244de4e7
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/wielder_of_anor.rb
CHANGED
@@ -2,12 +2,14 @@ require 'shellwords'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'rainbow'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'iamsellek_cl_helper'
|
5
6
|
|
6
7
|
require_relative 'wielder_of_anor/version'
|
7
8
|
|
8
9
|
module WielderOfAnor
|
9
10
|
class WielderOfAnor
|
10
11
|
include WielderOfAnorVersion
|
12
|
+
include IamsellekClHelper
|
11
13
|
|
12
14
|
def initialize
|
13
15
|
set_app_directory
|
@@ -30,8 +32,9 @@ module WielderOfAnor
|
|
30
32
|
|
31
33
|
def prepare(commit_message, force_commit)
|
32
34
|
# If there's just one, it's the current version. Don't run if the current config is present.
|
33
|
-
restore_settings
|
34
|
-
|
35
|
+
restore_settings('wielder_of_anor', VERSION) if
|
36
|
+
Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*").length > 1 &&
|
37
|
+
!(File.exists?("#{@app_directory}/lib/config.yaml"))
|
35
38
|
first_run unless File.exists?("#{@app_directory}/lib/config.yaml")
|
36
39
|
|
37
40
|
config = YAML.load_file("#{@app_directory}/lib/config.yaml")
|
@@ -97,47 +100,6 @@ module WielderOfAnor
|
|
97
100
|
abort
|
98
101
|
end
|
99
102
|
|
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
103
|
def first_run
|
142
104
|
lines_pretty_print 'Thanks for downloading Wielder of Anor! Let\'s run through the '\
|
143
105
|
'initial setup!'
|
@@ -204,15 +166,15 @@ module WielderOfAnor
|
|
204
166
|
|
205
167
|
until done do
|
206
168
|
lines_pretty_print Rainbow('Enter a forbidden word and hit enter. If you are done entering '\
|
207
|
-
'forbidden words
|
169
|
+
'forbidden words just hit enter instead.').yellow unless forbidden_words.count > 0
|
208
170
|
|
209
171
|
lines_pretty_print Rainbow('Added! Enter another forbidden word and hit enter. If you are done '\
|
210
|
-
'entering forbidden words,
|
172
|
+
'entering forbidden words, just hit enter instead.').yellow unless forbidden_words.count == 0
|
211
173
|
word = STDIN.gets.strip!
|
212
174
|
|
213
175
|
single_space
|
214
176
|
|
215
|
-
if word == '
|
177
|
+
if word == ''
|
216
178
|
done = true
|
217
179
|
else
|
218
180
|
forbidden_words << word
|
@@ -223,7 +185,7 @@ module WielderOfAnor
|
|
223
185
|
end
|
224
186
|
|
225
187
|
def git_diff
|
226
|
-
bash("git diff HEAD --name-only --staged > #{@files_changed_file_location}")
|
188
|
+
bash(@current_directory, "git diff HEAD --name-only --staged > #{@files_changed_file_location}")
|
227
189
|
end
|
228
190
|
|
229
191
|
def add_forbidden_word(word)
|
@@ -355,19 +317,13 @@ module WielderOfAnor
|
|
355
317
|
single_space
|
356
318
|
|
357
319
|
if input == 'yes' || input == 'y'
|
358
|
-
bash(%Q[git commit -m "#{@commit_message}"])
|
320
|
+
bash(@current_directory, %Q[git commit -m "#{@commit_message}"])
|
359
321
|
single_space
|
360
322
|
lines_pretty_print 'Committed.'
|
361
323
|
single_space
|
362
324
|
end
|
363
325
|
end
|
364
326
|
|
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
327
|
def set_app_directory
|
372
328
|
@app_directory = File.expand_path(File.dirname(__FILE__)).chomp('/lib')
|
373
329
|
end
|