Skip to content
Browse files

add build task; build to index.js

  • Loading branch information...
1 parent 0df7aec commit 865c2e9202e7371daf1384d33952fd58f0930571 James A. Rosen committed Sep 23, 2012
Showing with 70 additions and 1 deletion.
  1. +2 −1 Rakefile
  2. +34 −0 index.js
  3. +8 −0 lib/BuildTemplate.js
  4. +26 −0 lib/build.rake
View
3 Rakefile
@@ -15,4 +15,5 @@ end
Dir.glob( PROJECT_ROOT.join('lib/**/*.rake') ).each { |task| load task }
-task :spec => :jshint
+task :spec => :jshint
+task :build => :jshint # eventually :spec, once it's reliable
View
34 index.js
@@ -0,0 +1,34 @@
+// Ember-Progressbars.js version 0.0.0
+// (c) 2012 James A. Rosen, Zendesk Inc.
+// Timecop.js is freely distributable under the Apache v2 License
+// For all details, documentation, and bug reports, see
+// http://github.com/jamesarosen/ember-progressbars
+(function(){
+Ember.ProgressBars = Ember.ProgressBars || {};
+
+Ember.ProgressBars.Bar = Ember.View.extend({
+ template: Em.Handlebars.compile('<div class="bar" {{bindAttr class="statusClass"}}></div>'),
+
+ percent: 0,
+ status: undefined,
+
+ init: function() {
+ var classNames = this.get('classNames') || [];
+ classNames.push('progress');
+ this.set('classNames', classNames);
+ return this._super.apply(this, arguments);
+ },
+
+ onPercentChange: function() {
+ var percent = this.get('percent') || 0;
+ this.$('.bar').css('width', "%@%".fmt(percent) );
+ }.observes('percent'),
+
+ statusClass: Ember.computed(function() {
+ var status = this.get('status');
+ return status == null ? '' : 'bar-%@'.fmt(status);
+ }).property('status').cacheable()
+});
+
+
+}());
View
8 lib/BuildTemplate.js
@@ -0,0 +1,8 @@
+// Ember-Progressbars.js version {{ PROGRESSBARS_VERSION }}
+// (c) 2012 James A. Rosen, Zendesk Inc.
+// Timecop.js is freely distributable under the Apache v2 License
+// For all details, documentation, and bug reports, see
+// http://github.com/jamesarosen/ember-progressbars
+(function(){
+{{ PROGRESSBARS_LIBRARIES }}
+}());
View
26 lib/build.rake
@@ -0,0 +1,26 @@
+require 'stringio'
+require 'multi_json'
+
+desc 'build index.js for distribution via Bower'
+task :build do
+ build_template = File.read( PROJECT_ROOT.join('lib/BuildTemplate.js') )
+
+ version = MultiJson.decode(
+ File.read( PROJECT_ROOT.join('component.json') )
+ )['version']
+
+ contents = LIB_FILES.inject( StringIO.new ) do |sum, lib_file|
+ sum << File.read(lib_file)
+ sum << "\n"
+ sum
+ end.string
+
+ outfile = PROJECT_ROOT.join 'index.js'
+
+ File.open( outfile, 'w' ) do |f|
+ f.write build_template.
+ sub('{{ PROGRESSBARS_VERSION }}', version).
+ sub('{{ PROGRESSBARS_LIBRARIES }}', contents)
+ end
+ puts "Wrote #{outfile}"
+end

0 comments on commit 865c2e9

Please sign in to comment.
Something went wrong with that request. Please try again.