Skip to content

Commit

Permalink
Refactor Faker::Educator and add docs (faker-ruby#1772)
Browse files Browse the repository at this point in the history
* Refactor Faker::Educator.

Reorganize the to do the dynamic generation of strings in the YML itself.

Also reformat the YML to use one line per entry.

* Add YARD docs for Faker::Educator.

* Sorting things like a monkey

* More sorting

* Update educator.yml

* Update educator.yml
  • Loading branch information
connorshea authored and michebble committed Feb 16, 2020
1 parent 14717d4 commit 5792a82
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 12 deletions.
66 changes: 60 additions & 6 deletions lib/faker/default/educator.rb
Expand Up @@ -5,30 +5,84 @@ class Educator < Base
flexible :educator

class << self
##
# Produces a university name.
#
# @return [String]
#
# @example
# Faker::Educator.university #=> "Mallowtown Technical College"
#
# @faker.version 1.6.4
def university
"#{parse('educator.name')} #{fetch('educator.tertiary.type')}"
parse('educator.university')
end

##
# Produces a university degree.
#
# @return [String]
#
# @example
# Faker::Educator.degree #=> "Associate Degree in Criminology"
#
# @faker.version 1.9.2
def degree
"#{fetch('educator.tertiary.degree.type')} #{fetch('educator.tertiary.degree.subject')}"
parse('educator.degree')
end

alias course degree

##
# Produces a university subject.
#
# @return [String]
#
# @example
# Faker::Educator.subject #=> "Criminology"
#
# @faker.version 1.9.2
def subject
fetch('educator.tertiary.degree.subject')
fetch('educator.subject')
end

##
# Produces a course name.
#
# @return [String]
#
# @example
# Faker::Educator.course_name #=> "Criminology 101"
#
# @faker.version 1.9.2
def course_name
"#{fetch('educator.tertiary.degree.subject')} #{numerify(fetch('educator.tertiary.degree.course_number'))}"
numerify(parse('educator.course_name'))
end

##
# Produces a secondary school.
#
# @return [String]
#
# @example
# Faker::Educator.secondary_school #=> "Iceborough Secondary College"
#
# @faker.version 1.6.4
def secondary_school
"#{parse('educator.name')} #{fetch('educator.secondary')}"
parse('educator.secondary_school')
end

##
# Produces a campus name.
#
# @return [String]
#
# @example
# Faker::Educator.campus #=> "Vertapple Campus"
#
# @faker.version 1.6.4
def campus
"#{parse('educator.name')} Campus"
parse('educator.campus')
end
end
end
Expand Down
75 changes: 69 additions & 6 deletions lib/locales/en/educator.yml
@@ -1,11 +1,74 @@
en:
faker:
educator:
name: ['Marblewald', 'Mallowtown', 'Brookville', 'Flowerlake', 'Falconholt', 'Ostbarrow', 'Lakeacre', 'Clearcourt', 'Ironston', 'Mallowpond', 'Iceborough', 'Icelyn', 'Brighthurst', 'Bluemeadow', 'Vertapple', 'Ironbarrow']
secondary: ['High School', 'Secondary College', 'High']
name:
- Bluemeadow
- Brighthurst
- Brookville
- Clearcourt
- Falconholt
- Flowerlake
- Iceborough
- Icelyn
- Ironbarrow
- Ironston
- Lakeacre
- Mallowpond
- Mallowtown
- Marblewald
- Ostbarrow
- Vertapple
secondary:
- High
- High School
- Secondary College
university:
- "#{name} #{Educator.tertiary.university_type}"
secondary_school:
- "#{name} #{secondary}"
campus:
- "#{name} Campus"
subject:
- Applied Science (Psychology)
- Architectural Technology
- Arts
- Biological Science
- Biomedical Science
- Business
- Commerce
- Communications
- Computer Science
- Creative Arts
- Criminology
- Design
- Education
- Engineering
- Forensic Science
- Health Science
- Information Systems
- Law
- Medicine
- Nursing
- Psychology
- Teaching
degree:
- "#{Educator.tertiary.degree.type} #{subject}"
course_name:
- "#{subject} #{Educator.tertiary.degree.course_number}"
tertiary:
type: ['College', 'University', 'Technical College', 'TAFE']
university_type:
- College
- TAFE
- Technical College
- University
degree:
subject: ['Arts', 'Business', 'Education', 'Applied Science (Psychology)', 'Architectural Technology', 'Biological Science', 'Biomedical Science', 'Commerce', 'Communications', 'Creative Arts', 'Criminology', 'Design', 'Engineering', 'Forensic Science', 'Health Science', 'Information Systems', 'Computer Science', 'Law', 'Nursing', 'Medicine', 'Psychology', 'Teaching']
type: ['Associate Degree in', 'Bachelor of', 'Master of']
course_number: ['1##', '2##', '3##', '4##', '5##']
type:
- Associate Degree in
- Bachelor of
- Master of
course_number:
- 1##
- 2##
- 3##
- 4##
- 5##

0 comments on commit 5792a82

Please sign in to comment.