shattered 0.4.0.1 → 0.5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/lib/game_loader.rb +89 -8
  2. data/lib/rails_generator.rb +1 -1
  3. data/lib/rails_generator/base.rb +3 -3
  4. data/lib/rails_generator/commands.rb +91 -17
  5. data/lib/rails_generator/generators/applications/shattered_app/shattered_app_generator.rb +12 -12
  6. data/lib/rails_generator/generators/components/state/templates/state.rb +17 -0
  7. data/lib/rails_generator/generators/components/view/templates/view.rb +5 -2
  8. data/lib/rails_generator/lookup.rb +18 -17
  9. data/lib/rails_generator/manifest.rb +1 -1
  10. data/lib/rails_generator/options.rb +18 -10
  11. data/lib/rails_generator/scripts.rb +4 -4
  12. data/lib/rails_generator/simple_logger.rb +2 -2
  13. data/lib/rails_generator/spec.rb +1 -1
  14. data/lib/shatter.rb +1 -1
  15. data/lib/tasks/documentation.rake +46 -0
  16. data/lib/tasks/framework.rake +84 -0
  17. data/lib/tasks/log.rake +9 -0
  18. data/lib/tasks/misc.rake +4 -0
  19. data/lib/tasks/pre_namespace_aliases.rake +28 -0
  20. data/lib/tasks/shattered.rb +6 -0
  21. data/lib/tasks/statistics.rake +17 -0
  22. data/lib/tasks/testing.rake +102 -0
  23. data/lib/templates/Rakefile +4 -8
  24. data/lib/templates/configs/ogre_plugins.windows.cfg +14 -0
  25. data/lib/templates/environments/environment.rb +5 -2
  26. metadata +44 -53
  27. data/lib/templates/configs/Mac/shattered.app/Contents/Info.plist +0 -22
  28. data/lib/templates/configs/Mac/shattered.app/Contents/MacOS/shattered_mac +0 -0
  29. data/lib/templates/configs/Mac/shattered.app/Contents/PkgInfo +0 -1
  30. data/lib/templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/InfoPlist.strings +0 -0
  31. data/lib/templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib +0 -4
  32. data/lib/templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib +0 -20
  33. data/lib/templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/objects.nib +0 -0
  34. data/lib/templates/configs/Mac/shattered.app/Contents/Resources/rb_main.rb +0 -3
  35. data/lib/templates/configs/Mac/shattered.app/Contents/pbdevelopment.plist +0 -8
  36. data/lib/templates/configs/Mac/shattered.app/OgreLeaks.log +0 -144
  37. data/lib/templates/configs/Mac/shattered.app/OgreMemory.log +0 -29
  38. data/lib/templates/configs/ogre_plugins.rcfg +0 -16
@@ -1,4 +1,4 @@
1
- module Rails #:nodoc:all
1
+ module Rails
2
2
  module Generator
3
3
 
4
4
  # Manifest captures the actions a generator performs. Instantiate
@@ -1,10 +1,9 @@
1
1
  require 'optparse'
2
2
 
3
- module Rails #:nodoc:all
3
+ module Rails
4
4
  module Generator
5
5
  module Options
6
- def self.append_features(base)
7
- super
6
+ def self.included(base)
8
7
  base.extend(ClassMethods)
9
8
  class << base
10
9
  if respond_to?(:inherited)
@@ -96,8 +95,8 @@ module Rails #:nodoc:all
96
95
 
97
96
  # Raise a usage error. Override usage_message to provide a blurb
98
97
  # after the option parser summary.
99
- def usage
100
- raise UsageError, "#{@option_parser}\n#{usage_message}"
98
+ def usage(message = usage_message)
99
+ raise UsageError, "#{@option_parser}\n#{message}"
101
100
  end
102
101
 
103
102
  def usage_message
@@ -118,16 +117,25 @@ module Rails #:nodoc:all
118
117
 
119
118
  # Adds general options like -h and --quiet. Usually don't override.
120
119
  def add_general_options!(opt)
120
+ opt.separator ''
121
+ opt.separator 'Rails Info:'
122
+ opt.on('-v', '--version', 'Show the Rails version number and quit.')
123
+ opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
124
+
121
125
  opt.separator ''
122
126
  opt.separator 'General Options:'
123
127
 
124
- opt.on('-p', '--pretend', 'Run but do not make any changes.') { |options[:pretend]| }
128
+ opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
125
129
  opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
126
130
  opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
127
- opt.on('-q', '--quiet', 'Suppress normal output.') { |options[:quiet]| }
128
- opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |options[:backtrace]| }
129
- opt.on('-h', '--help', 'Show this help message.') { |options[:help]| }
130
- opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') { options[:svn] = Hash[*`svn status`.collect { |e| e.chop.split.reverse unless e.chop.split.size != 2 }.flatten] }
131
+ opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
132
+ opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
133
+ opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
134
+ options[:svn] = `svn status`.inject({}) do |opt, e|
135
+ opt[e.chomp[7..-1]] = true
136
+ opt
137
+ end
138
+ end
131
139
  end
132
140
 
133
141
  end
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/options'
2
2
 
3
- module Rails #:nodoc:all
3
+ module Rails
4
4
  module Generator
5
5
  module Scripts
6
6
 
@@ -38,7 +38,7 @@ module Rails #:nodoc:all
38
38
  protected
39
39
  # Override with your own script usage banner.
40
40
  def banner
41
- "Usage: #{$0} [options] generator [args]"
41
+ "Usage: #{$0} generator [options] [args]"
42
42
  end
43
43
 
44
44
  def usage_message
@@ -69,8 +69,8 @@ end_blurb
69
69
  #{$0} login
70
70
 
71
71
  Generator gems are also available:
72
- 1. gem list generator -s http://gems.rubyonrails.org
73
- 2. gem install login_generator -s http://gems.rubyonrails.org
72
+ 1. gem search -r generator
73
+ 2. gem install login_generator
74
74
  3. #{$0} login
75
75
 
76
76
  end_blurb
@@ -1,6 +1,6 @@
1
- module Rails #:nodoc:all
1
+ module Rails
2
2
  module Generator
3
- class SimpleLogger
3
+ class SimpleLogger # :nodoc:
4
4
  attr_reader :out
5
5
  attr_accessor :quiet
6
6
 
@@ -1,4 +1,4 @@
1
- module Rails #:nodoc:all
1
+ module Rails
2
2
  module Generator
3
3
  # A spec knows where a generator was found and how to instantiate it.
4
4
  # Metadata include the generator's name, its base path, and the source
@@ -1,4 +1,4 @@
1
- ["shattered_support", "shattered_ogre", "shattered_pack"].each do |component|
1
+ ["shattered_support", "shattered_ogrerb", "shattered_pack"].each do |component|
2
2
  lib_path = File.expand_path(File.dirname(__FILE__)+"/../../#{component}/lib")
3
3
  $: << lib_path if File.directory? lib_path
4
4
  require component
@@ -0,0 +1,46 @@
1
+ namespace :doc do
2
+ desc "Generate documentation for the application"
3
+ Rake::RDocTask.new("app") { |rdoc|
4
+ rdoc.rdoc_dir = 'doc/app'
5
+ rdoc.title = "Shattered Game Documentation"
6
+ rdoc.options << '--line-numbers' << '--inline-source'
7
+ rdoc.rdoc_files.include('doc/README_FOR_APP')
8
+ rdoc.rdoc_files.include('app/**/*.rb')
9
+ }
10
+
11
+ plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
12
+
13
+ desc "Generate documation for all installed plugins"
14
+ task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }
15
+
16
+ desc "Remove plugin documentation"
17
+ task :clobber_plugins do
18
+ rm_rf 'doc/plugins' rescue nil
19
+ end
20
+
21
+ namespace :plugins do
22
+ # Define doc tasks for each plugin
23
+ plugins.each do |plugin|
24
+ task(plugin => :environment) do
25
+ plugin_base = "vendor/plugins/#{plugin}"
26
+ options = []
27
+ files = Rake::FileList.new
28
+ options << "-o doc/plugins/#{plugin}"
29
+ options << "--title '#{plugin.titlecase} Plugin Documentation'"
30
+ options << '--line-numbers' << '--inline-source'
31
+ options << '-T html'
32
+
33
+ files.include("#{plugin_base}/lib/**/*.rb")
34
+ if File.exists?("#{plugin_base}/README")
35
+ files.include("#{plugin_base}/README")
36
+ options << "--main '#{plugin_base}/README'"
37
+ end
38
+ files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG")
39
+
40
+ options << files.to_s
41
+
42
+ sh %(rdoc #{options * ' '})
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,84 @@
1
+ namespace :shattered do
2
+ namespace :freeze do
3
+ desc "Lock this application to the current gems (by unpacking them into vendor/rails)"
4
+ task :gems do
5
+ deps = %w(shatter shattered_pack shattered_ogre)
6
+ require 'rubygems'
7
+ Gem.manage_gems
8
+
9
+ shattered = (version = ENV['VERSION']) ?
10
+ Gem.cache.search('shattered', "= #{version}").first :
11
+ Gem.cache.search('shattered').sort_by { |g| g.version }.last
12
+
13
+ version ||= shattered.version
14
+
15
+ unless shattered
16
+ puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available."
17
+ exit
18
+ end
19
+
20
+ puts "Freezing to the gems for Rails #{rails.version}"
21
+ rm_rf "vendor/shattered"
22
+ mkdir_p "vendor/shattered"
23
+
24
+ chdir("vendor/shattered") do
25
+ shattered.dependencies.select { |g| deps.include? g.name }.each do |g|
26
+ Gem::GemRunner.new.run(["unpack", "-v", "#{g.version_requirements}", "#{g.name}"])
27
+ mv(Dir.glob("#{g.name}*").first, g.name)
28
+ end
29
+
30
+ Gem::GemRunner.new.run(["unpack", "-v", "=#{version}", "rails"])
31
+ FileUtils.mv(Dir.glob("rails*").first, "railties")
32
+ end
33
+ end
34
+
35
+ desc "Lock to latest Shattered Edge or a specific revision with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)"
36
+ task :edge do
37
+ $verbose = false
38
+ `svn --version` rescue nil
39
+ unless !$?.nil? && $?.success?
40
+ $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails"
41
+ exit 1
42
+ end
43
+
44
+ rm_rf "vendor/shattered"
45
+ mkdir_p "vendor/shattered"
46
+
47
+ svn_root = "http://svn.shatteredruby.com/"
48
+
49
+ if ENV['TAG']
50
+ shattered_svn = "#{svn_root}/tags/#{ENV['TAG']}"
51
+ touch "vendor/shattered/TAG_#{ENV['TAG']}"
52
+ else
53
+ shattered_svn = "#{svn_root}/trunk"
54
+
55
+ if ENV['REVISION'].nil?
56
+ ENV['REVISION'] = /^r(\d+)/.match(%x{svn -qr HEAD log #{svn_root}})[1]
57
+ puts "REVISION not set. Using HEAD, which is revision #{ENV['REVISION']}."
58
+ end
59
+
60
+ touch "vendor/shattered/REVISION_#{ENV['REVISION']}"
61
+ end
62
+
63
+ for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice )
64
+ system "svn export #{shattered_svn}/#{framework} vendor/shattered/#{framework}" + (ENV['REVISION'] ? " -r #{ENV['REVISION']}" : "")
65
+ end
66
+ end
67
+ end
68
+
69
+ desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
70
+ task :unfreeze do
71
+ rm_rf "vendor/shattered"
72
+ end
73
+
74
+ desc "Update both configs, scripts and public/javascripts from shattered"
75
+ task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
76
+
77
+ namespace :update do
78
+ desc "Update boot/config.rb from your current rails install"
79
+ task :configs do
80
+ require 'railties_path'
81
+ FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', SHATTERED_ROOT + '/config/boot.rb')
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,9 @@
1
+ namespace :log do
2
+ desc "Truncates all *.log files in log/ to zero bytes"
3
+ task :clear do
4
+ FileList["log/*.log"].each do |log_file|
5
+ f = File.open(log_file, "w")
6
+ f.close
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ task :default => :test
2
+ task :environment do
3
+ require(File.join(SHATTERED_ROOT, 'config', 'environment'))
4
+ end
@@ -0,0 +1,28 @@
1
+ # clear
2
+ task :clear_logs => "log:clear"
3
+
4
+ # test
5
+ task :recent => "test:recent"
6
+ task :test_units => "test:units"
7
+ task :test_functional => "test:functionals"
8
+ task :test_plugins => "test:plugins"
9
+
10
+
11
+ # doc
12
+ task :appdoc => "doc:app"
13
+ task :apidoc => "doc:rails"
14
+ task :plugindoc => "doc:plugins"
15
+ task :clobber_plugindoc => "doc:clobber_plugins"
16
+
17
+ FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }.each do |plugin|
18
+ task :"#{plugin}_plugindoc" => "doc:plugins:#{plugin}"
19
+ end
20
+
21
+
22
+ # rails
23
+ task :freeze_gems => "rails:freeze:gems"
24
+ task :freeze_edge => "rails:freeze:edge"
25
+ task :unfreeze_rails => "rails:unfreeze"
26
+ task :add_new_scripts => "rails:update:scripts"
27
+ task :update_javascripts => "rails:update:javascripts"
28
+
@@ -0,0 +1,6 @@
1
+ # Load Rails rakefile extensions
2
+ Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
3
+
4
+ # Load any custom rakefile extensions
5
+ Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext }
6
+ Dir["./vendor/plugins/*/tasks/**/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,17 @@
1
+ STATS_DIRECTORIES = [
2
+ %w(Helpers app/helpers),
3
+ %w(Controllers app/controllers),
4
+ %w(APIs app/apis),
5
+ %w(Components components),
6
+ %w(Functional\ tests test/functional),
7
+ %w(Models app/models),
8
+ %w(Unit\ tests test/unit),
9
+ %w(Libraries lib/),
10
+ %w(Integration\ tests test/integration)
11
+ ].collect { |name, dir| [ name, "#{SHATTERED_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
12
+
13
+ desc "Report code statistics (KLOCs, etc) from the application"
14
+ task :stats do
15
+ require 'code_statistics'
16
+ CodeStatistics.new(*STATS_DIRECTORIES).to_s
17
+ end
@@ -0,0 +1,102 @@
1
+ TEST_CHANGES_SINCE = Time.now - 600
2
+
3
+ # Look up tests for recently modified sources.
4
+ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
5
+ FileList[source_pattern].map do |path|
6
+ if File.mtime(path) > touched_since
7
+ test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
8
+ test if File.exists?(test)
9
+ end
10
+ end.compact
11
+ end
12
+
13
+
14
+ # Recreated here from ActiveSupport because :uncommitted needs it before Rails is available
15
+ module Kernel
16
+ def silence_stderr
17
+ old_stderr = STDERR.dup
18
+ STDERR.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
19
+ STDERR.sync = true
20
+ yield
21
+ ensure
22
+ STDERR.reopen(old_stderr)
23
+ end
24
+ end
25
+
26
+ desc 'Test all units and functionals'
27
+ task :test do
28
+ Rake::Task["test:units"].invoke rescue got_error = true
29
+ Rake::Task["test:functionals"].invoke rescue got_error = true
30
+
31
+ if File.exist?("test/integration")
32
+ Rake::Task["test:integration"].invoke rescue got_error = true
33
+ end
34
+
35
+ raise "Test failures" if got_error
36
+ end
37
+
38
+ namespace :test do
39
+ desc 'Test recent changes'
40
+ Rake::TestTask.new(:recent) do |t|
41
+ since = TEST_CHANGES_SINCE
42
+ touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
43
+ recent_tests('app/models/*.rb', 'test/unit', since) +
44
+ recent_tests('app/controllers/*.rb', 'test/functional', since)
45
+
46
+ t.libs << 'test'
47
+ t.verbose = true
48
+ t.test_files = touched.uniq
49
+ end
50
+
51
+ desc 'Test changes since last checkin (only Subversion)'
52
+ Rake::TestTask.new(:uncommitted) do |t|
53
+ def t.file_list
54
+ changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
55
+
56
+ models = changed_since_checkin.select { |path| path =~ /app\/models\/.*\.rb/ }
57
+ controllers = changed_since_checkin.select { |path| path =~ /app\/controllers\/.*\.rb/ }
58
+
59
+ unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
60
+ functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
61
+
62
+ unit_tests.uniq + functional_tests.uniq
63
+ end
64
+
65
+ t.libs << 'test'
66
+ t.verbose = true
67
+ end
68
+
69
+ desc "Run the unit tests in test/unit"
70
+ Rake::TestTask.new(:units) do |t|
71
+ t.libs << "test"
72
+ t.pattern = 'test/unit/**/*_test.rb'
73
+ t.verbose = true
74
+ end
75
+
76
+ desc "Run the functional tests in test/functional"
77
+ Rake::TestTask.new(:functionals) do |t|
78
+ t.libs << "test"
79
+ t.pattern = 'test/functional/**/*_test.rb'
80
+ t.verbose = true
81
+ end
82
+
83
+ desc "Run the integration tests in test/integration"
84
+ Rake::TestTask.new(:integration) do |t|
85
+ t.libs << "test"
86
+ t.pattern = 'test/integration/**/*_test.rb'
87
+ t.verbose = true
88
+ end
89
+
90
+ desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
91
+ Rake::TestTask.new(:plugins => :environment) do |t|
92
+ t.libs << "test"
93
+
94
+ if ENV['PLUGIN']
95
+ t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
96
+ else
97
+ t.pattern = 'vendor/plugins/**/test/**/*_test.rb'
98
+ end
99
+
100
+ t.verbose = true
101
+ end
102
+ end
@@ -1,15 +1,11 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
3
-
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+ # Or in plugins/*/tasks/**/*.rake
4
4
  require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
5
 
6
6
  require 'rake'
7
7
  require 'rake/testtask'
8
8
  require 'rake/rdoctask'
9
9
 
10
- desc "Run the unit tests in test/unit"
11
- Rake::TestTask.new(:test) do |t|
12
- t.libs << "test"
13
- t.pattern = 'test/unit/**/*_test.rb'
14
- t.verbose = true
15
- end
10
+ require 'tasks/shattered'
11
+
@@ -0,0 +1,14 @@
1
+ # Defines plugins to load
2
+
3
+ # Define plugin folder
4
+ PluginFolder=.
5
+
6
+ # Define D3D rendering implementation plugin
7
+ #Plugin=RenderSystem_GL
8
+ #Plugin=RenderSystem_Direct3D7
9
+ Plugin=RenderSystem_Direct3D9
10
+ Plugin=Plugin_ParticleFX
11
+ Plugin=Plugin_BSPSceneManager
12
+ Plugin=Plugin_OctreeSceneManager
13
+ #Plugin=Plugin_CgProgramManager
14
+