Skip to content

Commit

Permalink
Merge pull request #46 from jherdman/aggressive-modernization
Browse files Browse the repository at this point in the history
Aggressive Modernization
  • Loading branch information
jherdman authored Jun 15, 2016
2 parents f8034cf + 603a429 commit 1fd7f3d
Show file tree
Hide file tree
Showing 26 changed files with 401 additions and 403 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

Expand Down
19 changes: 10 additions & 9 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
bower_components/
tests/
tmp/
dist/

/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.jshintrc
.watchmanconfig
.travis.yml
.npmignore
**/.gitkeep
bower.json
ember-cli-build.js
Brocfile.js
testem.json
testem.js
26 changes: 20 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
language: node_js
node_js:
- "0.12"
- "4"

sudo: false

cache:
directories:
- "/home/travis/.local"
- node_modules

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-1.13
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- "npm config set spin false"
- "npm install -g npm@^2"
- npm config set spin false
- npm install -g bower
- npm install phantomjs-prebuilt

install:
- npm install -g bower
- npm install
- bower install

script:
- npm test
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try $EMBER_TRY_SCENARIO test --skip-cleanup
2 changes: 1 addition & 1 deletion .watchmanconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore_dirs": ["tmp"]
"ignore_dirs": ["tmp", "dist"]
}
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) 2015
Copyright (c) 2016

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
98 changes: 58 additions & 40 deletions app/components/chartist-chart.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/* global Chartist */
import Ember from 'ember';

// This is a custom "undefined", just a safety measure to make sure someone else
// doesn't override undefined.
var UNDEF;
const {
computed,
observer,
Component,
String: {
capitalize
}
} = Ember;

export default Ember.Component.extend({
chart: UNDEF,
export default Component.extend({
chart: null,

// This is the structure that chartist is expecting, it can be overidden in
// your components which extend this one.
defaultDataStructure: { labels: [], series: [] },
defaultDataStructure: {
labels: [],
series: []
},

classNameBindings: ['ratio'],
classNames: ['ct-chart'],
Expand Down Expand Up @@ -40,40 +48,17 @@ export default Ember.Component.extend({
ratio: 'ct-square',

type: 'line',
chartType: Ember.computed('type', function() {
return Ember.String.capitalize(this.get('type'));
chartType: computed('type', function() {
return capitalize(this.get('type'));
}),

data: null,
options: UNDEF,
responsiveOptions: UNDEF,
options: null,
responsiveOptions: null,
updateOnData: true,

// This is where the business happens. This will only run if checkForReqs
// doesn't find any problems.
didInsertElement: function() {
var data = this.get('data') || this.get('defaultDataStructure');
var chart = new Chartist[this.get('chartType')](
this.get('element'),
data,
this.get('options'),
this.get('responsiveOptions')
);

this.set('chart', chart);

this._super();
},

onData: Ember.observer('data', function() {
if (this.get('updateOnData')) {
var opts = this.get('options') || {};
this.get('chart').update(
this.get('data'),
opts
);
}
}),
// Don't use this! It's a testing hook
_createdEventHook() {},

// Before trying to do anything else, let's check to see if any necessary
// attributes are missing or if anything else is fishy about attributes
Expand All @@ -82,12 +67,15 @@ export default Ember.Component.extend({
// We're doing this to help ease people into this project. Instead of just
// getting some "uncaught exception" we're hoping these error messages will
// point them in the right direction.
init: function() {
var data = this.get('data'),
type = this.get('type');
init() {
let data = this.get('data');
let type = this.get('type');

if (typeof data === 'string') {
console.info('Chartist-chart: The value of the "data" attribute on should be an object, it\'s a string.');

let defaultDataStructure = this.get('defaultDataStructure');

this.set('data', defaultDataStructure);
}

Expand All @@ -96,6 +84,36 @@ export default Ember.Component.extend({
this.set('type', 'line');
}

this._super();
}
this._super(...arguments);
},

// This is where the business happens. This will only run if checkForReqs
// doesn't find any problems.
didInsertElement() {
let data = this.get('data') || this.get('defaultDataStructure');

let chart = new Chartist[this.get('chartType')](
this.get('element'),
data,
this.get('options'),
this.get('responsiveOptions')
);

chart.on('created', this._createdEventHook);

this.set('chart', chart);

this._super(...arguments);
},

onData: observer('data', function() {
if (this.get('updateOnData')) {
let opts = this.get('options') || {};

this.get('chart').update(
this.get('data'),
opts
);
}
}),
});
15 changes: 4 additions & 11 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
{
"name": "ember-cli-chartist",
"dependencies": {
"jquery": "2.1.0",
"ember": "1.13.5",
"ember-data": "1.0.0-beta.17",
"ember-resolver": "0.1.15",
"loader.js": "ember-cli/loader.js#3.2.0",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.3.3",
"ember-qunit-notifications": "0.0.7",
"qunit": "1.17.1"
"ember": "~2.6.0",
"ember-cli-shims": "0.1.1",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0"
},
"devDependencies": {
"chartist": "~0.7.3"
Expand Down
52 changes: 36 additions & 16 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
/*jshint node:true*/
module.exports = {
scenarios: [
{
name: 'default',
dependencies: { }
bower: {
dependencies: { }
}
},
{
name: 'ember-1.13',
bower: {
dependencies: {
'ember': '~1.13.0'
},
resolutions: {
'ember': '~1.13.0'
}
}
},
{
name: 'ember-release',
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
bower: {
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
}
},
{
name: 'ember-beta',
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
bower: {
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
}
},
{
name: 'ember-canary',
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
bower: {
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
}
}
]
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true*/
'use strict';

module.exports = function(/* environment, appConfig */) {
Expand Down
11 changes: 3 additions & 8 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
var _ = require('lodash');

module.exports = function(defaults) {
// NOTE: This is temporary until the fix for
// https://github.com/ember-cli/ember-cli/issues/4435
// is released.
var opts = _.merge(defaults, {
var app = new EmberAddon(defaults, {
'ember-cli-chartist': {
useCustomCSS: true
}
});

var app = new EmberAddon(opts);

/*
This build file specifes the options for the dummy test app of this
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
Expand Down
Loading

0 comments on commit 1fd7f3d

Please sign in to comment.