xmvc 0.1.7 → 0.1.8

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
data/lib/xmvc/api.rb CHANGED
@@ -15,11 +15,6 @@ module Xmvc
15
15
  Xmvc::Stats.dispatch
16
16
  end
17
17
 
18
- desc "config", "Return configuration"
19
- def config
20
- Xmvc::Config
21
- end
22
-
23
18
  desc "secretary", "Return Sprockets::Secretary for app javascripts"
24
19
  def secretary
25
20
  say_status "Xmvc::API", "secretary #{config[:root]}, #{FileUtils.pwd}"
data/lib/xmvc/builder.rb CHANGED
@@ -16,13 +16,13 @@ module Xmvc
16
16
  end
17
17
 
18
18
  desc "setup", "Initialize config file"
19
- def setup
20
- Xmvc.ui.warn("Builder setup")
21
-
19
+ def setup
22
20
  Xmvc.secretary = Sprockets::Secretary.new({})
23
21
  Xmvc.public_path = File.expand_path("public")
24
- host = Vendor.new([], {})
25
- host.invoke("app", [Xmvc.environment])
22
+ host = Vendor.new([], {
23
+ :environment => Xmvc.environment
24
+ })
25
+ host.invoke("app")
26
26
  end
27
27
 
28
28
  private
@@ -10,10 +10,6 @@ module Xmvc
10
10
  desc "app", "Build application-host's assets"
11
11
  def app(environment)
12
12
  pkgs = []
13
- each_vendor do |vendor|
14
- builder = Vendor.new([], {})
15
- builder.invoke("build", [vendor, pkgs])
16
- end
17
13
 
18
14
  Xmvc.secretary.reset!({
19
15
  :source_files => Xmvc::Config[:javascripts]
data/lib/xmvc/cli.rb CHANGED
@@ -55,12 +55,13 @@ module Xmvc
55
55
  Xmvc.host = host
56
56
  options.delete(:shell)
57
57
 
58
- Xmvc::Config.setup(options)
58
+ # New Vendors replaces host above
59
+ Xmvc.vendors = options.delete(:vendors)
59
60
 
61
+ Xmvc::Config.setup(options)
60
62
  Xmvc.config = Xmvc::Config
61
-
62
63
  Xmvc.environment = Xmvc::Config[:environment]
63
-
64
+
64
65
  super
65
66
  end
66
67
 
data/lib/xmvc/config.rb CHANGED
@@ -133,20 +133,18 @@ module Xmvc
133
133
  # TODO: load and merge! specific environemnt.
134
134
  #
135
135
  def load(environment)
136
- # When generating a new app, there is no environment yet
137
- #
138
- #unless File.exists?("#{DEFAULT_ENVIRONMENT}.yml")
139
- # raise FileNotFound.new("Failed to load environment #{DEFAULT_ENVIRONMENT}.yml")
140
- #end
141
- config = {}
136
+ config = {}
137
+ if File.exists?("vendor.yml")
138
+ config.merge!(YAML.load_file("vendor.yml"))
139
+ #raise Xmvc::Error.new("Xmvc::Config failed to find #{File.expand_path('.')}/vendor.yml")
140
+ end
142
141
  if File.exists? "config/environment.yml"
143
- config = YAML.load_file("config/environment.yml")
142
+ config.merge!(YAML.load_file("config/environment.yml"))
144
143
  end
145
144
  if File.exists? "config/environments/#{environment}.yml"
146
145
  config.merge!(YAML.load_file("config/environments/#{environment}.yml"))
147
146
  end
148
147
  config
149
-
150
148
  end
151
149
 
152
150
  def save
@@ -24,14 +24,6 @@ module Xmvc
24
24
  options = options.dup
25
25
 
26
26
  App.start(params, options)
27
- Xmvc::Config.setup
28
- #FXmvc.public_path = File.expand_path("./public")
29
-
30
- builder = Xmvc::Builder.new([], {})
31
- packages = builder.invoke(:setup, [])
32
-
33
- boot = Boot.new([], {})
34
- boot.invoke(:generate, [packages])
35
27
 
36
28
  when "model"
37
29
  model = Model.new([], options.dup)
@@ -17,11 +17,15 @@ module Xmvc
17
17
  FileUtils.chdir(name)
18
18
  end
19
19
 
20
+ def vendor_spec
21
+ copy_file("vendor.yml", "vendor.yml")
22
+ end
23
+
20
24
  def create_app
21
25
  empty_directory("app")
22
26
  inside("app", {}) do
23
27
  #copy_file("App.js", "#{destination_root}/App.js")
24
- directory("models", "models")
28
+ empty_directory("models")
25
29
  directory("views", "views")
26
30
  directory("controllers", "controllers")
27
31
  end
@@ -32,16 +36,16 @@ module Xmvc
32
36
  end
33
37
 
34
38
  def create_lib
35
- directory("lib", "lib")
39
+ empty_directory("lib")
36
40
  end
37
41
 
38
42
  def create_public
39
43
  empty_directory("public")
40
44
  inside("public", {}) do
41
45
  copy_file("index.html", "index.html")
42
- directory("images", "images")
46
+ empty_directory("images")
47
+ empty_directory("javascripts")
43
48
  directory("stylesheets", "stylesheets")
44
- directory("javascripts", "javascripts")
45
49
  end
46
50
 
47
51
  end
@@ -49,22 +53,28 @@ module Xmvc
49
53
  def create_spec
50
54
  directory("spec", "spec", :recursive => false)
51
55
  inside("spec", {}) do
52
- directory("models", "models")
53
- directory("controllers", "controllers")
56
+ empty_directory("models")
57
+ empty_directory("controllers")
54
58
  end
55
59
  end
56
60
 
57
61
  def create_vendor
58
62
  directory("vendor", "vendor")
59
- inside("vendor", {}) do
63
+ inside("vendor", {}) do |pwd|
60
64
  empty_directory("plugins")
61
- end
62
- end
63
-
64
- def install_host
65
- inside("vendor", {}) do |dir|
66
- host = Xmvc.host::API.new([], {})
67
- host.invoke(:install, [dir])
65
+
66
+ #host = Xmvc.host::API.new([], {})
67
+ #host.invoke(:install, [dir])
68
+
69
+ Xmvc.vendors.each do |vendor|
70
+ say_status("install", vendor)
71
+ api = vendor::API.new([], {
72
+ :root => pwd,
73
+ :format => :js,
74
+ :asset_root => "public"
75
+ })
76
+ api.invoke(:install)
77
+ end
68
78
  end
69
79
  end
70
80
 
@@ -73,6 +83,36 @@ module Xmvc
73
83
  # install vendor/plugins here
74
84
  end
75
85
  end
86
+
87
+ def environment
88
+ Xmvc::Config.setup
89
+ end
90
+
91
+ def boot
92
+ ##
93
+ # We want to get rid of Xmvc::Builder in favour of each vendor providing its own secretary
94
+ #
95
+ @vendors = []
96
+ asset_root = File.join(self.destination_root, "public")
97
+ inside "vendor" do |dir|
98
+ Xmvc.vendors.each do |vendor|
99
+ @vendors << vendor::API.new([], {
100
+ :root => dir,
101
+ :format => :js,
102
+ :asset_root => asset_root
103
+ })
104
+ end
105
+ end
106
+
107
+ boot = Xmvc::Generator::Boot.new([], {
108
+ :root => self.destination_root,
109
+ :vendors => @vendors
110
+ })
111
+ Xmvc.ui.warn("Disabled default bundling")
112
+ #boot.invoke(:default)
113
+
114
+ boot.invoke(:sprockets)
115
+ end
76
116
  end
77
117
  end
78
118
  end
@@ -9,8 +9,13 @@ module Xmvc
9
9
  File.join(Xmvc::TEMPLATE_PATH)
10
10
  end
11
11
 
12
- desc "generate", "Generate the config/boot.js file"
13
- def generate(packages)
12
+ desc "default", "Generate the default index.html with config/boot.js"
13
+ def default
14
+ puts "Boot default is disabled"
15
+ return false
16
+
17
+ #builder = Xmvc::Builder.new([], {})
18
+ #packages = builder.invoke(:setup, [])
14
19
 
15
20
  host = Xmvc.host.config["name"]
16
21
  @development = []
@@ -47,6 +52,37 @@ module Xmvc
47
52
  template("boot.js", "config/boot.js")
48
53
  end
49
54
 
55
+ desc "sprockets", "Generate a sprockets compatible index page"
56
+ def sprockets
57
+ @javascripts = []
58
+ @stylesheets = []
59
+ options[:vendors].each do |vendor|
60
+ config = vendor.invoke(:config)
61
+ if config["host"] # <-- Host as in http://extjs.cachefly.net/...
62
+ config["javascripts"].each do |script|
63
+ @javascripts << File.join(config["host"], script)
64
+ end
65
+ config["stylesheets"].each do |url|
66
+ @stylesheets << File.join(config["host"], url)
67
+ end
68
+ else
69
+ @javascripts << File.join("/sprockets", "#{config['name']}.js")
70
+ if config["stylesheets"] # <-- We wanna' use Sass!
71
+ config["stylesheets"].each do |url|
72
+ @stylesheets << File.join("/public", "stylesheets", config["name"], url)
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ # Finallly, add the xmvc assets (ie: controllers, models, views, plugins, etc)
79
+ @javascripts << File.join("/sprockets", "app.js")
80
+
81
+ # Application sass / css??
82
+
83
+ template("index.html.sprockets", "public/index.html.sprockets")
84
+ end
85
+
50
86
  private
51
87
 
52
88
  def url_for_path(path)
@@ -0,0 +1,9 @@
1
+ module Xmvc
2
+ module Builder
3
+ class Environment < Thor
4
+
5
+ end
6
+ end
7
+ end
8
+
9
+
@@ -33,7 +33,8 @@ config:
33
33
  # All stylesheets to be loaded. These are all taken to be relative to the public/stylesheets directory,
34
34
  # and the .css is automatically appended
35
35
  #
36
- stylesheets: []
36
+ stylesheets:
37
+ - extjs-mvc-all.css
37
38
 
38
39
  # Overrides to include. These files should be located in the config/overrides directory
39
40
  overrides: []
@@ -0,0 +1,72 @@
1
+ # General settings used by ruby scripts
2
+
3
+ namespace: MyApp
4
+
5
+ ##
6
+ # Directory paths
7
+ # Original from extmvc, used with javascript asset-manager in config/boot.js
8
+ #
9
+ pluginsDIr: /vendor/plugins
10
+ libsDir: /lib
11
+ configDir: /config
12
+ overridesDir: /config/overrides
13
+ appDir: /app
14
+ vendor:
15
+ - extjs-mvc
16
+ mvcFilename: extjs-mvc-all-min
17
+
18
+
19
+ # Use config/application for general framework configuration
20
+ config:
21
+ - application
22
+ - routes
23
+
24
+ ##
25
+ # Begin standard xmvc vendor-spec
26
+ #
27
+ name: app
28
+
29
+ javascripts:
30
+ - config/application.js
31
+ - config/routes.js
32
+ - vendor/plugins/*/**.js
33
+ - overrides/*.js
34
+ - app/models/*.js
35
+ - app/controllers/*.js
36
+ - app/views/*/**.js
37
+
38
+ ##
39
+ # All stylesheets to be loaded. These are all taken to be relative to the public/stylesheets directory,
40
+ # and the .css is automatically appended
41
+ #
42
+ stylesheets: []
43
+
44
+ # Overrides to include. These files should be located in the config/overrides directory
45
+ overrides: []
46
+
47
+ # Plugins to include. Each will load vendor/plugins/SomePlugin/SomePlugin-all.js
48
+ plugins: []
49
+
50
+ # All of the models in this application, found in the app/models folder
51
+ models: []
52
+
53
+ # All of the controllers in this application, found in the app/controllers folder
54
+ controllers:
55
+ - application
56
+ - home
57
+
58
+ # All of the views in this application, as an object with the subfolder inside app/views as the key,
59
+ # and an array of filenames as the value. e.g.:
60
+ # views:
61
+ # index:
62
+ # - index
63
+ # - edit
64
+ # - new
65
+ # - view
66
+ # will load /app/views/index/index.js and app/views/index/my_view.js
67
+ views:
68
+ - layout:
69
+ - menu
70
+ - home:
71
+ - index
72
+
File without changes
@@ -0,0 +1,25 @@
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
+ <% @stylesheets.each do |url| %>
7
+ <link href="<%= url %>" rel="stylesheet" type="text/css" />
8
+ <% end %>
9
+
10
+ <% @javascripts.each do |url| %>
11
+ <script type="text/javascript" src="<%= url %>"></script>
12
+ <% end %>
13
+
14
+ <title>Ext MVC Application</title>
15
+ </head>
16
+
17
+ <body>
18
+ <div id="loading-mask"></div>
19
+ <div id="loading">
20
+ <div class="loading-indicator">
21
+ Loading...
22
+ </div>
23
+ </div>
24
+ </body>
25
+ </html>
data/lib/xmvc.rb CHANGED
@@ -4,10 +4,6 @@ require 'yaml'
4
4
  require 'json'
5
5
  require 'extlib'
6
6
  require 'whorm'
7
-
8
- require 'jammit-core'
9
- require 'jammit-core/cli'
10
-
11
7
  require 'sprockets'
12
8
 
13
9
  module Xmvc
@@ -27,6 +23,12 @@ module Xmvc
27
23
  #
28
24
  require 'xmvc/builder'
29
25
  require 'xmvc/config'
26
+
27
+ ##
28
+ # load sprockets helper immediately so we can mix in right away
29
+ require 'xmvc/helpers/sprockets'
30
+ include Xmvc::Helpers::Sprockets
31
+
30
32
  #require 'xmvc/api' # <-- autoloadable ?? check with Sinatra handlers "sprockets"
31
33
  autoload :Vendor, 'xmvc/vendor'
32
34
  autoload :Helpers, 'xmvc/helpers'
@@ -56,12 +58,6 @@ module Xmvc
56
58
  class NoFramework < Error; status_code(6) ; end
57
59
  class HostError < Error; status_code(10) ; end
58
60
  class VendorFileNotFound < Error; status_code(11) ; end
59
-
60
- ##
61
- # Add more error classes here
62
- #
63
- #class GemfileNotFound < BundlerError; status_code(10) ; end
64
- #class GemNotFound < BundlerError; status_code(7) ; end
65
61
 
66
62
  class << self
67
63
  ##
@@ -75,8 +71,16 @@ module Xmvc
75
71
 
76
72
  ##
77
73
  # An instance of supplied framework plugin, eg ExtJS::MVC::CLI
74
+ # deprecate
78
75
  #
79
76
  attr_accessor :host
77
+
78
+ ##
79
+ # [Thor]
80
+ #
81
+ attr_accessor :vendors
82
+
83
+
80
84
  ##
81
85
  # An instance of the sprockets secretary
82
86
  #
@@ -84,6 +88,8 @@ module Xmvc
84
88
 
85
89
  attr_accessor :public_path
86
90
 
91
+ ##
92
+ # Xmvc::
87
93
  attr_writer :config
88
94
 
89
95
  ##
@@ -94,7 +100,8 @@ module Xmvc
94
100
  def public_build_path(type, name, version=nil, suffix=nil)
95
101
  File.join(public_path, asset_dir(type), build_name(type, name, version, suffix))
96
102
  end
97
-
103
+
104
+ # TODO Get rid of following obsolete
98
105
  def public_build_url(type, name, version=nil, suffix=nil)
99
106
  File.join("/#{PUBLIC_PATH}", asset_dir(type), build_name(type, name, version, suffix))
100
107
  end
@@ -117,6 +124,8 @@ module Xmvc
117
124
  "stylesheets"
118
125
  when :images
119
126
  "images"
127
+ when :sass
128
+ "sass"
120
129
  end
121
130
  end
122
131
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
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-15 00:00:00 -04:00
17
+ date: 2010-03-16 00:00:00 -04:00
18
18
  default_executable: xmvc
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -130,6 +130,7 @@ files:
130
130
  - lib/xmvc/generators/app.rb
131
131
  - lib/xmvc/generators/boot.rb
132
132
  - lib/xmvc/generators/controller.rb
133
+ - lib/xmvc/generators/environment.rb
133
134
  - lib/xmvc/generators/layout.rb
134
135
  - lib/xmvc/generators/model.rb
135
136
  - lib/xmvc/generators/scaffold.rb
@@ -153,6 +154,7 @@ files:
153
154
  - lib/xmvc/generators/templates/app/public/public/stylesheets/extjs-mvc-all.css
154
155
  - lib/xmvc/generators/templates/app/public/spec/SpecHelper.js
155
156
  - lib/xmvc/generators/templates/app/public/spec/index.html
157
+ - lib/xmvc/generators/templates/app/public/vendor.yml
156
158
  - lib/xmvc/generators/templates/app/public/vendor/screw-unit/EXAMPLE.html
157
159
  - lib/xmvc/generators/templates/app/public/vendor/screw-unit/LICENSE
158
160
  - lib/xmvc/generators/templates/app/public/vendor/screw-unit/README.markdown
@@ -173,6 +175,8 @@ files:
173
175
  - lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/suite.html
174
176
  - lib/xmvc/generators/templates/app/public/vendor/screw-unit/vendor.yml
175
177
  - lib/xmvc/generators/templates/boot.js
178
+ - lib/xmvc/generators/templates/index.html
179
+ - lib/xmvc/generators/templates/index.html.sprockets
176
180
  - lib/xmvc/generators/templates/layout.html.erb
177
181
  - lib/xmvc/generators/templates/scaffold/ScaffoldController.js
178
182
  - lib/xmvc/generators/view.rb