-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c9596e
commit 8bd6b36
Showing
33 changed files
with
689 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 1 | ||
update_configs: | ||
- package_manager: 'javascript' | ||
directory: '/' | ||
update_schedule: 'live' | ||
version_requirement_updates: increase_versions | ||
automerged_updates: | ||
- match: | ||
dependency_type: 'development' | ||
update_type: 'all' | ||
- match: | ||
dependency_type: 'production' | ||
update_type: 'all' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module' | ||
}, | ||
plugins: [ | ||
'ember' | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:ember/recommended' | ||
], | ||
env: { | ||
browser: true | ||
}, | ||
rules: { | ||
}, | ||
overrides: [ | ||
// node files | ||
{ | ||
files: [ | ||
'.eslintrc.js', | ||
'.template-lintrc.js', | ||
'ember-cli-build.js', | ||
'index.js', | ||
'testem.js', | ||
'blueprints/*/index.js', | ||
'config/**/*.js', | ||
'tests/dummy/config/**/*.js' | ||
], | ||
excludedFiles: [ | ||
'addon/**', | ||
'addon-test-support/**', | ||
'app/**', | ||
'tests/dummy/app/**' | ||
], | ||
parserOptions: { | ||
sourceType: 'script' | ||
}, | ||
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 | ||
}) | ||
} | ||
] | ||
extends: '@clark/node' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
ember-service-helper | ||
============================================================================== | ||
# ember-service-helper | ||
|
||
[Short description of the addon.] | ||
[![Build Status](https://travis-ci.org/buschtoens/ember-service-helper.svg)](https://travis-ci.org/buschtoens/ember-service-helper) | ||
[![npm version](https://badge.fury.io/js/ember-service-helper.svg)](http://badge.fury.io/js/ember-service-helper) | ||
[![Download Total](https://img.shields.io/npm/dt/ember-service-helper.svg)](http://badge.fury.io/js/ember-service-helper) | ||
[![Ember Observer Score](https://emberobserver.com/badges/ember-service-helper.svg)](https://emberobserver.com/addons/ember-service-helper) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[![dependencies](https://img.shields.io/david/buschtoens/ember-service-helper.svg)](https://david-dm.org/buschtoens/ember-service-helper) | ||
[![devDependencies](https://img.shields.io/david/dev/buschtoens/ember-service-helper.svg)](https://david-dm.org/buschtoens/ember-service-helper) | ||
|
||
Simple template helper to inject services into templates. | ||
|
||
Compatibility | ||
------------------------------------------------------------------------------ | ||
|
||
* Ember.js v3.4 or above | ||
* Ember CLI v2.13 or above | ||
* Node.js v8 or above | ||
|
||
|
||
Installation | ||
------------------------------------------------------------------------------ | ||
## Installation | ||
|
||
``` | ||
ember install ember-service-helper | ||
``` | ||
|
||
## Usage | ||
|
||
Usage | ||
------------------------------------------------------------------------------ | ||
|
||
[Longer description of how to use the addon in apps.] | ||
|
||
|
||
Contributing | ||
------------------------------------------------------------------------------ | ||
|
||
See the [Contributing](CONTRIBUTING.md) guide for details. | ||
Example using [`ember-responsive`](https://github.com/freshbooks/ember-responsive). | ||
|
||
```hbs | ||
{{#if (get (service "breakpoints") "isDesktop")}} | ||
Desktop breakpoint | ||
{{else}} | ||
Mobile breakpoint | ||
{{/if}} | ||
``` | ||
|
||
License | ||
------------------------------------------------------------------------------ | ||
## Related | ||
|
||
This project is licensed under the [MIT License](LICENSE.md). | ||
- [Pre-RFC 543: Ability to inject service into Template Only component](https://github.com/emberjs/rfcs/issues/543) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@clark/ember' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getOwner } from '@ember/application'; | ||
import Helper from '@ember/component/helper'; | ||
import { assert } from '@ember/debug'; | ||
|
||
export default class ServiceHelper extends Helper { | ||
compute([serviceName]) { | ||
const service = getOwner(this).lookup(`service:${serviceName}`); | ||
assert(`The service '${serviceName}' does not exist`, service); | ||
|
||
return service; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@clark/ember' | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, service } from 'ember-service-helper/helpers/service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(/* environment, appConfig */) { | ||
return { }; | ||
return {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
{ | ||
"name": "ember-service-helper", | ||
"version": "0.0.0", | ||
"description": "The default blueprint for ember-cli addons.", | ||
"description": "Simple template helper to inject services into templates.", | ||
"keywords": [ | ||
"ember-addon" | ||
"ember-addon", | ||
"helper", | ||
"inject", | ||
"service", | ||
"template", | ||
"only", | ||
"component" | ||
], | ||
"repository": "", | ||
"repository": "buschtoens/ember-service-helper", | ||
"license": "MIT", | ||
"author": "", | ||
"author": "Jan Buschtöns <[email protected]> (https://jan.buschtoens.me)", | ||
"directories": { | ||
"doc": "doc", | ||
"test": "tests" | ||
|
@@ -24,16 +30,16 @@ | |
"ember-cli-babel": "^7.7.3" | ||
}, | ||
"devDependencies": { | ||
"@clark/eslint-config-ember": "^1.14.1", | ||
"@clark/eslint-config-node": "^1.14.1", | ||
"@ember/optional-features": "^0.7.0", | ||
"broccoli-asset-rev": "^3.0.0", | ||
"ember-cli": "~3.12.0", | ||
"ember-cli-dependency-checker": "^3.1.0", | ||
"ember-cli-eslint": "^5.1.0", | ||
"ember-cli-htmlbars": "^3.0.1", | ||
"ember-cli-htmlbars-inline-precompile": "^2.1.0", | ||
"ember-cli-inject-live-reload": "^1.8.2", | ||
"ember-cli-sri": "^2.1.1", | ||
"ember-cli-template-lint": "^1.0.0-beta.1", | ||
"ember-cli-uglify": "^2.1.0", | ||
"ember-disable-prototype-extensions": "^1.1.3", | ||
"ember-export-application-global": "^2.0.0", | ||
|
@@ -43,9 +49,9 @@ | |
"ember-resolver": "^5.0.1", | ||
"ember-source": "~3.12.0", | ||
"ember-source-channel-url": "^1.1.0", | ||
"ember-template-lint": "^1.5.3", | ||
"ember-try": "^1.0.0", | ||
"eslint-plugin-ember": "^6.2.0", | ||
"eslint-plugin-node": "^9.0.1", | ||
"eslint": "^6.3.0", | ||
"loader.js": "^4.7.0", | ||
"qunit-dom": "^0.8.4" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@clark/ember' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import EmberRouter from '@ember/routing/router'; | ||
|
||
import config from './config/environment'; | ||
|
||
const Router = EmberRouter.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL | ||
}); | ||
|
||
Router.map(function() { | ||
}); | ||
Router.map(function() {}); | ||
|
||
export default Router; |
Empty file.
File renamed without changes.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@clark/node' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { render } from '@ember/test-helpers'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
import { set } from '@ember/object'; | ||
import { run } from '@ember/runloop'; | ||
import Service from '@ember/service'; | ||
import Ember from 'ember'; | ||
|
||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Helpers | Service', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
const { onerror } = Ember; | ||
hooks.afterEach(() => { | ||
Ember.onerror = onerror; | ||
}); | ||
|
||
hooks.beforeEach(function() { | ||
this.owner.register( | ||
'service:some-service', | ||
class SomeService extends Service { | ||
init() { | ||
super.init(); | ||
|
||
this.isTrue = true; | ||
this.fruitType = 'Banana'; | ||
} | ||
} | ||
); | ||
}); | ||
|
||
test('it allows you to access a property on a service if it exists', async function(assert) { | ||
await render(hbs`{{get (service "some-service") "fruitType"}}`); | ||
assert.dom().includesText('Banana'); | ||
|
||
await render( | ||
hbs`{{if (get (service "some-service") "isTrue") "I am here"}}` | ||
); | ||
assert.dom().includesText('I am here'); | ||
|
||
const service = this.owner.lookup('service:some-service'); | ||
run(() => set(service, 'isTrue', false)); | ||
assert.dom().doesNotIncludeText('I am here'); | ||
}); | ||
|
||
test('it throws an error when trying to access a service that does not exist', async function(assert) { | ||
assert.expect(1); | ||
|
||
Ember.onerror = error => | ||
assert.equal( | ||
error.message, | ||
"Assertion Failed: The service 'not-a-service' does not exist" | ||
); | ||
|
||
await render(hbs`{{service "not-a-service"}}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import Application from '../app'; | ||
import config from '../config/environment'; | ||
import { setApplication } from '@ember/test-helpers'; | ||
import { start } from 'ember-qunit'; | ||
|
||
import Application from '../app'; | ||
import config from '../config/environment'; | ||
|
||
setApplication(Application.create(config.APP)); | ||
|
||
start(); |
Empty file.
Empty file.
Oops, something went wrong.