ninjs 0.13.6 → 0.13.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ninjs.gemspec +5 -290
- metadata +52 -345
- data/.bundle/config +0 -2
- data/CNAME +0 -1
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -36
- data/LICENSE +0 -29
- data/README.md +0 -348
- data/bin/ninjs +0 -218
- data/lib/ninjs.rb +0 -10
- data/lib/ninjs/command.rb +0 -91
- data/lib/ninjs/configuration.rb +0 -72
- data/lib/ninjs/dependencies.rb +0 -16
- data/lib/ninjs/generator.rb +0 -57
- data/lib/ninjs/helpers.rb +0 -17
- data/lib/ninjs/manifest.rb +0 -9
- data/lib/ninjs/notification.rb +0 -37
- data/lib/ninjs/project.rb +0 -233
- data/repository/jquery/1.1.4.js +0 -2508
- data/repository/jquery/1.2.6.js +0 -32
- data/repository/jquery/1.3.2.js +0 -19
- data/repository/jquery/1.4.2.js +0 -154
- data/repository/jquery/1.4.3.js +0 -166
- data/repository/jquery/1.4.4.js +0 -167
- data/repository/jquery/1.5.js +0 -16
- data/repository/jquery/fancybox/1.3.1.js +0 -1079
- data/repository/jquery/fancybox/assets/1.3.1/css/fancybox.css +0 -363
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/blank.gif +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_close.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_loading.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_left.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_right.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_e.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_n.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_ne.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_nw.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_s.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_se.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_sw.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_w.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_left.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_main.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_over.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_right.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-x.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png +0 -0
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js +0 -72
- data/repository/jquery/fancybox/latest.js +0 -1
- data/repository/jquery/latest.js +0 -1
- data/repository/jquery/mobile/1.0a3.js +0 -123
- data/repository/jquery/mobile/1.0a3/assets/css/jquery.mobile.css +0 -1652
- 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 +0 -1
- data/repository/jquery/mousewheel/3.0.2.js +0 -11
- data/repository/jquery/mousewheel/latest.js +0 -1
- data/repository/jquery/ui/1.8.7.js +0 -783
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.accordion.css +0 -19
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.all.css +0 -11
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.autocomplete.css +0 -53
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.base.css +0 -11
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.button.css +0 -38
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.core.css +0 -41
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.datepicker.css +0 -68
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.dialog.css +0 -21
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.progressbar.css +0 -11
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.resizable.css +0 -20
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.selectable.css +0 -10
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.slider.css +0 -24
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.tabs.css +0 -18
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.theme.css +0 -252
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_222222_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_2e83ff_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_454545_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_888888_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_cd0a0a_256x240.png +0 -0
- data/repository/jquery/ui/latest.js +0 -1
- data/repository/json2.js +0 -482
- data/repository/modernizr/1.5.js +0 -28
- data/repository/modernizr/latest.js +0 -1
- data/repository/ninjs/core/.core.pdoc.yaml +0 -0
- data/repository/ninjs/core/.existence.pdoc.yaml +0 -12
- data/repository/ninjs/core/.extend.pdoc.yaml +0 -0
- data/repository/ninjs/core/.nin.pdoc.yaml +0 -0
- data/repository/ninjs/core/application.js +0 -47
- data/repository/ninjs/core/existence.js +0 -277
- data/repository/ninjs/core/extend.js +0 -77
- data/repository/ninjs/core/module.js +0 -135
- data/repository/ninjs/core/nin.js +0 -4
- 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/ninjs/extensions/jquery.elements.js +0 -60
- data/repository/ninjs/tests/index.html +0 -21
- data/repository/ninjs/tests/ninjs.test.js +0 -188
- data/repository/ninjs/tests/ninjs.utilities.test.js +0 -137
- data/repository/ninjs/tests/qunit/qunit.css +0 -197
- data/repository/ninjs/tests/qunit/qunit.js +0 -1415
- data/repository/ninjs/utilities/all.js +0 -5
- data/repository/ninjs/utilities/array.js +0 -29
- data/repository/ninjs/utilities/cookie.js +0 -0
- data/repository/ninjs/utilities/css.js +0 -51
- data/repository/ninjs/utilities/number.js +0 -11
- data/repository/ninjs/utilities/string.js +0 -61
- 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/global.js +0 -7
- data/spec/fixtures/global.module.js +0 -7
- data/spec/fixtures/myapplication.js +0 -576
- data/spec/fixtures/nin.js +0 -573
- data/spec/fixtures/ninjs.conf +0 -6
- data/spec/fixtures/test.elements.js +0 -4
- data/spec/fixtures/test.js +0 -15
- data/spec/fixtures/test.model.js +0 -3
- data/spec/fixtures/test.module.js +0 -10
- data/spec/fixtures/updated.myapplication.js +0 -27
- data/spec/fixtures/utilities.js +0 -162
- data/spec/helpers_spec.rb +0 -11
- data/spec/integration_spec.rb +0 -257
- data/spec/manifest_spec.rb +0 -8
- data/spec/ninjs_spec.rb +0 -36
- data/spec/notification_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -5
- data/tmp/ff9e83aa019b712b90200b8d1b8fa0c7e14576af.json +0 -1
- data/tmp/metric_fu/_data/20110305.yml +0 -1548
- data/tmp/metric_fu/output/bluff-min.js +0 -1
- data/tmp/metric_fu/output/excanvas.js +0 -35
- data/tmp/metric_fu/output/js-class.js +0 -1
- data/tmp/metric_fu/output/lib_ninjs_dependencies.rb.html +0 -34
- data/tmp/metric_fu/output/lib_ninjs_helpers.rb.html +0 -34
- data/tmp/metric_fu/output/lib_ninjs_manifest.rb.html +0 -27
- data/tmp/metric_fu/output/rails_best_practices.js +0 -11
- data/tmp/metric_fu/scratch/rcov/rcov.txt +0 -1
data/.bundle/config
DELETED
data/CNAME
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ninjs.info
|
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "fssm", ">= 0"
|
6
|
-
gem "jsmin", ">= 0"
|
7
|
-
gem "sprockets", "1.0.2"
|
8
|
-
# Add dependencies to develop your gem here.
|
9
|
-
# Include everything needed to run rake, tests, features, etc.
|
10
|
-
group :development do
|
11
|
-
gem "shoulda", ">= 0"
|
12
|
-
gem "bundler", "~> 1.0.0"
|
13
|
-
gem "jeweler", "~> 1.5.2"
|
14
|
-
gem "rcov", ">= 0"
|
15
|
-
gem "rspec", ">= 0"
|
16
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.2)
|
5
|
-
fssm (0.2.2)
|
6
|
-
git (1.2.5)
|
7
|
-
jeweler (1.5.2)
|
8
|
-
bundler (~> 1.0.0)
|
9
|
-
git (>= 1.2.5)
|
10
|
-
rake
|
11
|
-
jsmin (1.0.1)
|
12
|
-
rake (0.8.7)
|
13
|
-
rcov (0.9.9)
|
14
|
-
rspec (2.4.0)
|
15
|
-
rspec-core (~> 2.4.0)
|
16
|
-
rspec-expectations (~> 2.4.0)
|
17
|
-
rspec-mocks (~> 2.4.0)
|
18
|
-
rspec-core (2.4.0)
|
19
|
-
rspec-expectations (2.4.0)
|
20
|
-
diff-lcs (~> 1.1.2)
|
21
|
-
rspec-mocks (2.4.0)
|
22
|
-
shoulda (2.11.3)
|
23
|
-
sprockets (1.0.2)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
bundler (~> 1.0.0)
|
30
|
-
fssm
|
31
|
-
jeweler (~> 1.5.2)
|
32
|
-
jsmin
|
33
|
-
rcov
|
34
|
-
rspec
|
35
|
-
shoulda
|
36
|
-
sprockets (= 1.0.2)
|
data/LICENSE
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
Copyright (c) 2010-2011 Dayton D. Nolan
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
No attribution is required by products that make use of this software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
Except as contained in this notice, the name(s) of the above copyright
|
24
|
-
holders shall not be used in advertising or otherwise to promote the sale,
|
25
|
-
use or other dealings in this Software without prior written authorization.
|
26
|
-
|
27
|
-
Contributors to this project agree to grant all rights to the copyright
|
28
|
-
holder of the primary product. Attribution is maintained in the source
|
29
|
-
control history of the product.
|
data/README.md
DELETED
@@ -1,348 +0,0 @@
|
|
1
|
-
Readme
|
2
|
-
======
|
3
|
-
|
4
|
-
About
|
5
|
-
-----
|
6
|
-
|
7
|
-
ninjs is a new way of building JavaScript applications that allows you to write modular, testable, and reusable JavaScript. ninjs is not really a framework. It provides three essential JavaScript development tools in one coherent package.
|
8
|
-
|
9
|
-
1. ninjs uses the "Sprockets" (http://getsprockets.org) JavaScript compiler to package and include scripts. This provides a way to manage all 3rd party and custom libraries and require them directly in your scripts.
|
10
|
-
2. ninjs includes a small JavaScript framework, based on the module pattern (http://javascript.crockford.com/private.html) and "JavaScript: The Good Parts" (http://www.amazon.com/gp/product/B0026OR2ZY/ref=s9_bbs_gw_d6_ir01?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0HQ3A0RDW9269GPJRGW8&pf_rd_t=101&pf_rd_p=470938631&pf_rd_i=507846), which provides a solid foundation for any JavaScript application.
|
11
|
-
3. The "ninjs" command line application eases the pain of repetitive tasks like compiling, scaffolding, and updating your application.
|
12
|
-
|
13
|
-
ninjs is written in Ruby (http://ruby-lang.org) and packaged as a Ruby gem (http://rubygems.org). However, it is not specific to Ruby or Rails development. While it certainly is usable in Rails or Ruby based projects, it is not designed for any one particular language or framework.
|
14
|
-
|
15
|
-
Installation
|
16
|
-
------------
|
17
|
-
|
18
|
-
You will need Ruby (1.8.x or 1.9.x) and RubyGems installed on your system to install ninjs using RubyGems. This is the easiest way of installing and recommended for most users.
|
19
|
-
|
20
|
-
```sh
|
21
|
-
gem install ninjs
|
22
|
-
```
|
23
|
-
|
24
|
-
For development, clone the project and add bin/ninjs to your path (or my favorite trick which is to put it in my development folder and make symbolic link in /usr/local/bin or wherever you put your scripts):
|
25
|
-
|
26
|
-
```sh
|
27
|
-
git clone git://github.com/textnotspeech/ninjs.git
|
28
|
-
ln -s ninjs/bin/ninjs /usr/local/bin/ninjs
|
29
|
-
```
|
30
|
-
|
31
|
-
Using the Command Line Application
|
32
|
-
==================================
|
33
|
-
|
34
|
-
The ninjs command line application is a simple way to quickly develop and manage your application. With it you can create an application, generate scaffolding, compile, and upgrade your application.
|
35
|
-
|
36
|
-
Create a ninjs application
|
37
|
-
==========================
|
38
|
-
|
39
|
-
The first ninjs command you'll need is the "create" command. As it's name implies, this command creates a brand new ninjs application template, creating the necessary files and directories. The create command accepts two arguments. The first argument is the name of your application object which is required. The second argument, which is optional, is a sub directory in which to install the application. For example, from the root of your project, you may wish to put your application in a "js" or "javascripts" directory (creating the directory if it does not exist). Omitting the directory option will create the application in your current working directory. Here is an example of creating a ninjs application in a sub directory named "js" in the current working directory:
|
40
|
-
|
41
|
-
```sh
|
42
|
-
ninjs create myapplication js
|
43
|
-
```
|
44
|
-
|
45
|
-
This will create a ninjs application in a directory named "js" in the current working directory. Now we can begin developing our application.
|
46
|
-
|
47
|
-
Create a ninjs module
|
48
|
-
=====================
|
49
|
-
|
50
|
-
Using the generate command we can create a module scafoold. The generate command takes two arguments, the first is the type of file you'd like to generate (module, elements, or model) and the second is the name of the file/module the scaffold is for. Here's some examples of using the generate command with a module named hello:
|
51
|
-
|
52
|
-
```sh
|
53
|
-
ninjs generate module hello
|
54
|
-
ninjs generate elements hello
|
55
|
-
ninjs generate model hello
|
56
|
-
```
|
57
|
-
|
58
|
-
If you'd like to generate a module with elements and a model all in one go you can pass the -e and -m flags respectively:
|
59
|
-
|
60
|
-
```sh
|
61
|
-
ninjs generate module hello -em
|
62
|
-
````
|
63
|
-
|
64
|
-
Although the generate method is very convenient, you may choose to create a module file manually in the /modules directory. By convention the file name ends with a suffix of .module. An example of a module named hello would look like this:
|
65
|
-
|
66
|
-
```sh
|
67
|
-
/modules/hello.module.js
|
68
|
-
```
|
69
|
-
|
70
|
-
The basic functionality of a module is to encapsulate specific pieces of logic into a namespace. You may think of a module as a class in the sense that it allows you to namespace properties and behavior within your application. Typically, a module encapsulates the behavior on a specific page. A ninjs module is an extremely lightweight object with a simple API which helps you write clear, concise code. Here's what an empty module scaffold looks like (generated with ninjs generate model hello -em):
|
71
|
-
|
72
|
-
```js
|
73
|
-
(function() {
|
74
|
-
var self = myapplication.add_module('hello');
|
75
|
-
|
76
|
-
//= require "../models/hello.model"
|
77
|
-
//= require "../elements/hello.elements"
|
78
|
-
|
79
|
-
myapplication.hello.actions = function() {
|
80
|
-
|
81
|
-
};
|
82
|
-
|
83
|
-
myapplication.hello.run();
|
84
|
-
})();
|
85
|
-
```
|
86
|
-
|
87
|
-
Notice the module is wrapped in a closure. This allows us to make a private reference to the current module named "self" due to the fact that the add_module method returns the module it creates. This gives us a consistent way to reference the module without having to use the entire namespace. We may also decide to put private variables and functions available to the module but not exposed to the rest of the application.
|
88
|
-
|
89
|
-
The actions method is the main method of your module. Also known as the composed method pattern, the actions method should simply be a list of other module methods. This makes it easy to scan the actions method to get a sense of what a given module does. It also encourages the "single responsibility principle" (http://en.wikipedia.org/wiki/Single_responsibility_principle).
|
90
|
-
|
91
|
-
The run method will execute the actions method when the DOM is ready to be manipulated. This is similar to jQuery's $(document).ready() method. If you wish to execute your modules actions as soon as the script is parsed you may call the execute method instead of run:
|
92
|
-
|
93
|
-
```js
|
94
|
-
myapplication.hello.execute();
|
95
|
-
```
|
96
|
-
|
97
|
-
This pattern allows you to write in a literate style, making your intentions clear and methods succinct. It's idiomatic to use the module namespace (instead of using self) when defining your module methods to enhance clarity. Another advantage of wrapping your modules in a closure is that you may choose to define an alias for your application object which makes it easier to type while avoiding creation of another global variable. To do this, simply pass in the application object as an argument to the outer function and then name the alias in the argument to the closure like so:
|
98
|
-
|
99
|
-
```js
|
100
|
-
(function(app) {
|
101
|
-
|
102
|
-
var self = app.add_module('hello');
|
103
|
-
|
104
|
-
app.hello.actions = function() {
|
105
|
-
|
106
|
-
};
|
107
|
-
|
108
|
-
app.hello.run();
|
109
|
-
|
110
|
-
})(myapplication);
|
111
|
-
```
|
112
|
-
|
113
|
-
You can also generate a scaffold with an alias using the -a option of the generate command. The previous example can be generated like so:
|
114
|
-
|
115
|
-
```sh
|
116
|
-
ninjs generate module hello -a
|
117
|
-
```
|
118
|
-
|
119
|
-
By default, the alias option will use "app" as the alias. To create a custom alias simply pass the name after the -a option like so:
|
120
|
-
|
121
|
-
```sh
|
122
|
-
ninjs generate module hello -a myalias
|
123
|
-
```
|
124
|
-
|
125
|
-
This will generate a file using an alias defined as "myalias". This is simply a convenience and a bit of syntactic sugar, although there are practical benefits to this as well. For example using this pattern, any module can be ported to another application simply by swapping out the application object passed to the closure.
|
126
|
-
|
127
|
-
Let's take a closer look at the "actions" composed method pattern. Let's define a simple module which demonstrates this:
|
128
|
-
|
129
|
-
```js
|
130
|
-
(function() {
|
131
|
-
var self = myapplication.add_module('hello');
|
132
|
-
|
133
|
-
myapplication.hello.actions = function() {
|
134
|
-
self.set_defaults();
|
135
|
-
self.say_hello();
|
136
|
-
};
|
137
|
-
|
138
|
-
myapplication.hello.set_defaults = function() {
|
139
|
-
self.greeting = 'Hello';
|
140
|
-
self.guest = 'World';
|
141
|
-
};
|
142
|
-
|
143
|
-
myapplication.hello.say_hello = function() {
|
144
|
-
alert(self.get_greeting());
|
145
|
-
};
|
146
|
-
|
147
|
-
myapplication.get_greeting = function() {
|
148
|
-
return self.greeting + ' ' + self.guest + '!';
|
149
|
-
};
|
150
|
-
|
151
|
-
myapplication.hello.run();
|
152
|
-
})();
|
153
|
-
```
|
154
|
-
|
155
|
-
Although the complexity of this module is contrived, we can easily see what this module does simply by glancing at the actions method. This will make your application logic easier to write, understand, modify, and test
|
156
|
-
|
157
|
-
Create module elements
|
158
|
-
======================
|
159
|
-
|
160
|
-
Another common best practice that ninjs encourages is cacheing your element selectors. For example, when using jQuery to select a DOM element, it's typical to assign the result of the selection to a variable in case you need it again. Here's what this looks like in practice:
|
161
|
-
|
162
|
-
```js
|
163
|
-
// Bad no-caching
|
164
|
-
$('#some-element').css({ 'background-color': '#FF0000' });
|
165
|
-
$('#some-element').html("I turned red");
|
166
|
-
|
167
|
-
// Good caching
|
168
|
-
var some_element = $('#some-element');
|
169
|
-
|
170
|
-
some_element.css({ 'background-color': '#FF0000' });
|
171
|
-
some_element.html("I turned red");
|
172
|
-
```
|
173
|
-
|
174
|
-
When we cache our selections, we only have to search the DOM once, improving performance.
|
175
|
-
|
176
|
-
The only problem with this is that we tend to manipulate a lot of elements and our code can become littered with them. At worst, they're strewn about the file wherever they are used, making it easy to accidentally re-assign them. At best, all selections are cached in one place and easy to see, which prevents us from accidentally caching them twice but it becomes a fair amount of boilerplate that crufts up the file. ninjs goes a step further by putting these cached selectors in their own file in the elements folder. This gives us one place to manage all the cached selectors available to our module.
|
177
|
-
|
178
|
-
Elements belong to a module and can be added using the elements method. To add elements to the hello module, let's add a hello.elements.js with the generate command:
|
179
|
-
|
180
|
-
```sh
|
181
|
-
ninjs generate elements hello
|
182
|
-
```
|
183
|
-
|
184
|
-
This will create a hello.elements.js file inside the elements directory. The elements scaffold looks like this:
|
185
|
-
|
186
|
-
```js
|
187
|
-
myapplication.hello.elements({
|
188
|
-
|
189
|
-
});
|
190
|
-
```
|
191
|
-
|
192
|
-
The elements method facilitates both setting and getting cached elements (violating the single responsibility principle for convenience). When passed an object, the elements method maps the key/value pairs of name/selector to the modules dom object. When passed a string, the elements method pulls the selector via it's name. To set a module's elements, pass an object of key value pairs like so:
|
193
|
-
|
194
|
-
```js
|
195
|
-
myapplication.hello.elements({
|
196
|
-
message_box: $('#message-box')
|
197
|
-
});
|
198
|
-
```
|
199
|
-
|
200
|
-
Now these cached jQuery selectors will be available via the elements command by passing it's name into the method like so:
|
201
|
-
|
202
|
-
```js
|
203
|
-
myapplication.hello.some_method = function() {
|
204
|
-
self.elements('message_box');
|
205
|
-
};
|
206
|
-
```
|
207
|
-
|
208
|
-
This pattern provides a consistent way to access and create elements and also creates an opportunity to add logic to the process (as in the ninjs.jquery.elements.js plugin). That's all there is to creating module elements. Now we require the file in the module using the "Sprockets require directive" (http://getsprockets.org/installation_and_usage#specifying_dependencies_with_the_require_directive) in hello.module.js.
|
209
|
-
|
210
|
-
```js
|
211
|
-
(function() {
|
212
|
-
var self = myapplication.add_module('hello');
|
213
|
-
|
214
|
-
//= require "../elements/hello.elements"
|
215
|
-
|
216
|
-
...
|
217
|
-
})();
|
218
|
-
```
|
219
|
-
|
220
|
-
Be sure to require the elements file after the "add_module" method is called. Now all elements defined in the elements method will be available to the module. Let's take our hello example and instead of alerting the greeting, let's put it in the message_box element (assuming an html page containing this element):
|
221
|
-
|
222
|
-
```js
|
223
|
-
...
|
224
|
-
|
225
|
-
myapplication.hello.say_hello = function() {
|
226
|
-
self.elements('message_box').html(self.get_greeting());
|
227
|
-
};
|
228
|
-
|
229
|
-
...
|
230
|
-
```
|
231
|
-
|
232
|
-
Again, this pattern keeps the logic very clear and our code very concise. It's easy to read, test, and refactor. With time, you'll develop your own naming conventions and standards. The important thing is to focus on good semantic names that accurately describe the properties and behavior of your application.
|
233
|
-
|
234
|
-
Most modules will be exactly like the one we just created, only with more methods. However, there is one more piece that helps you achieve greater modularity, which is ninjs models.
|
235
|
-
|
236
|
-
Create a ninjs model
|
237
|
-
====================
|
238
|
-
|
239
|
-
ninjs models are simply files in the /models directory that define a data structure for the module. Every module has a data object that stores properties for reuse or configuration.
|
240
|
-
|
241
|
-
Let's suppose I have a plugin that I want to use in my module. The plugin takes a configuration object, but I want to be able to set a default configuration for my module. I'll use the generate command to create a model:
|
242
|
-
|
243
|
-
```sh
|
244
|
-
ninjs generate model hello
|
245
|
-
```
|
246
|
-
|
247
|
-
This will create an empty model scaffold that looks like this:
|
248
|
-
|
249
|
-
```js
|
250
|
-
myapplication.hello.set_data({
|
251
|
-
|
252
|
-
});
|
253
|
-
```
|
254
|
-
|
255
|
-
The set_data method takes either an object or a string as the first argument. When an object is used as the first argument, the key value pairs contained in the object will be copied to the module's "data" object. When a string is used, the first argument is a string representing the name of the property to assign and the second is the value to assign to that property. Using the string method, we could define a configuration object for the plugin like so:
|
256
|
-
|
257
|
-
```js
|
258
|
-
myapplication.hello.set_data('plugin_config', {
|
259
|
-
width: 300,
|
260
|
-
height: 250
|
261
|
-
});
|
262
|
-
```
|
263
|
-
|
264
|
-
If we wish to set several properties at once we can use just an object as the first argument:
|
265
|
-
|
266
|
-
```js
|
267
|
-
myapplication.hello.set_data({
|
268
|
-
plugin_config: {
|
269
|
-
width: 300,
|
270
|
-
height: 250
|
271
|
-
},
|
272
|
-
another_property: 'some value'
|
273
|
-
});
|
274
|
-
```
|
275
|
-
|
276
|
-
Next we include the model in the module file:
|
277
|
-
|
278
|
-
```js
|
279
|
-
(function() {
|
280
|
-
var self = myapplication.add_module('hello');
|
281
|
-
|
282
|
-
//= require "../elements/hello.model.js"
|
283
|
-
//= require "../elements/hello.elements"
|
284
|
-
|
285
|
-
...
|
286
|
-
})();
|
287
|
-
```
|
288
|
-
|
289
|
-
Now whenever I use the plugin in my module, I can mix in the config object like so:
|
290
|
-
|
291
|
-
```js
|
292
|
-
...
|
293
|
-
|
294
|
-
myapplication.hello.setup_plugin = function() {
|
295
|
-
self.some_element.some_plugin(self.data.plugin_config);
|
296
|
-
self.another_element.some_plugin(self.data.plugin_config);
|
297
|
-
};
|
298
|
-
|
299
|
-
...
|
300
|
-
```
|
301
|
-
|
302
|
-
This way, we don't have to keep redefining the same properties each time we use this plugin. If we want to extend the defaults, we can use something like jQuery's extend method:
|
303
|
-
|
304
|
-
```js
|
305
|
-
...
|
306
|
-
|
307
|
-
myapplication.hello.setup_plugin = function() {
|
308
|
-
self.some_element.some_plugin(self.data.plugin_config);
|
309
|
-
self.another_element.some_plugin($.extend(self.data.plugin_config, {
|
310
|
-
height: 300,
|
311
|
-
color: #FF0000
|
312
|
-
}));
|
313
|
-
};
|
314
|
-
|
315
|
-
...
|
316
|
-
```
|
317
|
-
|
318
|
-
The model provides a foundation we can build from, helping use to keep our code DRY.
|
319
|
-
|
320
|
-
Compiling the application
|
321
|
-
=========================
|
322
|
-
|
323
|
-
Now that we have a complete module including elements and a model, we need to compile these into one coherent file to use in our html. To do so, we have 2 options. Open up a terminal and navigate to the root of your ninjs application. We can compile our application with one of 2 commands. The first choice is the compile command. From the root of your ninjs application type:
|
324
|
-
|
325
|
-
```sh
|
326
|
-
ninjs compile
|
327
|
-
```
|
328
|
-
|
329
|
-
This will compile all the files in the modules folder, resolving all dependencies using the Sprockets engine, and finally outputting them into the /application directory with the .module suffix removed. Our hello example module would compile into the application folder as hello.js. Now we can include the hello.js file (along with the myapplication.js) in our html document. Since running compile every time we make a change to any one of our module source files would quickly become a tedious chore, ninjs also has a watch command which will watch your project directory for changes and automatically compile when a file is changed. This speeds up development considerably and frankly makes ninjs usable in a daily development context. To watch a ninjs project simply navigate to the project root and issue the watch command:
|
330
|
-
|
331
|
-
```sh
|
332
|
-
ninjs watch
|
333
|
-
```
|
334
|
-
|
335
|
-
That's it! you've created a basic ninjs application! The only step left is to include the compiled script files in our markup:
|
336
|
-
|
337
|
-
```html
|
338
|
-
<!DOCTYPE html>
|
339
|
-
<head>
|
340
|
-
<title>ninjs Demo</title>
|
341
|
-
</head>
|
342
|
-
<body>
|
343
|
-
<script src="js/application/myapplication.js"></script>
|
344
|
-
<script src="js/application/hello.js"></script>
|
345
|
-
</body>
|
346
|
-
</html>
|
347
|
-
...
|
348
|
-
```
|
data/bin/ninjs
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'ninjs'
|
7
|
-
require 'optparse'
|
8
|
-
rescue LoadError
|
9
|
-
require 'rubygems'
|
10
|
-
require 'ninjs'
|
11
|
-
require 'optparse'
|
12
|
-
end
|
13
|
-
|
14
|
-
header = <<-HEADER
|
15
|
-
|
16
|
-
HEADER
|
17
|
-
|
18
|
-
create = <<-CREATE
|
19
|
-
create Creates a new ninjs application in the current working
|
20
|
-
directory or sub directory within.
|
21
|
-
|
22
|
-
Arguments:
|
23
|
-
application name - Name of the ninjs application
|
24
|
-
subdirectory* - Directory where the application will be
|
25
|
-
installed (created if non existent)
|
26
|
-
|
27
|
-
examples:
|
28
|
-
ninjs create myapp
|
29
|
-
ninjs create myapp subdirectory
|
30
|
-
CREATE
|
31
|
-
|
32
|
-
generate = <<-GEN
|
33
|
-
generate Generates scoffolding for the given component file type.
|
34
|
-
|
35
|
-
Arguments:
|
36
|
-
type - Type of application scaffold to create (module, elements, model).
|
37
|
-
name* - Name of the module to generate the scaffold for
|
38
|
-
|
39
|
-
Options:
|
40
|
-
-a, --alias name* - Create an alias of the application object
|
41
|
-
(defaults to "app"), passing a name is optional
|
42
|
-
-e, --elements - Generate an elements file
|
43
|
-
-m, --model - Generate a model file
|
44
|
-
|
45
|
-
examples:
|
46
|
-
ninjs generate module mymodule -em (generates module, elements and model)
|
47
|
-
ninjs generate module mymodule -a (generates an application alias)
|
48
|
-
ninjs generate elements mymodule -m (generates an elements and a model file)
|
49
|
-
ninjs generate model mymodule (generates an model file)
|
50
|
-
GEN
|
51
|
-
|
52
|
-
compile = <<-COMP
|
53
|
-
compile Compiles the ninjs project in the current working directory.
|
54
|
-
|
55
|
-
Options:
|
56
|
-
-c, --compress - Compress output with JsMin
|
57
|
-
|
58
|
-
example:
|
59
|
-
ninjs compile
|
60
|
-
COMP
|
61
|
-
|
62
|
-
watch = <<-WATCH
|
63
|
-
watch Watches the current working directory for file changes and
|
64
|
-
compiles when changes are detected.
|
65
|
-
|
66
|
-
example:
|
67
|
-
ninjs watch
|
68
|
-
WATCH
|
69
|
-
|
70
|
-
upd = <<-UPDATE
|
71
|
-
update Updates your application's core files to the latest version.
|
72
|
-
UPDATE
|
73
|
-
|
74
|
-
footer = <<-FOOTER
|
75
|
-
* optional argument
|
76
|
-
FOOTER
|
77
|
-
|
78
|
-
help = {
|
79
|
-
:header => header,
|
80
|
-
:create => create,
|
81
|
-
:generate => generate,
|
82
|
-
:compile => compile,
|
83
|
-
:watch => watch,
|
84
|
-
:update => upd,
|
85
|
-
:footer => footer
|
86
|
-
}
|
87
|
-
|
88
|
-
command = ARGV[0]
|
89
|
-
|
90
|
-
options = {
|
91
|
-
:alias => false,
|
92
|
-
:elements => false,
|
93
|
-
:model => false,
|
94
|
-
:help => false,
|
95
|
-
:compress => nil
|
96
|
-
}
|
97
|
-
|
98
|
-
optparse = OptionParser.new do|opts|
|
99
|
-
opts.on( '-h', '--help', 'Display this screen' ) do
|
100
|
-
options[:help] = true
|
101
|
-
end
|
102
|
-
|
103
|
-
opts.on( '-v', '--version', 'Display the version') do
|
104
|
-
time = Time.now
|
105
|
-
puts Ninjs::Notification.notice 'ninjs ' + Ninjs::VERSION
|
106
|
-
puts Ninjs::Notification.notice "Copyright (c) #{time.year} Dayton Nolan"
|
107
|
-
puts Ninjs::Notification.notice "Released under the MIT License"
|
108
|
-
exit
|
109
|
-
end
|
110
|
-
|
111
|
-
opts.on( '-a', '--alias [alias]', 'Generate application alias') do |als|
|
112
|
-
options[:alias] = als || "app"
|
113
|
-
end
|
114
|
-
|
115
|
-
opts.on( '-d', '--dest [dest]', 'Module destination directory') do |dest|
|
116
|
-
options[:dest] = dest
|
117
|
-
end
|
118
|
-
|
119
|
-
opts.on('-e', '--elements', 'Generate elements file') do
|
120
|
-
options[:elements] = true
|
121
|
-
end
|
122
|
-
|
123
|
-
opts.on('-m', '--model', 'Generate model file') do
|
124
|
-
options[:model] = true
|
125
|
-
end
|
126
|
-
|
127
|
-
opts.on('-c', '--compress', 'Compress with JsMin') do
|
128
|
-
options[:compress] = true
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
optparse.parse!
|
133
|
-
|
134
|
-
case command
|
135
|
-
# create
|
136
|
-
when "create"
|
137
|
-
if options[:help]
|
138
|
-
puts help[:create]
|
139
|
-
exit
|
140
|
-
end
|
141
|
-
app_name = ARGV[1]
|
142
|
-
sub_dir = ARGV[2] || nil
|
143
|
-
|
144
|
-
if app_name.nil?
|
145
|
-
puts "Error! Application name is required (ninjs create app_name)"
|
146
|
-
exit
|
147
|
-
end
|
148
|
-
|
149
|
-
sub_dir.nil? ? Ninjs::Command.create(app_name) : Ninjs::Command.create(app_name, sub_dir)
|
150
|
-
# generate
|
151
|
-
when "generate"
|
152
|
-
if options[:help]
|
153
|
-
puts help[:generate]
|
154
|
-
exit
|
155
|
-
end
|
156
|
-
|
157
|
-
errors = Hash.new
|
158
|
-
type = ARGV[1]
|
159
|
-
name = ARGV[2]
|
160
|
-
als = options[:alias] || nil
|
161
|
-
dest = options[:dest] || nil
|
162
|
-
|
163
|
-
errors[:type] = "Error! Scaffold type is required (ninjs generate module mymodule)" if type.nil?
|
164
|
-
errors[:name] = "Error! Module name is required (ninjs generate module mymodule)" if name.nil?
|
165
|
-
|
166
|
-
unless errors.empty?
|
167
|
-
errors.each do |error|
|
168
|
-
puts error
|
169
|
-
end
|
170
|
-
exit
|
171
|
-
end
|
172
|
-
|
173
|
-
dependencies = {
|
174
|
-
:model => options[:model],
|
175
|
-
:elements => options[:elements]
|
176
|
-
}
|
177
|
-
|
178
|
-
config = {
|
179
|
-
:type => type,
|
180
|
-
:name => name,
|
181
|
-
:alias => als,
|
182
|
-
:dest => dest,
|
183
|
-
:dependencies => dependencies
|
184
|
-
}
|
185
|
-
|
186
|
-
Ninjs::Command.generate(config)
|
187
|
-
# compile
|
188
|
-
when "compile"
|
189
|
-
if options[:help]
|
190
|
-
puts help[:compile]
|
191
|
-
exit
|
192
|
-
end
|
193
|
-
|
194
|
-
unless options[:compress].nil?
|
195
|
-
Ninjs::Command.compile(options[:compress])
|
196
|
-
else
|
197
|
-
Ninjs::Command.compile()
|
198
|
-
end
|
199
|
-
# watch
|
200
|
-
when "watch"
|
201
|
-
if options[:help]
|
202
|
-
puts help[:watch]
|
203
|
-
exit
|
204
|
-
end
|
205
|
-
Ninjs::Command.watch
|
206
|
-
# update
|
207
|
-
when "update"
|
208
|
-
if options[:help]
|
209
|
-
puts help[:update]
|
210
|
-
exit
|
211
|
-
end
|
212
|
-
Ninjs::Command.update
|
213
|
-
else
|
214
|
-
help.each do |section|
|
215
|
-
puts section.last + "\n"
|
216
|
-
end
|
217
|
-
exit
|
218
|
-
end
|