xmvc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +63 -0
  6. data/VERSION +1 -0
  7. data/bin/xmvc +13 -0
  8. data/lib/xmvc/README +20 -0
  9. data/lib/xmvc/builder.rb +72 -0
  10. data/lib/xmvc/builders/all_builder.rb +13 -0
  11. data/lib/xmvc/builders/app_builder.rb +36 -0
  12. data/lib/xmvc/builders/base.rb +138 -0
  13. data/lib/xmvc/builders/css_builder.rb +34 -0
  14. data/lib/xmvc/builders/docs_builder.rb +20 -0
  15. data/lib/xmvc/builders/mvc_builder.rb +33 -0
  16. data/lib/xmvc/builders/plugin_builder.rb +53 -0
  17. data/lib/xmvc/cli.rb +58 -0
  18. data/lib/xmvc/environment.rb +9 -0
  19. data/lib/xmvc/generator.rb +79 -0
  20. data/lib/xmvc/generators/app.rb +94 -0
  21. data/lib/xmvc/generators/base.rb +90 -0
  22. data/lib/xmvc/generators/controller.rb +41 -0
  23. data/lib/xmvc/generators/model.rb +40 -0
  24. data/lib/xmvc/generators/scaffold.rb +15 -0
  25. data/lib/xmvc/generators/templates/Controller.js +10 -0
  26. data/lib/xmvc/generators/templates/Model.js +9 -0
  27. data/lib/xmvc/generators/templates/ModelSpec.js +12 -0
  28. data/lib/xmvc/generators/templates/View.js +17 -0
  29. data/lib/xmvc/generators/templates/_Action.js +7 -0
  30. data/lib/xmvc/generators/templates/app/README.rdoc +152 -0
  31. data/lib/xmvc/generators/templates/app/app/App.js +64 -0
  32. data/lib/xmvc/generators/templates/app/app/controllers/application_controller.js +10 -0
  33. data/lib/xmvc/generators/templates/app/app/controllers/home_controller.js +10 -0
  34. data/lib/xmvc/generators/templates/app/app/views/home/index.js +17 -0
  35. data/lib/xmvc/generators/templates/app/app/views/layout/menu.js +23 -0
  36. data/lib/xmvc/generators/templates/app/config/application.js +1 -0
  37. data/lib/xmvc/generators/templates/app/config/boot.js +66 -0
  38. data/lib/xmvc/generators/templates/app/config/database.js +4 -0
  39. data/lib/xmvc/generators/templates/app/config/environment.json +62 -0
  40. data/lib/xmvc/generators/templates/app/config/environments/development.json +1 -0
  41. data/lib/xmvc/generators/templates/app/config/environments/production.json +4 -0
  42. data/lib/xmvc/generators/templates/app/config/routes.js +27 -0
  43. data/lib/xmvc/generators/templates/app/config/settings.yml +3 -0
  44. data/lib/xmvc/generators/templates/app/public/index.html +19 -0
  45. data/lib/xmvc/generators/templates/app/public/stylesheets/extjs-mvc-all.css +49 -0
  46. data/lib/xmvc/generators/templates/app/spec/SpecHelper.js +0 -0
  47. data/lib/xmvc/generators/templates/app/spec/index.html +66 -0
  48. data/lib/xmvc/generators/templates/app/vendor/screw-unit/EXAMPLE.html +68 -0
  49. data/lib/xmvc/generators/templates/app/vendor/screw-unit/LICENSE +22 -0
  50. data/lib/xmvc/generators/templates/app/vendor/screw-unit/README.markdown +307 -0
  51. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery-1.2.3.js +3408 -0
  52. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.fn.js +29 -0
  53. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.print.js +108 -0
  54. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.assets.js +36 -0
  55. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.behaviors.js +91 -0
  56. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.builder.js +80 -0
  57. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.css +90 -0
  58. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.events.js +42 -0
  59. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.matchers.js +145 -0
  60. data/lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.server.js +21 -0
  61. data/lib/xmvc/generators/templates/app/vendor/screw-unit/spec/behaviors_spec.js +178 -0
  62. data/lib/xmvc/generators/templates/app/vendor/screw-unit/spec/matchers_spec.js +237 -0
  63. data/lib/xmvc/generators/templates/app/vendor/screw-unit/spec/print_spec.js +119 -0
  64. data/lib/xmvc/generators/templates/app/vendor/screw-unit/spec/spec_helper.js +0 -0
  65. data/lib/xmvc/generators/templates/app/vendor/screw-unit/spec/suite.html +18 -0
  66. data/lib/xmvc/generators/templates/scaffold/ScaffoldController.js +18 -0
  67. data/lib/xmvc/generators/view.rb +33 -0
  68. data/lib/xmvc/plugin.rb +102 -0
  69. data/lib/xmvc/settings.rb +75 -0
  70. data/lib/xmvc/stats.rb +259 -0
  71. data/lib/xmvc/test.rb +9 -0
  72. data/lib/xmvc/testserver.ru +95 -0
  73. data/lib/xmvc/ui.rb +55 -0
  74. data/lib/xmvc/update.rb +71 -0
  75. data/lib/xmvc.rb +79 -0
  76. data/test/helper.rb +10 -0
  77. data/test/test_extjs-core.rb +7 -0
  78. data/xmvc.gemspec +142 -0
  79. metadata +237 -0
@@ -0,0 +1,23 @@
1
+ ExtMVC.registerView('layout', 'menu', {
2
+ xtype : 'treepanel',
3
+ title : 'Menu',
4
+ collapsible: true,
5
+
6
+ constructor: function(config) {
7
+ config = config || {};
8
+
9
+ Ext.applyIf(config, {
10
+ root: {
11
+ text : 'Menu',
12
+ id : 'menu',
13
+ nodeType: 'async',
14
+ expanded: true,
15
+ children: [
16
+
17
+ ]
18
+ }
19
+ });
20
+
21
+ Ext.tree.TreePanel.prototype.constructor.call(this, config);
22
+ }
23
+ });
@@ -0,0 +1 @@
1
+ ExtMVC.model.modelNamespace = MyApp.models;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Boots up the Ext MVC application in the current environment. The environment defaults to 'production',
3
+ * override by setting ?environment=someEnvironment to the end of the url. Default installed environments
4
+ * are 'development' and 'test'
5
+ */
6
+ (function() {
7
+ /**
8
+ * @private
9
+ * Inspects document.location and returns an object containing all of the url params
10
+ * @return {Object} The url params
11
+ */
12
+ var parseLocationParams = function() {
13
+ var args = window.location.search.split("?")[1],
14
+ //set default params
15
+ params = {
16
+ environment: 'production'
17
+ };
18
+
19
+ /**
20
+ * Read config data from url parameters
21
+ */
22
+ if (args != undefined) {
23
+ var argPairs = args.split("&");
24
+
25
+ for (var i=0; i < argPairs.length; i++) {
26
+ var splits = argPairs[i].split("="),
27
+ key = splits[0],
28
+ value = splits[1];
29
+
30
+ params[key] = value;
31
+ };
32
+ }
33
+
34
+ return params;
35
+ };
36
+
37
+ var params = parseLocationParams(),
38
+ environment = params.environment;
39
+
40
+ var fileOrders = {
41
+ production : [
42
+ 'http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js',
43
+ 'http://extjs.cachefly.net/ext-3.1.1/ext-all.js',
44
+ '/public/mvc/mvc-all.js',
45
+ '/public/app/app-all.js'
46
+ ],
47
+ development: [
48
+ 'http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js',
49
+ 'http://extjs.cachefly.net/ext-3.1.1/ext-all-debug.js',
50
+ '/public/mvc/mvc-all-debug.js'
51
+ ],
52
+ test : [
53
+ 'http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js',
54
+ 'http://extjs.cachefly.net/ext-3.1.1/ext-all-debug.js',
55
+ '/public/mvc/mvc-all.js',
56
+ '/public/app/app-all.js',
57
+ '../vendor/jspec/lib/jspec.js',
58
+ '../spec/TestHelper.js'
59
+ ]
60
+ };
61
+
62
+ var filesToLoad = fileOrders[environment];
63
+ for (var i=0; i < filesToLoad.length; i++) {
64
+ document.write('<script type="text/javascript" src="' + filesToLoad[i] + '"></script>');
65
+ };
66
+ })();
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Defines which database adapter to use in development, production and test
3
+ */
4
+
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This is the main environment file, which defines the files the comprise your application, and other settings.
3
+ * To add new files to your application, simply add them to the object in the appropriate place (see the inline comments for details)
4
+ */
5
+ {
6
+
7
+ /**
8
+ * Directory paths.
9
+ */
10
+ "pluginsDir" : '../vendor/plugins',
11
+ "libDir" : '../lib',
12
+ "configDir" : '../config',
13
+ "overridesDir": '../config/overrides',
14
+ "appDir" : '../app',
15
+ "vendor" : ['mvc'],
16
+ "mvcFilename" : 'ext-mvc-all-min',
17
+
18
+ /**
19
+ * Use config/application for general framework configuration
20
+ */
21
+ "config" : ['app/App', 'config/application', 'config/routes'],
22
+
23
+ /**
24
+ * All stylesheets to be loaded. These are all taken to be relative to the public/stylesheets directory, and the .css is
25
+ * automatically appended
26
+ */
27
+ "stylesheets": [
28
+
29
+ ],
30
+
31
+ //Overrides to include. These files should be located in the config/overrides directory
32
+ "overrides": [
33
+
34
+ ],
35
+
36
+ //Plugins to include. Each will load vendor/plugins/SomePlugin/SomePlugin-all.js
37
+ "plugins": [
38
+
39
+ ],
40
+
41
+ //All of the models in this application, found in the app/models folder
42
+ "models": [
43
+
44
+ ],
45
+
46
+ //All of the controllers in this application, found in the app/controllers folder
47
+ "controllers" : [
48
+
49
+
50
+ "application", "home"
51
+
52
+
53
+ ],
54
+
55
+ //All of the views in this application, as an object with the subfolder inside app/views as the key, and an array of filenames as the value.
56
+ //e.g.: views: {"index": ["index", "edit", "new", "view"]} will load /app/views/index/index.js and app/views/index/my_view.js
57
+ "views": [
58
+ {"layout": ["menu"]},
59
+ {"home" : ["index"]}
60
+ ]
61
+ }
62
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "stylesheets": ["application-all"],
3
+ "scripts" : []
4
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Defines all routes required for this application
3
+ */
4
+ ExtMVC.router.Router.defineRoutes = function(map) {
5
+ /**
6
+ * Sets up REST-like urls for a given model or models:
7
+ *
8
+ * map.resources('users');
9
+ *
10
+ * Is equivalent to:
11
+ * map.connect("users", {controller: 'users', action: 'index'}); // #users
12
+ * map.connect("users/new", {controller: 'users', action: 'new' }); // #users/new
13
+ * map.connect("users/:id/edit/", {controller: 'users', action: 'edit' }); // #users/1/edit
14
+ * map.connect("users/:id", {controller: 'users', action: 'show' }); // #users/1
15
+ *
16
+ * You can pass more than one model to a map.resources call, e.g.:
17
+ *
18
+ * map.resources('users', 'comments', 'pages', 'products');
19
+ */
20
+
21
+ //set up default routes
22
+ map.connect(":controller/:action");
23
+ map.connect(":controller/:action/:id");
24
+
25
+ //if no url, should a default
26
+ map.root({controller: 'home', action: 'index'});
27
+ };
@@ -0,0 +1,3 @@
1
+ # General settings used by ruby scripts
2
+ environment:
3
+ namespace: MyApp
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
6
+ <link href="http://extjs.cachefly.net/ext-3.1.1/resources/css/ext-all.css" rel='stylesheet' type='text/css' />
7
+ <link href='/public/stylesheets/extjs-mvc-all.css' rel='stylesheet' type='text/css' />
8
+ <title>Ext MVC Application</title>
9
+ </head>
10
+ <body>
11
+ <div id="loading-mask"></div>
12
+ <div id="loading">
13
+ <div class="loading-indicator">
14
+ Loading...
15
+ </div>
16
+ </div>
17
+ <script type="text/javascript" src="/config/boot.js"></script>
18
+ </body>
19
+ </html>
@@ -0,0 +1,49 @@
1
+ /** Loading mask */
2
+ #loading-mask {
3
+ position: absolute;
4
+ left: 0;
5
+ top: 0;
6
+ width: 100%;
7
+ height: 100%;
8
+ z-index: 21000; /* Normal loading masks are 20001 */
9
+ background-color: white;
10
+ }
11
+
12
+ #loading {
13
+ position: absolute;
14
+ left: 50%;
15
+ top: 50%;
16
+ padding: 2px;
17
+ z-index: 21001;
18
+ height: auto;
19
+ margin: -35px 0 0 -30px;
20
+ }
21
+
22
+ #loading .loading-indicator {
23
+ background: url(http://extjs.com/deploy/dev/docs/resources/extanim32.gif) no-repeat;
24
+ color: #555;
25
+ font: bold 13px tahoma,arial,helvetica;
26
+ padding: 8px 42px;
27
+ margin: 0;
28
+ text-align: center;
29
+ height: auto;
30
+ }
31
+
32
+ /* End Loading Mask */
33
+
34
+ /* Test Runner app - Move this somewhere else */
35
+
36
+ .x-grid3-row.pass {
37
+ background-color: #6FFF75;
38
+ }
39
+
40
+ .x-grid3-row.fail {
41
+ background-color: #FF6F6F;
42
+ }
43
+
44
+ .x-grid3-row.fail td {
45
+ /* background-color: red;*/
46
+ color: #fff;
47
+ }
48
+
49
+ /* End Test Runner app */
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+
4
+ <html>
5
+ <head>
6
+ <link type="text/css" rel="stylesheet" href="../vendor/screw-unit/lib/screw.css" />
7
+ <title>Application Specs</title>
8
+ </head>
9
+ <body>
10
+ <div id="dom_test" style="position: absolute; left: -9999"></div>
11
+
12
+ <!-- Library code (not directly part of the app) -->
13
+ <div id="libs">
14
+ <!-- Screw Unit -->
15
+ <script type="text/javascript" src="../vendor/screw-unit/lib/jquery-1.2.3.js"></script>
16
+ <script type="text/javascript" src="../vendor/screw-unit/lib/jquery.fn.js"></script>
17
+ <script type="text/javascript" src="../vendor/screw-unit/lib/jquery.print.js"></script>
18
+ <script type="text/javascript" src="../vendor/screw-unit/lib/screw.builder.js"></script>
19
+ <script type="text/javascript" src="../vendor/screw-unit/lib/screw.matchers.js"></script>
20
+ <script type="text/javascript" src="../vendor/screw-unit/lib/screw.events.js"></script>
21
+ <script type="text/javascript" src="../vendor/screw-unit/lib/screw.behaviors.js"></script>
22
+
23
+ <!-- Ext JS - using debug while in test mode -->
24
+ <script type="text/javascript" src="../vendor/ext/adapter/ext/ext-base.js"></script>
25
+ <script type="text/javascript" src="../vendor/ext/ext-all-debug.js"></script>
26
+
27
+ <!-- Ext MVC -->
28
+ <script type="text/javascript" src="../vendor/mvc/ext-mvc-all.js"></script>
29
+ </div>
30
+
31
+ <!-- Application Files - include any model, controller and view files you need to test here -->
32
+ <div id="app">
33
+ <script type="text/javascript" src="../app/OS.js"></script>
34
+
35
+ <div class="models">
36
+
37
+ </div>
38
+
39
+ <div class="controllers">
40
+
41
+ </div>
42
+
43
+ <div class="views">
44
+
45
+ </div>
46
+ </div>
47
+
48
+ <!-- Specs -->
49
+ <div id="specs">
50
+ <script type="text/javascript" src="SpecHelper.js"></script>
51
+
52
+ <div class="models">
53
+
54
+ </div>
55
+
56
+ <div class="controllers">
57
+
58
+ </div>
59
+
60
+ <div class="views">
61
+
62
+ </div>
63
+ </div>
64
+
65
+ </body>
66
+ </html>
@@ -0,0 +1,68 @@
1
+ <html>
2
+ <!--
3
+ This file is a fully-functioning example test case. Try opening this file in Firefox, Safari,
4
+ or Internet Explorer to see what a running test looks like.
5
+ This file demonstrates the the components involved in writing a simple test, such as:
6
+ * The necessary HTML to run a test (with the required <script> and <link rel="stylesheet"> tags),
7
+ * A "custom matcher" (i.e., a custom assertion) to make your tests more readable,
8
+ * And, a simple test with the necessary boiler-plate code to get you up and running.
9
+ Typically, these components are separated out into multiple files. To see what a more typical suite
10
+ of tests look like, look at the larger example in the examples/ directory.
11
+ -->
12
+ <head>
13
+ <!-- These are all of the necessary javascript and css files required to run your tests -->
14
+ <script src="lib/jquery-1.2.3.js"></script>
15
+ <script src="lib/jquery.fn.js"></script>
16
+ <script src="lib/jquery.print.js"></script>
17
+ <script src="lib/screw.builder.js"></script>
18
+ <script src="lib/screw.matchers.js"></script>
19
+ <script src="lib/screw.events.js"></script>
20
+ <script src="lib/screw.behaviors.js"></script>
21
+ <link rel="stylesheet" href="lib/screw.css">
22
+
23
+ <script type="text/javascript">
24
+ // Here is the system under test (SUT)--that is, your application code that you would like
25
+ // to test.
26
+ function foo() {
27
+ return 2;
28
+ }
29
+ </script>
30
+
31
+ <script type="text/javascript">
32
+ // Here is a Custom Matcher. A custom matcher is a custom assertion,
33
+ // tailored to your application; these help to make your tests more readable.
34
+ Screw.Matchers["be_even"] = {
35
+ match: function(expected, actual) {
36
+ return actual % 2 == 0;
37
+ },
38
+ failure_message: function(expected, actual, not) {
39
+ return 'expected ' + $.print(actual) + (not ? ' not' : '') + ' to be even';
40
+ }
41
+ }
42
+ </script>
43
+
44
+ <script type="text/javascript">
45
+ // Here is a sample test. Note that all tests are wrapped in
46
+ // "Screw.Unit(function() { ... })".
47
+ Screw.Unit(function() {
48
+ // Tests are organized into 'describes' and 'its', following the style of RSpec.
49
+ describe("foo", function() {
50
+ it("returns 2", function() {
51
+ // 'equal' is one among many matchers provided with the Screw.Unit distribution. It
52
+ // is smart enough to compare arrays, objects, and primitives.
53
+ expect(foo()).to(equal, 2);
54
+ });
55
+ });
56
+
57
+ describe("an undefined variable", function() {
58
+ // Here is a use of the custom matcher defined above.
59
+ it("is not defined", function() {
60
+ expect(2).to(be_even);
61
+ expect(3).to_not(be_even);
62
+ });
63
+ });
64
+ });
65
+ </script>
66
+ </head>
67
+ <body></body>
68
+ </html>
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Nick Kallen
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the 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
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.