pario 0.1.0.pre → 0.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +3 -1
  2. data/lib/pario.rb +101 -26
  3. data/lib/pario/version.rb +1 -1
  4. metadata +4 -4
data/README.rdoc CHANGED
@@ -5,12 +5,14 @@ Pario is a Gosu Game framework that helps to give you structure and a start for
5
5
  == Installation
6
6
 
7
7
  sudo gem install pario
8
+
9
+ * Windows users: gem install pario
8
10
 
9
11
  == Getting Started
10
12
 
11
13
  1. At the command prompt, create a new Pario application:
12
14
 
13
- pario new my_game
15
+ pario game my_game
14
16
 
15
17
  where myapp is the game name.
16
18
 
data/lib/pario.rb CHANGED
@@ -2,14 +2,16 @@ require 'optparse'
2
2
  require 'rdoc/usage'
3
3
  require 'ostruct'
4
4
  require 'date'
5
-
5
+ require 'erb'
6
6
 
7
7
  class Pario
8
8
  VERSION = '0.0.1'
9
+ Directories = %w{game lib media config}
9
10
 
10
- attr_reader :options
11
+ attr_reader :options, :command, :game_name, :arguments
11
12
 
12
13
  def initialize(arguments, stdin)
14
+ @command = command(arguments.delete_at(0))
13
15
  @arguments = arguments
14
16
  @stdin = stdin
15
17
 
@@ -17,29 +19,18 @@ class Pario
17
19
  @options = OpenStruct.new
18
20
  @options.verbose = false
19
21
  @options.quiet = false
20
- # TO DO - add additional defaults
21
22
  end
22
23
 
23
24
  # Parse options, check arguments, then process the command
24
25
  def run
25
-
26
- if parsed_options? && arguments_valid?
27
-
28
- puts "Start at #{DateTime.now}\
29
- \
30
- " if @options.verbose
31
-
32
- output_options if @options.verbose # [Optional]
33
-
34
- process_arguments
35
- process_command
36
-
37
- puts "\
38
- Finished at #{DateTime.now}" if @options.verbose
39
-
40
- else
41
- output_usage
42
- end
26
+ process_command
27
+
28
+ # if parsed_options? && arguments_valid?
29
+ # process_arguments
30
+ # process_command
31
+ # else
32
+ # output_usage
33
+ # end
43
34
 
44
35
  end
45
36
 
@@ -52,8 +43,6 @@ Finished at #{DateTime.now}" if @options.verbose
52
43
  opts.on('-v', '--version') { output_version ; exit 0 }
53
44
  opts.on('-h', '--help') { output_help }
54
45
  opts.on('-V', '--verbose') { @options.verbose = true }
55
- opts.on('-q', '--quiet') { @options.quiet = true }
56
- # TO DO - add additional options
57
46
 
58
47
  opts.parse!(@arguments) rescue return false
59
48
 
@@ -83,7 +72,7 @@ Finished at #{DateTime.now}" if @options.verbose
83
72
 
84
73
  # Setup the arguments
85
74
  def process_arguments
86
- # TO DO - place in local vars, etc
75
+ #TODO
87
76
  end
88
77
 
89
78
  def output_help
@@ -99,11 +88,97 @@ Finished at #{DateTime.now}" if @options.verbose
99
88
  puts "#{File.basename(__FILE__)} version #{VERSION}"
100
89
  end
101
90
 
91
+ def command(arg)
92
+ commands = %w{game create play}
93
+ if commands.include? arg
94
+ arg
95
+ else
96
+ raise "That command is not supported"
97
+ end
98
+ end
99
+
102
100
  def process_command
103
- # TO DO - do whatever this app does
104
-
101
+ send @command
105
102
  #process_standard_input # [Optional]
106
103
  end
104
+
105
+ def game
106
+ create_directories
107
+ create_base_files
108
+ # create_readme
109
+ # create_licesnse
110
+ end
111
+
112
+ def game_name
113
+ # For testing
114
+ # puts "*"*80
115
+ # raise "{:command => #{@command.inspect}, :arguments => #{@arguments[0].inspect}}"
116
+ @game_name ||= @arguments[0]
117
+ end
118
+
119
+ def create_base_files
120
+ build_main
121
+ # build_game_config
122
+ build_game_class
123
+ end
124
+
125
+ def build_game_class
126
+ Dir.chdir("game")
127
+ game_file = File.open(@game_name + ".rb", "w+")
128
+ game_file.puts game_class
129
+ end
130
+
131
+ def build_main
132
+ # "do you want to overwrite main.rb? Y/n" if File.exist?("main.rb")
133
+ main_file = File.open("main.rb", "w+")
134
+ main_file.puts main_class
135
+ end
136
+
137
+ def main_class
138
+ main_template = ERB.new <<-EOF
139
+ require 'rubygems'
140
+ require 'gosu'
141
+
142
+ Dir.glob(File.join("game", "*.rb")).each {|file| require file }
143
+
144
+
145
+ game = #{game_upcase}.new(800, 600)
146
+ game.show
147
+ EOF
148
+ main_template.result(binding)
149
+ end
150
+
151
+ def game_class
152
+ game_template = ERB.new <<-EOF
153
+ class #{game_upcase} < Gosu::Window
154
+ def initialize(window_width, window_height)
155
+ super(window_width,window_height,0)
156
+ end
157
+ end
158
+ EOF
159
+ game_template.result(binding)
160
+ end
161
+
162
+ def game_upcase
163
+ #TODO: need to handle camelcase
164
+ @game_name.to_s.gsub(/\b\w/){$&.upcase}
165
+ end
166
+
167
+ def create_directories
168
+ Dir.mkdir(game_name) unless File.directory?(game_name)
169
+ Dir.chdir(game_name)
170
+ Directories.each do |sub_folder|
171
+ Dir.mkdir sub_folder unless File.directory?(sub_folder)
172
+ end
173
+ end
174
+
175
+ def create
176
+ puts "Feature to come soon, I'm working on it!"
177
+ end
178
+
179
+ def play
180
+ %x{ruby main.rb}
181
+ end
107
182
 
108
183
  def process_standard_input
109
184
  input = @stdin.read
data/lib/pario/version.rb CHANGED
@@ -2,7 +2,7 @@ module Pario
2
2
  module Version
3
3
 
4
4
  MAJOR = '0'
5
- MINOR = '1'
5
+ MINOR = '2'
6
6
  MICRO = '0'
7
7
  RELEASE = 'pre'
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pario
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961915980
4
+ hash: 961915988
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
10
  - pre
11
- version: 0.1.0.pre
11
+ version: 0.2.0.pre
12
12
  platform: ruby
13
13
  authors:
14
14
  - Bill Davenport
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-02-12 00:00:00 -05:00
20
+ date: 2011-02-14 00:00:00 -05:00
21
21
  default_executable: pario
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency