extjs-mvc 0.3.10 → 0.4.0.a

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 (204) hide show
  1. data/LICENSE +1 -1
  2. data/README.rdoc +5 -173
  3. data/Rakefile +18 -20
  4. data/VERSION +1 -1
  5. data/bin/xmvc +13 -0
  6. data/lib/extjs-mvc/README +20 -0
  7. data/lib/extjs-mvc/builder.rb +83 -0
  8. data/lib/extjs-mvc/builders/all_builder.rb +15 -0
  9. data/lib/extjs-mvc/builders/app_builder.rb +36 -0
  10. data/lib/extjs-mvc/builders/base.rb +138 -0
  11. data/lib/extjs-mvc/builders/css_builder.rb +36 -0
  12. data/lib/extjs-mvc/builders/docs_builder.rb +20 -0
  13. data/lib/extjs-mvc/builders/mvc_builder.rb +33 -0
  14. data/lib/extjs-mvc/builders/plugin_builder.rb +53 -0
  15. data/lib/extjs-mvc/cli.rb +52 -0
  16. data/lib/extjs-mvc/generator.rb +79 -0
  17. data/lib/extjs-mvc/generators/app.rb +57 -0
  18. data/lib/extjs-mvc/generators/base.rb +53 -0
  19. data/lib/extjs-mvc/generators/controller.rb +41 -0
  20. data/lib/extjs-mvc/generators/model.rb +41 -0
  21. data/lib/extjs-mvc/generators/scaffold.rb +17 -0
  22. data/lib/extjs-mvc/generators/templates/Controller.js +17 -0
  23. data/lib/extjs-mvc/generators/templates/Model.js +9 -0
  24. data/lib/extjs-mvc/generators/templates/ModelSpec.js +12 -0
  25. data/lib/extjs-mvc/generators/templates/View.js +16 -0
  26. data/lib/extjs-mvc/generators/templates/_Action.js +7 -0
  27. data/lib/extjs-mvc/generators/templates/app/README.rdoc +152 -0
  28. data/lib/extjs-mvc/generators/templates/app/app/App.js +64 -0
  29. data/lib/extjs-mvc/generators/templates/app/app/controllers/ApplicationController.js +10 -0
  30. data/lib/extjs-mvc/generators/templates/app/app/controllers/HomeController.js +10 -0
  31. data/lib/extjs-mvc/generators/templates/app/app/views/home/Index.js +17 -0
  32. data/lib/extjs-mvc/generators/templates/app/app/views/layout/Menu.js +23 -0
  33. data/lib/extjs-mvc/generators/templates/app/config/application.js +1 -0
  34. data/lib/extjs-mvc/generators/templates/app/config/boot.js +67 -0
  35. data/lib/extjs-mvc/generators/templates/app/config/build.xml +77 -0
  36. data/lib/extjs-mvc/generators/templates/app/config/database.js +4 -0
  37. data/lib/extjs-mvc/generators/templates/app/config/environment.json +58 -0
  38. data/lib/extjs-mvc/generators/templates/app/config/environments/development.json +1 -0
  39. data/lib/extjs-mvc/generators/templates/app/config/environments/production.json +4 -0
  40. data/lib/extjs-mvc/generators/templates/app/config/routes.js +27 -0
  41. data/lib/extjs-mvc/generators/templates/app/config/settings.yml +3 -0
  42. data/lib/extjs-mvc/generators/templates/app/public/index.html +19 -0
  43. data/lib/extjs-mvc/generators/templates/app/public/stylesheets/ext-mvc-all.css +49 -0
  44. data/{test/active_record_test.rb → lib/extjs-mvc/generators/templates/app/spec/SpecHelper.js} +0 -0
  45. data/lib/extjs-mvc/generators/templates/app/spec/index.html +66 -0
  46. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/EXAMPLE.html +68 -0
  47. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/LICENSE +22 -0
  48. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/README.markdown +307 -0
  49. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery-1.2.3.js +3408 -0
  50. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery.fn.js +29 -0
  51. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/jquery.print.js +108 -0
  52. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.assets.js +36 -0
  53. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.behaviors.js +91 -0
  54. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.builder.js +80 -0
  55. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.css +90 -0
  56. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.events.js +42 -0
  57. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.matchers.js +145 -0
  58. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/lib/screw.server.js +21 -0
  59. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/behaviors_spec.js +178 -0
  60. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/matchers_spec.js +237 -0
  61. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/print_spec.js +119 -0
  62. data/{test/controller_test.rb → lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/spec_helper.js} +0 -0
  63. data/lib/extjs-mvc/generators/templates/app/vendor/screw-unit/spec/suite.html +18 -0
  64. data/lib/extjs-mvc/generators/templates/scaffold/ScaffoldController.js +18 -0
  65. data/lib/extjs-mvc/generators/view.rb +29 -0
  66. data/lib/extjs-mvc/plugin.rb +105 -0
  67. data/lib/extjs-mvc/scripts.rb +15 -0
  68. data/lib/extjs-mvc/settings.rb +75 -0
  69. data/lib/extjs-mvc/setup.rb +5 -0
  70. data/lib/extjs-mvc/stats.rb +241 -0
  71. data/lib/extjs-mvc/test.rb +11 -0
  72. data/lib/extjs-mvc/testserver.ru +95 -0
  73. data/lib/extjs-mvc/ui.rb +58 -0
  74. data/lib/extjs-mvc/update.rb +73 -0
  75. data/lib/extjs-mvc.rb +70 -32
  76. data/lib/js/App.js +219 -0
  77. data/lib/js/MVC.js +260 -0
  78. data/lib/js/Presenter.js +52 -0
  79. data/lib/js/README.rdoc +69 -0
  80. data/lib/js/build +21 -0
  81. data/lib/js/controller/Controller.js +278 -0
  82. data/lib/js/controller/CrudController.js +460 -0
  83. data/lib/js/lib/Array.js +26 -0
  84. data/lib/js/lib/Booter.js +415 -0
  85. data/lib/js/lib/ClassManager.js +191 -0
  86. data/lib/js/lib/ControllerClassManager.js +95 -0
  87. data/lib/js/lib/Dependencies.js +44 -0
  88. data/lib/js/lib/DispatchMatcher.js +98 -0
  89. data/lib/js/lib/Dispatcher.js +129 -0
  90. data/lib/js/lib/Environment.js +43 -0
  91. data/lib/js/lib/Inflector.js +138 -0
  92. data/lib/js/lib/ModelClassManager.js +19 -0
  93. data/lib/js/lib/Route.js +139 -0
  94. data/lib/js/lib/Router.js +282 -0
  95. data/lib/js/lib/String.js +94 -0
  96. data/lib/js/lib/ViewClassManager.js +229 -0
  97. data/lib/js/lib/notes.txt +32 -0
  98. data/lib/js/model/AdapterManager.js +30 -0
  99. data/lib/js/model/Association.js +26 -0
  100. data/lib/js/model/Base.js +63 -0
  101. data/lib/js/model/BelongsToAssociation.js +116 -0
  102. data/lib/js/model/Cache.js +131 -0
  103. data/lib/js/model/HasManyAssociation.js +160 -0
  104. data/lib/js/model/Model.js +331 -0
  105. data/lib/js/model/UrlBuilder.js +106 -0
  106. data/lib/js/model/adapters/AbstractAdapter.js +296 -0
  107. data/lib/js/model/adapters/MemoryAdapter.js +103 -0
  108. data/lib/js/model/adapters/RESTAdapter.js +345 -0
  109. data/lib/js/model/adapters/RESTJSONAdapter.js +68 -0
  110. data/lib/js/model/adapters/notes.txt +42 -0
  111. data/lib/js/model/associations/Association.js +192 -0
  112. data/lib/js/model/associations/notes.txt +87 -0
  113. data/lib/js/model/validations/Errors.js +136 -0
  114. data/lib/js/model/validations/Plugin.js +139 -0
  115. data/lib/js/model/validations/Validations.js +276 -0
  116. data/lib/js/notes/Charts.graffle +0 -0
  117. data/lib/js/overrides/Ext.Component.js +21 -0
  118. data/lib/js/overrides/Ext.extend.js +142 -0
  119. data/lib/js/spec/Array.spec.js +15 -0
  120. data/lib/js/spec/ExtMVC.spec.js +65 -0
  121. data/lib/js/spec/Model.spec.js +370 -0
  122. data/lib/js/spec/OS.spec.js +83 -0
  123. data/lib/js/spec/Router.spec.js +99 -0
  124. data/lib/js/spec/SpecHelper.js +106 -0
  125. data/lib/js/spec/String.spec.js +83 -0
  126. data/lib/js/spec/model/AbstractAdapter.spec.js +49 -0
  127. data/lib/js/spec/model/Associations.spec.js +99 -0
  128. data/lib/js/spec/model/Cache.spec.js +5 -0
  129. data/lib/js/spec/model/RESTAdapter.spec.js +19 -0
  130. data/lib/js/spec/model/ValidationErrors.spec.js +64 -0
  131. data/lib/js/spec/model/Validations.spec.js +166 -0
  132. data/lib/js/spec/model/ValidationsPlugin.spec.js +108 -0
  133. data/lib/js/spec/suite.html +60 -0
  134. data/lib/js/specs-old/JSSpec.css +216 -0
  135. data/lib/js/specs-old/JSSpec.js +1512 -0
  136. data/lib/js/specs-old/all.html +66 -0
  137. data/lib/js/specs-old/base.js +14 -0
  138. data/lib/js/specs-old/controller.js +17 -0
  139. data/lib/js/specs-old/diff_match_patch.js +1 -0
  140. data/lib/js/specs-old/model.js +70 -0
  141. data/lib/js/specs-old/route.js +38 -0
  142. data/lib/js/specs-old/router.js +59 -0
  143. data/lib/js/specs-old/string.js +22 -0
  144. data/lib/js/testrunner/JSpecFormatter.js +111 -0
  145. data/lib/js/testrunner/TestClient.js +181 -0
  146. data/lib/js/testrunner/TestGrid.js +351 -0
  147. data/lib/js/testrunner/TestRunner.js +110 -0
  148. data/lib/js/testrunner/TestViewport.js +94 -0
  149. data/lib/js/vendor/screw-unit/EXAMPLE.html +68 -0
  150. data/lib/js/vendor/screw-unit/LICENSE +22 -0
  151. data/lib/js/vendor/screw-unit/README.markdown +307 -0
  152. data/lib/js/vendor/screw-unit/lib/jquery-1.2.3.js +3408 -0
  153. data/lib/js/vendor/screw-unit/lib/jquery.fn.js +29 -0
  154. data/lib/js/vendor/screw-unit/lib/jquery.print.js +108 -0
  155. data/lib/js/vendor/screw-unit/lib/screw.assets.js +36 -0
  156. data/lib/js/vendor/screw-unit/lib/screw.behaviors.js +91 -0
  157. data/lib/js/vendor/screw-unit/lib/screw.builder.js +80 -0
  158. data/lib/js/vendor/screw-unit/lib/screw.css +91 -0
  159. data/lib/js/vendor/screw-unit/lib/screw.events.js +42 -0
  160. data/lib/js/vendor/screw-unit/lib/screw.matchers.js +145 -0
  161. data/lib/js/vendor/screw-unit/lib/screw.server.js +21 -0
  162. data/lib/js/vendor/screw-unit/spec/behaviors_spec.js +178 -0
  163. data/lib/js/vendor/screw-unit/spec/matchers_spec.js +237 -0
  164. data/lib/js/vendor/screw-unit/spec/print_spec.js +119 -0
  165. data/{test/data_mapper_test.rb → lib/js/vendor/screw-unit/spec/spec_helper.js} +0 -0
  166. data/lib/js/vendor/screw-unit/spec/suite.html +18 -0
  167. data/lib/js/view/FormWindow.js +184 -0
  168. data/lib/js/view/HasManyEditorGridPanel.js +211 -0
  169. data/lib/js/view/scaffold/Edit.js +46 -0
  170. data/lib/js/view/scaffold/Index.js +561 -0
  171. data/lib/js/view/scaffold/New.js +20 -0
  172. data/lib/js/view/scaffold/ScaffoldFormPanel.js +255 -0
  173. data/test/helper.rb +10 -0
  174. data/test/test_extjs-mvc-gem.rb +7 -0
  175. metadata +232 -56
  176. data/README +0 -12
  177. data/lib/controller/controller.rb +0 -28
  178. data/lib/core_ext/array/extract_options.rb +0 -15
  179. data/lib/extjs/component.rb +0 -71
  180. data/lib/extjs/data/store.rb +0 -131
  181. data/lib/helpers/component.rb +0 -37
  182. data/lib/helpers/store.rb +0 -7
  183. data/lib/model/active_record.rb +0 -89
  184. data/lib/model/base.rb +0 -370
  185. data/lib/model/data_mapper.rb +0 -66
  186. data/lib/model/mongo_mapper.rb +0 -64
  187. data/lib/test/macros.rb +0 -20
  188. data/test/app/config/application.rb +0 -70
  189. data/test/app/config/database.yml +0 -3
  190. data/test/app/db/schema.rb +0 -75
  191. data/test/app/models/active_record/address.rb +0 -4
  192. data/test/app/models/active_record/data_type.rb +0 -3
  193. data/test/app/models/active_record/group.rb +0 -4
  194. data/test/app/models/active_record/house.rb +0 -4
  195. data/test/app/models/active_record/location.rb +0 -5
  196. data/test/app/models/active_record/person.rb +0 -4
  197. data/test/app/models/active_record/user.rb +0 -6
  198. data/test/app/models/active_record/user_group.rb +0 -4
  199. data/test/component_test.rb +0 -15
  200. data/test/debug.log +0 -2969
  201. data/test/model_test.rb +0 -526
  202. data/test/mongo_mapper_test.rb +0 -0
  203. data/test/store_test.rb +0 -0
  204. data/test/test_helper.rb +0 -32
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Chris Scott
1
+ Copyright (c) 2009 Christocracy
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,185 +1,17 @@
1
- = mvc
2
-
3
- A collection of helpers, MVC mixins and PORs (plain-old-ruby-object) to assist with auto-generating ExtJS Stores (Ext.data.Store) including its associated DataReader (Ext.data.JsonReader, Ext.data.XmlReader) and DataWriter (Ext.data.JsonWriter, Ext.data.XmlWriter). Also contains a helper for rendering javascript component definitions via partials.
4
-
5
- See tutorial http://www.extjs.com/blog/2009/09/30/ext-js-on-rails-a-comprehensivetutorial/
6
-
7
- ===Installation
8
- % sudo gem install gemcutter
9
- % gem tumble (only have to do this once, adds gemcutter as primary gem-source)
10
- % sudo gem install extjs-mvc
11
-
12
- <b>Rails Installation:</b>
13
- In <tt>environment.rb</tt>,
14
-
15
- Rails::Initializer.run do |config|
16
- config.gem "extjs-mvc"
17
- end
18
-
19
- <b>Merb installation:</b>
20
- In <tt>config/dependencies.rb</tt>, Add extjs-mvc as a new dependency
21
-
22
- dependency "extjs-mvc"
23
-
24
- === An ORM Model mixin: ExtJS::Model
25
- extjs-mvc contains Model mixin named <tt>ExtJS::Model</tt> which works for <b>three</b> popular ORM frameworks, ActiveRecord, DataMapper and MongoMapper. The API for each framework is identical.
26
-
27
- Simply include the mixin into your model. Use the class-method <tt>extjs_fields</tt> to specify those
28
- fields with will be used to render the <tt>Ext.data.Record.create</tt> field-def'n.
29
-
30
- class User < ActiveRecord::Base
31
- include ExtJS::Model
32
-
33
- extjs_fields :exclude => [:password, :password_confirmation]
34
-
35
- # OR
36
- extjs_fields :name, :description
37
-
38
- # OR
39
- extjs_fields :only => [:name, :description] # actually the same as above
40
-
41
- # OR
42
- extjs_fields :additional => [:computed] # includes all database columns and an additional computed field
43
-
44
- # OR define a column as a Hash
45
- extjs_fields :description, :name => {"sortDir" => "ASC"}, :created_at => {"dateFormat" => "c"}
46
-
47
- # OR render associations, association-fields will have their "mapping" property set automatically
48
- extjs_fields :name, :description, :company => [:name, :description]
49
-
50
- def computed
51
- name.blank? ? login : name
52
- end
53
- end
54
-
55
- After including the model mixin <tt>ExtJS::Model</tt>, try typing the following in <tt>irb</tt> console:
56
- >> User.extjs_record
57
- => { :idProperty=>"id", :fields=>[
58
- {:type=>'int', :allowBlank=>true, :name=>"id"},
59
- {:type=>'string', :allowBlank=>false, :name=>"first", :defaultValue => nil},
60
- {:type=>'string', :allowBlank=>false, :name=>"last", :defaultValue => nil},
61
- {:type=>'string', :allowBlank=>false, :name=>"email", :defaultValue => nil}
62
- ]}
63
-
64
- An auto-generated <tt>Ext.data.JsonReader</tt> configuration!
65
-
66
-
67
- You can also define different sets of fields for different representations of your model.
68
-
69
- E.g. with the following definition:
70
-
71
- class User < ActiveRecord::Base
72
- include ExtJS::Model
73
-
74
- extjs_fieldset :grid, fields => [:name, :description, :company => [:name, :description]]
75
- extjs_fieldset :combo, [:full_name]
76
-
77
- def full_name
78
- "#{first_name} #{name}"
79
- end
80
- end
81
-
82
- You can get store configs for both representations with
83
- User.extjs_record(:grid)
84
- or
85
- User.extjs_record(:combo)
86
-
87
- And the corresponding data for the representations with
88
- User.first.to_record(:grid)
89
- or
90
- User.first.to_record(:combo)
91
-
92
-
93
- === An ActionController mixin: ExtJS::Controller
94
- The <tt>extjs-mvc</tt> Gem includes a framework agnostic Controller mixin which works with both Rails and Merb. Include this mixin into any controller which will need to generate an <tt>Ext.data.Store</tt>.
95
- <b>usage:</b>
96
-
97
- class UsersController < ActionController::Base
98
- include ExtJS::Controller
99
- end
100
-
101
- === View Helper: ExtJS::Helpers::Component
102
-
103
- <b>usage:</b>
104
-
105
- class UserController < ActionController::Base
106
- include ExtJS::Controller
107
- helper ExtJS::Helpers::Component
108
- end
109
-
110
- Now render Ext components using helper method <tt>extjs_component</tt>
111
-
112
- @viewport = extjs_component(
113
- "xtype" => "viewport",
114
- "frame" => true,
115
- "layout" => "border")
116
- @viewport.add("xtype" => "panel", "contentEl" => "hd", "region" => "north", "height" => 30)
117
- @viewport.add(:partial => "/users/grid", "itemId" => "users-grid", "region" => "west")
118
- @viewport.add(:partial => "/tasks/grid", "itemId" => "tasks-grid", "region" => "center")
119
- @viewport.add("xtype" => "panel", "contentEl" => "ft", "region" => "south", "height" => 20)
120
-
121
- Note how it can also render partials. Partials will be invoked with a local-variable named "container", a reference to the
122
- parent Ext::Component instance which added the partial. If no "container" is specified, it would be expected that your partial
123
- would provide its own "renderTo" or "contentEl" property, just as in Ext.Component from ExtJS javascript library.
124
-
125
-
126
- === View Helper: ExtJS::Helpers::Store
127
-
128
- Renders an Ext.data.Store with helper method <tt>extjs_store</tt>
129
-
130
- class UserController < ActionController::Base
131
- include ExtJS::Controller
132
- helper ExtJS::Helpers::Store
133
- end
134
-
135
- Now render a store in an erb template:
136
-
137
- @store = extjs_store(
138
- :controller => "users",
139
- :fieldset => :grid, # <-- Specify a particular fieldset as defined in the Model (used to render DataReader)
140
- :proxy => "http" # <-- default
141
- :format => "json" # <-- default
142
- :model => "user", # <-- default: controller_name.singularize
143
- :writer => {:encode => false},
144
- :config => { # <-- standard Ext.data.Store config-params
145
- "autoLoad" => true
146
- "autoSave" => true
147
- }
148
- )
149
-
150
- %= @store.render %
151
-
152
- === A Testing Mixin: ExtJS::TestMacros
153
- The <tt>extjs-mvc</tt> Gem includes a small set of testing macros to help unit-test models.
154
- This requires the 'Shoulda' gem from thoughtbot. Include this mixin inside the
155
- <tt>ActiveSupport::TestCase</tt> class in <tt>test/test_helper.rb</tt>
156
-
157
- ==== Usage
158
- <tt>test/test_helper.rb</tt>
159
- class ActiveSupport::TestCase
160
- extend ExtJS::TestMacros
161
- #...
162
- end
163
-
164
- In individual model unit tests:
165
- class ModelTest < ActiveSupport::TestCase
166
- should_require_extjs_fields :name, :email, :city
167
- #...
168
- #other tests
169
- end
1
+ = extjs-mvc-gem
170
2
 
3
+ Description goes here.
171
4
 
172
5
  == Note on Patches/Pull Requests
173
-
6
+
174
7
  * Fork the project.
175
8
  * Make your feature addition or bug fix.
176
9
  * Add tests for it. This is important so I don't break it in a
177
10
  future version unintentionally.
178
11
  * Commit, do not mess with rakefile, version, or history.
179
- (if you want to have your own version, that is fine but
180
- bump version in a commit by itself I can ignore when I pull)
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
181
13
  * Send me a pull request. Bonus points for topic branches.
182
14
 
183
15
  == Copyright
184
16
 
185
- Copyright (c) 2009 Chris Scott. See LICENSE for details.
17
+ Copyright (c) 2010 Christocracy. See LICENSE for details.
data/Rakefile CHANGED
@@ -5,30 +5,32 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "extjs-mvc"
8
- gem.summary = %Q{Ruby ORM tools to assist with rendering Ext.data.Store}
9
- gem.description = %Q{MVC tools to assist with ExtJS development in Rails and Merb}
8
+ gem.summary = %Q{A Rails-like MVC for the Ext JS javascript framework}
9
+ gem.description = %Q{A full-stack, Rails-like MVC for the Ext JS javascript framework (originally known as extmvc/extmvc)}
10
10
  gem.email = "christocracy@gmail.com"
11
- gem.homepage = "http://github.com/extjs/mvc"
12
- gem.authors = ["Chris Scott"]
13
- gem.add_development_dependency "shoulda"
14
- gem.add_development_dependency "mocha"
15
- gem.add_development_dependency "extlib"
11
+ gem.homepage = "http://github.com/christocracy/extjs-mvc-gem"
12
+ gem.authors = ["Ed Spencer and Chris Scott"]
13
+ gem.add_dependency "extlib"
14
+ gem.add_dependency "json"
15
+ gem.add_dependency "thor"
16
+ gem.add_dependency "jammit-core"
17
+ gem.add_dependency "hpricot"
18
+
19
+
20
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
21
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test,js}/**/*", 'lib/jeweler/templates/.gitignore']
16
22
 
17
- gem.test_files = []
18
- gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
19
-
20
23
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
24
  end
22
25
  Jeweler::GemcutterTasks.new
23
26
  rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
27
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
28
  end
26
29
 
27
-
28
30
  require 'rake/testtask'
29
31
  Rake::TestTask.new(:test) do |test|
30
32
  test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/*_test.rb'
33
+ test.pattern = 'test/**/test_*.rb'
32
34
  test.verbose = true
33
35
  end
34
36
 
@@ -36,7 +38,7 @@ begin
36
38
  require 'rcov/rcovtask'
37
39
  Rcov::RcovTask.new do |test|
38
40
  test.libs << 'test'
39
- test.pattern = 'test/**/*_test.rb'
41
+ test.pattern = 'test/**/test_*.rb'
40
42
  test.verbose = true
41
43
  end
42
44
  rescue LoadError
@@ -51,14 +53,10 @@ task :default => :test
51
53
 
52
54
  require 'rake/rdoctask'
53
55
  Rake::RDocTask.new do |rdoc|
54
- if File.exist?('VERSION')
55
- version = File.read('VERSION')
56
- else
57
- version = ""
58
- end
56
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
59
57
 
60
58
  rdoc.rdoc_dir = 'rdoc'
61
- rdoc.title = "mvc #{version}"
59
+ rdoc.title = "extjs-mvc-gem #{version}"
62
60
  rdoc.rdoc_files.include('README*')
63
61
  rdoc.rdoc_files.include('lib/**/*.rb')
64
62
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.4.0.a
data/bin/xmvc ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ # Check if an older version of extjs-mvc is installed
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
5
+ require 'extjs-mvc'
6
+ require 'extjs-mvc/cli'
7
+
8
+ begin
9
+ ExtJS::MVC::CLI.start
10
+ rescue ExtJS::MVC::Error => e
11
+ ExtJS::MVC.ui.error(e.message)
12
+ exit e.status_code
13
+ end
@@ -0,0 +1,20 @@
1
+ This directory contains a collection of Ruby scripts and classes which allow automation of common project tasks.
2
+ You can remove this directory if you don't use any of these tasks.
3
+
4
+ Usage:
5
+
6
+ From within the MVC application base directory:
7
+
8
+ ruby script/generate model MyModel field_1:string field_2:int field_3:boolean
9
+ ruby script/generate view viewNamespace viewName
10
+ ruby script/generate controller controllerName viewName1 viewName2 ...
11
+ ruby script/generate scaffold MyModel field_1:string field_2:int field_3:boolean
12
+
13
+ ruby script/plugin install git://github.com/extmvc/loadingmessage-plugin.git LoadingMessage (second arg optional)
14
+ ruby script/plugin install MyPluginFolder (where MyPluginFolder is a folder within the vendor/plugins directory)
15
+ ruby script/plugin uninstall MyPluginFolder
16
+
17
+ ruby script/build all
18
+ ruby script/build js
19
+ ruby script/build css
20
+
@@ -0,0 +1,83 @@
1
+ #require 'builders/base'
2
+ #require 'builders/all_builder'
3
+ #require 'builders/app_builder'
4
+ #require 'builders/css_builder'
5
+ #require 'builders/docs_builder'
6
+ #require 'builders/mvc_builder'
7
+ #require 'builders/plugins_builders'
8
+
9
+ module ExtJS
10
+ module MVC
11
+ class BuilderManager
12
+ class << self
13
+
14
+ def dispatch(name, *params)
15
+ name = name.to_sym
16
+ options = params.shift || {}
17
+ case name
18
+ when :setup
19
+ setup(options)
20
+ else
21
+ begin
22
+ @jammit = jammit(options)
23
+ @jammit.invoke(:build, [name])
24
+ rescue Jammit::Error => e
25
+ raise ExtJS::MVC::BuilderError.new(e.message)
26
+ end
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def setup(options)
33
+ begin
34
+ ##
35
+ # Invoke jammit init app-name so that Jammit creates it's config/assets.yml
36
+ # Note that we must pass-in the name of the newly created app @name so that
37
+ # Jammit appends that to its config_path, otherwise it would create its config file
38
+ # in the pwd.
39
+
40
+ @asset_root = options[:asset_root] || File.expand_path('.')
41
+
42
+ app_assets
43
+
44
+ jammit = Jammit::CLI.new([], options)
45
+ jammit.invoke(:init)
46
+ jammit.invoke(:config, ["set", "javascripts", {
47
+ "mvc" => mvc_assets,
48
+ "app" => app_assets
49
+ }])
50
+ jammit.invoke(:build)
51
+
52
+ rescue Jammit::Error => e
53
+ raise ExtJS::MVC::BuilderError.new(e.message)
54
+ end
55
+ end
56
+
57
+ def jammit(options={})
58
+ Jammit::CLI.new([], options)
59
+ end
60
+
61
+ def mvc_assets
62
+ YAML.load(File.read(File.join(@asset_root, 'vendor', 'mvc', 'build'))).map {|f|
63
+ File.join('vendor', 'mvc', f)
64
+ }
65
+ end
66
+
67
+ def app_assets
68
+ [
69
+ 'app/App.js',
70
+ 'config/application.js',
71
+ 'config/routes.js',
72
+ 'vendor/plugins/*/**.js',
73
+ 'overrides/*.js',
74
+ 'app/models/*.js',
75
+ 'app/controllers/*.js',
76
+ 'app/views/*/**.js'
77
+ ]
78
+ end
79
+
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,15 @@
1
+ module ExtJS
2
+ module MVC
3
+ class AllBuilder < Builder
4
+ def self.instances(args = [])
5
+ # set defaults
6
+ args = ['app', 'css', 'plugin', 'mvc'] if args.empty?
7
+ instances = []
8
+
9
+ args.each {|builderName| instances.concat(ExtMVC::BuilderManager.instances_for(builderName, []))}
10
+
11
+ return instances
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ module ExtJS
2
+ module MVC
3
+ class AppBuilder < Builder
4
+ def self.instances(args = [])
5
+ [ExtMVC::AppBuilder.new]
6
+ end
7
+
8
+ def file_list
9
+ # build to production environment
10
+ environment = ExtMVC.mvc_production_environment
11
+
12
+ return ExtMVC.application_files_for(environment)
13
+ end
14
+
15
+ def name
16
+ "Ext MVC Application"
17
+ end
18
+
19
+ def message
20
+ "Built #{name}"
21
+ end
22
+
23
+ def description
24
+ "Your #{name}"
25
+ end
26
+
27
+ def output_filename
28
+ "public/application-all.js"
29
+ end
30
+
31
+ def should_minify
32
+ true
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,138 @@
1
+
2
+ module ExtJS
3
+ module MVC
4
+ module Builder
5
+ class Base
6
+
7
+ # Subclasses must implement this method to return the name of the file that concatenated output will be saved to
8
+ def output_filename
9
+ raise
10
+ end
11
+
12
+ # Does the actual building - just concatenates file_list and optionally minifies
13
+ def build
14
+ concatenate(file_list, output_filename)
15
+ system('growlnotify -m "Built ' + name + '"')
16
+
17
+ if should_minify
18
+ minify output_filename
19
+ system('growlnotify -m "Minified ' + name + '"')
20
+ end
21
+
22
+ puts message
23
+ end
24
+
25
+ # Indicates whether the outputted filename should also be minified (defaults to false)
26
+ def should_minify
27
+ false
28
+ end
29
+
30
+ def name
31
+ "Unknown Package"
32
+ end
33
+
34
+ def message
35
+ "Build complete"
36
+ end
37
+
38
+ def description
39
+ directory_name
40
+ end
41
+
42
+ # Returns an array of all files to be concatenated, in the order they should be included
43
+ def file_list
44
+ has_build_file? ? order_from_build_file : guess_build_order
45
+ end
46
+
47
+ def has_build_file?
48
+ File.exists?(build_file_name)
49
+ end
50
+
51
+ def build_file_name
52
+ "#{directory_name}/build"
53
+ end
54
+
55
+ # Subclasses can override this method to return the string name of the directory under while the file_list resides
56
+ def directory_name
57
+ "./"
58
+ end
59
+
60
+ # Returns an array of all of the files listed in the build file
61
+ def order_from_build_file
62
+ build_files = []
63
+ file = File.open(build_file_name, "r")
64
+
65
+ while (line = file.gets)
66
+ line.gsub!(/\n/, '')
67
+ next if line =~ /^#/ || line.length.zero?
68
+
69
+ filename = "#{directory_name}/#{line}"
70
+
71
+ if File.exists?(filename)
72
+ build_files.push(filename) unless build_files.include?(filename)
73
+ else
74
+ js_files_in_glob(filename).each {|filename| build_files.push(filename) unless build_files.include?(filename)}
75
+ end
76
+ end
77
+
78
+ build_files
79
+ end
80
+
81
+ # Returns an array of all the .js files found in the plugin dir, in the order in which they are found
82
+ # (ignores the 'PluginName-all.js' file)
83
+ def guess_build_order
84
+ js_files_in_glob("#{directory_name}/**/*.js")
85
+ end
86
+
87
+ def js_files_in_glob(glob)
88
+ Dir[glob].select {|fileName| Regexp.new(output_filename).match(fileName).nil?}
89
+ end
90
+
91
+ private
92
+
93
+ # Concatenates an array of files together and saves
94
+ def concatenate(files, concatenated_filename, baseDir = './')
95
+ #remove old files, create blank ones again
96
+ if File.exists?(concatenated_filename)
97
+ File.delete(concatenated_filename)
98
+ # puts "Deleted old #{concatenated_filename}"
99
+ end
100
+ FileUtils.touch(concatenated_filename)
101
+
102
+ count = 0
103
+ file = File.open(concatenated_filename, 'w') do |f|
104
+ files.each do |i|
105
+ # remove the directory the app is in if add_dir is supplied
106
+ i = i.gsub(Regexp.new(ENV['app_dir']), '').gsub(/$(\/*)(.*)/, '\2') if ENV['app_dir']
107
+
108
+ f.puts(IO.read(File.join(baseDir, i)))
109
+ f.puts("\n")
110
+ count += 1
111
+ end
112
+ end
113
+
114
+ # puts "Concatenated #{count} files into #{concatenated_filename}"
115
+ # puts
116
+ end
117
+
118
+ # Minifies a file using YUI compressor
119
+ def minify(filename, minified_filename = nil)
120
+ if minified_filename.nil?
121
+ minified_filename = filename.gsub(/\.js$/, '-min.js')
122
+ end
123
+
124
+ if File.exists?(minified_filename)
125
+ FileUtils.rm(minified_filename)
126
+ # puts "Deleted old #{minified_filename}"
127
+ end
128
+
129
+ system("java -jar vendor/yui-compressor/build/yuicompressor-2.4.jar #{filename} -o #{minified_filename}")
130
+
131
+ # puts "Created minified file #{minified_filename}"
132
+ # puts
133
+ end
134
+
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,36 @@
1
+ module Ext
2
+ module MVC
3
+ class CssBuilder < Builder
4
+ def self.instances(args = [])
5
+ [ExtMVC::CssBuilder.new]
6
+ end
7
+
8
+ def file_list
9
+ # build to production environment
10
+ environment = ExtMVC.mvc_development_environment
11
+
12
+ return ExtJS::MVC.css_files_for(environment)
13
+ end
14
+
15
+ def name
16
+ "Ext MVC Application Stylesheets"
17
+ end
18
+
19
+ def message
20
+ "Built #{name}"
21
+ end
22
+
23
+ def description
24
+ "Your #{name}"
25
+ end
26
+
27
+ def output_filename
28
+ "public/stylesheets/application-all.css"
29
+ end
30
+
31
+ def directory_name
32
+ "public/stylesheets/"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ module Ext
2
+ module MVC
3
+ class DocsBuilder < Builder
4
+ def self.instances(args = [])
5
+ [ExtMVC::DocsBuilder.new]
6
+ end
7
+
8
+ def build
9
+ system("java -jar vendor/ext-doc/ext-doc.jar -p config/build.xml -o docs -t vendor/ext-doc/template/ext/template.xml -verbose")
10
+ app_name = ExtMVC.settings['docs']['title'] rescue ExtMVC.environment["namespace"] || "Ext MVC"
11
+ logo = ExtMVC.settings['docs']['logo'] rescue "resources/extjs.gif"
12
+
13
+ {:app_name => app_name, :logo => logo}.each_pair do |key, value|
14
+ ExtMVC.gsub_file("docs/index.html", "<%= @#{key} %>", value)
15
+ ExtMVC.gsub_file("docs/welcome.html", "<%= @#{key} %>", value)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ module Ext
2
+ module MVC
3
+ class MVCBuilder < Builder
4
+ def self.instances(args = [])
5
+ [ExtMVC::MVCBuilder.new]
6
+ end
7
+
8
+ def output_filename
9
+ "#{directory_name}/ext-mvc-all.js"
10
+ end
11
+
12
+ def directory_name
13
+ "vendor/mvc"
14
+ end
15
+
16
+ def should_minify
17
+ true
18
+ end
19
+
20
+ def name
21
+ "Ext MVC"
22
+ end
23
+
24
+ def message
25
+ "Built #{name}"
26
+ end
27
+
28
+ def description
29
+ "The #{name} framework (#{directory_name})"
30
+ end
31
+ end
32
+ end
33
+ end