Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember.inflector() is deprecated; Update README (resolves issue #6) #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
/libpeerconnection.log
npm-debug.log
testem.log
.node_modules.ember-try
bower.json.ember-try
package.json.ember-try
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
.bowerrc
.editorconfig
.ember-cli
.eslintrc.js
.gitignore
.jshintrc
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

sudo: false

cache:
directories:
- node_modules
- $HOME/.npm

env:
- EMBER_TRY_SCENARIO=default
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-default
- EMBER_TRY_SCENARIO=ember-1.13
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
Expand All @@ -28,11 +32,8 @@ before_install:
- npm install phantomjs-prebuilt
- phantomjs --version

install:
- npm install
- bower install

script:
- npm run lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016
Copyright (c) 2018

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:

Expand Down
55 changes: 41 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default AirtableSerializer.extend();

## Models

Your model's attributes should be named with camel case (i.e. `thisFieldName`). If your table has a column named `Name` (with the first letter capitalized), the attribute in your model must *also* be capitalized (i.e. `Name` in both). **Keep the names consistent**.

If you want to skip persistance of certain attributes (ex. formula columns) add the `readOnly` option:

##### **`models/product.js`**:
Expand All @@ -89,6 +91,8 @@ You can use all of the [API features](https://airtable.com/api) when querying Ai

##### **`routes/products.js`**:

The table in your airtable base should be pluralized. For example, below we are querying for our `product` model -- so in AirTable, our table should be title `products`. (Unlike the fields, this is case insensitive.)

```JavaScript
import Ember from 'ember';

Expand All @@ -105,7 +109,7 @@ export default Ember.Route.extend({
pageSize: 10,
// A list of sort objects that specifies how the records will be ordered.
sort: [{field: "name", direction: "desc"}],
// The name or ID of a view in the table.
// The name or ID of a view in the table.
view: 'active_products'
});
}
Expand All @@ -114,25 +118,48 @@ export default Ember.Route.extend({

# Development

## Installation
Installation
------------------------------------------------------------------------------

```
ember install my-addon
```


Usage
------------------------------------------------------------------------------

* `git clone` this repository
[Longer description of how to use the addon in apps.]


Contributing
------------------------------------------------------------------------------

### Installation

* `git clone <repository-url>`
* `cd my-addon`
* `npm install`
* `bower install`

## Running
### Linting

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

### Running tests

* `ember server`
* Visit your app at http://localhost:4200.
* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `npm test` – Runs `ember try:each` to test your addon against multiple Ember versions

## Running Tests
### Running the dummy application

* `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions)
* `ember test`
* `ember test --server`
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

## Building
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

* `ember build`
License
------------------------------------------------------------------------------

For more information on using ember-cli, visit [http://ember-cli.com/](http://ember-cli.com/).
This project is licensed under the [MIT License](LICENSE.md).
13 changes: 7 additions & 6 deletions addon/serializer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';
import DS from 'ember-data';
import { merge } from '@ember/polyfills';
import { isNone } from '@ember/utils';

const inflector = new Ember.Inflector();
import { pluralize } from 'ember-inflector';

export default DS.RESTSerializer.extend({

normalizeResponse(store, type, payload) {
const modelNamePlural = inflector.pluralize(type.modelName);
const modelNamePlural = pluralize(type.modelName);

if(payload.records) {
payload[modelNamePlural] = payload.records;
Expand All @@ -18,7 +19,7 @@ export default DS.RESTSerializer.extend({
delete payload.offset;

payload[modelNamePlural].forEach((record) => {
Ember.merge(record, record.fields);
merge(record, record.fields);
delete record.fields;
record.created = record.createdTime;
delete record.createdTime;
Expand Down Expand Up @@ -55,7 +56,7 @@ export default DS.RESTSerializer.extend({
if(this.keyForRelationship) {
key = this.keyForRelationship(key, "belongsTo", "serialize");
}
json[key] = Ember.isNone(belongsTo) ? [] : [ belongsTo ];
json[key] = isNone(belongsTo) ? [] : [ belongsTo ];
},

serializeHasMany(snapshot, json, relationship) {
Expand All @@ -66,7 +67,7 @@ export default DS.RESTSerializer.extend({
if(this.keyForRelationship) {
key = this.keyForRelationship(key, "hasMany", "serialize");
}
json[key] = Ember.isNone(hasMany) ? [] : hasMany;
json[key] = isNone(hasMany) ? [] : hasMany;
},

serializeAttribute(snapshot, json, key, attribute) {
Expand Down
2 changes: 0 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"name": "ember-airtable",
"dependencies": {
"ember": "~2.7.0",
"ember-cli-shims": "0.1.1",
"ember-qunit-notifications": "0.1.0",
"pretender": "^0.12.0"
}
Expand Down
12 changes: 12 additions & 0 deletions bower.json.ember-try
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "ember-airtable",
"dependencies": {
"ember": "components/ember#beta",
"ember-cli-shims": "0.1.1",
"ember-qunit-notifications": "0.1.0",
"pretender": "^0.12.0"
},
"resolutions": {
"ember": "beta"
}
}
Loading