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
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Christocracy
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
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = extjs-core
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
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)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Christocracy. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "xmvc"
8
+ gem.summary = %Q{A Rails-like, full-stack MVC framework generator geared towards generating towards the Ext JS framework.}
9
+ gem.description = %Q{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.}
10
+ gem.email = "christocracy@gmail.com"
11
+ gem.homepage = "http://github.com/christocracy/extjs-core"
12
+ gem.authors = ["Ed Spencer and Chris Scott"]
13
+
14
+ gem.add_dependency "extlib", ">=0.9.14"
15
+ gem.add_dependency "thor", ">=0.13.0"
16
+ gem.add_dependency "jammit-core", ">=0.1.0"
17
+ gem.add_dependency "whorm", ">=0.1.0"
18
+ gem.add_dependency "hpricot", ">=0.8.2"
19
+ gem.add_dependency "extjs-mvc", ">=0.4.0.a"
20
+
21
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
22
+ # gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
23
+
24
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
25
+ end
26
+ Jeweler::GemcutterTasks.new
27
+ rescue LoadError
28
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
29
+ end
30
+
31
+ require 'rake/testtask'
32
+ Rake::TestTask.new(:test) do |test|
33
+ test.libs << 'lib' << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+
38
+ begin
39
+ require 'rcov/rcovtask'
40
+ Rcov::RcovTask.new do |test|
41
+ test.libs << 'test'
42
+ test.pattern = 'test/**/test_*.rb'
43
+ test.verbose = true
44
+ end
45
+ rescue LoadError
46
+ task :rcov do
47
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
48
+ end
49
+ end
50
+
51
+ task :test => :check_dependencies
52
+
53
+ task :default => :test
54
+
55
+ require 'rake/rdoctask'
56
+ Rake::RDocTask.new do |rdoc|
57
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
58
+
59
+ rdoc.rdoc_dir = 'rdoc'
60
+ rdoc.title = "extjs-mvc-gem #{version}"
61
+ rdoc.rdoc_files.include('README*')
62
+ rdoc.rdoc_files.include('lib/**/*.rb')
63
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
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 'xmvc'
6
+ require 'xmvc/cli'
7
+
8
+ begin
9
+ Xmvc::CLI.start
10
+ rescue Xmvc::Error => e
11
+ Xmvc.ui.error(e.message)
12
+ exit e.status_code
13
+ end
data/lib/xmvc/README ADDED
@@ -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,72 @@
1
+ module Xmvc
2
+ class BuilderManager
3
+ class << self
4
+
5
+ def dispatch(name, *params)
6
+ name = name.to_sym
7
+ options = params.shift || {}
8
+ case name
9
+ when :setup
10
+ setup(options)
11
+ else
12
+ begin
13
+ @jammit = jammit(options)
14
+ @jammit.invoke(:build, [name])
15
+ rescue Jammit::Error => e
16
+ raise Xmvc::BuilderError.new(e.message)
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def setup(options)
24
+ begin
25
+ ##
26
+ # Invoke jammit init app-name so that Jammit creates it's config/assets.yml
27
+ # Note that we must pass-in the name of the newly created app @name so that
28
+ # Jammit appends that to its config_path, otherwise it would create its config file
29
+ # in the pwd.
30
+
31
+ @asset_root = options[:asset_root] || File.expand_path('.')
32
+
33
+ app_assets
34
+
35
+ jammit = Jammit::CLI.new([], options)
36
+ jammit.invoke(:init)
37
+ jammit.invoke(:config, ["set", "javascripts", {
38
+ "mvc" => mvc_assets,
39
+ "app" => app_assets
40
+ }])
41
+ jammit.invoke(:build)
42
+
43
+ rescue Jammit::Error => e
44
+ raise Xmvc::BuilderError.new(e.message)
45
+ end
46
+ end
47
+
48
+ def jammit(options={})
49
+ Jammit::CLI.new([], options)
50
+ end
51
+
52
+ def mvc_assets
53
+ YAML.load(File.read(File.join(@asset_root, 'vendor', 'mvc', 'build'))).map {|f|
54
+ File.join('vendor', 'mvc', f)
55
+ }
56
+ end
57
+
58
+ def app_assets
59
+ [
60
+ 'app/App.js',
61
+ 'config/application.js',
62
+ 'config/routes.js',
63
+ 'vendor/plugins/*/**.js',
64
+ 'overrides/*.js',
65
+ 'app/models/*.js',
66
+ 'app/controllers/*.js',
67
+ 'app/views/*/**.js'
68
+ ]
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,13 @@
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
@@ -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,34 @@
1
+ module Xmvc
2
+ class CssBuilder < Builder
3
+ #def self.instances(args = [])
4
+ # [ExtMVC::CssBuilder.new]
5
+ #end
6
+
7
+ def file_list
8
+ # build to production environment
9
+ #environment = ExtMVC.mvc_development_environment
10
+
11
+ #return ExtJS::MVC.css_files_for(environment)
12
+ end
13
+
14
+ def name
15
+ "Ext MVC Application Stylesheets"
16
+ end
17
+
18
+ def message
19
+ "Built #{name}"
20
+ end
21
+
22
+ def description
23
+ "Your #{name}"
24
+ end
25
+
26
+ def output_filename
27
+ "public/stylesheets/application-all.css"
28
+ end
29
+
30
+ def directory_name
31
+ "public/stylesheets/"
32
+ end
33
+ end
34
+ 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
@@ -0,0 +1,53 @@
1
+ module ExtJS
2
+ module MVC
3
+ class PluginBuilder < Builder
4
+ # returns an array of PluginBuilder instances based on input from the command line.
5
+ # The sole argument should be an array, where the first element will usually be a plugin name, or 'all'
6
+ def self.instances(args = [])
7
+ name = args[0] || 'all'
8
+
9
+ if name == 'all'
10
+ self.all_plugin_names.collect {|name| ExtMVC::PluginBuilder.new(name)}
11
+ else
12
+ [ExtMVC::PluginBuilder.new(name)]
13
+ end
14
+ end
15
+
16
+ attr_accessor :name
17
+
18
+ def initialize(name)
19
+ @name = name
20
+ end
21
+
22
+ def output_filename
23
+ "#{directory_name}/#{name}-all.js"
24
+ end
25
+
26
+ def message
27
+ "Built the #{name} plugin"
28
+ end
29
+
30
+ def description
31
+ "The #{name} plugin (#{directory_name})"
32
+ end
33
+
34
+ def directory_name
35
+ "#{ExtMVC::PluginBuilder.plugins_directory}/#{@name}"
36
+ end
37
+
38
+ # The plugins directory, relative to the directory the build command is run from
39
+ def self.plugins_directory
40
+ "vendor/plugins"
41
+ end
42
+
43
+ private
44
+
45
+ #Gets the name of each plugin directory inside vendor/plugins and calls self.plugin with it
46
+ def self.all_plugin_names
47
+ Dir.entries(self.plugins_directory).select {|fileName|
48
+ File.directory?("#{self.plugins_directory}/#{fileName}") && (fileName =~ /^\./) != 0
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
data/lib/xmvc/cli.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'thor'
2
+
3
+ require 'jammit-core'
4
+ require 'jammit-core/cli'
5
+
6
+ module Xmvc
7
+ class CLI < Thor
8
+ ARGV = ::ARGV.dup
9
+
10
+ desc "install", "Install a framework"
11
+ def install(path)
12
+ Xmvc.ui.confirm('install')
13
+ end
14
+
15
+ desc "generate", "Generate model, controller, view or app"
16
+ def generate(which, *params)
17
+ Xmvc.ensure_in_app unless which == 'app'
18
+ Xmvc::Generator.dispatch(which, *params)
19
+ end
20
+
21
+ desc "build", "Build stuff"
22
+ def build(name = :all, *params)
23
+ Xmvc.ensure_in_app
24
+ Xmvc::BuilderManager.dispatch(name, *params)
25
+ end
26
+
27
+ desc "plugin", "Manage plugins"
28
+ def plugin
29
+ Xmvc.ensure_in_app
30
+ Xmvc::Plugin.new('Frak')
31
+ end
32
+
33
+ desc "stats", "View code statistics"
34
+ def stats
35
+ Xmvc.ensure_in_app
36
+ #Xmvc::Stats.new('Frak')
37
+ end
38
+
39
+ desc "namespace", "Change the application's namespace"
40
+ def namespace(name)
41
+ Xmvc.ensure_in_app
42
+ Xmvc::Generator.dispatch("namespace", name)
43
+ end
44
+
45
+ def initialize(args=ARGV, config={}, options={})
46
+ # Boot UI
47
+ Xmvc.ui = UI::Shell.new(shell)
48
+
49
+ # Boot environment
50
+ Xmvc.environment = Xmvc::Environment.new(:development)
51
+
52
+ super
53
+ end
54
+
55
+ private
56
+
57
+ end
58
+ end
@@ -0,0 +1,9 @@
1
+ module Xmvc
2
+ class Environment
3
+ attr_reader :environment
4
+ def initialize(environment)
5
+ @environment = environment
6
+ Xmvc.ui.info("(loaded #{@environment.to_s} environement)")
7
+ end
8
+ end
9
+ end