shattered_ruby 0.5.0.2
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/bin/console +4 -0
- data/bin/destroy +9 -0
- data/bin/generate +7 -0
- data/bin/runner +9 -0
- data/bin/shatter +22 -0
- data/lib/commands/console.rb +23 -0
- data/lib/game_loader.rb +118 -0
- data/lib/rails_generator/base.rb +203 -0
- data/lib/rails_generator/commands.rb +519 -0
- data/lib/rails_generator/generators/applications/shattered_app/USAGE +10 -0
- data/lib/rails_generator/generators/applications/shattered_app/shattered_app_generator.rb +103 -0
- data/lib/rails_generator/generators/components/actor/actor_generator.rb +22 -0
- data/lib/rails_generator/generators/components/actor/templates/actor.rb +0 -0
- data/lib/rails_generator/generators/components/model/USAGE +17 -0
- data/lib/rails_generator/generators/components/model/model_generator.rb +22 -0
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +5 -0
- data/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +11 -0
- data/lib/rails_generator/generators/components/state/USAGE +30 -0
- data/lib/rails_generator/generators/components/state/state_generator.rb +19 -0
- data/lib/rails_generator/generators/components/state/templates/state.rb +31 -0
- data/lib/rails_generator/generators/components/view/USAGE +30 -0
- data/lib/rails_generator/generators/components/view/templates/material +4 -0
- data/lib/rails_generator/generators/components/view/templates/view.rb +9 -0
- data/lib/rails_generator/generators/components/view/view_generator.rb +28 -0
- data/lib/rails_generator/lookup.rb +209 -0
- data/lib/rails_generator/manifest.rb +53 -0
- data/lib/rails_generator/options.rb +143 -0
- data/lib/rails_generator/scripts/destroy.rb +7 -0
- data/lib/rails_generator/scripts/generate.rb +7 -0
- data/lib/rails_generator/scripts/update.rb +12 -0
- data/lib/rails_generator/scripts.rb +83 -0
- data/lib/rails_generator/simple_logger.rb +46 -0
- data/lib/rails_generator/spec.rb +44 -0
- data/lib/rails_generator.rb +43 -0
- data/lib/shatter.rb +7 -0
- data/lib/tasks/documentation.rake +46 -0
- data/lib/tasks/framework.rake +80 -0
- data/lib/tasks/log.rake +9 -0
- data/lib/tasks/misc.rake +4 -0
- data/lib/tasks/pre_namespace_aliases.rake +28 -0
- data/lib/tasks/shattered.rb +6 -0
- data/lib/tasks/statistics.rake +17 -0
- data/lib/tasks/testing.rake +102 -0
- data/lib/templates/MIT-LICENSE +20 -0
- data/lib/templates/README +35 -0
- data/lib/templates/Rakefile +11 -0
- data/lib/templates/configs/boot.rb +35 -0
- data/lib/templates/configs/empty.log +0 -0
- data/lib/templates/configs/ogre.cfg +4 -0
- data/lib/templates/configs/ogre_plugins.windows.cfg +14 -0
- data/lib/templates/configs/runner.rb +5 -0
- data/lib/templates/doc/README_FOR_APP +2 -0
- data/lib/templates/environments/environment.rb +10 -0
- data/lib/templates/media/basic.rmaterial +18 -0
- data/lib/templates/media/default.mesh +0 -0
- data/lib/templates/media/default.png +0 -0
- data/lib/templates/media/offset_map.rmaterial +117 -0
- data/lib/templates/test/test_helper.rb +5 -0
- metadata +153 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/options'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generator
|
5
|
+
module Scripts
|
6
|
+
|
7
|
+
# Generator scripts handle command-line invocation. Each script
|
8
|
+
# responds to an invoke! class method which handles option parsing
|
9
|
+
# and generator invocation.
|
10
|
+
class Base
|
11
|
+
include Options
|
12
|
+
default_options :collision => :ask, :quiet => false
|
13
|
+
|
14
|
+
# Run the generator script. Takes an array of unparsed arguments
|
15
|
+
# and a hash of parsed arguments, takes the generator as an option
|
16
|
+
# or first remaining argument, and invokes the requested command.
|
17
|
+
def run(args = [], runtime_options = {})
|
18
|
+
begin
|
19
|
+
parse!(args.dup, runtime_options)
|
20
|
+
rescue OptionParser::InvalidOption => e
|
21
|
+
# Don't cry, script. Generators want what you think is invalid.
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generator name is the only required option.
|
25
|
+
unless options[:generator]
|
26
|
+
usage if args.empty?
|
27
|
+
options[:generator] ||= args.shift
|
28
|
+
end
|
29
|
+
|
30
|
+
# Look up generator instance and invoke command on it.
|
31
|
+
Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke!
|
32
|
+
rescue => e
|
33
|
+
puts e
|
34
|
+
puts " #{e.backtrace.join("\n ")}\n" if options[:backtrace]
|
35
|
+
raise SystemExit
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
# Override with your own script usage banner.
|
40
|
+
def banner
|
41
|
+
"Usage: #{$0} generator [options] [args]"
|
42
|
+
end
|
43
|
+
|
44
|
+
def usage_message
|
45
|
+
usage = "\nInstalled Generators\n"
|
46
|
+
Rails::Generator::Base.sources.each do |source|
|
47
|
+
label = source.label.to_s.capitalize
|
48
|
+
names = source.names
|
49
|
+
usage << " #{label}: #{names.join(', ')}\n" unless names.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
usage << <<end_blurb
|
53
|
+
|
54
|
+
More are available at http://rubyonrails.org/show/Generators
|
55
|
+
1. Download, for example, login_generator.zip
|
56
|
+
2. Unzip to directory #{Dir.user_home}/.rails/generators/login
|
57
|
+
to use the generator with all your Rails apps
|
58
|
+
end_blurb
|
59
|
+
|
60
|
+
if Object.const_defined?(:SHATTERED_ROOT)
|
61
|
+
usage << <<end_blurb
|
62
|
+
or to #{File.expand_path(SHATTERED_ROOT)}/generators/login
|
63
|
+
to use with this app only.
|
64
|
+
end_blurb
|
65
|
+
end
|
66
|
+
|
67
|
+
usage << <<end_blurb
|
68
|
+
3. Run generate with no arguments for usage information
|
69
|
+
#{$0} login
|
70
|
+
|
71
|
+
Generator gems are also available:
|
72
|
+
1. gem search -r generator
|
73
|
+
2. gem install login_generator
|
74
|
+
3. #{$0} login
|
75
|
+
|
76
|
+
end_blurb
|
77
|
+
return usage
|
78
|
+
end
|
79
|
+
end # Base
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generator
|
3
|
+
class SimpleLogger # :nodoc:
|
4
|
+
attr_reader :out
|
5
|
+
attr_accessor :quiet
|
6
|
+
|
7
|
+
def initialize(out = $stdout)
|
8
|
+
@out = out
|
9
|
+
@quiet = false
|
10
|
+
@level = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def log(status, message, &block)
|
14
|
+
@out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet
|
15
|
+
indent(&block) if block_given?
|
16
|
+
end
|
17
|
+
|
18
|
+
def indent(&block)
|
19
|
+
@level += 1
|
20
|
+
if block_given?
|
21
|
+
begin
|
22
|
+
block.call
|
23
|
+
ensure
|
24
|
+
outdent
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def outdent
|
30
|
+
@level -= 1
|
31
|
+
if block_given?
|
32
|
+
begin
|
33
|
+
block.call
|
34
|
+
ensure
|
35
|
+
indent
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def method_missing(method, *args, &block)
|
42
|
+
log(method.to_s, args.first, &block)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generator
|
3
|
+
# A spec knows where a generator was found and how to instantiate it.
|
4
|
+
# Metadata include the generator's name, its base path, and the source
|
5
|
+
# which yielded it (PathSource, GemSource, etc.)
|
6
|
+
class Spec
|
7
|
+
attr_reader :name, :path, :source
|
8
|
+
|
9
|
+
def initialize(name, path, source)
|
10
|
+
@name, @path, @source = name, path, source
|
11
|
+
end
|
12
|
+
|
13
|
+
# Look up the generator class. Require its class file, find the class
|
14
|
+
# in ObjectSpace, tag it with this spec, and return.
|
15
|
+
def klass
|
16
|
+
unless @klass
|
17
|
+
require class_file
|
18
|
+
@klass = lookup_class
|
19
|
+
@klass.spec = self
|
20
|
+
end
|
21
|
+
@klass
|
22
|
+
end
|
23
|
+
|
24
|
+
def class_file
|
25
|
+
"#{path}/#{name}_generator.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def class_name
|
29
|
+
"#{name.camelize}Generator"
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
# Search for the first Class descending from Rails::Generator::Base
|
34
|
+
# whose name matches the requested class name.
|
35
|
+
def lookup_class
|
36
|
+
ObjectSpace.each_object(Class) do |obj|
|
37
|
+
return obj if obj.ancestors.include?(Rails::Generator::Base) and
|
38
|
+
obj.name.split('::').last == class_name
|
39
|
+
end
|
40
|
+
raise NameError, "Missing #{class_name} class in #{class_file}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2004 Jeremy Kemper
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
$:.unshift(File.dirname(__FILE__))
|
25
|
+
$:.unshift(File.dirname(__FILE__) + "/../../shattered_support/lib")
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'shattered_support'
|
29
|
+
rescue LoadError
|
30
|
+
require 'rubygems'
|
31
|
+
require_gem 'shattered_support'
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'rails_generator/base'
|
35
|
+
require 'rails_generator/lookup'
|
36
|
+
require 'rails_generator/commands'
|
37
|
+
|
38
|
+
Rails::Generator::Base.send(:include, Rails::Generator::Lookup)
|
39
|
+
Rails::Generator::Base.send(:include, Rails::Generator::Commands)
|
40
|
+
|
41
|
+
# Set up a default logger for convenience.
|
42
|
+
require 'rails_generator/simple_logger'
|
43
|
+
Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT)
|
data/lib/shatter.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
["shattered_support", "shattered_ogrerb", "shattered_pack"].each do |component|
|
2
|
+
lib_path = File.expand_path(File.dirname(__FILE__)+"/../../#{component}/lib")
|
3
|
+
$: << lib_path if File.directory? lib_path
|
4
|
+
require component
|
5
|
+
end
|
6
|
+
|
7
|
+
require File.dirname(__FILE__) + '/game_loader'
|
@@ -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,80 @@
|
|
1
|
+
namespace :shattered do
|
2
|
+
namespace :freeze do
|
3
|
+
desc "Lock this application to the current gems (by unpacking them into vendor/Shattered)"
|
4
|
+
task :gems do
|
5
|
+
require 'rubygems'
|
6
|
+
Gem.manage_gems
|
7
|
+
|
8
|
+
version = ENV['VERSION'] || Gem.cache.search('shattered').sort_by { |g| g.version }[-1].version
|
9
|
+
|
10
|
+
gems = Gem.cache.search('shattered', "= #{version}")
|
11
|
+
|
12
|
+
if gems.length == 0
|
13
|
+
puts "No shattered gem #{version} is installed. Do 'gem list shattered' to see what you have available."
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "Freezing to the gems for shattered #{gems[0].version}"
|
18
|
+
rm_rf "vendor/shattered"
|
19
|
+
mkdir_p "vendor/shattered"
|
20
|
+
|
21
|
+
chdir("vendor/shattered") do
|
22
|
+
gems.reverse.each do |g|
|
23
|
+
puts g.name
|
24
|
+
Gem::GemRunner.new.run(["unpack", "-v", "#{g.version}", "#{g.name}"])
|
25
|
+
mv(Dir.glob("#{g.name}*").first, g.name)
|
26
|
+
end
|
27
|
+
mv(Dir.glob("shattered_ruby").first, "shatter")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
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)"
|
32
|
+
task :edge do
|
33
|
+
$verbose = false
|
34
|
+
`svn --version` rescue nil
|
35
|
+
unless !$?.nil? && $?.success?
|
36
|
+
$stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Shattered"
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
|
40
|
+
rm_rf "vendor/shattered"
|
41
|
+
mkdir_p "vendor/shattered"
|
42
|
+
|
43
|
+
svn_root = "http://svn.shatteredruby.com/"
|
44
|
+
|
45
|
+
if ENV['TAG']
|
46
|
+
shattered_svn = "#{svn_root}/tags/#{ENV['TAG']}"
|
47
|
+
touch "vendor/shattered/TAG_#{ENV['TAG']}"
|
48
|
+
else
|
49
|
+
shattered_svn = "#{svn_root}/trunk"
|
50
|
+
|
51
|
+
if ENV['REVISION'].nil?
|
52
|
+
ENV['REVISION'] = /^r(\d+)/.match(%x{svn -qr HEAD log #{svn_root}})[1]
|
53
|
+
puts "REVISION not set. Using HEAD, which is revision #{ENV['REVISION']}."
|
54
|
+
end
|
55
|
+
|
56
|
+
touch "vendor/shattered/REVISION_#{ENV['REVISION']}"
|
57
|
+
end
|
58
|
+
|
59
|
+
for framework in %w( shatter shattered_pack shattered_support shattered_ogrerb )
|
60
|
+
system "svn export #{shattered_svn}/trunk/#{framework} vendor/shattered/#{framework}" + (ENV['REVISION'] ? " -r #{ENV['REVISION']}" : "")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
|
66
|
+
task :unfreeze do
|
67
|
+
rm_rf "vendor/shattered"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Update both configs, scripts and public/javascripts from shattered"
|
71
|
+
task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
|
72
|
+
|
73
|
+
namespace :update do
|
74
|
+
desc "Update boot/config.rb from your current Shattered install"
|
75
|
+
task :configs do
|
76
|
+
require 'railties_path'
|
77
|
+
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', SHATTERED_ROOT + '/config/boot.rb')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/tasks/log.rake
ADDED
data/lib/tasks/misc.rake
ADDED
@@ -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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2004 David Heinemeier Hansson
|
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.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
== Description of contents
|
2
|
+
|
3
|
+
A large part of this is inspired (cp -R) by Rails. The fact that a web framework and a game framework have so much in common amazes me.
|
4
|
+
|
5
|
+
Each project is created with the following directory structure:
|
6
|
+
|
7
|
+
log/
|
8
|
+
Ogre.log - For Ogre's errors
|
9
|
+
Shattered.log - For all of shattered's messages
|
10
|
+
|
11
|
+
test/
|
12
|
+
Anything that matches /.*_test.rb/ will be executed when testing.
|
13
|
+
|
14
|
+
app/
|
15
|
+
models/
|
16
|
+
All models here.
|
17
|
+
controllers/
|
18
|
+
All model controllers(AI, keyboard) here.
|
19
|
+
views/
|
20
|
+
The views are here, each with a corresponding directory.
|
21
|
+
puppy_view.rb
|
22
|
+
puppy/
|
23
|
+
puppy.mesh
|
24
|
+
puppy.skeleton
|
25
|
+
puppy.material
|
26
|
+
puppy.png
|
27
|
+
puppy_normals.png
|
28
|
+
|
29
|
+
config/
|
30
|
+
Here you will define the ogre and other configuration
|
31
|
+
|
32
|
+
script/
|
33
|
+
This contains the generators/runners/executable scripts
|
34
|
+
doc/
|
35
|
+
The documentation in this directory will be generated by rails rdoc.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
# Or in plugins/*/tasks/**/*.rake
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/shattered'
|
11
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Don't change this file. Configuration is done in config/environment.rb
|
2
|
+
|
3
|
+
unless defined?(SHATTERED_ROOT)
|
4
|
+
root_path = File.join(File.dirname(__FILE__), '..')
|
5
|
+
|
6
|
+
unless RUBY_PLATFORM =~ /mswin32/
|
7
|
+
require 'pathname'
|
8
|
+
root_path = Pathname.new(root_path).cleanpath(true).to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
SHATTERED_ROOT = root_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_shattered_edge(path)
|
15
|
+
shatter_path = "#{path}/shatter/lib"
|
16
|
+
$: << shatter_path if File.directory? shatter_path
|
17
|
+
require 'rubygems'
|
18
|
+
require 'shatter'
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_plugins(path)
|
22
|
+
Dir.foreach(path) do |plugin|
|
23
|
+
next if plugin == ".." || plugin == "."
|
24
|
+
|
25
|
+
plugin_file = "#{path}/#{plugin}/init"
|
26
|
+
require plugin_file if File.exists? "#{plugin_file}.rb"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Load the plugins, and Shattered Edge, if present
|
31
|
+
load_shattered_edge("#{SHATTERED_ROOT}/vendor/shattered")
|
32
|
+
|
33
|
+
# Load the plugins
|
34
|
+
load_plugins("#{SHATTERED_ROOT}/vendor/plugins")
|
35
|
+
|
File without changes
|
@@ -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
|
+
|