Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate ::Dune and ::Lovecraft #1503

Merged
merged 9 commits into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
- [PR #372](https://github.com/stympy/faker/pull/372) Add test_password_could_achieve_max_length [@oleksii-ti](https://github.com/oleksii-ti)

### Deprecation
- [PR #1503](https://github.com/stympy/faker/pull/1503) Add Books namespace [@vbrazo](https://github.com/vbrazo)
- Deprecates `::Dune`, `Lovecraft`
- [PR #1480](https://github.com/stympy/faker/pull/1480) Add Music, Movies and TvShows namespaces [@vbrazo](https://github.com/vbrazo)
- Deprecates `::Hobbit`, `HitchhikersGuideToTheGalaxy`, `::HarryPotter`, `::RockBand`, `::MichaelScott`, `::RuPaul`
- [PR #1481](https://github.com/stympy/faker/pull/1481) Add Blockchain namespace [@vbrazo](https://github.com/vbrazo)
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions doc/unreleased/books/dune.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Faker::Books::Dune

### A Faker module beyond your dreams, test data beyond your imagination.

```ruby
Faker::Books::Dune.character #=> "Leto Atreides"

Faker::Books::Dune.title #=> "Duke"

Faker::Books::Dune.planet #=> "Caladan"

Faker::Books::Dune.quote #=> "A dead man, surely, no longer requires that water."

Faker::Books::Dune.quote("baron_harkonnen") #=> "He who controls the spice, controls the universe!"

Faker::Books::Dune.saying #=> "You do not beg the sun for mercy."

Faker::Books::Dune.saying("fremen") #=> "May thy knife chip and shatter."
```
40 changes: 40 additions & 0 deletions doc/unreleased/books/lovecraft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Faker::Books::Lovecraft

```ruby
Faker::Books::Lovecraft.fhtagn(3) #=> "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document that argument there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?


Faker::Books::Lovecraft.deity #=> "Shub-Niggurath"

Faker::Books::Lovecraft.tome #=> "Book of Eibon"

Faker::Books::Lovecraft.location #=> "Kingsport"

Faker::Books::Lovecraft.word #=> "furtive"

# Optional arguments: word_count=4, random_words_to_add=6
Faker::Books::Lovecraft.sentence #=> "Furtive antiquarian squamous dank cat loathsome amorphous lurk."
Faker::Books::Lovecraft.sentence(3) #=> "Daemoniac antediluvian fainted squamous comprehension gambrel nameless singular."
Faker::Books::Lovecraft.sentence(3, 1) #=> "Amorphous indescribable tenebrous."

# Optional arguments: num=3, spaces_allowed = false
Faker::Books::Lovecraft.words #=> ["manuscript", "abnormal", "singular"]
Faker::Books::Lovecraft.words(2) #=> ["daemoniac", "cat"]
Faker::Books::Lovecraft.words(2, true) #=> ["lurk", "charnel"]

# Optional arguments: sentence_count=3
Faker::Books::Lovecraft.sentences #=> ["Nameless loathsome decadent gambrel.", "Ululate swarthy immemorial cat madness gibbous unmentionable unnamable.", "Decadent antediluvian non-euclidean tentacles amorphous tenebrous."]
Faker::Books::Lovecraft.sentences(2) #=> ["Antediluvian amorphous unmentionable singular accursed squamous immemorial.", "Gambrel daemoniac gibbous stygian shunned ululate iridescence abnormal."]

# Optional arguments: sentence_count=3, random_sentences_to_add=3
Faker::Books::Lovecraft.paragraph #=> "Squamous nameless daemoniac fungus ululate. Cyclopean stygian decadent loathsome manuscript tenebrous. Foetid abnormal stench. Dank non-euclidean comprehension eldritch. Charnel singular shunned lurk effulgence fungus."
Faker::Books::Lovecraft.paragraph(2) #=> "Decadent lurk tenebrous loathsome furtive spectral amorphous gibbous. Gambrel eldritch daemoniac cat madness comprehension stygian effulgence."
Faker::Books::Lovecraft.paragraph(2, 1) #=> "Stench cyclopean fainted antiquarian nameless. Antiquarian ululate tenebrous non-euclidean effulgence."

# Optional arguments: paragraph_count=3
Faker::Books::Lovecraft.paragraphs #=> ["Noisome daemoniac gibbous abnormal antediluvian. Unutterable fungus accursed stench noisome lurk madness indescribable. Antiquarian fungus gibbering lurk dank fainted. Hideous loathsome manuscript daemoniac lurk charnel foetid.", "Non-euclidean immemorial indescribable accursed furtive. Dank unnamable cyclopean tenebrous stench immemorial. Eldritch abnormal gibbering tenebrous. Singular accursed lurk.", "Charnel antediluvian unnamable cat blasphemous comprehension tenebrous. Nameless accursed amorphous unnamable stench. Squamous unnamable mortal accursed manuscript spectral gambrel amorphous. Shunned stygian charnel unutterable. Tenebrous ululate lurk amorphous unnamable."]
Faker::Books::Lovecraft.paragraphs(2) #=> ["Hideous amorphous manuscript antediluvian non-euclidean cat eldritch foetid. Stench squamous manuscript amorphous gibbering fainted gibbous. Accursed loathsome blasphemous iridescence antediluvian abnormal ululate manuscript. Singular manuscript gibbering decadent accursed indescribable.", "Tenebrous unnamable comprehension antediluvian lurk. Lurk spectral noisome gibbering. Furtive manuscript madness tenebrous daemoniac."]

# Optional arguments: chars=3, supplemental=false
Faker::Books::Lovecraft.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho."
Faker::Books::Lovecraft.paragraph_by_chars(256) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green."
```
18 changes: 0 additions & 18 deletions doc/unreleased/default/dune.md

This file was deleted.

40 changes: 0 additions & 40 deletions doc/unreleased/default/lovecraft.md

This file was deleted.

File renamed without changes.
58 changes: 58 additions & 0 deletions lib/faker/books/dune.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

module Faker
class Books
class Dune < Base
class << self
# QUOTED_CHARACTERS = fetch("dune.quotes")
# SAYING_SOURCES = %w(translate("faker.dune.sources"))

def character
fetch('dune.characters')
end

def title
fetch('dune.titles')
end

def planet
fetch('dune.planets')
end

def quote(character = nil)
quoted_characters = translate('faker.dune.quotes').keys

if character.nil?
character = sample(quoted_characters).to_s
else
character = character.to_s.downcase

unless quoted_characters.include?(character.to_sym)
raise ArgumentError,
"Characters quoted can be left blank or #{quoted_characters.join(', ')}"
end
end

fetch('dune.quotes.' + character)
end

def saying(source = nil)
sourced_sayings = translate('faker.dune.sayings').keys

if source.nil?
source = sample(sourced_sayings).to_s
else
source = source.to_s.downcase

unless sourced_sayings.include?(source.to_sym)
raise ArgumentError,
"Sources quoted in sayings can be left blank or #{sourced_sayings.join(', ')}"
end
end

fetch('dune.sayings.' + source)
end
end
end
end
end
73 changes: 73 additions & 0 deletions lib/faker/books/lovecraft.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: true

module Faker
class Books
class Lovecraft < Base
class << self
def location
fetch('lovecraft.location')
end

def fhtagn(number_of = 1)
Array.new(number_of) { fetch('lovecraft.fhtagn') }.join('. ')
end

def deity
fetch('lovecraft.deity')
end

def tome
fetch('lovecraft.tome')
end

def sentence(word_count = 4, random_words_to_add = 6)
words(word_count + rand(random_words_to_add.to_i).to_i, true).join(' ').capitalize + '.'
end

def word
random_word = sample(translate('faker.lovecraft.words'))
random_word =~ /\s/ ? word : random_word
end

def words(num = 3, spaces_allowed = false)
resolved_num = resolve(num)
word_list = translate('faker.lovecraft.words')
word_list *= ((resolved_num / word_list.length) + 1)

return shuffle(word_list)[0, resolved_num] if spaces_allowed

words = shuffle(word_list)[0, resolved_num]
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
end

def sentences(sentence_count = 3)
[].tap do |sentences|
1.upto(resolve(sentence_count)) do
sentences << sentence(3)
end
end
end

def paragraph(sentence_count = 3, random_sentences_to_add = 3)
sentences(resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ')
end

def paragraphs(paragraph_count = 3)
[].tap do |paragraphs|
1.upto(resolve(paragraph_count)) do
paragraphs << paragraph(3)
end
end
end

def paragraph_by_chars(chars = 256)
paragraph = paragraph(3)

paragraph += ' ' + paragraph(3) while paragraph.length < chars

paragraph[0...chars - 1] + '.'
end
end
end
end
end
56 changes: 0 additions & 56 deletions lib/faker/default/dune.rb

This file was deleted.

71 changes: 0 additions & 71 deletions lib/faker/default/lovecraft.rb

This file was deleted.

Loading