Skip to content

Commit

Permalink
Added simple and present expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlee2 committed Jan 24, 2019
1 parent 8a465e0 commit 4c21f91
Show file tree
Hide file tree
Showing 14 changed files with 2,705 additions and 314 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
indent_size = 4

[*.hbs]
insert_final_newline = false
Expand Down
60 changes: 7 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,11 @@
# nearley-tutorial
# Nearley Tutorial

This README outlines the details of collaborating on this Ember application.
A short introduction of this app could easily go here.
This is the code companion to my [Nearley: When Regex Isn't Enough](https://crunchingnumbers.live/), presented at the Ember ATX Meetup on 1/24/2019.

## Prerequisites
You can check how the project should look after each step, by running `git checkout` and specifying the branch name:

You will need the following things properly installed on your computer.

* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) (with npm)
* [Ember CLI](https://ember-cli.com/)
* [Google Chrome](https://google.com/chrome/)

## Installation

* `git clone <repository-url>` this repository
* `cd nearley-tutorial`
* `npm install`

## Running / Development

* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).
* Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).

### Code Generators

Make use of the many generators for code, try `ember help generate` for more details

### Running Tests

* `ember test`
* `ember test --server`

### Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`

### Building

* `ember build` (development)
* `ember build --environment production` (production)

### Deploying

Specify what it takes to deploy your app.

## Further Reading / Useful Links

* [ember.js](https://emberjs.com/)
* [ember-cli](https://ember-cli.com/)
* Development Browser Extensions
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
| Branch name | Added features |
| ----------- | ------------------------------------ |
| starter | Starter project |
| master | Added simple and present expressions |
35 changes: 18 additions & 17 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>NearleyTutorial</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Nearley Tutorial</title>
<meta name="author" content="Isaac J. Lee">
<meta name="description" content="Ember-Nearley tutorial for Ember ATX Meetup">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}
{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/nearley-tutorial.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/nearley-tutorial.css">

{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}
{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}

<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/nearley-tutorial.js"></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/nearley-tutorial.js"></script>

{{content-for "body-footer"}}
</body>
{{content-for "body-footer"}}
</body>
</html>
25 changes: 25 additions & 0 deletions app/utils/ldap-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ldapFilterGrammar from 'ldap-filter-grammar';
import nearley from 'nearley';

export default {
createLdapObject(ldapFilter) {
try {
const parser = new nearley.Parser(nearley.Grammar.fromCompiled(ldapFilterGrammar));

parser.feed(ldapFilter);
const results = parser.results;

// If there is a match, return the first result
if (results.length > 0) {
return results[0];
}

} catch (error) {
// If there is no match, return false
return false;

}

return false;
},
};
5 changes: 5 additions & 0 deletions compile-ldap-filter-grammar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nearleyc ./vendor/ldap-filter-grammar.ne -o ./vendor/ldap-filter-grammar-temp.js
browserify ./vendor/ldap-filter-grammar-temp.js -o ./vendor/ldap-filter-grammar.js -s ldap-filter-grammar
rm ./vendor/ldap-filter-grammar-temp.js

nearley-railroad ./vendor/ldap-filter-grammar.ne -o ./vendor/ldap-filter-grammar.html
2 changes: 1 addition & 1 deletion config/optional-features.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"jquery-integration": true
"jquery-integration": false
}
39 changes: 22 additions & 17 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
let app = new EmberApp(defaults, {
// Add options here
});
let app = new EmberApp(defaults, {
// Add options here
});

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('vendor/ldap-filter-grammar.js', {
using: [
{ transformation: 'amd', as: 'ldap-filter-grammar' },
],
});

return app.toTree();
};
return app.toTree();
};
Loading

0 comments on commit 4c21f91

Please sign in to comment.