forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/github.com/brianvoe/gofakeit/v6/hipster.go

218 lines
6.3 KiB
Go
Raw Normal View History

2024-04-26 19:30:35 +00:00
package gofakeit
import (
"errors"
"math/rand"
)
// HipsterWord will return a single hipster word
2024-04-26 19:30:35 +00:00
func HipsterWord() string { return hipsterWord(globalFaker.Rand) }
// HipsterWord will return a single hipster word
2024-04-26 19:30:35 +00:00
func (f *Faker) HipsterWord() string { return hipsterWord(f.Rand) }
func hipsterWord(r *rand.Rand) string { return getRandValue(r, []string{"hipster", "word"}) }
// HipsterSentence will generate a random sentence
2024-04-26 19:30:35 +00:00
func HipsterSentence(wordCount int) string { return hipsterSentence(globalFaker.Rand, wordCount) }
// HipsterSentence will generate a random sentence
2024-04-26 19:30:35 +00:00
func (f *Faker) HipsterSentence(wordCount int) string { return hipsterSentence(f.Rand, wordCount) }
func hipsterSentence(r *rand.Rand, wordCount int) string {
2024-04-26 19:30:35 +00:00
return sentenceGen(r, wordCount, hipsterWord)
2024-04-26 19:30:35 +00:00
}
// HipsterParagraph will generate a random paragraphGenerator
2024-04-26 19:30:35 +00:00
// Set Paragraph Count
2024-04-26 19:30:35 +00:00
// Set Sentence Count
2024-04-26 19:30:35 +00:00
// Set Word Count
2024-04-26 19:30:35 +00:00
// Set Paragraph Separator
2024-04-26 19:30:35 +00:00
func HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
2024-04-26 19:30:35 +00:00
return hipsterParagraph(globalFaker.Rand, paragraphCount, sentenceCount, wordCount, separator)
2024-04-26 19:30:35 +00:00
}
// HipsterParagraph will generate a random paragraphGenerator
2024-04-26 19:30:35 +00:00
// Set Paragraph Count
2024-04-26 19:30:35 +00:00
// Set Sentence Count
2024-04-26 19:30:35 +00:00
// Set Word Count
2024-04-26 19:30:35 +00:00
// Set Paragraph Separator
2024-04-26 19:30:35 +00:00
func (f *Faker) HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
2024-04-26 19:30:35 +00:00
return hipsterParagraph(f.Rand, paragraphCount, sentenceCount, wordCount, separator)
2024-04-26 19:30:35 +00:00
}
func hipsterParagraph(r *rand.Rand, paragraphCount int, sentenceCount int, wordCount int, separator string) string {
2024-04-26 19:30:35 +00:00
return paragraphGen(r, paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, hipsterSentence)
2024-04-26 19:30:35 +00:00
}
func addHipsterLookup() {
2024-04-26 19:30:35 +00:00
AddFuncLookup("hipsterword", Info{
Display: "Hipster Word",
Category: "hipster",
2024-04-26 19:30:35 +00:00
Description: "Trendy and unconventional vocabulary used by hipsters to express unique cultural preferences",
Example: "microdosing",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return hipsterWord(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("hipstersentence", Info{
Display: "Hipster Sentence",
Category: "hipster",
2024-04-26 19:30:35 +00:00
Description: "Sentence showcasing the use of trendy and unconventional vocabulary associated with hipster culture",
Example: "Microdosing roof chia echo pickled.",
Output: "string",
2024-04-26 19:30:35 +00:00
Params: []Param{
2024-04-26 19:30:35 +00:00
{Field: "wordcount", Display: "Word Count", Type: "int", Default: "5", Description: "Number of words in a sentence"},
},
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
wordCount, err := info.GetInt(m, "wordcount")
2024-04-26 19:30:35 +00:00
if err != nil {
2024-04-26 19:30:35 +00:00
return nil, err
2024-04-26 19:30:35 +00:00
}
2024-04-26 19:30:35 +00:00
if wordCount <= 0 || wordCount > 50 {
2024-04-26 19:30:35 +00:00
return nil, errors.New("invalid word count, must be greater than 0, less than 50")
2024-04-26 19:30:35 +00:00
}
return hipsterSentence(r, wordCount), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("hipsterparagraph", Info{
Display: "Hipster Paragraph",
Category: "hipster",
2024-04-26 19:30:35 +00:00
Description: "Paragraph showcasing the use of trendy and unconventional vocabulary associated with hipster culture",
2024-04-26 19:30:35 +00:00
Example: `Microdosing roof chia echo pickled meditation cold-pressed raw denim fingerstache normcore sriracha pork belly. Wolf try-hard pop-up blog tilde hashtag health butcher waistcoat paleo portland vinegar. Microdosing sartorial blue bottle slow-carb freegan five dollar toast you probably haven't heard of them asymmetrical chia farm-to-table narwhal banjo. Gluten-free blog authentic literally synth vinyl meh ethical health fixie banh mi Yuccie. Try-hard drinking squid seitan cray VHS echo chillwave hammock kombucha food truck sustainable.
2024-04-26 19:30:35 +00:00
Pug bushwick hella tote bag cliche direct trade waistcoat yr waistcoat knausgaard pour-over master. Pitchfork jean shorts franzen flexitarian distillery hella meggings austin knausgaard crucifix wolf heirloom. Crucifix food truck you probably haven't heard of them trust fund fixie gentrify pitchfork stumptown mlkshk umami chambray blue bottle. 3 wolf moon swag +1 biodiesel knausgaard semiotics taxidermy meh artisan hoodie +1 blue bottle. Fashion axe forage mixtape Thundercats pork belly whatever 90's beard selfies chambray cred mlkshk.
2024-04-26 19:30:35 +00:00
Shabby chic typewriter VHS readymade lo-fi bitters PBR&B gentrify lomo raw denim freegan put a bird on it. Raw denim cliche dreamcatcher pug fixie park trust fund migas fingerstache sriracha +1 mustache. Tilde shoreditch kickstarter franzen dreamcatcher green juice mustache neutra polaroid stumptown organic schlitz. Flexitarian ramps chicharrones kogi lo-fi mustache tilde forage street church-key williamsburg taxidermy. Chia mustache plaid mumblecore squid slow-carb disrupt Thundercats goth shoreditch master direct trade.`,
2024-04-26 19:30:35 +00:00
Output: "string",
2024-04-26 19:30:35 +00:00
Params: []Param{
2024-04-26 19:30:35 +00:00
{Field: "paragraphcount", Display: "Paragraph Count", Type: "int", Default: "2", Description: "Number of paragraphs"},
2024-04-26 19:30:35 +00:00
{Field: "sentencecount", Display: "Sentence Count", Type: "int", Default: "2", Description: "Number of sentences in a paragraph"},
2024-04-26 19:30:35 +00:00
{Field: "wordcount", Display: "Word Count", Type: "int", Default: "5", Description: "Number of words in a sentence"},
2024-04-26 19:30:35 +00:00
{Field: "paragraphseparator", Display: "Paragraph Separator", Type: "string", Default: "<br />", Description: "String value to add between paragraphs"},
},
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
paragraphCount, err := info.GetInt(m, "paragraphcount")
2024-04-26 19:30:35 +00:00
if err != nil {
2024-04-26 19:30:35 +00:00
return nil, err
2024-04-26 19:30:35 +00:00
}
2024-04-26 19:30:35 +00:00
if paragraphCount <= 0 || paragraphCount > 20 {
2024-04-26 19:30:35 +00:00
return nil, errors.New("invalid paragraph count, must be greater than 0, less than 20")
2024-04-26 19:30:35 +00:00
}
sentenceCount, err := info.GetInt(m, "sentencecount")
2024-04-26 19:30:35 +00:00
if err != nil {
2024-04-26 19:30:35 +00:00
return nil, err
2024-04-26 19:30:35 +00:00
}
2024-04-26 19:30:35 +00:00
if sentenceCount <= 0 || sentenceCount > 20 {
2024-04-26 19:30:35 +00:00
return nil, errors.New("invalid sentence count, must be greater than 0, less than 20")
2024-04-26 19:30:35 +00:00
}
wordCount, err := info.GetInt(m, "wordcount")
2024-04-26 19:30:35 +00:00
if err != nil {
2024-04-26 19:30:35 +00:00
return nil, err
2024-04-26 19:30:35 +00:00
}
2024-04-26 19:30:35 +00:00
if wordCount <= 0 || wordCount > 50 {
2024-04-26 19:30:35 +00:00
return nil, errors.New("invalid word count, must be greater than 0, less than 50")
2024-04-26 19:30:35 +00:00
}
paragraphSeparator, err := info.GetString(m, "paragraphseparator")
2024-04-26 19:30:35 +00:00
if err != nil {
2024-04-26 19:30:35 +00:00
return nil, err
2024-04-26 19:30:35 +00:00
}
return hipsterParagraph(r, paragraphCount, sentenceCount, wordCount, paragraphSeparator), nil
2024-04-26 19:30:35 +00:00
},
})
2024-04-26 19:30:35 +00:00
}