cryptozoologist 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +5 -5
- data/lib/cryptozoologist.rb +2 -2
- data/lib/cryptozoologist/configuration.rb +5 -5
- data/lib/cryptozoologist/version.rb +1 -1
- data/spec/cryptozoologist/configuration_spec.rb +12 -4
- data/spec/cryptozoologist_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06601375b1385300471f4c3483d20b4b6879aa14
|
4
|
+
data.tar.gz: 129ff159258be07a66bd4bf7964e52171a60f871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cbbc6fb596e675a5d220c76813b745cfc37e23ac3cb3f3f5300adb5eee590a74ee37acd017834b03b03ae7abd870f8bfec0ec40daa7a934fc7da7f511421bfe
|
7
|
+
data.tar.gz: b7a67f991bd65d65559cb18e8659e9b1d307b1ad7d6586af4380e941bc88dbd02f0f7851970d49b8bddacc58d981c7ea847963b3717caf55c53a33d0414b6525
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -40,7 +40,7 @@ Cryptozoologist.generate # => 'forest-green-wasp-getup'
|
|
40
40
|
|
41
41
|
### Generate a random color, animal, clothing item, or measure of quantity
|
42
42
|
|
43
|
-
These dictionaries will also follow your configuration settings (see below), _except for your
|
43
|
+
These dictionaries will also follow your configuration settings (see below), _except for your delimiter_ (the delimiter is not used here).
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
Cryptozoologist::Dictionary.animals.sample # => 'sun bear'
|
@@ -58,14 +58,14 @@ Configuration blocks take the following options:
|
|
58
58
|
config.exclude = []
|
59
59
|
config.include = []
|
60
60
|
config.order = []
|
61
|
-
config.
|
61
|
+
config.delimiter = ''
|
62
62
|
end
|
63
63
|
```
|
64
64
|
|
65
65
|
- `exclude` (array of symbols) allows you to exclude dictionary subtypes; defaults to no exclusions
|
66
66
|
- `include` (array of symbols) allows you to include optional dictionaries; defaults to no inclusions
|
67
67
|
- `order` (array of symbols) allows you to change the word order; defaults to animal-color-clothing
|
68
|
-
- `
|
68
|
+
- `delimiter` (string) allows you to specify a delimiter; defaults to `-`
|
69
69
|
|
70
70
|
### Configuration options
|
71
71
|
|
@@ -86,7 +86,7 @@ Configuration blocks take the following options:
|
|
86
86
|
- **must provide all 3 keys** as an array in the order in which you want words to appear
|
87
87
|
- `[:animals, :colors, :clothing]`
|
88
88
|
|
89
|
-
**
|
89
|
+
**delimiter (`config.delimiter`, `''`):**
|
90
90
|
|
91
91
|
- defaults to `'-'`
|
92
92
|
- any string is valid
|
@@ -98,7 +98,7 @@ Configuration blocks take the following options:
|
|
98
98
|
config.exclude = [:common]
|
99
99
|
config.include = [:quantity]
|
100
100
|
config.order = [:colors, :animals, :clothing]
|
101
|
-
config.
|
101
|
+
config.delimiter = '_'
|
102
102
|
end
|
103
103
|
|
104
104
|
Cryptozoologist.generate # => 'masses_yellow_zombie_shrug'
|
data/lib/cryptozoologist.rb
CHANGED
@@ -33,11 +33,11 @@ module Cryptozoologist
|
|
33
33
|
|
34
34
|
order.each do |library|
|
35
35
|
word = Dictionary.send(library).sample
|
36
|
-
compound_word = word.split(' ').join(@configuration.
|
36
|
+
compound_word = word.split(' ').join(@configuration.delimiter)
|
37
37
|
string += "#{compound_word}"
|
38
38
|
|
39
39
|
unless library == @configuration.order.last
|
40
|
-
string += "#{@configuration.
|
40
|
+
string += "#{@configuration.delimiter}"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Cryptozoologist
|
2
2
|
class Configuration
|
3
|
-
attr_reader :exclude, :
|
3
|
+
attr_reader :exclude, :delimiter, :order, :include
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@exclude = []
|
7
|
-
@
|
7
|
+
@delimiter = "-"
|
8
8
|
@order = [:colors, :animals, :clothing]
|
9
9
|
@include = []
|
10
10
|
end
|
@@ -18,10 +18,10 @@ module Cryptozoologist
|
|
18
18
|
@order = list
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
raise Errors::Configuration, "
|
21
|
+
def delimiter=(string)
|
22
|
+
raise Errors::Configuration, "delimiter must be a a string" unless string.is_a?(String)
|
23
23
|
|
24
|
-
@
|
24
|
+
@delimiter = string
|
25
25
|
end
|
26
26
|
|
27
27
|
def include=(inclusions)
|
@@ -54,9 +54,17 @@ describe Cryptozoologist::Configuration do
|
|
54
54
|
|
55
55
|
expect(Cryptozoologist.configuration.include).to eq([:quantity])
|
56
56
|
end
|
57
|
+
|
58
|
+
it 'sets valid inclusions' do
|
59
|
+
Cryptozoologist.configure do |config|
|
60
|
+
config.include = [:quantity]
|
61
|
+
end
|
62
|
+
|
63
|
+
expect(Cryptozoologist.configuration.include_quantity?).to be true
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
|
-
context '#
|
67
|
+
context '#delimiter' do
|
60
68
|
it 'defaults to "-"' do
|
61
69
|
expect(Cryptozoologist.generate.match('-')).to be_instance_of(MatchData)
|
62
70
|
end
|
@@ -64,14 +72,14 @@ describe Cryptozoologist::Configuration do
|
|
64
72
|
it 'requires a string' do
|
65
73
|
expect {
|
66
74
|
Cryptozoologist.configure do |config|
|
67
|
-
config.
|
75
|
+
config.delimiter = 1
|
68
76
|
end
|
69
77
|
}.to raise_error(Cryptozoologist::Errors::Configuration)
|
70
78
|
end
|
71
79
|
|
72
|
-
it 'changes the
|
80
|
+
it 'changes the delimiter when provided' do
|
73
81
|
Cryptozoologist.configure do |config|
|
74
|
-
config.
|
82
|
+
config.delimiter ='$'
|
75
83
|
end
|
76
84
|
|
77
85
|
expect(Cryptozoologist.generate.match('$')).to be_instance_of(MatchData)
|
@@ -20,7 +20,7 @@ describe Cryptozoologist do
|
|
20
20
|
expect(Cryptozoologist.generate).to be_instance_of(String)
|
21
21
|
end
|
22
22
|
|
23
|
-
it 'returns a string with the
|
23
|
+
it 'returns a string with the delimiter' do
|
24
24
|
expect(Cryptozoologist.generate.match('-')).to be_instance_of(MatchData)
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptozoologist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liz Abinante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|