xmvc 0.1.8 → 0.1.9

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 (39) hide show
  1. data/Rakefile +12 -3
  2. data/VERSION +1 -1
  3. data/lib/xmvc/api.rb +22 -31
  4. data/lib/xmvc/builder.rb +5 -22
  5. data/lib/xmvc/generator.rb +0 -2
  6. data/lib/xmvc/generators/app.rb +21 -18
  7. data/lib/xmvc/generators/boot.rb +19 -62
  8. data/lib/xmvc/generators/templates/app/public/config/application.js +2 -2
  9. data/lib/xmvc/generators/templates/index.html +22 -0
  10. data/lib/xmvc/helpers/sprockets.rb +25 -10
  11. data/lib/xmvc/vendor.rb +178 -15
  12. data/lib/xmvc.rb +31 -32
  13. data/test/app/public/javascripts/valid_vendor/valid_vendor-all-debug.js +1 -0
  14. data/test/app/test/app/vendor/ext/vendor.yml +19 -0
  15. data/test/app/vendor/ext/vendor.yml +19 -0
  16. data/test/app/vendor/valid_vendor/src/ValidVendor.js +1 -0
  17. data/test/app/vendor/valid_vendor/vendor.yml +4 -0
  18. data/test/helper.rb +7 -1
  19. data/test/lib/invalid_vendor/invalid_vendor.rb +15 -0
  20. data/test/lib/invalid_vendor/src/InvalidVendor.js +1 -0
  21. data/test/lib/nameless_vendor/nameless_vendor.rb +20 -0
  22. data/test/lib/nameless_vendor/src/ValidVendor.js +1 -0
  23. data/test/lib/nameless_vendor/vendor.yml +4 -0
  24. data/test/lib/valid_vendor/src/ValidVendor.js +1 -0
  25. data/test/lib/valid_vendor/valid_vendor.rb +18 -0
  26. data/test/lib/valid_vendor/vendor.yml +4 -0
  27. data/test/test_app_installer.rb +15 -0
  28. data/test/test_vendor_installer.rb +108 -0
  29. metadata +36 -15
  30. data/lib/xmvc/README +0 -20
  31. data/lib/xmvc/builders/all_builder.rb +0 -13
  32. data/lib/xmvc/builders/app_builder.rb +0 -36
  33. data/lib/xmvc/builders/base.rb +0 -138
  34. data/lib/xmvc/builders/css_builder.rb +0 -34
  35. data/lib/xmvc/builders/mvc_builder.rb +0 -33
  36. data/lib/xmvc/builders/plugin_builder.rb +0 -53
  37. data/lib/xmvc/builders/vendor.rb +0 -85
  38. data/lib/xmvc/plugin.rb +0 -102
  39. data/test/test_extjs-core.rb +0 -7
data/lib/xmvc.rb CHANGED
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'extlib'
6
6
  require 'whorm'
7
7
  require 'sprockets'
8
+ require 'thor'
8
9
 
9
10
  module Xmvc
10
11
 
@@ -24,18 +25,12 @@ module Xmvc
24
25
  require 'xmvc/builder'
25
26
  require 'xmvc/config'
26
27
 
27
- ##
28
- # load sprockets helper immediately so we can mix in right away
29
- require 'xmvc/helpers/sprockets'
30
- include Xmvc::Helpers::Sprockets
31
-
32
- #require 'xmvc/api' # <-- autoloadable ?? check with Sinatra handlers "sprockets"
28
+ autoload :Helpers, 'xmvc/helpers'
33
29
  autoload :Vendor, 'xmvc/vendor'
34
30
  autoload :Helpers, 'xmvc/helpers'
35
31
  autoload :API, 'xmvc/api'
36
32
  autoload :UI, 'xmvc/ui'
37
33
  autoload :Generator, 'xmvc/generator'
38
- autoload :Plugin, 'xmvc/plugin'
39
34
  autoload :Stats, 'xmvc/stats'
40
35
  autoload :Test, 'xmvc/test'
41
36
 
@@ -80,12 +75,6 @@ module Xmvc
80
75
  #
81
76
  attr_accessor :vendors
82
77
 
83
-
84
- ##
85
- # An instance of the sprockets secretary
86
- #
87
- attr_accessor :secretary
88
-
89
78
  attr_accessor :public_path
90
79
 
91
80
  ##
@@ -94,26 +83,40 @@ module Xmvc
94
83
 
95
84
  ##
96
85
  # @param {Symbol} type :js, :css, :image
97
- # @param {String} name
86
+ # @param {Xmvc::Vendor} vendor
87
+ # @param {Symbol} type :js|:css|:sass|:haml, etc
88
+ # @param {Symbol} environment :development|:production
89
+ #
90
+ def public_build_paths(environment, vendor, ext)
91
+ vspec = vendor.config
92
+ @rs = []
93
+ vendor.config[asset_dir(ext)].each do |file|
94
+ @rs << build_path(environment, vspec["host"], vspec["name"], vspec["version"], ext)
95
+ end
96
+ end
97
+
98
+ ##
99
+ # builds a public asset-path for a single asset-path
100
+ # @param {Symbol} environment
101
+ # @param {String} vendor name
98
102
  # @param {String} version
103
+ # @param {String} ext The file-extension :js, :css, :sass, etc.
99
104
  #
100
- def public_build_path(type, name, version=nil, suffix=nil)
101
- File.join(public_path, asset_dir(type), build_name(type, name, version, suffix))
105
+ def build_path(environment, host, name, version, ext)
106
+ unless host.include? "http://"
107
+ host = (host == PUBLIC_PATH) ? "/#{host}/#{asset_dir(ext)}" : "/#{host}"
108
+ end
109
+ File.join(host, name.to_s, build_name(environment, name, version, ext))
102
110
  end
103
-
104
- # TODO Get rid of following obsolete
105
- def public_build_url(type, name, version=nil, suffix=nil)
106
- File.join("/#{PUBLIC_PATH}", asset_dir(type), build_name(type, name, version, suffix))
111
+
112
+ def build_cachefly_url(host, name, version, file)
113
+ File.join(host, "#{name}-#{version}", file)
107
114
  end
108
115
 
109
- def build_name(type, name, version=nil, suffix=nil)
110
- version = "" if version.nil?
111
- suffix = "" if suffix.nil?
112
- package = name
113
- package += "-#{version}" unless version.empty?
114
- name += "-all"
115
- name += "-#{suffix}" unless suffix.empty?
116
- File.join(package, "#{name}.#{type.to_s}")
116
+ def build_name(environment, name, version, ext)
117
+ suffix = (environment == :development) ? "-all-debug" : "-all"
118
+ version = (version.nil? or version.empty?) ? "" : "-#{version}"
119
+ name.to_s+version.to_s+suffix+'.'+ext.to_s
117
120
  end
118
121
 
119
122
  def asset_dir(type)
@@ -150,10 +153,6 @@ module Xmvc
150
153
  @ui ||= UI.new
151
154
  end
152
155
 
153
- private
154
-
155
-
156
-
157
156
  end
158
157
  end
159
158
 
@@ -0,0 +1 @@
1
+ alert('ValidVendor');
@@ -0,0 +1,19 @@
1
+ # Defines the build order of Ext MVC. Comments indicated with a hash.
2
+ # Each line denotes either a single file, or a directory glob. If a glob, all matching files are included
3
+ # (unless they have already been defined)
4
+
5
+ name: ext
6
+
7
+ version: 3.1.1
8
+
9
+ dependencies:
10
+
11
+ host: http://extjs.cachefly.net
12
+
13
+ javascripts:
14
+ - adapter/ext/ext-base.js
15
+ - ext-all.js
16
+
17
+ stylesheets:
18
+ - resources/css/ext-all.css
19
+
@@ -0,0 +1,19 @@
1
+ # Defines the build order of Ext MVC. Comments indicated with a hash.
2
+ # Each line denotes either a single file, or a directory glob. If a glob, all matching files are included
3
+ # (unless they have already been defined)
4
+
5
+ name: ext
6
+
7
+ version: 3.1.1
8
+
9
+ dependencies:
10
+
11
+ host: http://extjs.cachefly.net
12
+
13
+ javascripts:
14
+ - adapter/ext/ext-base.js
15
+ - ext-all.js
16
+
17
+ stylesheets:
18
+ - resources/css/ext-all.css
19
+
@@ -0,0 +1 @@
1
+ alert('ValidVendor');
@@ -0,0 +1,4 @@
1
+ name: extjs
2
+
3
+ javascripts:
4
+ - src/*
data/test/helper.rb CHANGED
@@ -4,7 +4,13 @@ require 'shoulda'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'extjs-core'
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
8
+
9
+
10
+ require 'xmvc'
11
+ require 'xmvc/cli'
12
+ require 'extjs-mvc'
8
13
 
9
14
  class Test::Unit::TestCase
15
+
10
16
  end
@@ -0,0 +1,15 @@
1
+ module InvalidVendor
2
+ class API < Xmvc::Vendor
3
+
4
+ vendor_name :invalid_vendor
5
+
6
+ def self.source_root
7
+ File.dirname(__FILE__)
8
+ end
9
+
10
+ desc "install", "Install library"
11
+ def install
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1 @@
1
+ alert('InvalidVendor');
@@ -0,0 +1,20 @@
1
+ module NamelessVendor
2
+ class API < Xmvc::Vendor
3
+
4
+ ##
5
+ # This test-vendor does not define the required vendor_name property
6
+ #vendor_name :valid_vendor
7
+
8
+ def self.source_root
9
+ File.dirname(__FILE__)
10
+ end
11
+
12
+ desc "install", "Install library"
13
+ def install
14
+
15
+ inside empty_directory("src") do |src|
16
+ copy_file("NamelessVendor.js", "NamelessVendor.js")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ alert('ValidVendor');
@@ -0,0 +1,4 @@
1
+ name: extjs
2
+
3
+ javascripts:
4
+ - src/*
@@ -0,0 +1 @@
1
+ alert('ValidVendor');
@@ -0,0 +1,18 @@
1
+ module ValidVendor
2
+ class API < Xmvc::Vendor
3
+
4
+ vendor_name :valid_vendor
5
+
6
+ def self.source_root
7
+ File.dirname(__FILE__)
8
+ end
9
+
10
+ desc "install", "Install library"
11
+ def install
12
+
13
+ inside empty_directory("src") do |src|
14
+ copy_file("ValidVendor.js", "ValidVendor.js")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ name: extjs
2
+
3
+ javascripts:
4
+ - src/*
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestAppInstaller < Test::Unit::TestCase
4
+ context "An app named foo" do
5
+
6
+ setup {
7
+
8
+ }
9
+ should "probably rename this file and start testing for real" do
10
+ assert true
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,108 @@
1
+ require 'helper'
2
+
3
+ # Include a 3 example vendors, one good, two bad.
4
+ require 'valid_vendor/valid_vendor'
5
+ require 'invalid_vendor/invalid_vendor'
6
+ require 'nameless_vendor/nameless_vendor'
7
+
8
+ require 'extjs'
9
+
10
+ ##
11
+ # You must run this test from gem-root
12
+ #
13
+ FileUtils.chdir("test/app")
14
+
15
+ class TestVendorInstaller < Test::Unit::TestCase
16
+ VENDOR_ROOT = "vendor"
17
+
18
+ context "A valid vendor" do
19
+ should "install" do
20
+ path = "vendor/valid_vendor"
21
+ FileUtils.rm_rf(path) if File.exists? path
22
+ vendor = ValidVendor::API.install({
23
+ :root => "vendor"
24
+ })
25
+ assert File.exists?(File.join(VENDOR_ROOT, "valid_vendor/vendor.yml")), FileUtils.pwd
26
+ end
27
+
28
+ should "load" do
29
+ vendor = ValidVendor::API.load({
30
+ :root => "vendor"
31
+ })
32
+ assert vendor.config.kind_of?(Hash) and vendor.config["name"] == ValidVendor::API.vendor_name
33
+ end
34
+
35
+ should "return secretary" do
36
+ vendor = ValidVendor::API.load({
37
+ :root => "vendor"
38
+ })
39
+ secretary = vendor.invoke(:secretary)
40
+ assert secretary.instance_of?(Sprockets::Secretary)
41
+ end
42
+
43
+ should "secretary should contain corresponding number of files as exist in valid_vendor/src/*" do
44
+ count = Dir["vendor/valid_vendor/src/**/*.js"].length
45
+ vendor = ValidVendor::API.load({
46
+ :root => "vendor"
47
+ })
48
+ secretary = vendor.invoke(:secretary)
49
+ assert secretary.preprocessor.source_files.length == count
50
+ end
51
+
52
+ should "bundle assets" do
53
+ vendor = ValidVendor::API.load({
54
+ :root => "vendor"
55
+ })
56
+ vendor.invoke(:bundle)
57
+ end
58
+ end
59
+
60
+ context "An invalid vendor with no vendor.yml defined" do
61
+ setup {
62
+ path = "test/app/vendor/invalid_vendor"
63
+ FileUtils.rm_rf(path) if File.exists? path
64
+ }
65
+
66
+ should "Fail with SpecNotFound exception" do
67
+ begin
68
+ InvalidVendor::API.install({
69
+ :root => "test/app/vendor"
70
+ })
71
+ rescue StandardError => e
72
+ assert e.instance_of? Xmvc::Vendor::SpecNotFound
73
+ end
74
+ end
75
+ end
76
+
77
+ context "A vendor with no vendor_name defined" do
78
+ setup {
79
+ path = "test/app/vendor/nameless_vendor"
80
+ FileUtils.rm_rf(path) if File.exists? path
81
+ }
82
+
83
+ should "Fail with Xmvc::Vendor::Error" do
84
+
85
+ begin
86
+ NamelessVendor::API.install({
87
+ :root => "test/app/vendor"
88
+ })
89
+ rescue StandardError => e
90
+ assert e.instance_of? Xmvc::Vendor::Error
91
+ end
92
+ end
93
+ end
94
+
95
+ context "The extjs Gem" do
96
+ setup {
97
+ path = "test/app/vendor/#{ExtJS::API.vendor_name}"
98
+ FileUtils.rm_r(path) if File.exists? path
99
+ }
100
+
101
+ should "install" do
102
+ ExtJS::API.install({
103
+ :root => "test/app/vendor"
104
+ })
105
+ #assert File.exists? "test/app/vendor/#{ExtJS::API.vendor_name}"
106
+ end
107
+ end
108
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ed Spencer and Chris Scott
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-16 00:00:00 -04:00
17
+ date: 2010-03-19 00:00:00 -04:00
18
18
  default_executable: xmvc
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -86,7 +86,7 @@ dependencies:
86
86
  type: :runtime
87
87
  version_requirements: *id005
88
88
  - !ruby/object:Gem::Dependency
89
- name: thoughtbot-shoulda
89
+ name: shoulda
90
90
  prerelease: false
91
91
  requirement: &id006 !ruby/object:Gem::Requirement
92
92
  requirements:
@@ -97,6 +97,18 @@ dependencies:
97
97
  version: "0"
98
98
  type: :development
99
99
  version_requirements: *id006
100
+ - !ruby/object:Gem::Dependency
101
+ name: cucumber
102
+ prerelease: false
103
+ requirement: &id007 !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ type: :development
111
+ version_requirements: *id007
100
112
  description: A full-stack, full-stack MVC framework generator geared towards generating towards the Ext JS framework. The actual javascript framework implementation is provided by the Gem extjs-mvc. This gem contains a series of builders and erb-templates for auto-generating javascript model, view and controller class-files.
101
113
  email: christocracy@gmail.com
102
114
  executables:
@@ -113,17 +125,9 @@ files:
113
125
  - VERSION
114
126
  - bin/xmvc
115
127
  - lib/xmvc.rb
116
- - lib/xmvc/README
117
128
  - lib/xmvc/api.rb
118
129
  - lib/xmvc/builder.rb
119
- - lib/xmvc/builders/all_builder.rb
120
- - lib/xmvc/builders/app_builder.rb
121
- - lib/xmvc/builders/base.rb
122
- - lib/xmvc/builders/css_builder.rb
123
130
  - lib/xmvc/builders/docs_builder.rb
124
- - lib/xmvc/builders/mvc_builder.rb
125
- - lib/xmvc/builders/plugin_builder.rb
126
- - lib/xmvc/builders/vendor.rb
127
131
  - lib/xmvc/cli.rb
128
132
  - lib/xmvc/config.rb
129
133
  - lib/xmvc/generator.rb
@@ -182,7 +186,6 @@ files:
182
186
  - lib/xmvc/generators/view.rb
183
187
  - lib/xmvc/helpers.rb
184
188
  - lib/xmvc/helpers/sprockets.rb
185
- - lib/xmvc/plugin.rb
186
189
  - lib/xmvc/stats.rb
187
190
  - lib/xmvc/test.rb
188
191
  - lib/xmvc/testserver.ru
@@ -190,8 +193,22 @@ files:
190
193
  - lib/xmvc/update.rb
191
194
  - lib/xmvc/vendor.rb
192
195
  - lib/xmvc/vendor/plugin.rb
196
+ - test/app/public/javascripts/valid_vendor/valid_vendor-all-debug.js
197
+ - test/app/test/app/vendor/ext/vendor.yml
198
+ - test/app/vendor/ext/vendor.yml
199
+ - test/app/vendor/valid_vendor/src/ValidVendor.js
200
+ - test/app/vendor/valid_vendor/vendor.yml
193
201
  - test/helper.rb
194
- - test/test_extjs-core.rb
202
+ - test/lib/invalid_vendor/invalid_vendor.rb
203
+ - test/lib/invalid_vendor/src/InvalidVendor.js
204
+ - test/lib/nameless_vendor/nameless_vendor.rb
205
+ - test/lib/nameless_vendor/src/ValidVendor.js
206
+ - test/lib/nameless_vendor/vendor.yml
207
+ - test/lib/valid_vendor/src/ValidVendor.js
208
+ - test/lib/valid_vendor/valid_vendor.rb
209
+ - test/lib/valid_vendor/vendor.yml
210
+ - test/test_app_installer.rb
211
+ - test/test_vendor_installer.rb
195
212
  has_rdoc: true
196
213
  homepage: http://github.com/christocracy/extjs-core
197
214
  licenses: []
@@ -224,4 +241,8 @@ specification_version: 3
224
241
  summary: A Rails-like, full-stack MVC framework generator geared towards generating towards the Ext JS framework.
225
242
  test_files:
226
243
  - test/helper.rb
227
- - test/test_extjs-core.rb
244
+ - test/lib/invalid_vendor/invalid_vendor.rb
245
+ - test/lib/nameless_vendor/nameless_vendor.rb
246
+ - test/lib/valid_vendor/valid_vendor.rb
247
+ - test/test_app_installer.rb
248
+ - test/test_vendor_installer.rb
data/lib/xmvc/README DELETED
@@ -1,20 +0,0 @@
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
-
@@ -1,13 +0,0 @@
1
- module Xmvc
2
- class AllBuilder < Builder
3
- def self.instances(args = [])
4
- # set defaults
5
- args = ['app', 'css', 'plugin', 'mvc'] if args.empty?
6
- instances = []
7
-
8
- #args.each {|builderName| instances.concat(ExtMVC::BuilderManager.instances_for(builderName, []))}
9
-
10
- return instances
11
- end
12
- end
13
- end
@@ -1,36 +0,0 @@
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