Merge branch 'build-tooling-and-scripts'
Showing
9 changed files
with
32 additions
and
102 deletions
Gemfile
deleted
100644 → 0
Gemfile.lock
deleted
100644 → 0
1 | GEM | ||
2 | remote: http://rubygems.org/ | ||
3 | specs: | ||
4 | closure-compiler (1.1.6) | ||
5 | coffee-script (2.2.0) | ||
6 | coffee-script-source | ||
7 | execjs | ||
8 | coffee-script-source (1.3.3) | ||
9 | execjs (1.4.0) | ||
10 | multi_json (~> 1.0) | ||
11 | ffi (1.0.11) | ||
12 | guard (1.0.2) | ||
13 | ffi (>= 0.5.0) | ||
14 | thor (~> 0.14.6) | ||
15 | guard-coffeescript (0.6.0) | ||
16 | coffee-script (>= 2.2.0) | ||
17 | guard (>= 0.8.3) | ||
18 | multi_json (1.3.6) | ||
19 | thor (0.14.6) | ||
20 | |||
21 | PLATFORMS | ||
22 | ruby | ||
23 | |||
24 | DEPENDENCIES | ||
25 | closure-compiler | ||
26 | coffee-script | ||
27 | guard | ||
28 | guard-coffeescript |
Guardfile
deleted
100644 → 0
Rakefile
deleted
100644 → 0
1 | require 'rubygems' | ||
2 | |||
3 | BUILD_DIRECTORY = 'lib' | ||
4 | SRC_DIRECTORY = 'src' | ||
5 | |||
6 | desc "build the toast-min.js files for distribution" | ||
7 | task :default => :clean do | ||
8 | FileUtils.mkdir_p(BUILD_DIRECTORY) | ||
9 | compile_js | ||
10 | end | ||
11 | |||
12 | task :build => :default | ||
13 | |||
14 | desc "removes the build directory" | ||
15 | task :clean do | ||
16 | print_action('Removing existing build directory') do | ||
17 | FileUtils.rm_rf(BUILD_DIRECTORY) | ||
18 | end | ||
19 | end | ||
20 | |||
21 | def compile_js() | ||
22 | require 'coffee-script' | ||
23 | require 'closure-compiler' | ||
24 | |||
25 | source = File.read(File.join(SRC_DIRECTORY, 'rivets.coffee')) | ||
26 | FileUtils.mkdir_p(BUILD_DIRECTORY) | ||
27 | output = File.join(BUILD_DIRECTORY, 'rivets.js') | ||
28 | minified_output = File.join(BUILD_DIRECTORY, 'rivets-min.js') | ||
29 | |||
30 | compiled = '' | ||
31 | print_action("Compiling CoffeeScript to '#{output}'") do | ||
32 | File.open(output, 'w+') do |file| | ||
33 | compiled = CoffeeScript.compile(source) | ||
34 | file.write(compiled) | ||
35 | end | ||
36 | end | ||
37 | |||
38 | print_action("Minifying Javascript to '#{minified_output}'") do | ||
39 | File.open(minified_output, 'w+') do |file| | ||
40 | file.write(Closure::Compiler.new.compress(compiled)) | ||
41 | end | ||
42 | end | ||
43 | end | ||
44 | |||
45 | def print_action(action, &block) | ||
46 | print "#{action}... " | ||
47 | STDOUT.flush | ||
48 | |||
49 | if block.call() | ||
50 | puts 'done' | ||
51 | else | ||
52 | puts 'failed' | ||
53 | end | ||
54 | end |
grunt.js
0 → 100644
1 | module.exports = function(grunt) { | ||
2 | grunt.initConfig({ | ||
3 | lint: { | ||
4 | files: ['grunt.js', 'lib/**/*.js', 'spec/**/*.js'] | ||
5 | }, | ||
6 | min: { | ||
7 | dist: { | ||
8 | src: 'lib/rivets.js', | ||
9 | dest: 'lib/rivets.min.js' | ||
10 | } | ||
11 | }, | ||
12 | watch: { | ||
13 | files: 'src/rivets.coffee', | ||
14 | tasks: 'build' | ||
15 | }, | ||
16 | }); | ||
17 | |||
18 | grunt.registerTask('default', 'watch'); | ||
19 | |||
20 | grunt.registerTask('compile', 'Compiles CoffeeScript source into JavaScript.', function(){ | ||
21 | var coffee = require('coffee-script'); | ||
22 | var js = coffee.compile(grunt.file.read('src/rivets.coffee')); | ||
23 | if (js) grunt.file.write('lib/rivets.js', js); | ||
24 | }); | ||
25 | |||
26 | grunt.registerTask('build', 'compile min'); | ||
27 | }; |
lib/rivets-min.js
deleted
100644 → 0
1 | (function(){var p,h,c,k,r,s,l,t,u,j,v,e=function(a,b){return function(){return a.apply(b,arguments)}},x=[].indexOf||function(a){for(var b=0,w=this.length;b<w;b++)if(b in this&&this[b]===a)return b;return-1};k=c=h=p=void 0;String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});p=function(){function a(b,a,d,i,f,g){this.el=b;this.type=a;this.bindType=d;this.model=i;this.keypath=f;this.formatters=g!=null?g:[];this.publish=e(this.publish,this);this.bind=e(this.bind, | ||
2 | this);this.set=e(this.set,this);this.routine=this.bindType==="event"?t(this.type):h[this.type]||r(this.type)}a.prototype.set=function(b){var a,d,i,f;f=this.formatters;d=0;for(i=f.length;d<i;d++){a=f[d];b=c.formatters[a](b)}if(this.bindType==="event"){this.routine(this.el,b,this.currentListener);return this.currentListener=b}return this.routine(this.el,b)};a.prototype.bind=function(){c.adapter.subscribe(this.model,this.keypath,this.set);c.preloadData&&this.set(c.adapter.read(this.model,this.keypath)); | ||
3 | if(this.bindType==="bidirectional")return l(this.el,"change",this.publish)};a.prototype.publish=function(b){return c.adapter.publish(this.model,this.keypath,u(b.target||b.srcElement))};return a}();k=function(){function a(b,a){this.el=b;this.models=a;this.bind=e(this.bind,this);this.build=e(this.build,this);this.bindingRegExp=e(this.bindingRegExp,this);if(this.el.jquery)this.el=this.el.get(0);this.build()}a.prototype.bindingRegExp=function(){var b;return(b=c.prefix)?RegExp("^data-"+b+"-"):/^data-/}; | ||
4 | a.prototype.build=function(){var b,a,d,i,f,g,c,e,m,n,h,o,k,l,j;this.bindings=[];d=this.bindingRegExp();f=/^on-/;i=[this.el];i.concat(Array.prototype.slice.call(this.el.getElementsByTagName("*")));h=0;for(k=i.length;h<k;h++){e=i[h];j=e.attributes;o=0;for(l=j.length;o<l;o++){b=j[o];if(d.test(b.name)){a="attribute";n=b.name.replace(d,"");var q=g=m=c=void 0;g=b.value.split("|");q=[];c=0;for(m=g.length;c<m;c++){b=g[c];q.push(b.trim())}m=q;g=m.shift().split(".");c=this.models[g.shift()];g=g.join(".");if(f.test(n)){n= | ||
5 | n.replace(f,"");a="event"}else x.call(s,n)>=0&&(a="bidirectional");this.bindings.push(new p(e,n,a,c,g,m))}}}};a.prototype.bind=function(){var b,a,d,c,f;c=this.bindings;f=[];a=0;for(d=c.length;a<d;a++){b=c[a];f.push(b.bind())}return f};return a}();l=function(a,b,c){return window.addEventListener?a.addEventListener(b,c):a.attachEvent(b,c)};v=function(a,b,c){return window.removeEventListener?a.removeEventListener(b,c):a.detachEvent(b,c)};u=function(a){switch(a.type){case "text":case "textarea":case "password":case "select-one":return a.value; | ||
6 | case "checkbox":case "radio":return a.checked}};t=function(a){return function(b,c,d){c&&l(b,a,c);if(d)return v(b,a,d)}};r=function(a){return function(b,c){return c?b.setAttribute(a,c):b.removeAttribute(a)}};s=["value","checked","unchecked","selected","unselected"];h={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:function(a,b){return a.checked=!!b},unchecked:function(a,b){return a.checked=!b},selected:function(a,b){return a.selected=!!b},unselected:function(a, | ||
7 | b){return a.selected=!b},show:function(a,b){return a.style.display=b?"":"none"},hide:function(a,b){return a.style.display=b?"none":""},html:function(a,b){return a.innerHTML=b||""},value:function(a,b){return a.value=b},text:function(a,b){return a.innerText!=null?a.innerText=b||"":a.textContent=b||""}};c={preloadData:!0};j={configure:function(a){var b,e,d;a==null&&(a={});d=[];for(b in a){e=a[b];d.push(c[b]=e)}return d},register:function(a,b){return h[a]=b},bind:function(a,b){var c;b==null&&(b={});c= | ||
8 | new k(a,b);c.bind();return c}};"undefined"!==typeof module&&null!==module?module.exports=j:this.rivets=j}).call(this); |
lib/rivets.min.js
0 → 100644
1 | (function(){var a,b,c,d,e,f,g,h,i=function(a,b){return function(){return a.apply(b,arguments)}},j=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};a={},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),a.Binding=function(){function c(c,d,f,g,h,j){this.el=c,this.type=d,this.bindType=f,this.model=g,this.keypath=h,this.formatters=j!=null?j:[],this.publish=i(this.publish,this),this.bind=i(this.bind,this),this.set=i(this.set,this),this.bindType==="event"?this.routine=e(this.type):this.routine=a.routines[this.type]||b(this.type)}return c.prototype.set=function(b){var c,d,e,f;f=this.formatters;for(d=0,e=f.length;d<e;d++)c=f[d],b=a.config.formatters[c](b);return this.bindType==="event"?(this.routine(this.el,b,this.currentListener),this.currentListener=b):this.routine(this.el,b)},c.prototype.bind=function(){a.config.adapter.subscribe(this.model,this.keypath,this.set),a.config.preloadData&&this.set(a.config.adapter.read(this.model,this.keypath));if(this.bindType==="bidirectional")return d(this.el,"change",this.publish)},c.prototype.publish=function(b){var c;return c=b.target||b.srcElement,a.config.adapter.publish(this.model,this.keypath,f(c))},c}(),a.View=function(){function b(a,b){this.el=a,this.models=b,this.bind=i(this.bind,this),this.build=i(this.build,this),this.bindingRegExp=i(this.bindingRegExp,this),this.el.jquery&&(this.el=this.el.get(0)),this.build()}return b.prototype.bindingRegExp=function(){var b;return b=a.config.prefix,b?new RegExp("^data-"+b+"-"):/^data-/},b.prototype.build=function(){var b,d,e,f,g,h,i,k,l,m,n,o,p,q,r,s,t;this.bindings=[],e=this.bindingRegExp(),g=/^on-/,f=[this.el],f.concat(Array.prototype.slice.call(this.el.getElementsByTagName("*")));for(p=0,r=f.length;p<r;p++){k=f[p],t=k.attributes;for(q=0,s=t.length;q<s;q++)b=t[q],e.test(b.name)&&(d="attribute",o=b.name.replace(e,""),n=function(){var a,c,d,e;d=b.value.split("|"),e=[];for(a=0,c=d.length;a<c;a++)m=d[a],e.push(m.trim());return e}(),l=n.shift().split("."),i=this.models[l.shift()],h=l.join("."),g.test(o)?(o=o.replace(g,""),d="event"):j.call(c,o)>=0&&(d="bidirectional"),this.bindings.push(new a.Binding(k,o,d,i,h,n)))}},b.prototype.bind=function(){var a,b,c,d,e;d=this.bindings,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.bind());return e},b}(),d=function(a,b,c){return window.addEventListener?a.addEventListener(b,c):a.attachEvent(b,c)},h=function(a,b,c){return window.removeEventListener?a.removeEventListener(b,c):a.detachEvent(b,c)},f=function(a){switch(a.type){case"text":case"textarea":case"password":case"select-one":return a.value;case"checkbox":case"radio":return a.checked}},e=function(a){return function(b,c,e){c&&d(b,a,c);if(e)return h(b,a,e)}},b=function(a){return function(b,c){return c?b.setAttribute(a,c):b.removeAttribute(a)}},c=["value","checked","unchecked","selected","unselected"],a.routines={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:function(a,b){return a.checked=!!b},unchecked:function(a,b){return a.checked=!b},selected:function(a,b){return a.selected=!!b},unselected:function(a,b){return a.selected=!b},show:function(a,b){return a.style.display=b?"":"none"},hide:function(a,b){return a.style.display=b?"none":""},html:function(a,b){return a.innerHTML=b||""},value:function(a,b){return a.value=b},text:function(a,b){return a.innerText!=null?a.innerText=b||"":a.textContent=b||""}},a.config={preloadData:!0},g={configure:function(b){var c,d,e;b==null&&(b={}),e=[];for(c in b)d=b[c],e.push(a.config[c]=d);return e},register:function(b,c){return a.routines[b]=c},bind:function(b,c){var d;return c==null&&(c={}),d=new a.View(b,c),d.bind(),d}},typeof module!="undefined"&&module!==null?module.exports=g:this.rivets=g}).call(this); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -12,7 +12,8 @@ | ... | @@ -12,7 +12,8 @@ |
12 | "type" : "git", | 12 | "type" : "git", |
13 | "url" : "https://github.com/mikeric/rivets.git" | 13 | "url" : "https://github.com/mikeric/rivets.git" |
14 | }, | 14 | }, |
15 | "scripts" : { | 15 | "devDependencies" : { |
16 | "build" : "coffee -o lib -c src" | 16 | "grunt" : "0.3.x", |
17 | "coffee-script" : "1.3.x" | ||
17 | } | 18 | } |
18 | } | 19 | } | ... | ... |
-
Please register or sign in to post a comment