mr_poole 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/mr_poole/config.rb +24 -1
- data/lib/mr_poole/helper.rb +1 -1
- data/lib/mr_poole/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: 55b01d175e1b4409aa3952570665706d4cb48b12
|
4
|
+
data.tar.gz: e3e8070ed4000eae92275b01c2ba420ff7424432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e7f154e7cc3cab30bfecc709f5fc132d39fa69a0e62742bc9f6436bef2aa901f8633f87ae474a3524913997c795c3c5af2c1c86dde696866b0e623af808afb1
|
7
|
+
data.tar.gz: 357f0267e6992c9b944f1ff8b1ff01947ad28da1e6a36e2880f9ffde82b585cb03e304da7f1e883810d9650c6aef2027ff9763090af0d677eef1edf9cc6a4033
|
data/CHANGES.md
CHANGED
data/lib/mr_poole/config.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
+
# YAML parsing in old rubies didn't use Psych, and so throws a NameError later
|
5
|
+
# when we check for one after we parse our YAML. Before we start, we'll check
|
6
|
+
# for that and create a dummy Pysch::SyntaxError constant. Older ruby YAML
|
7
|
+
# errors will be caught by check_word_separator and will throw a TypeError
|
8
|
+
# instead.
|
9
|
+
if RUBY_VERSION < '1.9'
|
10
|
+
class Psych
|
11
|
+
SyntaxError = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
module MrPoole
|
5
16
|
class Config
|
6
17
|
|
@@ -10,10 +21,11 @@ module MrPoole
|
|
10
21
|
yaml = YAML.load(File.read('_config.yml'))
|
11
22
|
@config = OpenStruct.new(yaml["poole"])
|
12
23
|
@config.srcdir = yaml['source'] if yaml['source']
|
24
|
+
check_word_separator
|
13
25
|
else
|
14
26
|
@config = OpenStruct.new
|
15
27
|
end
|
16
|
-
rescue Psych::SyntaxError
|
28
|
+
rescue TypeError, ::Psych::SyntaxError
|
17
29
|
bad_yaml_message
|
18
30
|
exit
|
19
31
|
end
|
@@ -33,6 +45,17 @@ module MrPoole
|
|
33
45
|
|
34
46
|
private
|
35
47
|
|
48
|
+
# on old rubies, the YAML parser doesn't throw an error if you pass
|
49
|
+
# something like 'word_separator: -', it just assumes you want an array
|
50
|
+
# with the elment nil. We'll check for that case and die, since it's not
|
51
|
+
# what we want here.
|
52
|
+
def check_word_separator
|
53
|
+
return unless @config.word_separator
|
54
|
+
if @config.word_separator == [nil]
|
55
|
+
raise TypeError
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
36
59
|
def bad_yaml_message
|
37
60
|
puts 'Error reading YAML file _config.yml!'
|
38
61
|
puts ' (Did you forget to escape a hyphen?)'
|
data/lib/mr_poole/helper.rb
CHANGED
@@ -93,7 +93,7 @@ module MrPoole
|
|
93
93
|
puts ''
|
94
94
|
puts "This is Mr. Poole, version #{MrPoole::VERSION}, running on ruby version #{RUBY_VERSION}"
|
95
95
|
puts ''
|
96
|
-
puts 'Copyright
|
96
|
+
puts 'Copyright 2014, Michael McClimon'
|
97
97
|
puts 'https://github.com/mmcclimon/mr_poole'
|
98
98
|
puts ''
|
99
99
|
exit
|
data/lib/mr_poole/version.rb
CHANGED