Skip to content

Commit

Permalink
Merge pull request #3 from michaelcarter-wf/cleanup
Browse files Browse the repository at this point in the history
EPL-6511: Initial Workiva json_schema release
  • Loading branch information
Rosie the Robot authored Jan 18, 2018
2 parents 0d5dbd4 + 614a56c commit 8584ab3
Show file tree
Hide file tree
Showing 30 changed files with 1,040 additions and 865 deletions.
183 changes: 183 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# Contributing to json_schema

Looking to contribute something to the json_schema library? __Here's how you can help.__

+ __[Coding Standards](#coding-standards)__
+ [General Formatting Guidelines](#general-formatting-guidelines)
+ __[Using the Issue Tracker](#using-the-issue-tracker)__
+ [Reporting Bugs](#bug-reports)
+ [Feature Requests](#feature-requests)
+ [Submitting Pull Requests](#pull-requests)
+ __[Developer Workflow](#developer-workflow)__




## Coding standards

A lot can be gained by writing code in a consistent way. Moreover, always remember that code is written and
maintained by _people_. Ensure your code is descriptive, well commented, and approachable by others.

__ALWAYS__ adhere to the [Dart Style Guide]. _Please take the time to read it if you have never done so._

 


### General formatting guidelines

+ __AVOID__ lines longer than 120 characters.
+ __AVOID__ using `dartfmt` as an excuse to ignore good judgement about
whether your code is readable and approachable by others.

 
 



## Using the issue tracker

The issue tracker is the preferred channel for [bug reports](#bug-reports) and [feature requests](#feature-requests),
but __please follow the guidelines:__

+ __Fill out the template we've provided.__

+ __Be Professional__
+ Please __do not__ derail or troll issues. Keep the discussion on topic and respect the opinions of others.

+ __Not that Professional__
+ Feel free to include _relevant_ animated gifs to drive home your message / request.

 


### Bug reports

A bug is a _demonstrable problem_ that is caused by the code in the repository.

_Good bug reports are extremely helpful - thank you!__

__Guidelines for bug reports:__

1. __Search for existing issues.__ Duplicate issues can become cumbersome, and you'd help us out a lot by first
checking if someone else has reported the same issue. Moreover, the issue may have already been resolved with a
fix available.

2. __Record a screencast of yourself reproducing the issue__.
1. Be sure the problem exists in json_schema's code by building a
reduced test case that one of the reviewers can pull locally
and test out.

3. __Share as much information as possible.__ Include operating system and version, browser and version, etc. where appropriate.

Always include steps to reproduce the bug.

__Example Bug Report:__

> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> `<url>` - a link to branch with the reduced test case
>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
&nbsp;


### Feature requests

Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the
project. It's up to *you* to make a strong case to convince the `json_schema` team of the merits of this feature.
Please provide as much detail and context as possible.

&nbsp;


### Pull requests

Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope
and avoid containing unrelated commits.

__Please ask first__ before embarking on any significant pull request (e.g. implementing features, refactoring code,
porting to a different language), otherwise you risk spending a lot of time working on something that the project's
lead developers might not want to merge into the project.

Please adhere to the [Dart Style Guide] for all changes contained in your pull requests.

Adhering to the following process is the best way to get your work included in the project:

1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:

```bash
# Navigate to the directory where you store repos locally
cd ~/your-local-git-repo-spot
# Clone your fork of the repo into the current directory
git clone git@github.com:<your-username>/json_schema
# Navigate to the newly cloned directory
cd ~/your-local-git-repo-spot/json_schema
# Assign the repo you forked from to a remote called "upstream"
git remote add upstream git@github.com:Workiva/json_schema
```

2. If you cloned a while ago, get the latest changes from upstream:

```bash
git checkout master
git pull upstream master
```

3. Create a new topic branch that will contain your feature, change, or fix:

```bash
git checkout -b <topic-branch-name>
```

4. Commit your changes in logical chunks. Please adhere to these
[git commit message guidelines](#git-commit-message-standards) or your code is unlikely be merged into the master
branch. Optionally, you can use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase)
feature to tidy up your commits before making them public.
5. Write tests for your changes.
1. There are no exceptions.
2. If you're having trouble, reach out in your PR about how to best go about testing your changes.

6. If you have merge conflicts, locally merge the upstream master branch into your topic branch:

```bash
git pull upstream master
```

7. Push your topic branch up to your fork:

```bash
git push origin <topic-branch-name>
```

8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
with a clear title and description - following all the [issue guidelines](#using-the-issue-tracker) listed above.

&nbsp;
&nbsp;


## Developer Workflow

The `json_schema` developer workflow couldn't be any more simple!
When you're ready to run the tests... run:

```bash
pub run dart_dev test
```


[Dart Style Guide]: https://www.dartlang.org/guides/language/effective-dart/style
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--- Provide a general summary of the issue in the title above -->

<!--- Provide the type of issue (Bug, Improvement, Feature Request) -->
## Type

## Details
<!--- If you're describing a bug, tell us what happens instead of the expected behavior -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

<!--- Delete the following sections if not submitting a bug -->

## Steps to Reproduce
<!--- Provide steps to reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version:
* Browser name / VM and version:
* Operating System and version:

> __FYI:__ @michaelcarter-wf
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Ultimate problem:


## How it was fixed:


## Testing suggestions:


## Potential areas of regression:



---

> __FYA:__ @michaelcarter-wf
13 changes: 6 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
*.~*~
.idea/
.packages
packages
build/
.pub/
.project
.pub/
*.dart.js
*.iml
*.ipr
*.iws
.idea/
*.dart.js
*.js_
*.js.deps
*.js.map
# custom <additional>
build/
coverage
packages
pubspec.lock
# end <additional>

10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ language: dart
sudo: false
dart:
- stable
- dev
script: ./tool/travis.sh
script:
- pub get --packages-dir
- pub run dependency_validator --ignore dart_style,coverage
- pub run dart_dev format --check
- pub run dart_dev analyze
- pub run dart_dev test
- pub run dart_dev coverage --no-html
- bash <(curl -s https://codecov.io/bash) -f coverage/coverage.lcov
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.8

* Code cleanup
* Strong mode
* Switch build tools to dart_dev

## 1.0.7

* Update dependency constraint on the `args` package.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013-2017 Workiva Inc.
Copyright 2013-2018 Workiva Inc.

Licensed under the Boost Software License (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A *dart:io* dependent library for validating json instances against json schema (version Draft 04)

![Build Status](https://travis-ci.org/patefacio/json_schema.svg)
![Build Status](https://travis-ci.org/workiva/json_schema.svg)


# How To Validate
Expand Down
67 changes: 50 additions & 17 deletions bin/gensamples.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
// Copyright 2013-2018 Workiva Inc.
//
// Licensed under the Boost Software License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.boost.org/LICENSE_1_0.txt
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This software or document includes material copied from or derived
// from JSON-Schema-Test-Suite (https://github.com/json-schema-org/JSON-Schema-Test-Suite),
// Copyright (c) 2012 Julian Berman, which is licensed under the following terms:
//
// Copyright (c) 2012 Julian Berman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import 'dart:io';
import 'package:path/path.dart';
import 'package:json_schema/json_schema.dart';
import 'package:json_schema/schema_dot.dart';

main() {
var sourcePath = join(dirname(dirname(absolute(Platform.script.toFilePath()))),
'dot_samples', 'schemas');
var sourcePath = join(dirname(dirname(absolute(Platform.script.toFilePath()))), 'dot_samples', 'schemas');
var outPath = join(dirname(sourcePath), 'schemaout');
new Directory(sourcePath).listSync().forEach((jsonFile) {
var fname = jsonFile.path;
var base = basenameWithoutExtension(fname);
var dotFilename = join(outPath, '$base.dot');
var pngOut = join(outPath, '$base.png');

Schema.createSchemaFromUrl(fname)
.then((schema) {
new File(dotFilename).writeAsStringSync(createDot(schema));
})
.then((_) {

Process.run('dot', ['-Tpng', '-o$pngOut', dotFilename])
.then((ProcessResult processResult) {
if(processResult.exitCode == 0) {
print("Finished running dot -Tpng -o$pngOut $fname");
} else {
print("FAILED: running dot -Tpng -o$pngOut $fname");
}
});
Schema.createSchemaFromUrl(fname).then((schema) {
new File(dotFilename).writeAsStringSync(createDot(schema));
}).then((_) {
Process.run('dot', ['-Tpng', '-o$pngOut', dotFilename]).then((ProcessResult processResult) {
if (processResult.exitCode == 0) {
print("Finished running dot -Tpng -o$pngOut $fname");
} else {
print("FAILED: running dot -Tpng -o$pngOut $fname");
}
});
});
});
}
}
Loading

0 comments on commit 8584ab3

Please sign in to comment.