ninjs 0.14.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -2
- data/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +13 -11
- data/README.md +108 -93
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/bin/ninjs +24 -22
- data/lib/ninjs/command.rb +32 -21
- data/lib/ninjs/configuration.rb +35 -53
- data/lib/ninjs/generator.rb +6 -6
- data/lib/ninjs/notification.rb +5 -5
- data/lib/ninjs/project.rb +31 -25
- data/ninjs.gemspec +18 -142
- data/repository/ninjs/core/application.js +13 -24
- data/repository/ninjs/core/dom.js +87 -68
- data/repository/ninjs/core/existence.js +44 -105
- data/repository/ninjs/core/extend.js +11 -32
- data/repository/ninjs/core/module.js +53 -107
- data/repository/ninjs/core/nin.js +5 -7
- data/repository/ninjs/tests/extension.test.js +0 -10
- data/repository/ninjs/tests/index.html +19 -20
- data/repository/ninjs/tests/module.test.js +52 -56
- data/repository/ninjs/utilities/array.js +8 -8
- data/repository/ninjs/utilities/cookie.js +59 -0
- data/repository/ninjs/utilities/css.js +7 -7
- data/repository/ninjs/utilities/number.js +2 -2
- data/repository/ninjs/utilities/string.js +26 -26
- data/spec/cli_spec.rb +90 -88
- data/spec/command_spec.rb +104 -137
- data/spec/configuration_spec.rb +23 -37
- data/spec/fixtures/_global.module.js +9 -0
- data/spec/fixtures/compressed.myapp.js +23 -44
- data/spec/fixtures/foo.elements.js +1 -1
- data/spec/fixtures/foo.js +5 -5
- data/spec/fixtures/foo.model.js +1 -1
- data/spec/fixtures/foo.module.js +3 -3
- data/spec/fixtures/hello.elements.js +1 -1
- data/spec/fixtures/hello.js +5 -5
- data/spec/fixtures/hello.model.js +1 -1
- data/spec/fixtures/hello.module.js +3 -3
- data/spec/fixtures/myapp.initial.js +198 -329
- data/spec/fixtures/myapp.js +285 -357
- data/spec/fixtures/mymodule.alias.module.js +2 -2
- data/spec/fixtures/mymodule.dependencies.module.js +2 -2
- data/spec/fixtures/mymodule.elements.js +1 -1
- data/spec/fixtures/mymodule.model.js +1 -1
- data/spec/fixtures/mymodule.module.js +2 -2
- data/spec/fixtures/mymodule.module_alias.module.js +10 -0
- data/spec/fixtures/new.ninjs.conf +2 -0
- data/spec/fixtures/nin.js +198 -329
- data/spec/fixtures/ninjs.conf +2 -0
- data/spec/fixtures/updated.ninjs.conf +8 -0
- data/spec/generator_spec.rb +37 -26
- data/spec/ninjs_spec.rb +6 -6
- data/spec/project_spec.rb +229 -221
- data/spec/spec_helper.rb +3 -1
- data/spec/testspec_spec.rb +7 -0
- metadata +28 -145
- data/repository/json2.js +0 -482
- data/repository/modernizr/1.5.js +0 -28
- data/repository/modernizr/latest.js +0 -1
- data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
- data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/FileInfo.nd +0 -16
- data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
- data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
- data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
- data/repository/ninjs/docs/Languages.txt +0 -113
- data/repository/ninjs/docs/Menu.txt +0 -63
- data/repository/ninjs/docs/Topics.txt +0 -81
- data/repository/ninjs/docs/files/core/application-js.html +0 -44
- data/repository/ninjs/docs/files/core/existence-js.html +0 -60
- data/repository/ninjs/docs/files/core/extend-js.html +0 -55
- data/repository/ninjs/docs/files/core/module-js.html +0 -80
- data/repository/ninjs/docs/files/core/nin-js.html +0 -38
- data/repository/ninjs/docs/index.html +0 -1
- data/repository/ninjs/docs/index/Classes.html +0 -33
- data/repository/ninjs/docs/index/Files.html +0 -45
- data/repository/ninjs/docs/index/Functions.html +0 -65
- data/repository/ninjs/docs/index/General.html +0 -85
- data/repository/ninjs/docs/index/Variables.html +0 -45
- data/repository/ninjs/docs/javascript/main.js +0 -841
- data/repository/ninjs/docs/javascript/prettify.js +0 -1526
- data/repository/ninjs/docs/javascript/searchdata.js +0 -152
- data/repository/ninjs/docs/search/ClassesN.html +0 -20
- data/repository/ninjs/docs/search/FilesA.html +0 -20
- data/repository/ninjs/docs/search/FilesE.html +0 -20
- data/repository/ninjs/docs/search/FilesM.html +0 -20
- data/repository/ninjs/docs/search/FilesN.html +0 -20
- data/repository/ninjs/docs/search/FunctionsA.html +0 -20
- data/repository/ninjs/docs/search/FunctionsC.html +0 -20
- data/repository/ninjs/docs/search/FunctionsE.html +0 -20
- data/repository/ninjs/docs/search/FunctionsI.html +0 -20
- data/repository/ninjs/docs/search/FunctionsM.html +0 -20
- data/repository/ninjs/docs/search/FunctionsR.html +0 -20
- data/repository/ninjs/docs/search/FunctionsS.html +0 -20
- data/repository/ninjs/docs/search/FunctionsSymbols.html +0 -20
- data/repository/ninjs/docs/search/FunctionsU.html +0 -20
- data/repository/ninjs/docs/search/GeneralA.html +0 -20
- data/repository/ninjs/docs/search/GeneralC.html +0 -20
- data/repository/ninjs/docs/search/GeneralD.html +0 -20
- data/repository/ninjs/docs/search/GeneralE.html +0 -20
- data/repository/ninjs/docs/search/GeneralF.html +0 -20
- data/repository/ninjs/docs/search/GeneralI.html +0 -20
- data/repository/ninjs/docs/search/GeneralM.html +0 -20
- data/repository/ninjs/docs/search/GeneralN.html +0 -20
- data/repository/ninjs/docs/search/GeneralR.html +0 -20
- data/repository/ninjs/docs/search/GeneralS.html +0 -20
- data/repository/ninjs/docs/search/GeneralSymbols.html +0 -20
- data/repository/ninjs/docs/search/GeneralT.html +0 -20
- data/repository/ninjs/docs/search/GeneralU.html +0 -20
- data/repository/ninjs/docs/search/GeneralV.html +0 -20
- data/repository/ninjs/docs/search/NoResults.html +0 -15
- data/repository/ninjs/docs/search/VariablesD.html +0 -20
- data/repository/ninjs/docs/search/VariablesN.html +0 -20
- data/repository/ninjs/docs/search/VariablesR.html +0 -20
- data/repository/ninjs/docs/search/VariablesT.html +0 -20
- data/repository/ninjs/docs/styles/main.css +0 -828
- data/repository/nullconsole.js +0 -7
- data/repository/qunit/assets/css/qunit.css +0 -196
- data/repository/qunit/qunit.js +0 -1374
- data/repository/selectivizr/1.0.js +0 -5
- data/repository/selectivizr/latest.js +0 -1
- data/repository/syntaxhighlighter/all.js +0 -11
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +0 -226
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +0 -331
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +0 -120
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +0 -113
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +0 -216
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +0 -7
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +0 -48
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +0 -120
- data/repository/syntaxhighlighter/shAutoloader.js +0 -17
- data/repository/syntaxhighlighter/shBrushAS3.js +0 -59
- data/repository/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/repository/syntaxhighlighter/shBrushBash.js +0 -59
- data/repository/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/repository/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/repository/syntaxhighlighter/shBrushCpp.js +0 -97
- data/repository/syntaxhighlighter/shBrushCss.js +0 -91
- data/repository/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/repository/syntaxhighlighter/shBrushDiff.js +0 -41
- data/repository/syntaxhighlighter/shBrushErlang.js +0 -52
- data/repository/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/repository/syntaxhighlighter/shBrushJScript.js +0 -52
- data/repository/syntaxhighlighter/shBrushJava.js +0 -57
- data/repository/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/repository/syntaxhighlighter/shBrushPerl.js +0 -72
- data/repository/syntaxhighlighter/shBrushPhp.js +0 -88
- data/repository/syntaxhighlighter/shBrushPlain.js +0 -33
- data/repository/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/repository/syntaxhighlighter/shBrushPython.js +0 -64
- data/repository/syntaxhighlighter/shBrushRuby.js +0 -55
- data/repository/syntaxhighlighter/shBrushSass.js +0 -94
- data/repository/syntaxhighlighter/shBrushScala.js +0 -51
- data/repository/syntaxhighlighter/shBrushSql.js +0 -66
- data/repository/syntaxhighlighter/shBrushVb.js +0 -56
- data/repository/syntaxhighlighter/shBrushXml.js +0 -69
- data/repository/syntaxhighlighter/shCore.js +0 -17
- data/repository/syntaxhighlighter/shLegacy.js +0 -17
data/spec/fixtures/ninjs.conf
CHANGED
data/spec/generator_spec.rb
CHANGED
@@ -3,29 +3,29 @@ require "spec_helper"
|
|
3
3
|
describe Ninjs::Generator do
|
4
4
|
before :each do
|
5
5
|
@config = {
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
6
|
+
project: Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR }),
|
7
|
+
type: 'module',
|
8
|
+
name: 'mymodule',
|
9
|
+
alias: nil,
|
10
|
+
dest: 'application',
|
11
|
+
src: 'elements',
|
12
|
+
dependencies: { elements: false, model: false }
|
13
13
|
}
|
14
14
|
|
15
15
|
@test_dirs = %w(modules elements models)
|
16
16
|
@test_dirs.each do |dir|
|
17
|
-
FileUtils.mkdir(dir)
|
17
|
+
FileUtils.mkdir("#{SPEC_DIR}/#{dir}")
|
18
18
|
end
|
19
19
|
|
20
|
-
File.open(
|
21
|
-
file << File.open(
|
20
|
+
File.open("#{SPEC_DIR}/ninjs.conf", 'w+') do |file|
|
21
|
+
file << File.open("#{SPEC_DIR}/fixtures/ninjs.conf").readlines.join('')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
after :each do
|
26
|
-
FileUtils.rm_rf
|
26
|
+
FileUtils.rm_rf "#{SPEC_DIR}/ninjs.conf"
|
27
27
|
@test_dirs.each do |dir|
|
28
|
-
FileUtils.rm_rf dir
|
28
|
+
FileUtils.rm_rf "#{SPEC_DIR}/#{dir}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,7 +33,7 @@ describe Ninjs::Generator do
|
|
33
33
|
generator = Ninjs::Generator.new(@config)
|
34
34
|
suppress_output { generator.generate }
|
35
35
|
|
36
|
-
|
36
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.module.js"
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should generate a module with an alias' do
|
@@ -43,7 +43,7 @@ describe Ninjs::Generator do
|
|
43
43
|
generator = Ninjs::Generator.new(@config)
|
44
44
|
suppress_output { generator.generate }
|
45
45
|
|
46
|
-
|
46
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.alias.module.js"
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should should generate an elements file' do
|
@@ -51,7 +51,7 @@ describe Ninjs::Generator do
|
|
51
51
|
generator = Ninjs::Generator.new(@config)
|
52
52
|
suppress_output { generator.generate }
|
53
53
|
|
54
|
-
|
54
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should should generate a model file' do
|
@@ -59,24 +59,35 @@ describe Ninjs::Generator do
|
|
59
59
|
generator = Ninjs::Generator.new(@config)
|
60
60
|
suppress_output { generator.generate }
|
61
61
|
|
62
|
-
|
62
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should generate a module file with dependencies' do
|
66
66
|
generator = Ninjs::Generator.new({
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
67
|
+
project: Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR}),
|
68
|
+
type: 'module',
|
69
|
+
name: 'mymodule',
|
70
|
+
alias: nil,
|
71
|
+
dest: 'application',
|
72
|
+
src: 'modules',
|
73
|
+
dependencies: { elements: true, model: true }
|
74
74
|
})
|
75
75
|
suppress_output { generator.generate }
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.dependencies.module.js"
|
78
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
79
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
80
80
|
end
|
81
81
|
|
82
|
+
it 'should generate a module file with a dynamic alias' do
|
83
|
+
new_conf = File.open("#{SPEC_DIR}/fixtures/updated.ninjs.conf", "r").readlines.join("")
|
84
|
+
File.open("#{SPEC_DIR}/ninjs.conf", "w+") do |file|
|
85
|
+
file << new_conf
|
86
|
+
end
|
87
|
+
@config[:project].config.read
|
88
|
+
generator = Ninjs::Generator.new(@config)
|
89
|
+
suppress_output { generator.generate }
|
90
|
+
|
91
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.module_alias.module.js"
|
92
|
+
end
|
82
93
|
end
|
data/spec/ninjs_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Ninjs do
|
4
|
-
it 'should have
|
5
|
-
Ninjs::BASE_DIR.
|
4
|
+
it 'should have a BASE_DIR constant' do
|
5
|
+
Ninjs::BASE_DIR.should_not be_nil
|
6
6
|
end
|
7
7
|
|
8
|
-
it 'should have
|
9
|
-
Ninjs::LIB_DIR.
|
8
|
+
it 'should have a LIB_DIR constant' do
|
9
|
+
Ninjs::LIB_DIR.should_not be_nil
|
10
10
|
end
|
11
11
|
|
12
|
-
it 'should have
|
13
|
-
Ninjs::ROOT_DIR.
|
12
|
+
it 'should have a ROOT_DIR' do
|
13
|
+
Ninjs::ROOT_DIR.should_not be_nil
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should have the correct VERSION' do
|
data/spec/project_spec.rb
CHANGED
@@ -1,243 +1,251 @@
|
|
1
1
|
require "spec_helper.rb"
|
2
2
|
|
3
3
|
describe Ninjs::Project do
|
4
|
+
|
4
5
|
it "should exist" do
|
5
6
|
Ninjs::Project.should_not be_nil
|
6
7
|
end
|
7
|
-
|
8
|
+
|
8
9
|
it "should have a @root setter method" do
|
9
|
-
suppress_output { @project = Ninjs::Project.new 'myapp' }
|
10
|
-
@project.root =
|
11
|
-
@project.root.should ==
|
10
|
+
suppress_output { @project = Ninjs::Project.new({ name: 'myapp' }) }
|
11
|
+
@project.root = SPEC_DIR
|
12
|
+
@project.root.should == SPEC_DIR
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
context 'Instantiation without an existing config file' do
|
15
16
|
before :each do
|
16
|
-
suppress_output
|
17
|
+
suppress_output do
|
18
|
+
@project = Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR })
|
19
|
+
end
|
17
20
|
end
|
18
|
-
|
21
|
+
|
19
22
|
after :each do
|
20
|
-
File.delete
|
23
|
+
File.delete "#{SPEC_DIR}/ninjs.conf" if File.exists? "#{SPEC_DIR}/ninjs.conf"
|
21
24
|
end
|
22
|
-
|
25
|
+
|
23
26
|
it 'should raise an error if initialized without a name' do
|
24
|
-
File.delete
|
25
|
-
lambda{ project = Ninjs::Project.new }.should raise_error(ArgumentError)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
27
|
+
File.delete "#{SPEC_DIR}/ninjs.conf" if File.exists? "#{SPEC_DIR}/ninjs.conf"
|
28
|
+
lambda{ project = Ninjs::Project.new(root: SPEC_DIR) }.should raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have a root variable' do
|
32
|
+
@project.root.should == SPEC_DIR
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have an empty modules array' do
|
36
|
+
@project.modules.should == Array.new
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a config object' do
|
40
|
+
@project.config.should_not be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should set the config.name property' do
|
44
|
+
@project.config.name.should == 'myapp'
|
45
|
+
end
|
46
|
+
end # Instantiation without an existing config file
|
47
|
+
|
45
48
|
context "Instantiation with an existing config file" do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
49
|
+
before :each do
|
50
|
+
File.open "#{SPEC_DIR}/ninjs.conf", 'w' do |file|
|
51
|
+
file << %Q{name: something\noutput: expanded\ndependencies: ["<jquery/latest>"]\nautoload: ["../lib/utilities"]\nsrc_dir: classes\ndest_dir: compiled}
|
52
|
+
end
|
53
|
+
|
54
|
+
@project = Ninjs::Project.new({ root: SPEC_DIR })
|
55
|
+
end
|
56
|
+
|
57
|
+
after :each do
|
58
|
+
File.delete "#{SPEC_DIR}/ninjs.conf"
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have a valid config object' do
|
62
|
+
@project.config.should_not be_nil
|
63
|
+
@project.config.name.should == 'something'
|
64
|
+
@project.config.output.should == 'expanded'
|
65
|
+
@project.config.dependencies.should == ["<jquery/latest>"]
|
66
|
+
@project.config.autoload.should == ["../lib/utilities"]
|
67
|
+
@project.config.src_dir.should == 'classes'
|
68
|
+
@project.config.dest_dir.should == 'compiled'
|
69
|
+
end
|
70
|
+
end # Instantiation with an existing config file
|
67
71
|
|
68
72
|
context "Project Creation" do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
end
|
73
|
+
before :each do
|
74
|
+
suppress_output do
|
75
|
+
@project = Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR })
|
76
|
+
@project.create_project_scaffold
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
after :each do
|
81
|
+
FileUtils.rm_rf "#{SPEC_DIR}/application"
|
82
|
+
FileUtils.rm_rf "#{SPEC_DIR}/elements"
|
83
|
+
FileUtils.rm_rf "#{SPEC_DIR}/lib"
|
84
|
+
FileUtils.rm_rf "#{SPEC_DIR}/models"
|
85
|
+
FileUtils.rm_rf "#{SPEC_DIR}/modules"
|
86
|
+
FileUtils.rm_rf "#{SPEC_DIR}/plugins"
|
87
|
+
FileUtils.rm_rf "#{SPEC_DIR}/tests"
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should create a project directory structure' do
|
91
|
+
File.directory?("#{SPEC_DIR}/application").should be_true
|
92
|
+
File.directory?("#{SPEC_DIR}/elements").should be_true
|
93
|
+
File.directory?("#{SPEC_DIR}/lib").should be_true
|
94
|
+
File.directory?("#{SPEC_DIR}/models").should be_true
|
95
|
+
File.directory?("#{SPEC_DIR}/modules").should be_true
|
96
|
+
File.directory?("#{SPEC_DIR}/plugins").should be_true
|
97
|
+
File.directory?("#{SPEC_DIR}/tests").should be_true
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should create a ninjs lib file' do
|
101
|
+
suppress_output { @project.create_ninjs_lib_file }
|
102
|
+
File.exists?("#{SPEC_DIR}/lib/nin.js").should be_true
|
103
|
+
"#{SPEC_DIR}/lib/nin.js".should be_same_file_as "#{SPEC_DIR}/fixtures/nin.js"
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should create a utilities file' do
|
107
|
+
suppress_output { @project.create_utility_lib_file }
|
108
|
+
File.exists?("#{SPEC_DIR}/lib/utilities.js").should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should create an application file' do
|
112
|
+
suppress_output do
|
113
|
+
@project.create_ninjs_lib_file
|
114
|
+
@project.create_ninjs_application_file
|
115
|
+
end
|
116
|
+
|
117
|
+
File.exists?("#{SPEC_DIR}/application/myapp.js").should be_true
|
118
|
+
application_file_content = File.open("#{SPEC_DIR}/application/myapp.js").readlines
|
119
|
+
application_file_content.shift
|
120
|
+
application_file_content.join('').should == File.open("#{SPEC_DIR}/fixtures/myapp.initial.js").readlines.join('')
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should import test files' do
|
124
|
+
suppress_output { @project.import_test_files }
|
125
|
+
|
126
|
+
File.exists?("#{SPEC_DIR}/tests").should be_true
|
127
|
+
File.exists?("#{SPEC_DIR}/tests/index.html").should be_true
|
128
|
+
File.exists?("#{SPEC_DIR}/tests/application.test.js").should be_true
|
129
|
+
File.exists?("#{SPEC_DIR}/tests/array.utilities.test.js").should be_true
|
130
|
+
File.exists?("#{SPEC_DIR}/tests/existence.test.js").should be_true
|
131
|
+
File.exists?("#{SPEC_DIR}/tests/extension.test.js").should be_true
|
132
|
+
File.exists?("#{SPEC_DIR}/tests/module.test.js").should be_true
|
133
|
+
File.exists?("#{SPEC_DIR}/tests/qspec.js").should be_true
|
134
|
+
File.exists?("#{SPEC_DIR}/tests/string.utilities.test.js").should be_true
|
135
|
+
end
|
136
|
+
end # Project Creation
|
133
137
|
|
134
138
|
context 'Project management' do
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
FileUtils.cp 'fixtures/hello.module.js', File.expand_path('modules')
|
142
|
-
FileUtils.cp 'fixtures/hello.elements.js', File.expand_path('elements')
|
143
|
-
FileUtils.cp 'fixtures/hello.model.js', File.expand_path('models')
|
144
|
-
FileUtils.cp 'fixtures/foo.module.js', File.expand_path('modules')
|
145
|
-
FileUtils.cp 'fixtures/foo.elements.js', File.expand_path('elements')
|
146
|
-
FileUtils.cp 'fixtures/foo.model.js', File.expand_path('models')
|
147
|
-
end
|
148
|
-
|
149
|
-
after :each do
|
150
|
-
FileUtils.rm_rf 'application'
|
151
|
-
FileUtils.rm_rf 'modules'
|
152
|
-
FileUtils.rm_rf 'elements'
|
153
|
-
FileUtils.rm_rf 'models'
|
154
|
-
FileUtils.rm_rf 'lib'
|
155
|
-
FileUtils.rm_rf 'plugins'
|
156
|
-
FileUtils.rm_rf 'tests'
|
157
|
-
FileUtils.rm_rf 'ninjs.conf'
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'should create a config file' do
|
161
|
-
'ninjs.conf'.should be_same_file_as 'fixtures/ninjs.conf'
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should get modules' do
|
165
|
-
@project.get_modules
|
166
|
-
@project.modules.should == [
|
167
|
-
"/Volumes/Storage/Development/ninjs/spec/modules/foo.module.js",
|
168
|
-
"/Volumes/Storage/Development/ninjs/spec/modules/hello.module.js"
|
169
|
-
]
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'should compile a module' do
|
173
|
-
@project.compile_module File.expand_path('modules/hello.module.js'), 'hello'
|
174
|
-
File.exists?('application/hello.js').should be_true
|
175
|
-
'application/hello.js'.should be_same_file_as 'fixtures/hello.js'
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'should add modules from a directory' do
|
179
|
-
@project.add_scripts_to_models(File.expand_path('modules'))
|
180
|
-
|
181
|
-
@project.modules.should == [
|
182
|
-
'/Volumes/Storage/Development/ninjs/spec/modules/foo.module.js',
|
183
|
-
'/Volumes/Storage/Development/ninjs/spec/modules/hello.module.js'
|
184
|
-
]
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'should compile the modules' do
|
188
|
-
@project.add_scripts_to_models(File.expand_path('modules'))
|
189
|
-
@project.compile_modules
|
139
|
+
before :each do
|
140
|
+
suppress_output do
|
141
|
+
@project = Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR })
|
142
|
+
@project.create
|
143
|
+
end
|
190
144
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
145
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.module.js", "#{SPEC_DIR}/modules"
|
146
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.elements.js", "#{SPEC_DIR}/elements"
|
147
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.model.js", "#{SPEC_DIR}/models"
|
148
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.module.js", "#{SPEC_DIR}/modules"
|
149
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.elements.js", "#{SPEC_DIR}/elements"
|
150
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.model.js", "#{SPEC_DIR}/models"
|
151
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/_global.module.js", "#{SPEC_DIR}/modules"
|
152
|
+
end
|
153
|
+
|
154
|
+
after :each do
|
155
|
+
FileUtils.rm_rf "#{SPEC_DIR}/application"
|
156
|
+
FileUtils.rm_rf "#{SPEC_DIR}/modules"
|
157
|
+
FileUtils.rm_rf "#{SPEC_DIR}/elements"
|
158
|
+
FileUtils.rm_rf "#{SPEC_DIR}/models"
|
159
|
+
FileUtils.rm_rf "#{SPEC_DIR}/lib"
|
160
|
+
FileUtils.rm_rf "#{SPEC_DIR}/plugins"
|
161
|
+
FileUtils.rm_rf "#{SPEC_DIR}/tests"
|
162
|
+
FileUtils.rm_rf "#{SPEC_DIR}/ninjs.conf"
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should create a config file' do
|
166
|
+
"#{SPEC_DIR}/ninjs.conf".should be_same_file_as "#{SPEC_DIR}/fixtures/ninjs.conf"
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should get modules' do
|
170
|
+
@project.get_modules
|
171
|
+
@project.modules.include?("#{SPEC_DIR}/modules/foo.module.js").should be_true
|
172
|
+
@project.modules.include?("#{SPEC_DIR}/modules/hello.module.js").should be_true
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should compile a module' do
|
176
|
+
@project.compile_module "#{SPEC_DIR}/modules/hello.module.js", 'hello'
|
177
|
+
File.exists?("#{SPEC_DIR}/application/hello.js").should be_true
|
178
|
+
"#{SPEC_DIR}/application/hello.js".should be_same_file_as "#{SPEC_DIR}/fixtures/hello.js"
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should add modules from a directory' do
|
182
|
+
@project.add_scripts_to_models("#{SPEC_DIR}/modules")
|
183
|
+
@project.modules.include?("#{SPEC_DIR}/modules/foo.module.js").should be_true
|
184
|
+
@project.modules.include?("#{SPEC_DIR}/modules/hello.module.js").should be_true
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should compile the modules' do
|
188
|
+
@project.add_scripts_to_models("#{SPEC_DIR}/modules")
|
189
|
+
@project.compile_modules
|
190
|
+
|
191
|
+
"#{SPEC_DIR}/application/hello.js".should be_same_file_as "#{SPEC_DIR}/fixtures/hello.js"
|
192
|
+
"#{SPEC_DIR}/application/foo.js".should be_same_file_as "#{SPEC_DIR}/fixtures/foo.js"
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should not compile prefixed modules' do
|
196
|
+
@project.add_scripts_to_models("#{SPEC_DIR}/modules")
|
197
|
+
@project.compile_modules
|
198
|
+
|
199
|
+
File.exists?("#{SPEC_DIR}/application/_global.js").should_not be_true
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should write the dependencies to a file' do
|
203
|
+
FileUtils.touch "#{SPEC_DIR}/dependencies.js"
|
204
|
+
|
205
|
+
File.open("#{SPEC_DIR}/dependencies.js", 'w') do |file|
|
206
|
+
@project.write_dependencies(file)
|
207
|
+
end
|
208
|
+
|
209
|
+
"#{SPEC_DIR}/dependencies.js".should be_same_file_as "#{SPEC_DIR}/fixtures/dependencies.js"
|
210
|
+
|
211
|
+
File.delete "#{SPEC_DIR}/dependencies.js"
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should write the core to a file' do
|
215
|
+
FileUtils.touch "#{SPEC_DIR}/core.js"
|
216
|
+
|
217
|
+
File.open("#{SPEC_DIR}/core.js", 'w') do |file|
|
218
|
+
@project.write_core(file)
|
219
|
+
end
|
220
|
+
|
221
|
+
"#{SPEC_DIR}/core.js".should be_same_file_as "#{SPEC_DIR}/fixtures/core.js"
|
222
|
+
|
223
|
+
File.delete "#{SPEC_DIR}/core.js"
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'should write the autoloaded files to a file' do
|
227
|
+
FileUtils.touch "#{SPEC_DIR}/autoload.js"
|
228
|
+
|
229
|
+
File.open("#{SPEC_DIR}/autoload.js", 'w') do |file|
|
230
|
+
@project.write_autoload(file)
|
231
|
+
end
|
232
|
+
|
233
|
+
"#{SPEC_DIR}/autoload.js".should be_same_file_as "#{SPEC_DIR}/fixtures/autoload.js"
|
234
|
+
|
235
|
+
File.delete "#{SPEC_DIR}/autoload.js"
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should update the application file' do
|
239
|
+
suppress_output { @project.update_application_file }
|
240
|
+
"#{SPEC_DIR}/application/myapp.js".should be_same_file_as "#{SPEC_DIR}/fixtures/myapp.js"
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should compress an application' do
|
244
|
+
@project.config.dest_dir = 'spec/application'
|
245
|
+
@project.compress_application
|
246
|
+
"#{SPEC_DIR}/application/myapp.js".should be_same_file_as "#{SPEC_DIR}/fixtures/compressed.myapp.js"
|
247
|
+
end
|
248
|
+
|
249
|
+
end # Project management
|
242
250
|
|
243
251
|
end
|