Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnggel authored and nnnggel committed May 18, 2020
1 parent 3cf0123 commit 07b5732
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 30 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## [0.0.1] - TODO: Add release date.

* TODO: Describe initial release.
## 1.0.0
* Support .properties
* Support .json
* Support .yaml
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
# config_reader
## What is config_reader
A flutter library for reading config files online or offline.
[github](https://github.com/nnnggel/config_reader)

A new Flutter project.
## What format does config_reader support
[.properties](https://en.wikipedia.org/wiki/.properties)
> readProperties
> readOnlineProperties

## Getting Started
[.json](https://en.wikipedia.org/wiki/JSON)
> readJson
> readOnlineJson

This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
[.yaml](https://en.wikipedia.org/wiki/YAML)
> readYaml
> readOnlineYaml

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Result type
All method will return a **MAP** for result. As json and yaml files are designed to support map or LIST as root, config_reader will add a root node for "list".

For example:
json:
```
[
"Cat",
"Dog",
"Goldfish"
]
```
yaml:
```
- Cat
- Dog
- Goldfish
```
Will return:
```
{list: [Cat, Dog, Goldfish]}
```

## More case
see test/config_reader_test.dart
12 changes: 3 additions & 9 deletions lib/config_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,9 @@ class ConfigReader {

void main() {
ConfigReader.readYaml("""
languages:
- Ruby
- Perl
- Python
websites:
YAML: yaml.org
Ruby: ruby-lang.org
Python: python.org
Perl: use.perl.org
- Cat
- Dog
- Goldfish
""").then((value) {
print(value);
});
Expand Down
7 changes: 3 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: config_reader
description: A new Flutter project.
version: 0.0.1
author:
homepage:
description: A flutter library for reading config files online or offline.
version: 1.0.0
homepage: https://github.com/nnnggel/config_reader

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down
8 changes: 4 additions & 4 deletions test/config_reader_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:config_reader/config_reader.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:config_reader/config_reader.dart';

void main() {
test('ConfigReader:readProperties', () async {
Expand Down Expand Up @@ -71,15 +71,15 @@ websites:
expect(map2['list'][0], 'Cat');
});

test('ConfigReader:readOnlineJson', () async {
test('ConfigReader:readOnlineYaml', () async {
// map
Map<String, dynamic> map = await ConfigReader.readOnlineJson(
Map<dynamic, dynamic> map = await ConfigReader.readOnlineYaml(
'https://raw.githubusercontent.com/nnnggel/config_reader/master/test/testfile/test_map.yaml');
expect(map['websites']['YAML'], 'yaml.org');
expect(map['languages'][0], 'Ruby');

// list
Map<String, dynamic> map2 = await ConfigReader.readOnlineJson(
Map<dynamic, dynamic> map2 = await ConfigReader.readOnlineYaml(
'https://raw.githubusercontent.com/nnnggel/config_reader/master/test/testfile/test_list.yaml');
expect(map2['list'][0], 'Cat');
});
Expand Down

0 comments on commit 07b5732

Please sign in to comment.