Skip to content

Commit

Permalink
feat(model): added copy-with, to-json to countries (#64)
Browse files Browse the repository at this point in the history
* style(docs): style currencies and langs changelogs

* chore(deps): removed sealed_languages dependency

* refactor: refactoring of code-gen extensions

* style: rename extensions to follow the same pattern

* style: move world country helpers out of extensions dir

* refactor: refactor of to-string overrides

* feat(model): implement to-map/from-map and proper to-string
In countries.

* refactor: re-run code gen for official world countries

* refactor: refactoring of code-gen

* test: added new to-json tests for world country model

* test(unit): add tests for submodel methods

* refactor: added named and translated name classes

* test: unit test new name-related extensions and methods

* refactor(model)!: convert translations to iterable

* docs: added documentation for new extensions

* feat(cli): created cli tools

* feat: update imports/exports in countries

* feat(cli): added basic utils for cli tools

* feat(cli): added exports generator to cli tools

* docs: update changelog and readme

* chore(deps): update dev_dependencies

* docs(interface): added dartdoc to the named constructor

* fix(ci): added more excludes to spell-checker

* fix: fix coverage drop because of constructor
  • Loading branch information
tsinis authored Oct 7, 2023
1 parent c4b4209 commit 47968ba
Show file tree
Hide file tree
Showing 99 changed files with 30,330 additions and 28,299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@ twemoji
uint
Validator
wcslen
Asm
Bdi
configs
Cze
deserializing
https
img
Refactoring
Svn
TODO
url
usd
Vnm
26 changes: 23 additions & 3 deletions .vscode/sealed_world.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"name": "GitHub Setup",
"path": "../.github"
},
{
"name": "CLI Tools",
"path": "../tools"
},
{
"name": "Flutter World",
"path": "../packages/world_countries"
Expand All @@ -27,7 +31,21 @@
"**/.git": true,
"coverage/**": true,
"**/coverage/*": true,
"**/*.g.dart": true
"**/*.g.dart": true,
"**/*.freezed.dart": true,
"**/*.select.dart": true
},
"explorer.confirmDragAndDrop": false,
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml, flutter_*.yaml, icons_launcher.yaml",
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
"readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
"*.dart": "$(capture).g.dart, $(capture).freezed.dart, $(capture).select.dart, $(capture).config.dart",
"*.graphql": "$(capture).gql.dart, $(capture).*.gql.dart",
"schema.graphql": "schema.schema.gql.dart",
"firebase.json": ".firebaserc"
},
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
Expand All @@ -50,12 +68,14 @@
"source.sortMembers": "never"
}
},
"cSpell.words": ["Cinis"],
"cSpell.words": ["Cinis", "cioc", "demonym", "demonyms", "gini"],
"cSpell.useGitignore": true,
"cSpell.ignorePaths": [
".git", // Ignore the .git directory
"**/lib/**/*.data.dart",
"**/lib/**/*.g.dart",
"**/lib/**/*.freezed.dart",
"**/lib/**/*.select.dart",
"**/.vscode/sealed_world.code-workspace"
],
"bracket-pair-colorizer-2.highlightActiveScope": true,
Expand All @@ -81,7 +101,7 @@
"merge-conflict.autoNavigateNextConflict.enabled": true,
"code-runner.clearPreviousOutput": false,
"dimmer.delay": 1000,
"dimmer.opacity": 75,
"dimmer.opacity": 80,
"dimmer.enabled": true,
"yaml.keyOrdering": false
},
Expand Down
14 changes: 14 additions & 0 deletions packages/sealed_countries/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 0.6.0

- refactor(model)!: translations are now list of translated name
- style!: renamed extensions to follow the same naming pattern
- feat(model): added copy with, to-json etc.
- refactor(model): functional method parameters are now sorted

NEW FEATURES:

- Added copyWith, toJson etc. to the WorldCountry and all sub-classes.
- Refactoring in existing functional methods (sorting params to match list sorting).
- Translations are now List<TranslatedName> instead of List<CountryName>, however CountryName is just an extension on top of TranslatedName (you can reference to name instead of common and fullName instead of official). There will be way more translations provided in upcoming version 0.7.0.
- Renaming of extensions to follow the eco-system naming pattern.

## 0.5.0

- refactor(model): factory constructors and static methods for data classes creation now implicitly trimming and comparing uppercase string inputs
Expand Down
5 changes: 2 additions & 3 deletions packages/sealed_countries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This ISO-driven, fully tested and pure Dart package provides information about w

## Features


**WorldCountry** class provides the following information about countries:

| **Field** | **Required** | **Description** | **Example for CountryIrl** |
Expand Down Expand Up @@ -45,15 +44,15 @@ This ISO-driven, fully tested and pure Dart package provides information about w
| `postalCode` | Yes | The postal code information of the country. | `PostalCode` with format and regExp |
| `startOfWeek` | Yes | The first day of the week in the country. | `Weekday.monday` |
| `regionalBlocs` | No | The regional blocs of the country. | `[BlocEU()]` |
| `translations` | Yes | The translations of the country name. | List of 25 `CountryName`s in different languages |
| `translations` | Yes | The translations of the country name. | List of 25 `TranslatedName`s in different languages |

Compile time constant list of all countries accessible via `WorldCountry.list` and more over, the **WorldCountry** class provides the following methods:

- `maybeFromValue` - returns a country instance if the value matches the provided value, otherwise returns `null`.
- `fromCode` - returns a country instance if the value matches the provided ISO 3166-1 Alpha-3 code.
- `fromCodeShort` - returns a country instance if the value matches the provided ISO 3166-1 Alpha-2 code.

and (thanks to sealed nature of the class) functional-style like methods: `whenOrNull`, `maybeWhen`, `when`, `map`, `maybeMap`.
and (thanks to sealed nature of the class) functional-style like methods: `whenOrNull`, `maybeWhen`, `when`, `map`, `maybeMap`. You can also find a lot of common method you may know from Dart ecosystem - `toString` overrides, `copyWith`, `toJson`, etc.

## Getting started

Expand Down
2 changes: 1 addition & 1 deletion packages/sealed_countries/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main() {
/// Prints all the countries in the world with their phone code.
for (final country in WorldCountry.list) {
print(
"${country.nameEnglish.common} code: ${country.idd.phoneCode()}",
"${country.name.common} code: ${country.idd.phoneCode()}",
);
}
}
22 changes: 16 additions & 6 deletions packages/sealed_countries/lib/sealed_countries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@
library sealed_countries;

export "package:sealed_currencies/sealed_currencies.dart";
export "package:sealed_languages/sealed_languages.dart";

export "src/data/geo/continental_sections.data.dart";
export "src/data/geo/continents.data.dart";
export "src/data/official_world_countries.data.dart";
export "src/data/other_world_countries.data.dart";
export "src/data/regional_bloc/regional_bloc.data.dart";
export "src/helpers/extensions/country_submodels/capital_extension.dart";
export "src/helpers/extensions/country_submodels/capital_info_extension.dart";
export "src/helpers/extensions/country_submodels/car_extension.dart";
export "src/helpers/extensions/country_submodels/country_name_extension.dart";
export "src/helpers/extensions/country_submodels/demonyms_extension.dart";
export "src/helpers/extensions/country_submodels/gini_extension.dart";
export "src/helpers/extensions/country_submodels/idd_extension.dart";
export "src/helpers/extensions/country_submodels/lat_lng_extension.dart";
export "src/helpers/extensions/country_submodels/maps_extension.dart";
export "src/helpers/extensions/country_submodels/postal_code_extension.dart";
export "src/helpers/extensions/country_submodels/weekday_extension.dart";
export "src/helpers/extensions/world_country/date_time_extension.dart";
export "src/helpers/extensions/world_country/geo_extension.dart";
export "src/helpers/extensions/world_country/getters_extension.dart";
export "src/helpers/extensions/world_country/name_extension.dart";
export "src/helpers/extensions/world_country/web_resources_extension.dart";
export "src/helpers/extensions/translated_name_extension.dart";
export "src/helpers/world_country/world_country_copy_with.dart";
export "src/helpers/world_country/world_country_date_time.dart";
export "src/helpers/world_country/world_country_geo.dart";
export "src/helpers/world_country/world_country_getters.dart";
export "src/helpers/world_country/world_country_json.dart";
export "src/helpers/world_country/world_country_names.dart";
export "src/helpers/world_country/world_country_web_resources.dart";
export "src/interfaces/named.dart";
export "src/model/country/country.dart";
export "src/model/country/submodels/capital.dart";
export "src/model/country/submodels/capital_info.dart";
Expand All @@ -31,7 +39,9 @@ export "src/model/country/submodels/idd.dart";
export "src/model/country/submodels/lat_lng.dart";
export "src/model/country/submodels/maps.dart";
export "src/model/country/submodels/postal_code.dart";
export "src/model/country/submodels/weekday.dart";
export "src/model/geo/region.dart";
export "src/model/geo/submodels/continent.dart";
export "src/model/regional_bloc/world_bloc.dart";
export "src/model/translated_name.dart";
export "src/model/typedefs/utc_duration_difference.dart";
Loading

0 comments on commit 47968ba

Please sign in to comment.