railgun 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ class TestState < Railgun::BaseState
2
+ def load
3
+ end
4
+
5
+ def update
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ #config.initial_state = :test_state
2
+ # config.app_base_directory = 'app'
3
+ # config.log_level = :debug
4
+ # config.log_directory = 'log'
5
+ # config.log_file = 'development.log'
6
+ # config.jme_log_file = 'jme.log
7
+ # config.overwrite_log_on_startup = true
8
+ # config.use_fixed_updates = true
9
+ # config.fixed_update_rate = 60
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << "script/lib"
4
+ require 'inflector'
5
+
6
+ #TODO: make this act more like the rails generate command so you can pass in a camel case name and get underscores, etc.
7
+ command = ARGV[0]
8
+ target = ARGV[1]
9
+
10
+ case command
11
+ when "state"
12
+ dir = "app/states"
13
+ text =<<ENDL
14
+ class #{Inflector.camelize(target)} < Railgun::BaseState
15
+ def load
16
+ end
17
+
18
+ def update
19
+ end
20
+ end
21
+ ENDL
22
+ else
23
+ puts "I don't understand how to generate a #{command}"
24
+ exit
25
+ end
26
+
27
+ destination_file = File.expand_path(File.dirname(__FILE__) + "/../" + dir + "/" + Inflector.underscore(target) + ".rb")
28
+ if File.exists?(destination_file)
29
+ puts "File #{destination_file} already exists"
30
+ else
31
+ f = File.new(destination_file, "w+")
32
+ f << text
33
+ end
@@ -0,0 +1,52 @@
1
+ Inflector.inflections do |inflect|
2
+ inflect.plural(/$/, 's')
3
+ inflect.plural(/s$/i, 's')
4
+ inflect.plural(/(ax|test)is$/i, '\1es')
5
+ inflect.plural(/(octop|vir)us$/i, '\1i')
6
+ inflect.plural(/(alias|status)$/i, '\1es')
7
+ inflect.plural(/(bu)s$/i, '\1ses')
8
+ inflect.plural(/(buffal|tomat)o$/i, '\1oes')
9
+ inflect.plural(/([ti])um$/i, '\1a')
10
+ inflect.plural(/sis$/i, 'ses')
11
+ inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
12
+ inflect.plural(/(hive)$/i, '\1s')
13
+ inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
14
+ inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
15
+ inflect.plural(/(matr|vert|ind)ix|ex$/i, '\1ices')
16
+ inflect.plural(/([m|l])ouse$/i, '\1ice')
17
+ inflect.plural(/^(ox)$/i, '\1en')
18
+ inflect.plural(/(quiz)$/i, '\1zes')
19
+
20
+ inflect.singular(/s$/i, '')
21
+ inflect.singular(/(n)ews$/i, '\1ews')
22
+ inflect.singular(/([ti])a$/i, '\1um')
23
+ inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
24
+ inflect.singular(/(^analy)ses$/i, '\1sis')
25
+ inflect.singular(/([^f])ves$/i, '\1fe')
26
+ inflect.singular(/(hive)s$/i, '\1')
27
+ inflect.singular(/(tive)s$/i, '\1')
28
+ inflect.singular(/([lr])ves$/i, '\1f')
29
+ inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y')
30
+ inflect.singular(/(s)eries$/i, '\1eries')
31
+ inflect.singular(/(m)ovies$/i, '\1ovie')
32
+ inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
33
+ inflect.singular(/([m|l])ice$/i, '\1ouse')
34
+ inflect.singular(/(bus)es$/i, '\1')
35
+ inflect.singular(/(o)es$/i, '\1')
36
+ inflect.singular(/(shoe)s$/i, '\1')
37
+ inflect.singular(/(cris|ax|test)es$/i, '\1is')
38
+ inflect.singular(/(octop|vir)i$/i, '\1us')
39
+ inflect.singular(/(alias|status)es$/i, '\1')
40
+ inflect.singular(/^(ox)en/i, '\1')
41
+ inflect.singular(/(vert|ind)ices$/i, '\1ex')
42
+ inflect.singular(/(matr)ices$/i, '\1ix')
43
+ inflect.singular(/(quiz)zes$/i, '\1')
44
+
45
+ inflect.irregular('person', 'people')
46
+ inflect.irregular('man', 'men')
47
+ inflect.irregular('child', 'children')
48
+ inflect.irregular('sex', 'sexes')
49
+ inflect.irregular('move', 'moves')
50
+
51
+ inflect.uncountable(%w(equipment information rice money species series fish sheep))
52
+ end
@@ -0,0 +1,275 @@
1
+ require 'singleton'
2
+
3
+ # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
4
+ # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
5
+ # in inflections.rb.
6
+ module Inflector
7
+ # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
8
+ # inflection rules. Examples:
9
+ #
10
+ # Inflector.inflections do |inflect|
11
+ # inflect.plural /^(ox)$/i, '\1\2en'
12
+ # inflect.singular /^(ox)en/i, '\1'
13
+ #
14
+ # inflect.irregular 'octopus', 'octopi'
15
+ #
16
+ # inflect.uncountable "equipment"
17
+ # end
18
+ #
19
+ # New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
20
+ # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
21
+ # already have been loaded.
22
+ class Inflections
23
+ include Singleton
24
+
25
+ attr_reader :plurals, :singulars, :uncountables
26
+
27
+ def initialize
28
+ @plurals, @singulars, @uncountables = [], [], []
29
+ end
30
+
31
+ # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
32
+ # The replacement should always be a string that may include references to the matched data from the rule.
33
+ def plural(rule, replacement)
34
+ @plurals.insert(0, [rule, replacement])
35
+ end
36
+
37
+ # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
38
+ # The replacement should always be a string that may include references to the matched data from the rule.
39
+ def singular(rule, replacement)
40
+ @singulars.insert(0, [rule, replacement])
41
+ end
42
+
43
+ # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
44
+ # for strings, not regular expressions. You simply pass the irregular in singular and plural form.
45
+ #
46
+ # Examples:
47
+ # irregular 'octopus', 'octopi'
48
+ # irregular 'person', 'people'
49
+ def irregular(singular, plural)
50
+ plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
51
+ singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
52
+ end
53
+
54
+ # Add uncountable words that shouldn't be attempted inflected.
55
+ #
56
+ # Examples:
57
+ # uncountable "money"
58
+ # uncountable "money", "information"
59
+ # uncountable %w( money information rice )
60
+ def uncountable(*words)
61
+ (@uncountables << words).flatten!
62
+ end
63
+
64
+ # Clears the loaded inflections within a given scope (default is :all). Give the scope as a symbol of the inflection type,
65
+ # the options are: :plurals, :singulars, :uncountables
66
+ #
67
+ # Examples:
68
+ # clear :all
69
+ # clear :plurals
70
+ def clear(scope = :all)
71
+ case scope
72
+ when :all
73
+ @plurals, @singulars, @uncountables = [], [], []
74
+ else
75
+ instance_variable_set "@#{scope}", []
76
+ end
77
+ end
78
+ end
79
+
80
+ extend self
81
+
82
+ def inflections
83
+ if block_given?
84
+ yield Inflections.instance
85
+ else
86
+ Inflections.instance
87
+ end
88
+ end
89
+
90
+ # Returns the plural form of the word in the string.
91
+ #
92
+ # Examples
93
+ # "post".pluralize #=> "posts"
94
+ # "octopus".pluralize #=> "octopi"
95
+ # "sheep".pluralize #=> "sheep"
96
+ # "words".pluralize #=> "words"
97
+ # "the blue mailman".pluralize #=> "the blue mailmen"
98
+ # "CamelOctopus".pluralize #=> "CamelOctopi"
99
+ def pluralize(word)
100
+ result = word.to_s.dup
101
+
102
+ if inflections.uncountables.include?(result.downcase)
103
+ result
104
+ else
105
+ inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
106
+ result
107
+ end
108
+ end
109
+
110
+ # The reverse of pluralize, returns the singular form of a word in a string.
111
+ #
112
+ # Examples
113
+ # "posts".singularize #=> "post"
114
+ # "octopi".singularize #=> "octopus"
115
+ # "sheep".singluarize #=> "sheep"
116
+ # "word".singluarize #=> "word"
117
+ # "the blue mailmen".singularize #=> "the blue mailman"
118
+ # "CamelOctopi".singularize #=> "CamelOctopus"
119
+ def singularize(word)
120
+ result = word.to_s.dup
121
+
122
+ if inflections.uncountables.include?(result.downcase)
123
+ result
124
+ else
125
+ inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
126
+ result
127
+ end
128
+ end
129
+
130
+ # By default, camelize converts strings to UpperCamelCase. If the argument to camelize
131
+ # is set to ":lower" then camelize produces lowerCamelCase.
132
+ #
133
+ # camelize will also convert '/' to '::' which is useful for converting paths to namespaces
134
+ #
135
+ # Examples
136
+ # "active_record".camelize #=> "ActiveRecord"
137
+ # "active_record".camelize(:lower) #=> "activeRecord"
138
+ # "active_record/errors".camelize #=> "ActiveRecord::Errors"
139
+ # "active_record/errors".camelize(:lower) #=> "activeRecord::Errors"
140
+ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
141
+ if first_letter_in_uppercase
142
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
143
+ else
144
+ lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
145
+ end
146
+ end
147
+
148
+ # Capitalizes all the words and replaces some characters in the string to create
149
+ # a nicer looking title. Titleize is meant for creating pretty output. It is not
150
+ # used in the Rails internals.
151
+ #
152
+ # titleize is also aliased as as titlecase
153
+ #
154
+ # Examples
155
+ # "man from the boondocks".titleize #=> "Man From The Boondocks"
156
+ # "x-men: the last stand".titleize #=> "X Men: The Last Stand"
157
+ def titleize(word)
158
+ humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
159
+ end
160
+
161
+ # The reverse of +camelize+. Makes an underscored form from the expression in the string.
162
+ #
163
+ # Changes '::' to '/' to convert namespaces to paths.
164
+ #
165
+ # Examples
166
+ # "ActiveRecord".underscore #=> "active_record"
167
+ # "ActiveRecord::Errors".underscore #=> active_record/errors
168
+ def underscore(camel_cased_word)
169
+ camel_cased_word.to_s.gsub(/::/, '/').
170
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
171
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
172
+ tr("-", "_").
173
+ downcase
174
+ end
175
+
176
+ # Replaces underscores with dashes in the string.
177
+ #
178
+ # Example
179
+ # "puni_puni" #=> "puni-puni"
180
+ def dasherize(underscored_word)
181
+ underscored_word.gsub(/_/, '-')
182
+ end
183
+
184
+ # Capitalizes the first word and turns underscores into spaces and strips _id.
185
+ # Like titleize, this is meant for creating pretty output.
186
+ #
187
+ # Examples
188
+ # "employee_salary" #=> "Employee salary"
189
+ # "author_id" #=> "Author"
190
+ def humanize(lower_case_and_underscored_word)
191
+ lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
192
+ end
193
+
194
+ # Removes the module part from the expression in the string
195
+ #
196
+ # Examples
197
+ # "ActiveRecord::CoreExtensions::String::Inflections".demodulize #=> "Inflections"
198
+ # "Inflections".demodulize #=> "Inflections"
199
+ def demodulize(class_name_in_module)
200
+ class_name_in_module.to_s.gsub(/^.*::/, '')
201
+ end
202
+
203
+ # Create the name of a table like Rails does for models to table names. This method
204
+ # uses the pluralize method on the last word in the string.
205
+ #
206
+ # Examples
207
+ # "RawScaledScorer".tableize #=> "raw_scaled_scorers"
208
+ # "egg_and_ham".tableize #=> "egg_and_hams"
209
+ # "fancyCategory".tableize #=> "fancy_categories"
210
+ def tableize(class_name)
211
+ pluralize(underscore(class_name))
212
+ end
213
+
214
+ # Create a class name from a table name like Rails does for table names to models.
215
+ # Note that this returns a string and not a Class. (To convert to an actual class
216
+ # follow classify with constantize.)
217
+ #
218
+ # Examples
219
+ # "egg_and_hams".classify #=> "EggAndHam"
220
+ # "post".classify #=> "Post"
221
+ def classify(table_name)
222
+ # strip out any leading schema name
223
+ camelize(singularize(table_name.to_s.sub(/.*\./, '')))
224
+ end
225
+
226
+ # Creates a foreign key name from a class name.
227
+ # +separate_class_name_and_id_with_underscore+ sets whether
228
+ # the method should put '_' between the name and 'id'.
229
+ #
230
+ # Examples
231
+ # "Message".foreign_key #=> "message_id"
232
+ # "Message".foreign_key(false) #=> "messageid"
233
+ # "Admin::Post".foreign_key #=> "post_id"
234
+ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
235
+ underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
236
+ end
237
+
238
+ # Constantize tries to find a declared constant with the name specified
239
+ # in the string. It raises a NameError when the name is not in CamelCase
240
+ # or is not initialized.
241
+ #
242
+ # Examples
243
+ # "Module".constantize #=> Module
244
+ # "Class".constantize #=> Class
245
+ def constantize(camel_cased_word)
246
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
247
+ raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
248
+ end
249
+
250
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
251
+ end
252
+
253
+ # Ordinalize turns a number into an ordinal string used to denote the
254
+ # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
255
+ #
256
+ # Examples
257
+ # ordinalize(1) # => "1st"
258
+ # ordinalize(2) # => "2nd"
259
+ # ordinalize(1002) # => "1002nd"
260
+ # ordinalize(1003) # => "1003rd"
261
+ def ordinalize(number)
262
+ if (11..13).include?(number.to_i % 100)
263
+ "#{number}th"
264
+ else
265
+ case number.to_i % 10
266
+ when 1: "#{number}st"
267
+ when 2: "#{number}nd"
268
+ when 3: "#{number}rd"
269
+ else "#{number}th"
270
+ end
271
+ end
272
+ end
273
+ end
274
+
275
+ require 'inflections'
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ java -Djava.library.path=lib/railgun/native/macosx -jar lib/railgun/railgun.jar
@@ -0,0 +1 @@
1
+ java -Djava.library.path=lib/railgun/native/win32 -jar lib/railgun/railgun.jar
@@ -0,0 +1,38 @@
1
+ require 'ftools'
2
+
3
+ PROJECT_NAME = ARGV[0]
4
+ TARGET_DIR = File.expand_path(Dir.pwd + "/" + PROJECT_NAME)
5
+ SOURCE_DIR = File.expand_path(File.dirname(__FILE__) + "/..")
6
+
7
+ Dir.mkdir(TARGET_DIR)
8
+
9
+ # Generate the directory structure for the new application
10
+ # Gems does not pull in empty directories so app_skeleton only
11
+ # contains populated directories
12
+ Dir.mkdir(TARGET_DIR + "/app")
13
+ Dir.mkdir(TARGET_DIR + "/app/entities")
14
+ Dir.mkdir(TARGET_DIR + "/app/states")
15
+ Dir.mkdir(TARGET_DIR + "/app/views")
16
+ Dir.mkdir(TARGET_DIR + "/assets")
17
+ Dir.mkdir(TARGET_DIR + "/assets/models")
18
+ Dir.mkdir(TARGET_DIR + "/config")
19
+ Dir.mkdir(TARGET_DIR + "/config/keymaps")
20
+ Dir.mkdir(TARGET_DIR + "/lib")
21
+ Dir.mkdir(TARGET_DIR + "/lib/railgun")
22
+ Dir.mkdir(TARGET_DIR + "/log")
23
+ Dir.mkdir(TARGET_DIR + "/script")
24
+ Dir.mkdir(TARGET_DIR + "/script/lib")
25
+
26
+ Dir.chdir(SOURCE_DIR + "/app_skeleton")
27
+ Dir.glob("**/*").each do |file|
28
+ File.copy(file, TARGET_DIR + "/" + file) unless File.directory?(file)
29
+ end
30
+
31
+ Dir.chdir(SOURCE_DIR + "/dist")
32
+ Dir.glob("**/*").each do |file|
33
+ Dir.mkdir(TARGET_DIR + "/lib/railgun/" + file) if File.directory?(file)
34
+ File.copy(file, TARGET_DIR + "/lib/railgun/" + file) unless File.directory?(file)
35
+ end
36
+
37
+ #TODO: chmod any files in the script directory to be executable
38
+ #TODO: verify that the railgun command overwrites any old files when re-run
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.3
3
+ specification_version: 1
4
+ name: railgun
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.1
7
+ date: 2007-06-01 00:00:00 -07:00
8
+ summary: Railgun game engine
9
+ require_paths:
10
+ - lib
11
+ email: david@koontzfamily.com
12
+ homepage: http://railgun.rubyforge.org
13
+ rubyforge_project: railgun
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - David Koontz
31
+ files:
32
+ - bin/railgun
33
+ - dist/lib
34
+ - dist/lib/jinput.jar
35
+ - dist/lib/jme-awt.jar
36
+ - dist/lib/jme-effects.jar
37
+ - dist/lib/jme-model.jar
38
+ - dist/lib/jme-sound.jar
39
+ - dist/lib/jme-terrain.jar
40
+ - dist/lib/jme.jar
41
+ - dist/lib/jruby-complete.jar
42
+ - dist/lib/lwjgl.jar
43
+ - dist/lib/lwjgl_util.jar
44
+ - dist/native
45
+ - dist/native/linux
46
+ - dist/native/linux/libjinput-linux.so
47
+ - dist/native/linux/liblwjgl.so
48
+ - dist/native/linux/libopenal.so
49
+ - dist/native/macosx
50
+ - dist/native/macosx/libjinput-osx.jnilib
51
+ - dist/native/macosx/liblwjgl.jnilib
52
+ - dist/native/macosx/openal.dylib
53
+ - dist/native/win32
54
+ - dist/native/win32/jinput-dx8.dll
55
+ - dist/native/win32/jinput-raw.dll
56
+ - dist/native/win32/lwjgl.dll
57
+ - dist/native/win32/OpenAL32.dll
58
+ - dist/railgun.jar
59
+ - app_skeleton/app
60
+ - app_skeleton/app/entities
61
+ - app_skeleton/app/states
62
+ - app_skeleton/app/states/test_state.rb
63
+ - app_skeleton/app/views
64
+ - app_skeleton/assets
65
+ - app_skeleton/assets/models
66
+ - app_skeleton/config
67
+ - app_skeleton/config/application.rb
68
+ - app_skeleton/config/keymaps
69
+ - app_skeleton/lib
70
+ - app_skeleton/log
71
+ - app_skeleton/script
72
+ - app_skeleton/script/generate
73
+ - app_skeleton/script/lib
74
+ - app_skeleton/script/lib/inflections.rb
75
+ - app_skeleton/script/lib/inflector.rb
76
+ - app_skeleton/script/run
77
+ - app_skeleton/script/run.bat
78
+ test_files: []
79
+
80
+ rdoc_options: []
81
+
82
+ extra_rdoc_files: []
83
+
84
+ executables:
85
+ - railgun
86
+ extensions: []
87
+
88
+ requirements: []
89
+
90
+ dependencies: []
91
+