wielder_of_anor 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47f95532e9ef0f162cee99d705e5ff57d76e603f
4
- data.tar.gz: 19b253f236f65500cc08ed86a79b4292d2e7ad1c
3
+ metadata.gz: 98ff99d194882de2e091e089a9185b491818c3df
4
+ data.tar.gz: eb20c71aa2dff09875da8db419955b2f96d2103e
5
5
  SHA512:
6
- metadata.gz: cb7b6cdaeaf0762b20bdb52bf95d0129ff7b61060859f2b6872c8ba913c6bbc087777cf95ced720bdd2e2cf66ff4671711ca6d04034886d24ea14dc45b58caf4
7
- data.tar.gz: f7aadde722183cd655b094feaee85aa976a24ad2bbdaa75eab375ddb5f3d05ec096d8eca3993f61a6057a1cf4fa9a0f913636fd0b3e7d2129c992f854218dd02
6
+ metadata.gz: 1eee1b20cc4cea88221cf2c3104e8de57f24aeca76ed93b682968f26da8d45c8bcfa8e33b0d5c72c8dc836a43a5dbfd8c794292bec82047864e25c41b2952854
7
+ data.tar.gz: 68573daf715a6e9967a223ab4a082a9a409de81d0ddbd72ce023e692badf2d89e18a020277d2dd9ce4821edd3fbf1e54330922f7b0e5c0191dd1aaaf244de4e7
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ docs/files_changed
3
3
  config/config.yaml
4
4
  Gemfile.lock
5
5
  .idea
6
- .bundle
6
+ .bundle
7
+ .pkg
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem 'rainbow', '~>2.1.0'
4
- gem 'gemspec'
4
+ gem 'gemspec'
5
+ gem 'iamsellek_cl_helper'
@@ -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 if Dir.glob("#{@app_directory.chomp("/wielder_of_anor-#{VERSION}")}/wielder_of_anor*").length > 1 &&
34
- !(File.exists?("#{@app_directory}/lib/config.yaml"))
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, type \'x211\' and hit enter instead.').yellow unless forbidden_words.count > 0
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, type \'x211\' and hit enter instead.').yellow unless forbidden_words.count == 0
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 == 'x211'
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
@@ -1,3 +1,3 @@
1
1
  module WielderOfAnorVersion
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wielder_of_anor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sellek