Skip to content

Commit

Permalink
Merge branch 'master' of github.com:drager/faker
Browse files Browse the repository at this point in the history
  • Loading branch information
drager committed Sep 4, 2019
2 parents b24f681 + 2b46f51 commit 0e41b71
Show file tree
Hide file tree
Showing 53 changed files with 1,385 additions and 301 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eval "$(lorri direnv)"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
build/
packages
pubspec.lock
.dart_tool/
.packages
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.1.0
- Added lorem sentences and words
- Added continents
- Added generics to `randomGenerator.element()`

## 1.0.0
- Make faker compatible with Dart 2.0.

## 0.0.5
- fix: Remove illegal chars from generated domain words

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# faker
[![Build Status](https://travis-ci.org/drager/faker.svg?branch=master)](https://travis-ci.org/drager/faker)
[![Coverage Status](https://coveralls.io/repos/drager/faker/badge.svg)](https://coveralls.io/r/drager/faker)
[![Faker on pub](https://img.shields.io/pub/v/faker.svg)](https://pub.dartlang.org/packages/faker)

A library for Dart that generates fake data.

Expand Down Expand Up @@ -33,6 +34,9 @@ main() {
faker.person.suffix();
// Sr.
faker.lorem.sentence();
// Nec nam aliquam sem et
}
```

Expand Down
61 changes: 29 additions & 32 deletions lib/faker.dart
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
/// A library for Dart that generates fake data.
library faker;
import 'dart:math';
export 'src/faker.dart';

part 'src/faker.dart';
export 'src/random_generator.dart';

part 'src/random_generator.dart';
export 'src/address.dart';
export 'src/conference.dart';
export 'src/company.dart';
export 'src/currency.dart';
export 'src/food.dart';
export 'src/guid.dart';
export 'src/internet.dart';
export 'src/job.dart';
export 'src/person.dart';
export 'src/sport.dart';

part 'src/address.dart';
part 'src/conference.dart';
part 'src/company.dart';
part 'src/currency.dart';
part 'src/food.dart';
part 'src/guid.dart';
part 'src/internet.dart';
part 'src/job.dart';
part 'src/person.dart';
part 'src/sport.dart';

part 'src/data/address/city_suffixes.dart';
part 'src/data/address/countries.dart';
part 'src/data/address/country_codes.dart';
part 'src/data/address/neighborhoods.dart';
part 'src/data/address/street_suffixes.dart';
part 'src/data/conference/conference_names.dart';
part 'src/data/currency/currency_names.dart';
part 'src/data/currency/currency_codes.dart';
part 'src/data/food/cuisines.dart';
part 'src/data/food/dishes.dart';
part 'src/data/food/restaurants.dart';
part 'src/data/person/firstnames.dart';
part 'src/data/person/lastnames.dart';
part 'src/data/job/job_adj.dart';
part 'src/data/job/job_noun.dart';
part 'src/data/job/job_prefix.dart';
part 'src/data/sport/sport_names.dart';
export 'src/data/address/city_suffixes.dart';
export 'src/data/address/countries.dart';
export 'src/data/address/country_codes.dart';
export 'src/data/address/neighborhoods.dart';
export 'src/data/address/street_suffixes.dart';
export 'src/data/conference/conference_names.dart';
export 'src/data/currency/currency_names.dart';
export 'src/data/currency/currency_codes.dart';
export 'src/data/food/cuisines.dart';
export 'src/data/food/dishes.dart';
export 'src/data/food/restaurants.dart';
export 'src/data/person/firstnames.dart';
export 'src/data/person/lastnames.dart';
export 'src/data/job/job_adj.dart';
export 'src/data/job/job_noun.dart';
export 'src/data/job/job_prefix.dart';
export 'src/data/sport/sport_names.dart';
23 changes: 19 additions & 4 deletions lib/src/address.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
part of faker;
import 'random_generator.dart';
import 'faker.dart';
import 'data/address/street_suffixes.dart';
import 'data/address/city_suffixes.dart';
import 'data/address/neighborhoods.dart';
import 'data/address/countries.dart';
import 'data/address/country_codes.dart';
import 'data/address/continents.dart';

class Address {
static const compassDirections = const ['North', 'East', 'West', 'South'];
Expand Down Expand Up @@ -42,9 +49,9 @@ class Address {
/// faker.address.cityPrefix();
/// ```
String cityPrefix() => [
random.element(compassDirections),
random.element(cityPrefixes)
].join(' ');
random.element(compassDirections),
random.element(cityPrefixes)
].join(' ');

/// Generates a city suffix.
///
Expand Down Expand Up @@ -111,4 +118,12 @@ class Address {
/// faker.address.countryCode();
/// ```
String countryCode() => random.element(countryCodes);

/// Generates a continent.
///
/// Example:
/// ```dart
/// faker.address.continent();
/// ```
String continent() => random.element(continents);
}
3 changes: 2 additions & 1 deletion lib/src/company.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
part of faker;
import 'faker.dart';
import 'random_generator.dart';

class Company {
static const _companySuffixes = const ['Inc', 'and Sons', 'LLC', 'Group'];
Expand Down
3 changes: 2 additions & 1 deletion lib/src/conference.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
part of faker;
import 'random_generator.dart';
import 'data/conference/conference_names.dart';

class Conference {
const Conference();
Expand Down
5 changes: 3 additions & 2 deletions lib/src/currency.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
part of faker;
import 'random_generator.dart';
import 'data/currency/currency_codes.dart';
import 'data/currency/currency_names.dart';

class Currency {

const Currency();

/// Generates a currency code.
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/address/city_suffixes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const citySuffixes = const [
'town',
'ton',
Expand Down
12 changes: 12 additions & 0 deletions lib/src/data/address/continents.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const continents = const [
'Africa',
'Antarctica',
'Asia',
'Europe',
'North America',

// Some people use austrailia, whilst others use oceania.
'Oceania',

'South America',
];
2 changes: 0 additions & 2 deletions lib/src/data/address/countries.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const countries = const [
"Afghanistan",
"Åland Islands",
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/address/country_codes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const countryCodes = const [
'AF',
'AX',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/address/neighborhoods.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const neighborhoods = const [
'East of Telegraph Road',
'North Norridge',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/address/street_suffixes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const streetSuffixes = const [
'Alley',
'Avenue',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/conference/conference_names.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const conferenceNames = const [
'Social Mobile Payments Americas',
'LatAm HSE in Oil, Gas and Petrochemicals',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/currency/currency_codes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const currencyCodes = const [
'AED',
'AFN',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/currency/currency_names.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const currencyNames = const [
"UAE Dirham",
"Afghani",
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/food/cuisines.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const cuisines = const [
'American Chinese',
'Argentinian food',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/food/dishes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const dishes = const [
"Minestrone",
"Baked Alaska",
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/food/restaurants.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const restaurants = const [
"21 Club",
"241 Pizza",
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/job/job_adj.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const jobAdj = const [
'Solutions',
'Program',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/job/job_noun.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const jobNoun = const [
'Supervisor',
'Associate',
Expand Down
2 changes: 0 additions & 2 deletions lib/src/data/job/job_prefix.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
part of faker;

const jobPrefix = const [
'Lead',
'Senior',
Expand Down
Loading

0 comments on commit 0e41b71

Please sign in to comment.