From c97c0a350f189b4310dd991f1abcb91fd2bed825 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 21 Sep 2015 16:09:09 -0400 Subject: [PATCH 1/2] Make compatible with versions prior to 1.13 --- .travis.yml | 7 ++++++- addon/ext/link.js | 8 ++++---- addon/initializers/metrics-link.js | 7 +++++++ config/ember-try.js | 20 ++++++++++++++++++++ package.json | 2 +- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8197d316..fc5aa569 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ cache: env: - EMBER_TRY_SCENARIO=default + - EMBER_TRY_SCENARIO=ember-1.11 + - EMBER_TRY_SCENARIO=ember-1.12.1 - EMBER_TRY_SCENARIO=ember-release - EMBER_TRY_SCENARIO=ember-beta - EMBER_TRY_SCENARIO=ember-canary @@ -21,7 +23,10 @@ matrix: - env: EMBER_TRY_SCENARIO=ember-canary before_install: - - export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH + - mkdir -p travis-phantomjs + - wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 + - tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs + - export PATH=$PWD/travis-phantomjs:$PATH - "npm config set spin false" - "npm install -g npm@^2" diff --git a/addon/ext/link.js b/addon/ext/link.js index 8a27eca8..405fe210 100644 --- a/addon/ext/link.js +++ b/addon/ext/link.js @@ -1,18 +1,19 @@ import Ember from 'ember'; const { - LinkComponent, inject, isPresent, get, + getWithDefault, String: { camelize } } = Ember; +const LinkComponent = Ember.LinkComponent || Ember.LinkView; export default LinkComponent.reopen({ metrics: inject.service(), click() { - const attrs = Object.keys(get(this, 'attrs')); + const attrs = Object.keys(getWithDefault(this, 'attrs', this)); const metricsProperties = this._deserializeEvent(attrs); const hasMetricsKeys = isPresent(Object.keys(metricsProperties)); @@ -28,8 +29,7 @@ export default LinkComponent.reopen({ attrs.forEach((attr) => { if (attr.indexOf('metrics') !== -1) { - const strippedAttr = attr.replace('metrics', ''); - const camelizedAttr = camelize(strippedAttr); + const camelizedAttr = camelize(attr.replace('metrics', '')); metricsProperties[camelizedAttr] = get(this, attr); } }); diff --git a/addon/initializers/metrics-link.js b/addon/initializers/metrics-link.js index 048b7f66..08e20f02 100644 --- a/addon/initializers/metrics-link.js +++ b/addon/initializers/metrics-link.js @@ -1,7 +1,14 @@ import Ember from 'ember'; import LinkComponent from 'ember-metrics/ext/link'; +const { isBlank } = Ember; + export function initialize() { + if (isBlank(Ember.LinkComponent)) { + Ember.LinkView = Ember.LinkComponent; + return; + } + Ember.LinkComponent = LinkComponent; } diff --git a/config/ember-try.js b/config/ember-try.js index 83dab0f1..f99e13f1 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,9 +1,29 @@ +/* jshint node: true */ + module.exports = { scenarios: [ { name: 'default', dependencies: { } }, + { + name: 'ember-1.11', + dependencies: { + 'ember': '~1.11.0' + }, + resolutions: { + 'ember': '~1.11.0' + } + }, + { + name: 'ember-1.12.1', + dependencies: { + 'ember': '1.12.1' + }, + resolutions: { + 'ember': '1.12.1' + } + }, { name: 'ember-release', dependencies: { diff --git a/package.json b/package.json index 521fd765..36275f2f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "ember-cli": "1.13.8", "ember-cli-app-version": "0.5.0", "ember-cli-dependency-checker": "^1.0.1", - "ember-cli-htmlbars": "0.7.9", "ember-cli-htmlbars-inline-precompile": "^0.2.0", "ember-cli-ic-ajax": "0.2.1", "ember-cli-inject-live-reload": "^1.3.1", @@ -57,6 +56,7 @@ "mixpanel" ], "dependencies": { + "ember-cli-htmlbars": "0.7.9", "ember-cli-babel": "^5.1.3" }, "ember-addon": { From b949472a640ccfb13e149c14bb6d3b4f478d0b55 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 21 Sep 2015 16:26:42 -0400 Subject: [PATCH 2/2] Version bump to 0.3.0 --- README.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 450d9c82..53d2b6f2 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ For Ember CLI < `0.2.3`: ember install:addon ember-metrics ``` +## Compatibility +This addon is tested against the `release`, `beta`, and `canary` channels, as well as `~1.11.0`, and `1.12.1`. + ## Configuration To setup, you should first configure the service through `config/environment`: diff --git a/package.json b/package.json index 36275f2f..5da28f00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-metrics", - "version": "0.2.0", + "version": "0.3.0", "description": "Send data to multiple analytics integrations without re-implementing new API", "directories": { "doc": "doc",