shattered 0.3.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,4 @@
1
- #!/usr/bin/ruby18
2
- irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
1
+ #!/usr/bin/env ruby
3
2
 
4
- require 'optparse'
5
- options = { :sandbox => false, :irb => irb }
6
- OptionParser.new do |opt|
7
- opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| }
8
- opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |options[:irb]| }
9
- opt.parse!(ARGV)
10
- end
11
-
12
- libs = " -r irb/completion"
13
- libs << " -r #{File.dirname(__FILE__)}/../config/environment"
14
- libs << " -r console_sandbox" if options[:sandbox]
15
-
16
- if options[:sandbox]
17
- puts "Loading #{ENV['RAILS_ENV']} environment in sandbox."
18
- puts "Any modifications you make will be rolled back on exit."
19
- else
20
- puts "Loading #{ENV['RAILS_ENV']} environment."
21
- end
22
- exec "#{options[:irb]} #{libs} --prompt-mode simple"
3
+ require "#{File.dirname(__FILE__)}/../config/boot"
4
+ require "commands/console"
@@ -0,0 +1,23 @@
1
+ irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
2
+
3
+ require 'optparse'
4
+ options = { :sandbox => false, :irb => irb }
5
+ OptionParser.new do |opt|
6
+ opt.banner = "Usage: console [environment] [options]"
7
+ opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| }
8
+ opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |options[:irb]| }
9
+ opt.parse!(ARGV)
10
+ end
11
+
12
+ libs = " -r irb/completion"
13
+ libs << " -r #{SHATTERED_ROOT}/config/environment"
14
+ libs << " -r console_sandbox" if options[:sandbox]
15
+
16
+ ENV['SHATTERED_ENV'] = ARGV.first || ENV['SHATTERED_ENV'] || 'development'
17
+ if options[:sandbox]
18
+ puts "Loading #{ENV['SHATTER_ENV']} environment in sandbox."
19
+ puts "Any modifications you make will be rolled back on exit."
20
+ else
21
+ puts "Loading #{ENV['SHATTER_ENV']} environment."
22
+ end
23
+ exec "#{options[:irb]} #{libs} --simple-prompt"
@@ -19,20 +19,19 @@ class GameLoader
19
19
  end
20
20
  end
21
21
  def run
22
- view = ShatteredView::Runner.new @environment
23
- view.add_to_environment @environment
24
- control = ShatteredController::Runner.new(@environment)
25
- ShatteredPack::Configuration.environment=@environment
22
+ load_environment
26
23
  load_all_sources(SHATTERED_ROOT)
27
24
 
28
- begin
29
- require "#{SHATTERED_ROOT}/app/states/#{@environment[:start_state].to_s}_state"
30
- rescue StandardError => output
31
- puts output.message
32
- end
33
-
34
25
  eval("#{@environment[:start_state].to_s.camelize}State").new
35
- control.start_game
26
+
27
+ @control.start_game(@environment)
28
+ end
29
+ def load_environment
30
+ view = ShatteredView::Runner.new @environment
31
+ view.add_to_environment @environment
32
+ @control = ShatteredController::Runner.new(@environment)
33
+ ShatteredPack::Configuration.environment=@environment
34
+ return @environment
36
35
  end
37
36
  end
38
37
  end
@@ -45,7 +45,7 @@ class ShatteredAppGenerator < Rails::Generator::Base #:nodoc:all
45
45
  m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib"
46
46
  m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib"
47
47
  m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/objects.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/objects.nib"
48
- m.file "templates/configs/Mac/shattered.app/Contents/Resources/rb_main.rb", "config/Mac/shattered.app/Contents/Resources/rb_main.rb"
48
+ m.file "templates/configs/Mac/shattered.app/Contents/Resources/rb_main.rb", "config/Mac/shattered.app/Contents/Resources/rb_main.rb"
49
49
 
50
50
  # Scripts
51
51
  %w( generate runner console destroy ).each do |file|
@@ -63,8 +63,8 @@ class ShatteredAppGenerator < Rails::Generator::Base #:nodoc:all
63
63
  }
64
64
 
65
65
  # basic rmaterial
66
- m.file "templates/media/basic.rmaterial", "media/templates/basic.rmaterial"
67
- m.file "templates/media/offset_map.rmaterial", "media/templates/offset_map.rmaterial"
66
+ m.file "templates/media/basic.rmaterial", "app/media/common/templates/basic.rmaterial"
67
+ m.file "templates/media/offset_map.rmaterial", "app/media/common/templates/offset_map.rmaterial"
68
68
  end
69
69
  end
70
70
 
@@ -87,11 +87,10 @@ class ShatteredAppGenerator < Rails::Generator::Base #:nodoc:all
87
87
  # Installation skeleton. Intermediate directories are automatically
88
88
  # created so don't sweat their absence here.
89
89
  BASEDIRS = %w(
90
- app/controllers
91
90
  app/models
92
91
  app/views
93
- media/programs
94
- media/templates
92
+ app/media/common/programs
93
+ app/media/common/templates
95
94
  config/Mac/shattered.app/Contents/MacOS
96
95
  config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib
97
96
  doc
@@ -6,18 +6,17 @@
6
6
  # Rails::Generator::Scripts::Generate.new.run(ARGV)
7
7
  require File.dirname(__FILE__) + '/../model/model_generator'
8
8
  require File.dirname(__FILE__) + '/../view/view_generator'
9
- require File.dirname(__FILE__) + '/../controller/controller_generator'
10
9
 
11
10
  class ActorGenerator < Rails::Generator::NamedBase #:nodoc:
12
11
  def manifest
13
- model=["model", file_name]
14
- view=["view", file_name]
15
- controller=["controller", file_name]
16
- Rails::Generator::Scripts::Generate.new.run(model)
17
- Rails::Generator::Scripts::Generate.new.run(view)
18
- Rails::Generator::Scripts::Generate.new.run(controller)
19
-
20
- record do |m|
12
+ generators = [ModelGenerator, ViewGenerator]
13
+ record do |m|
14
+ generators.each do |generator|
15
+ generator.check_collisions(m, class_path, class_name)
16
+ end
17
+ generators.each do |generator|
18
+ generator.generate(m, class_path, file_name)
19
+ end
21
20
  end
22
21
  end
23
- end
22
+ end
@@ -1,16 +1,22 @@
1
1
  class ModelGenerator < Rails::Generator::NamedBase #:nodoc:
2
2
  def manifest
3
3
  record do |m|
4
- # Check for class naming collisions.
4
+ self.class.check_collisions(m, class_path, class_name)
5
+ self.class.generate(m, class_path, file_name)
6
+ end
7
+ end
8
+
9
+ def self.check_collisions(m, class_path, class_name)
10
+ # Check for class naming collisions.
5
11
  m.class_collisions class_path, class_name, "#{class_name}Test"
12
+ end
13
+ def self.generate(m, class_path, file_name)
14
+ # Model, test, and fixture directories.
15
+ m.directory File.join('app/models', class_path)
16
+ m.directory File.join('test/unit', class_path)
6
17
 
7
- # Model, test, and fixture directories.
8
- m.directory File.join('app/models', class_path)
9
- m.directory File.join('test/unit', class_path)
10
-
11
- # Model class, unit test, and fixtures.
12
- m.template 'model.rb', File.join('app/models', class_path, "#{file_name}_model.rb")
13
- m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
14
- end
18
+ # Model class, unit test, and fixtures.
19
+ m.template '../../model/templates/model.rb', File.join('app/models', class_path, "#{file_name}.rb")
20
+ m.template '../../model/templates/unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
15
21
  end
16
22
  end
@@ -1,2 +1,2 @@
1
- class <%= class_name %>Model < ShatteredModel::Base
1
+ class <%= class_name %> < ShatteredModel::Base
2
2
  end
@@ -1,3 +1,4 @@
1
1
  class <%= class_name %>View < ShatteredView::Base
2
- mesh "<%= file_name %>"
2
+ material "<%= file_name %>_material", :template => "basic", :texture => "<%= file_name %>.png"
3
+ mesh "<%= file_name %>", :material => :<%= file_name %>_material
3
4
  end
@@ -1,18 +1,28 @@
1
1
  class ViewGenerator < Rails::Generator::NamedBase #:nodoc:
2
2
  def manifest
3
3
  record do |m|
4
- # Check for class naming collisions.
4
+ self.class.check_collisions(m, class_path, class_name)
5
+ self.class.generate(m, class_path, file_name)
6
+ end
7
+ end
8
+
9
+ def self.check_collisions(m, class_path, class_name)
10
+ # Check for class naming collisions.
5
11
  m.class_collisions class_path, "#{class_name}View"
12
+ end
13
+ def self.generate(m, class_path, file_name)
14
+ # Controller, helper, views, and test directories.
15
+ m.directory File.join('app/views', class_path)
16
+ m.directory File.join('app/media', class_path, file_name)
6
17
 
7
- # Controller, helper, views, and test directories.
8
- m.directory File.join('app/views', class_path)
9
- m.directory File.join('app/views', class_path, file_name)
10
-
11
- # Controller class, functional test, and helper class.
12
- m.template 'view.rb',
13
- File.join('app/views',
14
- class_path,
15
- "#{file_name}_view.rb")
16
- end
18
+ # Controller class, functional test, and helper class.
19
+ m.template '../../view/templates/view.rb',
20
+ File.join('app/views',
21
+ class_path,
22
+ "#{file_name}_view.rb")
23
+ m.file "../../../../../templates/media/default.mesh",
24
+ File.join( 'app/media', class_path, file_name, "#{file_name}.mesh")
25
+ m.file "../../../../../templates/media/default.png",
26
+ File.join( 'app/media', class_path, file_name, "#{file_name}.png")
17
27
  end
18
28
  end
@@ -1,6 +1,15 @@
1
+ # Don't change this file. Configuration is done in config/environment.rb
1
2
 
2
- SHATTERED_ROOT = File.join(File.dirname(__FILE__), '..')
3
+ unless defined?(SHATTERED_ROOT)
4
+ root_path = File.join(File.dirname(__FILE__), '..')
3
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
4
13
 
5
14
  def load_shattered_edge(path)
6
15
  shatter_path = "#{path}/shatter/lib"
@@ -9,7 +18,6 @@ def load_shattered_edge(path)
9
18
  require 'shatter'
10
19
  end
11
20
 
12
-
13
21
  def load_plugins(path)
14
22
  Dir.foreach(path) do |plugin|
15
23
  next if plugin == ".." || plugin == "."
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: shattered
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.3
7
- date: 2006-07-18 00:00:00 -06:00
6
+ version: "0.4"
7
+ date: 2006-09-10 00:00:00 -06:00
8
8
  summary: "Shattered: The main package tieing together controller, view, and model"
9
9
  require_paths:
10
10
  - lib
@@ -33,11 +33,13 @@ files:
33
33
  - bin/generate
34
34
  - bin/runner
35
35
  - bin/shatter
36
+ - lib/commands
36
37
  - lib/game_loader.rb
37
38
  - lib/rails_generator
38
39
  - lib/rails_generator.rb
39
40
  - lib/shatter.rb
40
41
  - lib/templates
42
+ - lib/commands/console.rb
41
43
  - lib/rails_generator/base.rb
42
44
  - lib/rails_generator/commands.rb
43
45
  - lib/rails_generator/generators
@@ -54,17 +56,11 @@ files:
54
56
  - lib/rails_generator/generators/applications/shattered_app/shattered_app_generator.rb
55
57
  - lib/rails_generator/generators/applications/shattered_app/USAGE
56
58
  - lib/rails_generator/generators/components/actor
57
- - lib/rails_generator/generators/components/controller
58
59
  - lib/rails_generator/generators/components/model
59
60
  - lib/rails_generator/generators/components/state
60
61
  - lib/rails_generator/generators/components/view
61
62
  - lib/rails_generator/generators/components/actor/actor_generator.rb
62
- - lib/rails_generator/generators/components/controller/controller_generator.rb
63
- - lib/rails_generator/generators/components/controller/templates
64
- - lib/rails_generator/generators/components/controller/USAGE
65
- - lib/rails_generator/generators/components/controller/templates/controller.rb
66
- - lib/rails_generator/generators/components/controller/templates/functional_test.rb
67
- - lib/rails_generator/generators/components/controller/templates/view.rhtml
63
+ - lib/rails_generator/generators/components/actor/templates
68
64
  - lib/rails_generator/generators/components/model/model_generator.rb
69
65
  - lib/rails_generator/generators/components/model/templates
70
66
  - lib/rails_generator/generators/components/model/USAGE
@@ -118,6 +114,8 @@ files:
118
114
  - lib/templates/doc/README_FOR_APP
119
115
  - lib/templates/environments/environment.rb
120
116
  - lib/templates/media/basic.rmaterial
117
+ - lib/templates/media/default.mesh
118
+ - lib/templates/media/default.png
121
119
  - lib/templates/media/offset_map.rmaterial
122
120
  - lib/templates/test/test_helper.rb
123
121
  test_files: []
@@ -141,7 +139,7 @@ dependencies:
141
139
  requirements:
142
140
  - - ">="
143
141
  - !ruby/object:Gem::Version
144
- version: 0.3.3
142
+ version: "0.4"
145
143
  version:
146
144
  - !ruby/object:Gem::Dependency
147
145
  name: shattered_pack
@@ -150,7 +148,7 @@ dependencies:
150
148
  requirements:
151
149
  - - ">="
152
150
  - !ruby/object:Gem::Version
153
- version: 0.3.3
151
+ version: "0.4"
154
152
  version:
155
153
  - !ruby/object:Gem::Dependency
156
154
  name: shattered_support
@@ -159,5 +157,5 @@ dependencies:
159
157
  requirements:
160
158
  - - ">="
161
159
  - !ruby/object:Gem::Version
162
- version: 0.3.3
160
+ version: "0.4"
163
161
  version:
@@ -1,30 +0,0 @@
1
- Description:
2
- The controller generator creates stubs for a new controller and its views.
3
-
4
- The generator takes a controller name and a list of views as arguments.
5
- The controller name may be given in CamelCase or under_score and should
6
- not be suffixed with 'Controller'. To create a controller within a
7
- module, specify the controller name as 'module/controller'.
8
-
9
- The generator creates a controller class in app/controllers with view
10
- templates in app/views/controller_name, a helper class in app/helpers,
11
- and a functional test suite in test/functional.
12
-
13
- Example:
14
- ./script/generate controller CreditCard open debit credit close
15
-
16
- Credit card controller with URLs like /credit_card/debit.
17
- Controller: app/controllers/credit_card_controller.rb
18
- Views: app/views/credit_card/debit.rhtml [...]
19
- Helper: app/helpers/credit_card_helper.rb
20
- Test: test/functional/credit_card_controller_test.rb
21
-
22
- Modules Example:
23
- ./script/generate controller 'admin/credit_card' suspend late_fee
24
-
25
- Credit card admin controller with URLs /admin/credit_card/suspend.
26
- Controller: app/controllers/admin/credit_card_controller.rb
27
- Views: app/views/admin/credit_card/debit.rhtml [...]
28
- Helper: app/helpers/admin/credit_card_helper.rb
29
- Test: test/functional/admin/credit_card_controller_test.rb
30
-
@@ -1,32 +0,0 @@
1
- class ControllerGenerator < Rails::Generator::NamedBase #:nodoc:
2
- def manifest
3
- record do |m|
4
- # Check for class naming collisions.
5
- m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
6
-
7
- # Controller, helper, views, and test directories.
8
- m.directory File.join('app/controllers', class_path)
9
- #m.directory File.join('app/helpers', class_path)
10
- #m.directory File.join('app/views', class_path, file_name)
11
- #m.directory File.join('test/functional', class_path)
12
-
13
- # Controller class, functional test, and helper class.
14
- m.template 'controller.rb',
15
- File.join('app/controllers',
16
- class_path,
17
- "#{file_name}_controller.rb")
18
-
19
- # Functional tests are a good idea, but not yet encompassed
20
- # m.template 'functional_test.rb',
21
- # File.join('test/functional',
22
- # class_path,
23
- # "#{file_name}_controller_test.rb")
24
-
25
- # m.template 'helper.rb',
26
- # File.join('app/helpers',
27
- # class_path,
28
- # "#{file_name}_helper.rb")
29
-
30
- end
31
- end
32
- end
@@ -1,5 +0,0 @@
1
- class <%= class_name %>Controller < ShatteredController::Base
2
- key :pressed => :w, :action => :move_forward
3
- def move_forward
4
- end
5
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
2
- require '<%= file_path %>_controller'
3
-
4
- # Re-raise errors caught by the controller.
5
- class <%= class_name %>Controller; def rescue_action(e) raise e end; end
6
-
7
- class <%= class_name %>ControllerTest < Test::Unit::TestCase
8
- def setup
9
- @controller = <%= class_name %>Controller.new
10
- @request = ActionController::TestRequest.new
11
- @response = ActionController::TestResponse.new
12
- end
13
-
14
- # Replace this with your real tests.
15
- def test_truth
16
- assert true
17
- end
18
- end
@@ -1,2 +0,0 @@
1
- <h1><%= class_name %>#<%= action %></h1>
2
- <p>Find me in <%= path %></p>