ninjs 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +64 -0
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/bin/ninjs +14 -5
- data/lib/ninjs.rb +0 -3
- data/lib/ninjs/command.rb +67 -110
- data/lib/ninjs/configuration.rb +33 -39
- data/lib/ninjs/project.rb +14 -31
- data/ninjs.conf +7 -0
- data/ninjs.gemspec +63 -5
- data/repository/jquery/1.5.js +16 -0
- data/repository/jquery/latest.js +1 -1
- data/repository/jquery/mobile/1.0a3.js +123 -0
- data/repository/jquery/mobile/1.0a3/assets/css/jquery.mobile.css +1652 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/ajax-loader.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-off.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-on.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-off.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-on.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icon-search-black.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-black.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-white.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-black.png +0 -0
- data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-white.png +0 -0
- data/repository/jquery/mobile/latest.js +1 -0
- data/spec/fixtures/global.js +7 -0
- data/spec/fixtures/global.module.js +7 -0
- data/spec/fixtures/myapplication.js +576 -0
- data/spec/fixtures/nin.js +573 -0
- data/spec/fixtures/ninjs.conf +6 -0
- data/spec/fixtures/test.elements.js +4 -0
- data/spec/fixtures/test.js +15 -0
- data/spec/fixtures/test.model.js +3 -0
- data/spec/fixtures/test.module.js +10 -0
- data/spec/fixtures/updated.myapplication.js +27 -0
- data/spec/fixtures/utilities.js +162 -0
- data/spec/ninjs_spec.rb +257 -0
- data/spec/spec_helper.rb +2 -1
- data/tmp/ff9e83aa019b712b90200b8d1b8fa0c7e14576af.json +1 -0
- data/tmp/metric_fu/_data/20110305.yml +1548 -0
- data/tmp/metric_fu/output/bluff-min.js +1 -0
- data/tmp/metric_fu/output/churn.html +692 -0
- data/tmp/metric_fu/output/excanvas.js +35 -0
- data/tmp/metric_fu/output/flay.html +566 -0
- data/tmp/metric_fu/output/flay.js +11 -0
- data/tmp/metric_fu/output/flog.html +2392 -0
- data/tmp/metric_fu/output/flog.js +12 -0
- data/tmp/metric_fu/output/hotspots.html +3607 -0
- data/tmp/metric_fu/output/index.html +572 -0
- data/tmp/metric_fu/output/js-class.js +1 -0
- data/tmp/metric_fu/output/lib_ninjs.rb.html +49 -0
- data/tmp/metric_fu/output/lib_ninjs_command.rb.html +137 -0
- data/tmp/metric_fu/output/lib_ninjs_configuration.rb.html +107 -0
- data/tmp/metric_fu/output/lib_ninjs_dependencies.rb.html +34 -0
- data/tmp/metric_fu/output/lib_ninjs_helpers.rb.html +34 -0
- data/tmp/metric_fu/output/lib_ninjs_manifest.rb.html +27 -0
- data/tmp/metric_fu/output/lib_ninjs_project.rb.html +236 -0
- data/tmp/metric_fu/output/rails_best_practices.js +11 -0
- data/tmp/metric_fu/output/rcov.html +566 -0
- data/tmp/metric_fu/output/rcov.js +11 -0
- data/tmp/metric_fu/output/reek.html +1294 -0
- data/tmp/metric_fu/output/reek.js +20 -0
- data/tmp/metric_fu/output/roodi.html +599 -0
- data/tmp/metric_fu/output/roodi.js +11 -0
- data/tmp/metric_fu/report.yml +1548 -0
- data/tmp/metric_fu/scratch/rcov/rcov.txt +1 -0
- metadata +94 -27
- data/spec/test_spec.rb +0 -5
@@ -0,0 +1,15 @@
|
|
1
|
+
MyApplication.add_module('TestModule');
|
2
|
+
|
3
|
+
$(document).ready(function() {
|
4
|
+
MyApplication.TestModule.test_id = $('#test-element-with-id');
|
5
|
+
console.log(MyApplication.TestModule.test_id);
|
6
|
+
});
|
7
|
+
MyApplication.test_model = {
|
8
|
+
some_data_member: 'some data value'
|
9
|
+
};
|
10
|
+
|
11
|
+
MyApplication.TestModule.actions = function() {
|
12
|
+
console.log(MyApplication.TestModule.test_id.html());
|
13
|
+
};
|
14
|
+
|
15
|
+
MyApplication.TestModule.run();
|
@@ -0,0 +1,10 @@
|
|
1
|
+
MyApplication.add_module('TestModule');
|
2
|
+
|
3
|
+
//= require "../elements/test.elements.js"
|
4
|
+
//= require "../models/test.model.js"
|
5
|
+
|
6
|
+
MyApplication.TestModule.actions = function() {
|
7
|
+
console.log(MyApplication.TestModule.test_id.html());
|
8
|
+
};
|
9
|
+
|
10
|
+
MyApplication.TestModule.run();
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
if(is_defined===undefined){var is_defined=function(variable){return(variable===undefined)?false:true;};}
|
3
|
+
if(!is_defined(is_undefined)){var is_undefined=function(variable){return(variable===undefined)?true:false;};}
|
4
|
+
if(is_undefined(is_typeof)){var is_typeof=function(type,variable){try{if(is_undefined(type)){throw new SyntaxError("is_typeof(Type, variable): type is undefined");}
|
5
|
+
if(is_undefined(variable)){throw new SyntaxError("is_typeof(Type, variable): variable is undefined");}
|
6
|
+
return(variable.constructor==type)?true:false;}
|
7
|
+
catch(error){document.write(error.message);}};}
|
8
|
+
if(is_undefined(is_numeric)){var is_numeric=function(suspect){if(is_typeof(Number,suspect)){return true;}
|
9
|
+
else{var pattern=/^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(suspect);}};}
|
10
|
+
if(is_undefined(die)){var die=function(last_words){if(is_undefined(last_words)){lastwords=''}
|
11
|
+
document.write(lastwords)};}
|
12
|
+
if(is_undefined(Object.prototype['method'])){Object.prototype.method=function(name,func){try{if(is_undefined(name)){throw new SyntaxError("Object.method(name, func): name is undefined");}
|
13
|
+
if(is_undefined(func)){throw new SyntaxError("Object.method(name, func): func is undefined");}
|
14
|
+
if(is_undefined(this.prototype[name])){this.prototype[name]=func;return this;}}
|
15
|
+
catch(error){document.write(error.message);}};}
|
16
|
+
if(is_undefined(Object.prototype['clone'])){Object.method('clone',function(){if(typeof this!=='object'||this===null){return this;}
|
17
|
+
if(this instanceof Node||this instanceof NodeList||this instanceof NamedNodeMap){die('You cannot clone a Node, Nodelist or NamedNodeMap');}
|
18
|
+
var clone=is_typeof(Array,this)?[]:{};for(var prop in this){if(this.hasOwnProperty(prop)){clone[prop]=this[prop];}}
|
19
|
+
return clone;});}
|
20
|
+
var JudoModule=function(){};JudoModule.method('actions',function(){});JudoModule.method('run',function(){this.actions();});var JudoApplication=function(){};JudoApplication.method('add_module',function(name){try{if(is_undefined(name)){throw new SyntaxError("JudoApplication.add_module(name): name is undefined");}
|
21
|
+
if(is_defined(this[name])){throw new SyntaxError("JudoApplication.add_module(name): '"+name+"' already declared");}
|
22
|
+
this[name]=new JudoModule();}
|
23
|
+
catch(error){document.write(error.message);}});var Judo::Configuration=new JudoApplication();Array.method('is_empty',function(){return(this.length<1)?true:false;});Array.method('not_empty',function(){return(this.length>0)?true:false;});Array.method('each',function(callback){try{if(is_undefined(callback)){throw new SyntaxError("Array.each(callback): callback is undefined");}
|
24
|
+
for(var i=0;i<this.length;i++){var args=[this[i],i];callback.apply(this,args);}}
|
25
|
+
catch(error){document.write(error.message);}});Array.method('contains',function(suspect){var matches=[];this.each(function(value,index){if(value===suspect){matches.push(index);}});return matches.not_empty()?matches:false;});Array.method('shuffle',function(){var clone=this.clone();for(var j,x,i=clone.length;i;j=parseInt(Math.random()*i),x=clone[--i],clone[i]=clone[j],clone[j]=x);return clone;});String.method('is_empty',function(){return(this=='')?true:false;});String.method('not_empty',function(){return(this=='')?false:true;});String.method('is_number',function(){var pattern=/^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(this);});String.method('trim',function(){return this.replace(/^\s+|\s+$/g,"");});String.method('ltrim',function(){return this.replace(/^\s+/,"");});String.method('rtrim',function(){return this.replace(/\s+$/,"");});String.method('each',function(callback){try{if(is_undefined(callback)){throw new SyntaxError("String.each(callback): callback is undefined");}
|
26
|
+
for(var i=0;i<this.length;i++){var args=[this.charAt(i),i];callback.apply(this,args);}}
|
27
|
+
catch(error){document.write(error.message);}});String.method('capitalize',function(){return this.substr(0,1).toUpperCase()+this.substr(1);});String.method('reverse',function(){return this.split('').reverse().join('');});String.method('to_n',function(){return parseFloat(this);});String.method('pluck',function(needle){var pattern=new RegExp(needle,'g');return this.replace(pattern,'');});String.method('single_space',function(){var no_hard_spaces=this.replace(/\ \;/g,' ');return no_hard_spaces.replace(/\s+/g,' ');});String.method('compress',function(){return this.replace(/\s+/g,'');});String.method('shuffle',function(){return this.split('').shuffle().join('');})
|
@@ -0,0 +1,162 @@
|
|
1
|
+
Array.method('is_empty', function() {
|
2
|
+
return (this.length < 1) ? true : false;
|
3
|
+
});
|
4
|
+
|
5
|
+
Array.method('not_empty', function() {
|
6
|
+
return (this.length > 0) ? true : false;
|
7
|
+
});
|
8
|
+
|
9
|
+
Array.method('each', function(callback) {
|
10
|
+
try {
|
11
|
+
if(is_undefined(callback)) {
|
12
|
+
throw new SyntaxError("Array.each(callback): callback is undefined");
|
13
|
+
}
|
14
|
+
|
15
|
+
for (var i = 0; i < this.length; i++) {
|
16
|
+
var args = [this[i], i];
|
17
|
+
callback.apply(this, args);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
catch(error) {
|
21
|
+
alert(error.message);
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
Array.method('contains', function(suspect) {
|
26
|
+
var matches = [];
|
27
|
+
this.each(function(value, index) {
|
28
|
+
if(value === suspect) {
|
29
|
+
matches.push(index);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
|
33
|
+
return matches.not_empty() ? matches : false;
|
34
|
+
});
|
35
|
+
String.method('is_empty', function() {
|
36
|
+
return (this.length < 1) ? true : false;
|
37
|
+
});
|
38
|
+
|
39
|
+
String.method('not_empty', function() {
|
40
|
+
return (this.length < 1) ? false : true;
|
41
|
+
});
|
42
|
+
|
43
|
+
String.method('is_numeric', function() {
|
44
|
+
var pattern = /^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
45
|
+
return pattern.test(this);
|
46
|
+
});
|
47
|
+
|
48
|
+
String.method('trim', function() {
|
49
|
+
return this.replace(/^\s+|\s+$/g, "");
|
50
|
+
});
|
51
|
+
|
52
|
+
String.method('ltrim', function() {
|
53
|
+
return this.replace(/^\s+/,"");
|
54
|
+
});
|
55
|
+
|
56
|
+
String.method('rtrim', function() {
|
57
|
+
return this.replace(/\s+$/,"");
|
58
|
+
});
|
59
|
+
|
60
|
+
String.method('each', function(callback) {
|
61
|
+
try {
|
62
|
+
if(is_undefined(callback)) {
|
63
|
+
throw new SyntaxError("String.each(callback): callback is undefined");
|
64
|
+
}
|
65
|
+
|
66
|
+
for (var i = 0; i < this.length; i++) {
|
67
|
+
var args = [this.charAt(i), i];
|
68
|
+
callback.apply(this, args);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
catch(error) {
|
72
|
+
alert(error.message);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
|
76
|
+
String.method('capitalize', function() {
|
77
|
+
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
78
|
+
});
|
79
|
+
|
80
|
+
String.method('reverse', function() {
|
81
|
+
return this.split('').reverse().join('');
|
82
|
+
});
|
83
|
+
|
84
|
+
String.method('to_n', function() {
|
85
|
+
return parseFloat(this);
|
86
|
+
});
|
87
|
+
|
88
|
+
String.method('pluck', function(needle) {
|
89
|
+
var pattern = new RegExp(needle, 'g');
|
90
|
+
return this.replace(pattern, '');
|
91
|
+
});
|
92
|
+
|
93
|
+
String.method('single_space', function() {
|
94
|
+
var no_hard_spaces = this.replace(/\ \;/g, ' ');
|
95
|
+
return no_hard_spaces.replace(/\s+/g, ' ');
|
96
|
+
});
|
97
|
+
|
98
|
+
String.method('compress', function() {
|
99
|
+
return this.replace(/\s+/g, '');
|
100
|
+
});
|
101
|
+
Number.method('to_hex', function() {
|
102
|
+
if (this === 0) {
|
103
|
+
return "00";
|
104
|
+
}
|
105
|
+
|
106
|
+
var chars = "0123456789ABCDEF";
|
107
|
+
var n = Math.max(0, this);
|
108
|
+
n = Math.min(n, 255);
|
109
|
+
n = Math.round(n);
|
110
|
+
return chars.charAt((n - n % 16)/16) + chars.charAt(n % 16);
|
111
|
+
});
|
112
|
+
var CSS = function() {};
|
113
|
+
|
114
|
+
CSS.rgb2hex = function(r,g,b) {
|
115
|
+
pattern = /(\d{1,3})\,\s?(\d{1,3})\,\s?(\d{1,3})/gi;
|
116
|
+
var rgb;
|
117
|
+
if (is_typeof(String, r)) {
|
118
|
+
rgb = r.match(pattern);
|
119
|
+
rgb = rgb[0].split(',');
|
120
|
+
}
|
121
|
+
else {
|
122
|
+
rgb = false;
|
123
|
+
}
|
124
|
+
|
125
|
+
if (rgb) {
|
126
|
+
r = parseInt(rgb[0], 10);
|
127
|
+
g = parseInt(rgb[1], 10);
|
128
|
+
b = parseInt(rgb[2], 10);
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
r = parseInt(r, 10);
|
132
|
+
g = parseInt(g, 10);
|
133
|
+
b = parseInt(b, 10);
|
134
|
+
}
|
135
|
+
return '#' + r.to_hex() + g.to_hex() + b.to_hex();
|
136
|
+
};
|
137
|
+
|
138
|
+
CSS.hex2rgb = function(hex) {
|
139
|
+
hex = hex.replace('#', '');
|
140
|
+
|
141
|
+
var rgb = [];
|
142
|
+
|
143
|
+
rgb[0] = parseInt(hex.substring(0,2), 16);
|
144
|
+
rgb[1] = parseInt(hex.substring(2,4), 16);
|
145
|
+
rgb[2] = parseInt(hex.substring(4,6), 16);
|
146
|
+
|
147
|
+
rgb.red = rgb[0];
|
148
|
+
rgb.green = rgb[1];
|
149
|
+
rgb.blue = rgb[2];
|
150
|
+
|
151
|
+
rgb.to_s = function() {
|
152
|
+
return 'rgb(' + rgb.red +', ' + rgb.green + ', ' + rgb.blue + ')';
|
153
|
+
};
|
154
|
+
|
155
|
+
rgb.each = function(callback) {
|
156
|
+
for (var i = 0; i < 3; i++) {
|
157
|
+
callback.call(this, rgb[i]);
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
return rgb;
|
162
|
+
};
|
data/spec/ninjs_spec.rb
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Ninjs do
|
4
|
+
context 'When instantiating a new project' do
|
5
|
+
before :each do
|
6
|
+
@spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) + '/'
|
7
|
+
@project_path = @spec_dir + 'js/'
|
8
|
+
@new_project = Ninjs::Project.new 'spec/js', 'MyApplication'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have the correct app_filename' do
|
12
|
+
@new_project.config.app_filename.should === 'myapplication'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have the correct project_path' do
|
16
|
+
@new_project.project_path.should === @project_path
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have a @config property' do
|
20
|
+
@new_project.config.should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the correct @config.name' do
|
24
|
+
@new_project.config.name.should === 'MyApplication'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have the correct @config.output' do
|
28
|
+
@new_project.config.output.should === 'expanded'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have the correct @config.dependencies' do
|
32
|
+
@new_project.config.dependencies.should == ["<jquery/latest>"]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the correct @config.autoload' do
|
36
|
+
@new_project.config.autoload.should == ["<ninjs/utilities/all>"]
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have the corect @config.base_url' do
|
40
|
+
@new_project.config.base_url.should == 'http://www.example.com/'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should have the correct @config.test_path' do
|
44
|
+
@new_project.config.test_path.should == 'tests/'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should respond to create' do
|
48
|
+
@new_project.should respond_to :create
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should create the project directory' do
|
52
|
+
@new_project.create
|
53
|
+
File.exists?('/Volumes/Storage/Development/ninjs/spec/js').should be_true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have created the Ninjs::Manifest directories' do
|
57
|
+
Ninjs::Manifest.directories.each do |folder|
|
58
|
+
File.exists?("#{@project_path}#{folder}").should be_true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have created a config file' do
|
63
|
+
File.exists?("#{@project_path}ninjs.conf").should be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have created the application file' do
|
67
|
+
File.exists?("#{@project_path}application/myapplication.js").should be_true
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have created the /lib/nin.js file' do
|
71
|
+
File.exists?("#{@project_path}lib/nin.js")
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should have created the /lib/utilities.js file' do
|
75
|
+
File.exists?("#{@project_path}lib/utilities.js").should be_true
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should have created the /tests/index.html file' do
|
79
|
+
File.exists?("#{@project_path}tests/index.html").should be_true
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should have created the /tests/ninjs.test.js file' do
|
83
|
+
File.exists?("#{@project_path}tests/ninjs.test.js").should be_true
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should have created the /tests/ninjs.utilties.test.js file' do
|
87
|
+
File.exists?("#{@project_path}tests/ninjs.utilities.test.js").should be_true
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should have the correct config file content' do
|
91
|
+
expected_conf_file = File.open('/Volumes/Storage/Development/ninjs/spec/fixtures/ninjs.conf', 'r')
|
92
|
+
expected_conf_content = expected_conf_file.readlines
|
93
|
+
expected_conf_file.close
|
94
|
+
|
95
|
+
ninjs_conf_file = File.open("#{@project_path}ninjs.conf", 'r')
|
96
|
+
ninjs_conf_content = ninjs_conf_file.readlines
|
97
|
+
ninjs_conf_file.close
|
98
|
+
|
99
|
+
ninjs_conf_content.should === expected_conf_content
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should have the correct application file content' do
|
103
|
+
expected_file = File.open('/Volumes/Storage/Development/ninjs/spec/fixtures/myapplication.js', 'r')
|
104
|
+
expected_content = expected_file.readlines
|
105
|
+
|
106
|
+
# .shift is to remove the generated comment which should never match
|
107
|
+
expected_content.shift
|
108
|
+
expected_file.close
|
109
|
+
|
110
|
+
actual_file = File.open("#{@project_path}application/myapplication.js", 'r')
|
111
|
+
actual_content = actual_file.readlines
|
112
|
+
actual_content.shift
|
113
|
+
actual_file.close
|
114
|
+
|
115
|
+
actual_content.should === expected_content
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should have the correct /lib/nin.js content' do
|
119
|
+
expected_ninjs_lib_file = File.open('/Volumes/Storage/Development/ninjs/spec/fixtures/nin.js', "r")
|
120
|
+
expected_ninjs_lib_content= expected_ninjs_lib_file.readlines
|
121
|
+
expected_ninjs_lib_file.close
|
122
|
+
|
123
|
+
ninjs_lib_file = File.open("#{@project_path}lib/nin.js", "r")
|
124
|
+
ninjs_lib_content = ninjs_lib_file.readlines
|
125
|
+
ninjs_lib_file.close
|
126
|
+
|
127
|
+
ninjs_lib_content.should === expected_ninjs_lib_content
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should have the correct /lib/utilities.js' do
|
131
|
+
expected_utility_lib_file = File.open("/Volumes/Storage/Development/ninjs/spec/fixtures/utilities.js", "r")
|
132
|
+
expected_utility_lib_content = expected_utility_lib_file.readlines
|
133
|
+
expected_utility_lib_file.close
|
134
|
+
|
135
|
+
utility_lib_file = File.open("#{@project_path}lib/utilities.js", "r")
|
136
|
+
utility_lib_content = utility_lib_file.readlines
|
137
|
+
utility_lib_file.close
|
138
|
+
|
139
|
+
utility_lib_content.should === expected_utility_lib_content
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'and a project is updated' do
|
143
|
+
|
144
|
+
before :each do
|
145
|
+
@path = Dir.getwd
|
146
|
+
@project = Ninjs::Project.new 'spec/js/'
|
147
|
+
|
148
|
+
FileUtils.cp("#{@path}/spec/fixtures/global.module.js", "#{@path}/spec/js/modules") unless File.exists?("#{@path}/spec/js/modules/global.module.js")
|
149
|
+
FileUtils.cp("#{@path}/spec/fixtures/test.module.js", "#{@path}/spec/js/modules") unless File.exists?("#{@path}/spec/js/modules/test.module.js")
|
150
|
+
FileUtils.cp("#{@path}/spec/fixtures/test.elements.js", "#{@path}/spec/js/elements") unless File.exists?("#{@path}/spec/js/elements/test.elements.js")
|
151
|
+
FileUtils.cp("#{@path}/spec/fixtures/test.model.js", "#{@path}/spec/js/models") unless File.exists?("#{@path}/spec/js/models/test.model.js")
|
152
|
+
@project.update
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should have created the /application/global.js module' do
|
156
|
+
File.exists?("#{@path}/spec/js/application/global.js").should be_true
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should have created the /application/test.js module' do
|
160
|
+
File.exists?("#{@path}/spec/js/application/test.js").should be_true
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should have the correct /application/global.js content' do
|
164
|
+
expected_global_file = File.open("#{@path}/spec/fixtures/global.js", "r")
|
165
|
+
expected_global_content = expected_global_file.readlines
|
166
|
+
expected_global_file.close
|
167
|
+
|
168
|
+
actual_global_file = File.open("#{@path}/spec/js/application/global.js", "r")
|
169
|
+
actual_global_content = actual_global_file.readlines
|
170
|
+
actual_global_file.close
|
171
|
+
|
172
|
+
actual_global_content.should == expected_global_content
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should have the correct /application/test.js content' do
|
176
|
+
expected_test_file = File.open("#{@path}/spec/fixtures/test.js", "r")
|
177
|
+
expected_test_content = expected_test_file.readlines
|
178
|
+
expected_test_file.close
|
179
|
+
|
180
|
+
actual_test_file = File.open("#{@path}/spec/js/application/test.js", "r")
|
181
|
+
actual_test_content = actual_test_file.readlines
|
182
|
+
actual_test_file.close
|
183
|
+
|
184
|
+
actual_test_content.should == expected_test_content
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
end# context When instantiating a new project
|
189
|
+
|
190
|
+
context 'When instantiating a project from a config file' do
|
191
|
+
before :each do
|
192
|
+
@spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) + '/'
|
193
|
+
@project_path = @spec_dir + 'js/'
|
194
|
+
@existing_project = Ninjs::Project.new 'spec/js'
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should have the correct app_filename' do
|
198
|
+
@existing_project.config.app_filename.should === 'myapplication'
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should have the correct project_path' do
|
202
|
+
@existing_project.project_path.should === @project_path
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should have the correct @config.name' do
|
206
|
+
@existing_project.config.name.should === 'MyApplication'
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should have the correct @config.output' do
|
210
|
+
@existing_project.config.output === 'expanded'
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should have the correct @config.dependencies' do
|
214
|
+
@existing_project.config.dependencies.should == ["<jquery/latest>"]
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should have the correct @config.autoload' do
|
218
|
+
@existing_project.config.autoload.should == ["<ninjs/utilities/all>"]
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should have the corect @config.base_url' do
|
222
|
+
@existing_project.config.base_url == 'http://www.example.com/'
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should have the correct @config.test_path' do
|
226
|
+
@existing_project.config.test_path == 'tests/'
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should not need a hack to delete all the files' do
|
230
|
+
File.delete("#{@project_path}ninjs.conf") if File.exists?("#{@project_path}ninjs.conf")
|
231
|
+
File.delete("#{@project_path}application/myapplication.js") if File.exists?("#{@project_path}application/myapplication.js")
|
232
|
+
File.delete("#{@project_path}application/global.js") if File.exists?("#{@project_path}application/global.js")
|
233
|
+
File.delete("#{@project_path}application/test.js") if File.exists?("#{@project_path}application/test.js")
|
234
|
+
File.delete("#{@project_path}elements/test.elements.js") if File.exists?("#{@project_path}elements/test.elements.js")
|
235
|
+
File.delete("#{@project_path}models/test.model.js") if File.exists?("#{@project_path}models/test.model.js")
|
236
|
+
File.delete("#{@project_path}lib/nin.js") if File.exists?("#{@project_path}lib/nin.js")
|
237
|
+
File.delete("#{@project_path}lib/utilities.js") if File.exists?("#{@project_path}lib/utilities.js")
|
238
|
+
File.delete("#{@project_path}tests/index.html") if File.exists?("#{@project_path}tests/index.html")
|
239
|
+
File.delete("#{@project_path}tests/ninjs.test.js") if File.exists?("#{@project_path}tests/ninjs.test.js")
|
240
|
+
File.delete("#{@project_path}tests/ninjs.utilities.test.js") if File.exists?("#{@project_path}tests/ninjs.utilities.test.js")
|
241
|
+
File.delete("#{@project_path}tests/qunit/qunit.css") if File.exists?("#{@project_path}tests/qunit/qunit.css")
|
242
|
+
File.delete("#{@project_path}tests/qunit/qunit.js") if File.exists?("#{@project_path}tests/qunit/qunit.js")
|
243
|
+
Dir.delete("#{@project_path}tests/qunit") if File.exists?("#{@project_path}tests/qunit")
|
244
|
+
File.delete("#{@project_path}modules/global.module.js") if File.exists?("#{@project_path}modules/global.module.js")
|
245
|
+
File.delete("#{@project_path}modules/test.module.js") if File.exists?("#{@project_path}modules/test.module.js")
|
246
|
+
|
247
|
+
Ninjs::Manifest.directories.each do |folder|
|
248
|
+
Dir.delete("#{@project_path}#{folder}") if File.exists? "#{@project_path}#{folder}"
|
249
|
+
end
|
250
|
+
|
251
|
+
Dir.delete('/Volumes/Storage/Development/ninjs/spec/js') if File.exists?('/Volumes/Storage/Development/ninjs/spec/js')
|
252
|
+
true.should be_true
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|