cryptozoologist 3.0.0 → 3.1.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/CHANGELOG.md +4 -0
- data/README.md +17 -2
- data/lib/cryptozoologist.rb +5 -1
- data/lib/cryptozoologist/dictionaries.rb +8 -0
- data/lib/cryptozoologist/dictionaries/cities/teminologies.rb +9 -0
- data/lib/cryptozoologist/dictionaries/cities/words.rb +9 -0
- data/lib/cryptozoologist/dictionary.rb +4 -0
- data/lib/cryptozoologist/generator.rb +18 -1
- data/lib/cryptozoologist/version.rb +1 -1
- data/spec/cryptozoologist/generator_spec.rb +33 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09791606d26cc558e12ccd78ba862963ef208a7d
|
4
|
+
data.tar.gz: 26a3f40019b4274cd0b6f3f1e92e4e68fda64672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d969c28223dfa7d731d3b7307a880fe672217235a3a903565f161ed51a500530ebad246652d092ef5d52cc2d1d3a9f05abca99e1f438364e42ef1d3012a8f76
|
7
|
+
data.tar.gz: 83b718c59a20eda2ec7fb45472e981fe6b1e293bb7b46c92880a7970e3a3307d0a53282555db272ebadef1a95b1b8e68e012b13e950993f6ff2cf91512654b5d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.1.0
|
4
|
+
|
5
|
+
- added a city method - generate an animal city with `Cryptozoologist.city`!
|
6
|
+
|
3
7
|
## 3.0.0
|
4
8
|
|
5
9
|
**Important!!** Now requires Ruby 2.3.0 or higher (as of writing, Ruby 2.2 is in security maintenance mode, while 2.3 is in normal maintanance mode).
|
data/README.md
CHANGED
@@ -22,11 +22,12 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Cryptozoologist provides
|
25
|
+
Cryptozoologist provides four main functions:
|
26
26
|
|
27
27
|
* `Cryptozoologist.random`: returns a string separated by a delimiter (_Note_: aliased as `Cryptozoologist.generate` for backwards compatibility with anything below version 3)
|
28
28
|
* `Cryptozoologist.lorem(sentence_count)`: returns `sentence_count` number of sentences, separated by punctuation randomly selected from `["!", ".", "?"]`
|
29
29
|
* `Cryptozoologist.street_address`: returns a string formatted to US street address standards (house number and street name) using the animal dictionaries (_Note_: ignores animal subdictionary exclusions)
|
30
|
+
* `Cryptozoologist.city`: returns a string representing a city that uses the animal dictionaries
|
30
31
|
|
31
32
|
Each method will respect your configuration settings where applicable.
|
32
33
|
|
@@ -45,6 +46,7 @@ The complete list of dictionaries includes:
|
|
45
46
|
* `Cryptozoologist::Dictionary.filler` ("a", "the", etc)
|
46
47
|
* `Cryptozoologist::Dictionary.punctuation`
|
47
48
|
* `Cryptozoologist::Dictionary.addresses` ("Lane", "Street", etc - I don't know what this part of an address is called!)
|
49
|
+
* `Cryptozoologist::Dictionary.cities`
|
48
50
|
|
49
51
|
### `Cryptozoologist.random`
|
50
52
|
|
@@ -91,7 +93,20 @@ Cryptozoologist.street_address # => 2558 Sea Dragon Court
|
|
91
93
|
|
92
94
|
This only uses the `Animal` dictionaries and will *ignore your configuration to exclude subdictionaries*.
|
93
95
|
|
94
|
-
|
96
|
+
### `Cryptozoologist.city`
|
97
|
+
|
98
|
+
The `Cryptozoologist.city` method will return a string containing an animal city.
|
99
|
+
|
100
|
+
Example:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Cryptozoologist.city # => Goat Tower
|
104
|
+
Cryptozoologist.city # => Raccoon City
|
105
|
+
Cryptozoologist.city # => Mandrill Hills
|
106
|
+
Cryptozoologist.city # => Lionville
|
107
|
+
```
|
108
|
+
|
109
|
+
## Configuration
|
95
110
|
|
96
111
|
Configuration blocks take the following options:
|
97
112
|
|
data/lib/cryptozoologist.rb
CHANGED
@@ -27,6 +27,10 @@ module Cryptozoologist
|
|
27
27
|
colors: {
|
28
28
|
paint: Colors::Paint,
|
29
29
|
web: Colors::WebSafe
|
30
|
+
},
|
31
|
+
cities: {
|
32
|
+
words: Cities::Words,
|
33
|
+
terminologies: Cities::Terminologies
|
30
34
|
}
|
31
35
|
}
|
32
36
|
end
|
@@ -43,6 +47,10 @@ module Cryptozoologist
|
|
43
47
|
Addresses.list
|
44
48
|
end
|
45
49
|
|
50
|
+
def cities
|
51
|
+
create_list(:cities)
|
52
|
+
end
|
53
|
+
|
46
54
|
private
|
47
55
|
def create_list(key)
|
48
56
|
list = []
|
@@ -48,12 +48,29 @@ module Cryptozoologist
|
|
48
48
|
|
49
49
|
# Generates a string for a street address with a number and street. Only
|
50
50
|
# uses animal dictionaries and does not respect config exclusions.
|
51
|
-
#
|
51
|
+
#
|
52
52
|
def street_address
|
53
53
|
number = rand(1..9000)
|
54
54
|
street = Dictionary.animals.sample
|
55
55
|
street = street.split(" ").map! {|word| word.capitalize! }.join(" ")
|
56
56
|
"#{number} #{street} #{Dictionary.addresses.sample}"
|
57
57
|
end
|
58
|
+
|
59
|
+
def city
|
60
|
+
exclude = Cryptozoologist.configuration.exclude
|
61
|
+
cities_words = Cryptozoologist::Cities::Words.list
|
62
|
+
cities_terminologies = Cryptozoologist::Cities::Terminologies.list
|
63
|
+
words_formatted = exclude.include?(:words) ? [] : cities_words.map { |word| " #{word.capitalize}" }
|
64
|
+
terminologies = exclude.include?(:terminologies) ? [] : cities_terminologies
|
65
|
+
city_labels = words_formatted + terminologies
|
66
|
+
|
67
|
+
"#{one_word_animals.sample.capitalize}#{city_labels.sample}"
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def one_word_animals
|
73
|
+
Dictionary.animals.select {|animal| animal.split(' ').count == 1}
|
74
|
+
end
|
58
75
|
end
|
59
76
|
end
|
@@ -13,7 +13,7 @@ describe Cryptozoologist do
|
|
13
13
|
|
14
14
|
it 'generates the number of sentences requested' do
|
15
15
|
sentence = Cryptozoologist.lorem(3)
|
16
|
-
punctuation = sentence.
|
16
|
+
punctuation = sentence.scan(/[.|?|!]/)
|
17
17
|
expect(punctuation.length).to eq(3)
|
18
18
|
end
|
19
19
|
end
|
@@ -28,7 +28,11 @@ describe Cryptozoologist do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe('with quantity') do
|
31
|
+
let(:test_quantity_library) { ["quantity"] }
|
32
|
+
|
31
33
|
before do
|
34
|
+
allow(Cryptozoologist::Dictionary).to receive(:send).and_call_original
|
35
|
+
allow(Cryptozoologist::Dictionary).to receive(:send).with(:quantity).and_return(test_quantity_library)
|
32
36
|
Cryptozoologist.configure do |config|
|
33
37
|
config.include = [:quantity]
|
34
38
|
config.delimiter = "_"
|
@@ -41,7 +45,6 @@ describe Cryptozoologist do
|
|
41
45
|
end
|
42
46
|
|
43
47
|
it 'only has one word from the quantity list' do
|
44
|
-
Cryptozoologist.random
|
45
48
|
random = Cryptozoologist.random.split("_")
|
46
49
|
matches = Cryptozoologist::Dictionaries::Quantity.list.select do |word|
|
47
50
|
random.include?(word)
|
@@ -73,4 +76,32 @@ describe Cryptozoologist do
|
|
73
76
|
expect(Cryptozoologist::Dictionary.addresses.include?(@street.last)).to be true
|
74
77
|
end
|
75
78
|
end
|
79
|
+
|
80
|
+
context '#city' do
|
81
|
+
before do
|
82
|
+
@city = Cryptozoologist.city
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should return a string' do
|
86
|
+
expect(@city).to be_instance_of(String)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should include an animal' do
|
90
|
+
has_animal = false
|
91
|
+
Cryptozoologist::Dictionary.animals.each do |animal|
|
92
|
+
has_animal = @city.downcase.include?(animal) if @city.downcase.include?(animal)
|
93
|
+
end
|
94
|
+
|
95
|
+
expect(has_animal).to be true
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should include a city label' do
|
99
|
+
has_city = false
|
100
|
+
Cryptozoologist::Dictionary.cities.each do |city|
|
101
|
+
has_city = @city.downcase.include?(city) if @city.downcase.include?(city)
|
102
|
+
end
|
103
|
+
|
104
|
+
expect(has_city).to be true
|
105
|
+
end
|
106
|
+
end
|
76
107
|
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: 3.
|
4
|
+
version: 3.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: 2017-
|
11
|
+
date: 2017-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,8 @@ files:
|
|
99
99
|
- lib/cryptozoologist/dictionaries/addresses.rb
|
100
100
|
- lib/cryptozoologist/dictionaries/animals/common.rb
|
101
101
|
- lib/cryptozoologist/dictionaries/animals/mythical.rb
|
102
|
+
- lib/cryptozoologist/dictionaries/cities/teminologies.rb
|
103
|
+
- lib/cryptozoologist/dictionaries/cities/words.rb
|
102
104
|
- lib/cryptozoologist/dictionaries/clothing.rb
|
103
105
|
- lib/cryptozoologist/dictionaries/colors/paint.rb
|
104
106
|
- lib/cryptozoologist/dictionaries/colors/web_safe.rb
|
@@ -146,3 +148,4 @@ test_files:
|
|
146
148
|
- spec/cryptozoologist/generator_spec.rb
|
147
149
|
- spec/cryptozoologist_spec.rb
|
148
150
|
- spec/spec_helper.rb
|
151
|
+
has_rdoc:
|