the_game 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,5 +1,7 @@
1
1
  the_game Copyright (C) 2012 Shigeki Kitajima
2
2
 
3
+ <http://shigeki.99k.org/the_game/>
4
+
3
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
6
 
5
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
data/README.rdoc CHANGED
@@ -7,7 +7,8 @@ or from source:
7
7
  rake install
8
8
  == Usage
9
9
  Run the executable +the_game+.
10
- Usage: the_game.rb [options] [mode]
10
+
11
+ Usage: the_game.rb [options] [MODE]
11
12
 
12
13
  Options
13
14
  -n, --name NAME Set character's name to NAME.
@@ -16,6 +17,7 @@ Run the executable +the_game+.
16
17
  -h, --help Display this message and exit
17
18
  -l, --license Display license and exit
18
19
  -v, --version Display version and exit
20
+
19
21
  == Copyright
20
- Copyright (c) 2012 Shigeki Kitajima. See LICENSE.txt for further details.
22
+ :include:LICENSE.txt
21
23
 
data/bin/the_game CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+ #:include:the_game/bin/the_game
3
3
  require 'the_game'
4
- TheGame::Game.new.start!
4
+ require 'the_game/cli'
5
+
6
+ TheGame::CLI.start!(ARGV)
data/lib/the_game/cli.rb CHANGED
@@ -0,0 +1,33 @@
1
+ require 'optparse'
2
+
3
+ # Command-line interface
4
+ module TheGame::CLI
5
+ class << self
6
+ def start!(args = ARGV)
7
+ @game = TheGame::Game.new
8
+ @game_mode = :help
9
+
10
+ opts = OptionParser.new(args) do |opts|
11
+ opts.banner = "Usage: the_game [options] [mode]"
12
+ opts.separator ''
13
+
14
+ opts.separator 'Options'
15
+ opts.on("-n", "--name NAME", "Set character's name to NAME.") { |n| @game.name = n }
16
+
17
+ opts.separator 'Modes'
18
+ opts.on("-p", "--play", "Play the game") { @game_mode = :play }
19
+ opts.on("-h", "--help", "Display this message and exit")
20
+ opts.on("-l", "--license", "Display license and exit") { @game_mode = :license }
21
+ opts.on("-v", "--version", "Display version and exit") { @game_mode = :version }
22
+ end
23
+
24
+ opts.parse!
25
+
26
+ case @game_mode
27
+ when :play then @game.start!
28
+ when :license then puts TheGame::LICENSE
29
+ when :version then puts "the_game v#{TheGame::Version::STRING}"
30
+ else puts opts end
31
+ end
32
+ end
33
+ end
@@ -18,7 +18,7 @@ class TheGame::Command
18
18
  end
19
19
 
20
20
  def method_missing(m, g, a)
21
- "#{m.to_s.command_sanitize}: unknown command"
21
+ "#{m.to_s.command_sanitize}: command not found"
22
22
  end
23
23
 
24
24
  def _args(g, a)
data/lib/the_game/game.rb CHANGED
@@ -40,7 +40,7 @@ class TheGame::Game
40
40
  case key.downcase.to_sym
41
41
  when :name then @name = value
42
42
  when :level then @level = value
43
- else raise ArgumentError, "No matching key for #{key}" end
43
+ else raise ArgumentError, "Cannot set #{key}!" end
44
44
  rescue Exception => e
45
45
  return e
46
46
  end
@@ -1,9 +1,11 @@
1
1
  module TheGame
2
2
  LICENSE = "the_game Copyright (C) 2012 Shigeki Kitajima
3
3
 
4
+ <http://shigeki.99k.org/the_game/>
5
+
4
6
  This program is open source: you can redistribute it and/or modify it under the
5
7
  terms of the MIT License. This program is distributed in the hope that it will
6
8
  be useful, but WITHOUT ANY WARRANTY.
7
-
9
+
8
10
  <http://opensource.org/licenses/MIT/>"
9
11
  end
@@ -1,6 +1,8 @@
1
+ raise "Sorry, only works with ruby >= 1.9 right now." if RUBY_VERSION < "1.9"
2
+
1
3
  module TheGame
2
4
  module Version
3
- STRING = "0.0.5"
5
+ STRING = "0.0.6"
4
6
  ARRAY = STRING.split('.')
5
7
  MAJOR = ARRAY[0]
6
8
  MINOR = ARRAY[1]
data/lib/the_game.rb CHANGED
@@ -13,13 +13,5 @@ module TheGame
13
13
  Dir.mkdir(THEGAME_DIR) unless File.directory? THEGAME_DIR
14
14
  File.open(SAVEFILE_PATH,"w"){|f|f<<""} unless File.file? SAVEFILE_PATH
15
15
  end
16
-
17
- def start!
18
- case @mode
19
- when :play then @game.start!
20
- when :license then puts LICENSE
21
- when :version then puts "the_game.rb v#{TheGame::VERSION}"
22
- else puts @opts end
23
- end
24
16
  end
25
- end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_game
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-06 00:00:00.000000000 Z
12
+ date: 2012-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &15777180 !ruby/object:Gem::Requirement
16
+ requirement: &17844180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *15777180
24
+ version_requirements: *17844180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &15736780 !ruby/object:Gem::Requirement
27
+ requirement: &17843140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *15736780
35
+ version_requirements: *17843140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &15736140 !ruby/object:Gem::Requirement
38
+ requirement: &17842440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *15736140
46
+ version_requirements: *17842440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &15735200 !ruby/object:Gem::Requirement
49
+ requirement: &17841660 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,8 +54,9 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *15735200
58
- description: The Game.
57
+ version_requirements: *17841660
58
+ description: the_game is a text-based game written in Ruby, but it doesn't do much
59
+ right now.
59
60
  email: shigeki.kitajima@gmail.com
60
61
  executables:
61
62
  - the_game
@@ -77,9 +78,9 @@ files:
77
78
  - lib/the_game/helpers/string.rb
78
79
  - lib/the_game/license.rb
79
80
  - lib/the_game/version.rb
80
- homepage: https://rubygems.org/gems/the_game
81
+ homepage: http://shigeki.99k.org/the_game/
81
82
  licenses:
82
- - CC 3.0 (BY-NC-SA)
83
+ - MIT
83
84
  post_install_message:
84
85
  rdoc_options: []
85
86
  require_paths:
@@ -92,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
93
  version: '0'
93
94
  segments:
94
95
  - 0
95
- hash: -3350087069672982418
96
+ hash: -3503081812645725962
96
97
  required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  none: false
98
99
  requirements:
@@ -104,5 +105,5 @@ rubyforge_project:
104
105
  rubygems_version: 1.8.13
105
106
  signing_key:
106
107
  specification_version: 3
107
- summary: It's the_game.
108
+ summary: A text-based adventure game.
108
109
  test_files: []