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/command_spec.rb
CHANGED
@@ -5,20 +5,20 @@ describe Ninjs::Command do
|
|
5
5
|
context 'API' do
|
6
6
|
before :each do
|
7
7
|
suppress_output do
|
8
|
-
@project = Ninjs::Project.new 'myapp'
|
8
|
+
@project = Ninjs::Project.new({ name: 'myapp', root: SPEC_DIR })
|
9
9
|
@project.create
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
after :each do
|
14
|
-
FileUtils.rm_rf
|
15
|
-
FileUtils.rm_rf
|
16
|
-
FileUtils.rm_rf
|
17
|
-
FileUtils.rm_rf
|
18
|
-
FileUtils.rm_rf
|
19
|
-
FileUtils.rm_rf
|
20
|
-
FileUtils.rm_rf
|
21
|
-
FileUtils.rm_rf
|
14
|
+
FileUtils.rm_rf "#{SPEC_DIR}/application"
|
15
|
+
FileUtils.rm_rf "#{SPEC_DIR}/modules"
|
16
|
+
FileUtils.rm_rf "#{SPEC_DIR}/elements"
|
17
|
+
FileUtils.rm_rf "#{SPEC_DIR}/models"
|
18
|
+
FileUtils.rm_rf "#{SPEC_DIR}/lib"
|
19
|
+
FileUtils.rm_rf "#{SPEC_DIR}/plugins"
|
20
|
+
FileUtils.rm_rf "#{SPEC_DIR}/tests"
|
21
|
+
FileUtils.rm_rf "#{SPEC_DIR}/ninjs.conf"
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should have a watch command' do
|
@@ -44,190 +44,157 @@ describe Ninjs::Command do
|
|
44
44
|
|
45
45
|
context 'Usage' do
|
46
46
|
after :each do
|
47
|
-
FileUtils.rm_rf
|
48
|
-
FileUtils.rm_rf
|
49
|
-
FileUtils.rm_rf
|
50
|
-
FileUtils.rm_rf
|
51
|
-
FileUtils.rm_rf
|
52
|
-
FileUtils.rm_rf
|
53
|
-
FileUtils.rm_rf
|
54
|
-
FileUtils.rm_rf
|
55
|
-
FileUtils.rm_rf
|
47
|
+
FileUtils.rm_rf "#{SPEC_DIR}/application"
|
48
|
+
FileUtils.rm_rf "#{SPEC_DIR}/modules"
|
49
|
+
FileUtils.rm_rf "#{SPEC_DIR}/elements"
|
50
|
+
FileUtils.rm_rf "#{SPEC_DIR}/models"
|
51
|
+
FileUtils.rm_rf "#{SPEC_DIR}/lib"
|
52
|
+
FileUtils.rm_rf "#{SPEC_DIR}/plugins"
|
53
|
+
FileUtils.rm_rf "#{SPEC_DIR}/tests"
|
54
|
+
FileUtils.rm_rf "#{SPEC_DIR}/ninjs.conf"
|
55
|
+
FileUtils.rm_rf "#{SPEC_DIR}/js" if File.exists? "#{SPEC_DIR}/js"
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should create a new application' do
|
59
|
-
suppress_output { Ninjs::Command.create({ :
|
59
|
+
suppress_output { Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR }) }
|
60
60
|
|
61
|
-
|
61
|
+
"#{SPEC_DIR}/ninjs.conf".should be_same_file_as "#{SPEC_DIR}/fixtures/ninjs.conf"
|
62
62
|
|
63
|
-
File.directory?("application").should be_true
|
64
|
-
File.directory?("elements").should be_true
|
65
|
-
File.directory?("lib").should be_true
|
66
|
-
File.directory?("models").should be_true
|
67
|
-
File.directory?("modules").should be_true
|
68
|
-
File.directory?("plugins").should be_true
|
69
|
-
File.directory?("tests").should be_true
|
63
|
+
File.directory?("#{SPEC_DIR}/application").should be_true
|
64
|
+
File.directory?("#{SPEC_DIR}/elements").should be_true
|
65
|
+
File.directory?("#{SPEC_DIR}/lib").should be_true
|
66
|
+
File.directory?("#{SPEC_DIR}/models").should be_true
|
67
|
+
File.directory?("#{SPEC_DIR}/modules").should be_true
|
68
|
+
File.directory?("#{SPEC_DIR}/plugins").should be_true
|
69
|
+
File.directory?("#{SPEC_DIR}/tests").should be_true
|
70
70
|
|
71
|
-
File.exists?(
|
72
|
-
File.exists?(
|
71
|
+
File.exists?("#{SPEC_DIR}/lib/nin.js").should be_true
|
72
|
+
File.exists?("#{SPEC_DIR}/lib/utilities.js").should be_true
|
73
73
|
|
74
|
-
File.exists?(
|
75
|
-
application_file_content = File.open("application/myapp.js").readlines
|
74
|
+
File.exists?("#{SPEC_DIR}/application/myapp.js").should be_true
|
75
|
+
application_file_content = File.open("#{SPEC_DIR}/application/myapp.js").readlines
|
76
76
|
application_file_content.shift
|
77
|
-
application_file_content.join('').should == File.open(
|
77
|
+
application_file_content.join('').should == File.open("#{SPEC_DIR}/fixtures/myapp.initial.js").readlines.join('')
|
78
78
|
|
79
|
-
File.exists?(
|
80
|
-
File.exists?(
|
81
|
-
File.exists?(
|
82
|
-
File.exists?(
|
83
|
-
File.exists?(
|
84
|
-
File.exists?(
|
85
|
-
File.exists?(
|
86
|
-
File.exists?(
|
87
|
-
File.exists?(
|
79
|
+
File.exists?("#{SPEC_DIR}/tests").should be_true
|
80
|
+
File.exists?("#{SPEC_DIR}/tests/index.html").should be_true
|
81
|
+
File.exists?("#{SPEC_DIR}/tests/application.test.js").should be_true
|
82
|
+
File.exists?("#{SPEC_DIR}/tests/array.utilities.test.js").should be_true
|
83
|
+
File.exists?("#{SPEC_DIR}/tests/existence.test.js").should be_true
|
84
|
+
File.exists?("#{SPEC_DIR}/tests/extension.test.js").should be_true
|
85
|
+
File.exists?("#{SPEC_DIR}/tests/module.test.js").should be_true
|
86
|
+
File.exists?("#{SPEC_DIR}/tests/qspec.js").should be_true
|
87
|
+
File.exists?("#{SPEC_DIR}/tests/string.utilities.test.js").should be_true
|
88
88
|
end
|
89
89
|
|
90
|
-
it 'should create a new application in a subdirectory' do
|
91
|
-
suppress_output { Ninjs::Command.create({ :name => 'myapp', :directory => 'js' }) }
|
92
|
-
|
93
|
-
'js/ninjs.conf'.should be_same_file_as 'fixtures/ninjs.conf'
|
94
|
-
|
95
|
-
File.directory?("js/application").should be_true
|
96
|
-
File.directory?("js/elements").should be_true
|
97
|
-
File.directory?("js/lib").should be_true
|
98
|
-
File.directory?("js/models").should be_true
|
99
|
-
File.directory?("js/modules").should be_true
|
100
|
-
File.directory?("js/plugins").should be_true
|
101
|
-
File.directory?("js/tests").should be_true
|
102
|
-
|
103
|
-
File.exists?(File.expand_path("js/lib/nin.js")).should be_true
|
104
|
-
File.exists?(File.expand_path("js/lib/utilities.js")).should be_true
|
105
|
-
|
106
|
-
File.exists?(File.expand_path("js/application/myapp.js")).should be_true
|
107
|
-
application_file_content = File.open("js/application/myapp.js").readlines
|
108
|
-
application_file_content.shift
|
109
|
-
application_file_content.join('').should == File.open('fixtures/myapp.initial.js').readlines.join('')
|
110
|
-
|
111
|
-
File.exists?(File.expand_path("js/tests")).should be_true
|
112
|
-
File.exists?(File.expand_path("js/tests/index.html")).should be_true
|
113
|
-
File.exists?(File.expand_path("js/tests/application.test.js")).should be_true
|
114
|
-
File.exists?(File.expand_path("js/tests/array.utilities.test.js")).should be_true
|
115
|
-
File.exists?(File.expand_path("js/tests/existence.test.js")).should be_true
|
116
|
-
File.exists?(File.expand_path("js/tests/extension.test.js")).should be_true
|
117
|
-
File.exists?(File.expand_path("js/tests/module.test.js")).should be_true
|
118
|
-
File.exists?(File.expand_path("js/tests/qspec.js")).should be_true
|
119
|
-
File.exists?(File.expand_path("js/tests/string.utilities.test.js")).should be_true
|
120
|
-
end
|
121
|
-
|
122
90
|
it 'should compile the application' do
|
123
|
-
suppress_output { Ninjs::Command.create({ :
|
124
|
-
|
125
|
-
FileUtils.cp 'fixtures/hello.module.js', File.expand_path('modules')
|
126
|
-
FileUtils.cp 'fixtures/hello.elements.js', File.expand_path('elements')
|
127
|
-
FileUtils.cp 'fixtures/hello.model.js', File.expand_path('models')
|
128
|
-
FileUtils.cp 'fixtures/foo.module.js', File.expand_path('modules')
|
129
|
-
FileUtils.cp 'fixtures/foo.elements.js', File.expand_path('elements')
|
130
|
-
FileUtils.cp 'fixtures/foo.model.js', File.expand_path('models')
|
91
|
+
suppress_output { Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR }) }
|
131
92
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
93
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.module.js", "#{SPEC_DIR}/modules"
|
94
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.elements.js", "#{SPEC_DIR}/elements"
|
95
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.model.js", "#{SPEC_DIR}/models"
|
96
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.module.js", "#{SPEC_DIR}/modules"
|
97
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.elements.js", "#{SPEC_DIR}/elements"
|
98
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.model.js", "#{SPEC_DIR}/models"
|
99
|
+
|
100
|
+
suppress_output { Ninjs::Command.compile({ path: SPEC_DIR }) }
|
101
|
+
|
102
|
+
File.exists?("#{SPEC_DIR}/application/hello.js").should be_true
|
103
|
+
File.exists?("#{SPEC_DIR}/application/foo.js").should be_true
|
136
104
|
end
|
137
|
-
|
105
|
+
|
138
106
|
it 'should update the application' do
|
139
|
-
suppress_output { Ninjs::Command.create({ :
|
140
|
-
|
141
|
-
File.open(
|
107
|
+
suppress_output { Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR }) }
|
108
|
+
|
109
|
+
File.open("#{SPEC_DIR}/lib/nin.js", 'w+') do |file|
|
142
110
|
file << 'changed'
|
143
111
|
end
|
144
|
-
|
145
|
-
suppress_output { Ninjs::Command.update }
|
146
|
-
|
147
|
-
|
112
|
+
|
113
|
+
suppress_output { Ninjs::Command.update(SPEC_DIR) }
|
114
|
+
|
115
|
+
"#{SPEC_DIR}/lib/nin.js".should be_same_file_as "#{SPEC_DIR}/fixtures/nin.js"
|
148
116
|
end
|
149
117
|
|
150
118
|
it 'should generate a module file' do
|
151
119
|
suppress_output do
|
152
|
-
Ninjs::Command.create({ :
|
120
|
+
Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR })
|
153
121
|
Ninjs::Command.generate({
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
122
|
+
project: Ninjs::Project.new({ root: SPEC_DIR }),
|
123
|
+
type: 'module',
|
124
|
+
name: 'mymodule',
|
125
|
+
alias: nil,
|
126
|
+
dest: nil,
|
127
|
+
dependencies: nil
|
160
128
|
})
|
161
129
|
end
|
162
130
|
|
163
|
-
|
131
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.module.js"
|
164
132
|
end
|
165
133
|
|
166
134
|
it 'should generate a module file with an alias' do
|
167
135
|
suppress_output do
|
168
|
-
Ninjs::Command.create({ :
|
136
|
+
Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR })
|
169
137
|
Ninjs::Command.generate({
|
170
|
-
:
|
171
|
-
:
|
172
|
-
:
|
173
|
-
:
|
174
|
-
:
|
175
|
-
:
|
138
|
+
project: Ninjs::Project.new({ root: SPEC_DIR }),
|
139
|
+
type: 'module',
|
140
|
+
name: 'mymodule',
|
141
|
+
alias: 'app',
|
142
|
+
dest: nil,
|
143
|
+
dependencies: nil
|
176
144
|
})
|
177
145
|
end
|
178
146
|
|
179
|
-
|
147
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.alias.module.js"
|
180
148
|
end
|
181
149
|
|
182
150
|
it 'should generate an elements file' do
|
183
151
|
suppress_output do
|
184
|
-
Ninjs::Command.create({ :
|
152
|
+
Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR })
|
185
153
|
Ninjs::Command.generate({
|
186
|
-
:
|
187
|
-
:
|
188
|
-
:
|
189
|
-
:
|
190
|
-
:
|
191
|
-
:
|
154
|
+
project: Ninjs::Project.new({ root: SPEC_DIR }),
|
155
|
+
type: 'elements',
|
156
|
+
name: 'mymodule',
|
157
|
+
alias: nil,
|
158
|
+
dest: nil,
|
159
|
+
dependencies: nil
|
192
160
|
})
|
193
161
|
end
|
194
162
|
|
195
|
-
|
163
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
196
164
|
end
|
197
165
|
|
198
166
|
it 'should generate a model file' do
|
199
167
|
suppress_output do
|
200
|
-
Ninjs::Command.create({ :
|
168
|
+
Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR })
|
201
169
|
Ninjs::Command.generate({
|
202
|
-
:
|
203
|
-
:
|
204
|
-
:
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
170
|
+
project: Ninjs::Project.new({ root: SPEC_DIR }),
|
171
|
+
type: 'model',
|
172
|
+
name: 'mymodule',
|
173
|
+
alias: nil,
|
174
|
+
dest: nil,
|
175
|
+
dependencies: nil
|
208
176
|
})
|
209
177
|
end
|
210
178
|
|
211
|
-
|
179
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
212
180
|
end
|
213
181
|
|
214
182
|
it 'should generate a module file with dependencies' do
|
215
183
|
suppress_output do
|
216
|
-
Ninjs::Command.create({ :
|
184
|
+
Ninjs::Command.create({ name: 'myapp', root: SPEC_DIR })
|
217
185
|
Ninjs::Command.generate({
|
218
|
-
:
|
219
|
-
:
|
220
|
-
:
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
186
|
+
project: Ninjs::Project.new({ root: SPEC_DIR }),
|
187
|
+
type: 'module',
|
188
|
+
name: 'mymodule',
|
189
|
+
alias: nil,
|
190
|
+
dest: nil,
|
191
|
+
dependencies: { elements: true, model: true }
|
224
192
|
})
|
225
193
|
end
|
226
194
|
|
227
|
-
|
228
|
-
|
229
|
-
|
195
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.dependencies.module.js"
|
196
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
197
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
230
198
|
end
|
231
|
-
end
|
232
|
-
# Usage
|
199
|
+
end # Usage
|
233
200
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Ninjs::Configuration do
|
4
4
|
context 'Instantiation' do
|
5
5
|
before :each do
|
6
|
-
suppress_output { @config = Ninjs::Configuration.new
|
6
|
+
suppress_output { @config = Ninjs::Configuration.new SPEC_DIR }
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should exist' do
|
@@ -11,60 +11,46 @@ describe Ninjs::Configuration do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should have a root variable' do
|
14
|
-
@config.root.should ==
|
14
|
+
@config.root.should == SPEC_DIR
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'should have a setting setter method' do
|
18
|
-
@config.setting(:name, 'someapp')
|
19
|
-
@config.name.should == 'someapp'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should have a settings hash' do
|
23
|
-
@config.settings.has_key?(:name).should be_true
|
24
|
-
@config.settings[:name].should == 'application'
|
25
|
-
|
26
|
-
@config.settings.has_key?(:src_dir).should be_true
|
27
|
-
@config.settings[:src_dir].should == 'modules'
|
28
|
-
|
29
|
-
@config.settings.has_key?(:dest_dir).should be_true
|
30
|
-
@config.settings[:dest_dir].should == 'application'
|
31
|
-
|
32
|
-
@config.settings.has_key?(:output).should be_true
|
33
|
-
@config.settings[:output].should == 'expanded'
|
34
|
-
|
35
|
-
@config.settings.has_key?(:dependencies).should be_true
|
36
|
-
@config.settings[:dependencies].should == ['<jquery/latest>']
|
37
|
-
|
38
|
-
@config.settings.has_key?(:autoload).should be_true
|
39
|
-
@config.settings[:autoload].should == ['../lib/utilities']
|
40
|
-
end
|
41
|
-
|
42
17
|
it 'should have the correct default instance variables' do
|
43
|
-
@config.root.should ==
|
18
|
+
@config.root.should == SPEC_DIR
|
44
19
|
@config.name.should == 'application'
|
45
20
|
@config.output.should == "expanded"
|
46
|
-
@config.asset_root.should ==
|
21
|
+
@config.asset_root.should == File.expand_path('../', SPEC_DIR)
|
47
22
|
@config.dependencies.should == ["<jquery/latest>"]
|
48
23
|
@config.autoload.should == ["../lib/utilities"]
|
49
24
|
@config.src_dir.should == "modules"
|
50
25
|
@config.dest_dir.should == "application"
|
26
|
+
@config.module_alias.should == "mod"
|
51
27
|
end
|
52
|
-
end
|
53
|
-
|
28
|
+
end # Instantiation
|
29
|
+
|
54
30
|
context "New config" do
|
55
31
|
before :each do
|
56
32
|
suppress_output do
|
57
|
-
@config = Ninjs::Configuration.new
|
33
|
+
@config = Ninjs::Configuration.new SPEC_DIR
|
58
34
|
@config.write
|
59
35
|
end
|
60
36
|
end
|
61
|
-
|
37
|
+
|
62
38
|
after :each do
|
63
|
-
File.delete
|
39
|
+
File.delete "#{SPEC_DIR}/ninjs.conf"
|
64
40
|
end
|
65
|
-
|
41
|
+
|
66
42
|
it 'should create a configuration file from defaults' do
|
67
|
-
|
43
|
+
"#{SPEC_DIR}/ninjs.conf".should be_same_file_as "#{SPEC_DIR}/fixtures/new.ninjs.conf"
|
68
44
|
end
|
69
|
-
|
45
|
+
|
46
|
+
it 'should read properties to config' do
|
47
|
+
File.open("#{SPEC_DIR}/ninjs.conf", "w+") do |file|
|
48
|
+
file << File.open("#{SPEC_DIR}/fixtures/updated.ninjs.conf").readlines.join("")
|
49
|
+
end
|
50
|
+
|
51
|
+
@config.read
|
52
|
+
@config.asset_root.should == File.expand_path(SPEC_DIR)
|
53
|
+
end
|
54
|
+
end # New config
|
55
|
+
|
70
56
|
end
|
@@ -1,59 +1,38 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
if(!is_defined(window.is_undefined)){window.is_undefined=function(suspect){return(suspect===undefined)?true:false;};}
|
4
|
-
if(is_undefined(window.is_typeof)){window.is_typeof=function(type,suspect){if(is_undefined(type)){throw new SyntaxError("is_typeof(Type, suspect): type is undefined");}
|
2
|
+
is_defined=function(suspect){return((suspect===undefined)||(suspect===null))?false:true;};is_undefined=function(suspect){return(suspect===undefined)?true:false;};is_typeof=function(type,suspect){if(is_undefined(type)){throw new SyntaxError("is_typeof(Type, suspect): type is undefined");}
|
5
3
|
if(is_undefined(suspect)){throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");}
|
6
|
-
return(suspect.constructor==type)?true:false;};}
|
7
|
-
|
8
|
-
|
9
|
-
if(
|
10
|
-
if(is_undefined(window.is_array)){window.is_array=function(suspect){return is_typeof(Array,suspect);};}
|
11
|
-
if(is_undefined(window.is_number)){window.is_number=function(suspect){return is_typeof(Number,suspect);};}
|
12
|
-
if(is_undefined(window.is_date)){window.is_date=function(suspect){return is_typeof(Date,suspect);};}
|
13
|
-
if(is_undefined(window.is_bool)){window.is_bool=function(suspect){return is_typeof(Boolean,suspect);};}
|
14
|
-
if(is_undefined(window.is_regex)){window.is_regex=function(suspect){return is_typeof(RegExp,suspect);};}
|
15
|
-
if(is_undefined(window.is_empty)){window.is_empty=function(suspect){return suspect.length===0;};}
|
16
|
-
if(is_undefined(window.is_not_empty)){window.is_not_empty=function(suspect){return suspect.length>=1;};}
|
17
|
-
if(is_undefined(Function.prototype['method'])){Function.prototype.method=function(name,func){if(is_undefined(name)){throw new SyntaxError("Object.method(name, func): name is undefined");}
|
18
|
-
if(is_undefined(func)){throw new SyntaxError("Object.method(name, func): func is undefined");}
|
19
|
-
if(is_undefined(this.prototype[name])){this.prototype[name]=func;return this;}};}
|
20
|
-
if(is_undefined(window.unless)){window.unless=function(expression,callback,fallback){if(is_undefined(expression)){throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");}
|
21
|
-
if(is_undefined(callback)){throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");}
|
22
|
-
if(!expression){callback.call(this);}
|
23
|
-
else if(is_defined(fallback)){fallback.call(this);}};}
|
24
|
-
if(is_undefined(Function.prototype['method'])){Function.prototype.method=function(name,func){if(is_undefined(name)){throw new SyntaxError("Object.method(name, func): name is undefined");}
|
25
|
-
if(is_undefined(func)){throw new SyntaxError("Object.method(name, func): func is undefined");}
|
26
|
-
if(is_undefined(this.prototype[name])){this.prototype[name]=func;return this;}};}
|
27
|
-
if(is_undefined(window.unless)){window.unless=function(expression,callback,fallback){if(is_undefined(expression)){throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");}
|
28
|
-
if(is_undefined(callback)){throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");}
|
29
|
-
if(!expression){callback.call(this);}
|
30
|
-
else if(is_defined(fallback)){fallback.call(this);}};}
|
31
|
-
var userAgent=navigator.userAgent;var browser={agent:userAgent,mozilla:(/mozilla/.test(userAgent.toLowerCase()))&&(!/(compatible|webkit)/.test(userAgent.toLowerCase())),webkit:/webkit/.test(userAgent.toLowerCase()),firefox:/firefox/.test(userAgent.toLowerCase()),chrome:/webkit/.test(userAgent.toLowerCase()),safari:/safari/.test(userAgent.toLowerCase()),opera:/opera/.test(userAgent.toLowerCase()),msie:(/msie/.test(userAgent.toLowerCase()))&&(!/opera/.test(userAgent.toLowerCase()))};var readyBound=false;var isReady=false;var readyList=[];function domReady(){if(!isReady){isReady=true;if(readyList){for(var fn=0;fn<readyList.length;fn++){readyList[fn].call(window,[]);}
|
4
|
+
return(suspect.constructor==type)?true:false;};is_numeric=function(suspect){if(is_typeof(Number,suspect)){return true;}
|
5
|
+
else{var pattern=/^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(suspect);}};is_string=function(suspect){return is_typeof(String,suspect);};is_array=function(suspect){return is_typeof(Array,suspect);};is_number=function(suspect){return is_typeof(Number,suspect);};is_date=function(suspect){return is_typeof(Date,suspect);};is_bool=function(suspect){return is_typeof(Boolean,suspect);};is_regex=function(suspect){return is_typeof(RegExp,suspect);};is_empty=function(suspect){return suspect.length===0;};is_not_empty=function(suspect){return suspect.length>=1;};unless=function(expression,callback,fallback){if(is_undefined(callback)){throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");}
|
6
|
+
if(!!!expression){callback.call(this);}
|
7
|
+
else{if(is_defined(fallback)){fallback.call(this);}}};var dom=(function(){var userAgent=navigator.userAgent;var browser={agent:userAgent,mozilla:(/mozilla/.test(userAgent.toLowerCase()))&&!(/(compatible|webkit)/.test(userAgent.toLowerCase())),webkit:/webkit/.test(userAgent.toLowerCase()),firefox:/firefox/.test(userAgent.toLowerCase()),chrome:/webkit/.test(userAgent.toLowerCase()),safari:/safari/.test(userAgent.toLowerCase()),opera:/opera/.test(userAgent.toLowerCase()),msie:(/msie/.test(userAgent.toLowerCase()))&&!(/opera/.test(userAgent.toLowerCase()))};var readyBound=false;var isReady=false;var readyList=[];function domReady(){if(!isReady){isReady=true;if(readyList){for(var fn=0;fn<readyList.length;fn++){readyList[fn].call(window,[]);}
|
32
8
|
readyList=[];}}}
|
33
|
-
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}
|
34
|
-
|
9
|
+
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}
|
10
|
+
else{window.onload=function(){if(oldonload){oldonload();}
|
11
|
+
func();};}}
|
12
|
+
function bindReady(){if(readyBound){return;}
|
35
13
|
readyBound=true;if(document.addEventListener&&!browser.opera){document.addEventListener("DOMContentLoaded",domReady,false);}
|
36
|
-
if(browser.msie&&window==top)(function(){if(isReady)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
14
|
+
if(browser.msie&&window==top){(function(){if(isReady){return;}
|
15
|
+
try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}
|
16
|
+
domReady();})();}
|
17
|
+
if(browser.opera){document.addEventListener("DOMContentLoaded",function(){if(isReady){return;}
|
18
|
+
for(var i=0;i<document.styleSheets.length;i++){if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}
|
19
|
+
domReady();}},false);}
|
20
|
+
if(browser.safari){var numStyles;(function(){if(isReady){return;}
|
21
|
+
if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}
|
41
22
|
if(numStyles===undefined){var links=document.getElementsByTagName("link");for(var i=0;i<links.length;i++){if(links[i].getAttribute('rel')=='stylesheet'){numStyles++;}}
|
42
23
|
var styles=document.getElementsByTagName("style");numStyles+=styles.length;}
|
43
24
|
if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}
|
44
25
|
domReady();})();}
|
45
|
-
addLoadEvent(domReady);}
|
46
|
-
|
47
|
-
this.actions();});NinjsModule.
|
26
|
+
addLoadEvent(domReady);}
|
27
|
+
return{bind:bindReady,is_ready:isReady,ready_list:readyList};})();NinjsDOM=function(){this.cached_selectors={};};NinjsDOM.prototype.ready=function(fn,args){dom.bind();if(dom.is_ready()){fn.call(window,args||[]);}
|
28
|
+
else{dom.ready_list.push(function(){return fn.call(window,args||[]);});}};dom.bind();NinjsModule=function(name){this.dom=new NinjsDOM(this);this.data={};this.name=name;};NinjsModule.prototype.actions=function(){};NinjsModule.prototype.run=function(){var mod=this;this.dom.ready(function(){mod.execute();});};NinjsModule.prototype.execute=function(){this.actions();};NinjsModule.prototype.elements=function(elements){if(is_undefined(elements)){if(is_typeof(Object,elements)){throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");}
|
48
29
|
else if(is_string(elements)){throw new SyntaxError("NinjsModule.elements(name): name is undefined");}}
|
49
30
|
if(is_string(elements)){var name=elements;return this.dom.cached_selectors[name];}
|
50
|
-
else{var dom=this.dom;dom.ready(function(){for(var key in elements){if(elements.hasOwnProperty(key)){dom.cached_selectors[key]=elements[key];}}});}}
|
31
|
+
else{var dom=this.dom;dom.ready(function(){for(var key in elements){if(elements.hasOwnProperty(key)){dom.cached_selectors[key]=elements[key];}}});}};NinjsModule.prototype.set_data=function(key,value){if(is_undefined(key)){throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');}
|
51
32
|
if(is_typeof(String,key)&&is_undefined(value)){throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');}
|
52
33
|
if(is_typeof(String,key)){this.data[key]=value;}
|
53
34
|
else if(is_typeof(Object,key)){var data=key;for(var property in data){this.data[property]=data[property];}}
|
54
|
-
return this;}
|
55
|
-
catch(error){alert("Test harness requires jQueryUI");}});});});window.NinjsApplication=function(base_url,tests_path){if(is_defined(tests_path)){this.tests_path=tests_path;}
|
56
|
-
if(is_defined(base_url)){this.site_url=function(path){var path=path||'';return base_url+path;};}};NinjsApplication.method('add_module',function(name){if(is_undefined(name)){throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");}
|
35
|
+
return this;};NinjsApplication=function(){};NinjsApplication.prototype.add_module=function(name){if(is_undefined(name)){throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");}
|
57
36
|
if(is_defined(this[name])){throw new SyntaxError("NinjsApplication.add_module(name): '"+name+"' already declared");}
|
58
37
|
if(this.name===name){throw new SyntaxError("NinjsApplication.add_module(name): a module cannot have the same name as the application");}
|
59
|
-
return this[name]=new NinjsModule(name);}
|
38
|
+
return this[name]=new NinjsModule(name);};var myapp=new NinjsApplication();
|