Skip to content

Commit

Permalink
Revert "Allow disabling the usage of open compounds in sentences (fak…
Browse files Browse the repository at this point in the history
…er-ruby#2109)"

This reverts commit 5cbb62e.
  • Loading branch information
droznyk committed Oct 23, 2020
1 parent 9acb8c5 commit 634be94
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 47 deletions.
3 changes: 1 addition & 2 deletions doc/books/lovecraft.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ Faker::Books::Lovecraft.location #=> "Kingsport"

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

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

# Keyword arguments: number, spaces_allowed
Faker::Books::Lovecraft.words #=> ["manuscript", "abnormal", "singular"]
Expand Down
4 changes: 1 addition & 3 deletions doc/default/hipster.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ Faker::Hipster.words(number: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"]
Faker::Hipster.words(number: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"]
Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]

# Keyword arguments: word_count, supplemental, random_words_to_add, open_compounds_allowed
# Keyword arguments: word_count, supplemental, random_words_to_add
Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it."
Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard."
Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac."
Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: true) #=> "Kale chips nihil eos."
Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."

# Keyword arguments: number, supplemental
Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."]
Expand Down
8 changes: 2 additions & 6 deletions lib/faker/books/lovecraft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def tome
#
# @param word_count [Integer] The number of words to have in the sentence
# @param random_words_to_add [Integer]
# @param open_compounds_allowed [Boolean] If true, generated sentence can contain words having additional spaces
#
# @return [String]
#
Expand All @@ -81,18 +80,15 @@ def tome
# @example
# Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 1)
# #=> "Amorphous indescribable tenebrous."
# @example
# Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 0, open_compounds_allowed: true)
# #=> "Effulgence unmentionable gambrel."
#
# @faker.version 1.9.3
def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6, open_compounds_allowed: true)
def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6)
warn_for_deprecated_arguments do |keywords|
keywords << :word_count if legacy_word_count != NOT_GIVEN
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
end

words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: open_compounds_allowed).join(' ').capitalize + '.'
words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.'
end

##
Expand Down
9 changes: 3 additions & 6 deletions lib/faker/default/hipster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spa
#
# @param word_count [Integer] Specifies the number of words in the sentence
# @param supplemental [Boolean] Specifies if the words are supplemental
# @param random_words_to_add [Integer] Specifies the number of random words to add
# @param open_compounds_allowed [Boolean] Specifies if the generated sentence can contain words having additional spaces
# @param random_words_to_add [Boolean] Specifies the number of random words to add
# @return [String]
#
# @example
Expand All @@ -69,20 +68,18 @@ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spa
# Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac."
# Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: true) #=> "Kale chips nihil eos."
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
#
# @faker.version 1.6.0
# rubocop:disable Metrics/ParameterLists
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
# rubocop:enable Metrics/ParameterLists
warn_for_deprecated_arguments do |keywords|
keywords << :word_count if legacy_word_count != NOT_GIVEN
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
end

words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize + '.'
words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
end

##
Expand Down
15 changes: 0 additions & 15 deletions test/faker/books/test_lovecraft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ def test_words_with_large_count_params
assert(array.length == 250 || array.length == 500)
end

def test_sentence_with_open_compounds_allowed
1000.times do
sentence = @tester.sentence(word_count: 5, random_words_to_add: 0, open_compounds_allowed: true)
assert(sentence.split.length >= 5)
end
end

# Sentence should not contain any open compounds
def test_sentence_without_open_compounds_allowed
1000.times do
sentence = @tester.sentence(word_count: 5, random_words_to_add: 0, open_compounds_allowed: false)
assert(sentence.split.length == 5)
end
end

def test_paragraph_char_count
paragraph = @tester.paragraph_by_chars
assert(paragraph.length == 256)
Expand Down
15 changes: 0 additions & 15 deletions test/faker/default/test_faker_hipster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ def test_words_with_large_count_params
assert(array.length == 250 || array.length == 500)
end

def test_sentence_with_open_compounds_allowed
1000.times do
sentence = @tester.sentence(word_count: 5, random_words_to_add: 0, open_compounds_allowed: true)
assert(sentence.split.length >= 5)
end
end

# Sentence should not contain any open compounds
def test_sentence_without_open_compounds_allowed
1000.times do
sentence = @tester.sentence(word_count: 5, random_words_to_add: 0, open_compounds_allowed: false)
assert(sentence.split.length == 5)
end
end

def test_paragraph_char_count
paragraph = @tester.paragraph_by_chars(characters: 256)
assert(paragraph.length == 256)
Expand Down

0 comments on commit 634be94

Please sign in to comment.