minecraft 0.2.0 → 0.2.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.
data/CHANGES.md CHANGED
@@ -1,8 +1,16 @@
1
+ 0.2.1 (2011-08-22)
2
+ ------------------
3
+
4
+ * Fixed `!points` and `!board`
5
+ * Bugfix on `call_command`
6
+ * Added more test suites.
7
+ * A `!help` command suitable for new privilege system.
8
+
1
9
  0.2.0 (2011-08-21)
2
10
  ------------------
3
11
 
4
12
  * Added configuration file capability.
5
- * Added `!points`, `!board`, `!kickvote`, `!vote`, `!cancelvote`, `!kickvotes`, `!roulette`, `change_time`, `!om`, `!dehop`, `!op`
13
+ * Added `!points`, `!board`, `!kickvote`, `!vote`, `!cancelvote`, `!kickvotes`, `!roulette`, `change_time`, `!om`, `!dehop`, `!hop`
6
14
  * Added time changes (morning, night, dawn, etc...)
7
15
  * Separated half-op and op privileges.
8
16
  * `!property` now lists properties if none specified.
@@ -7,35 +7,40 @@ module Minecraft
7
7
  # Gives a user a specific amount of points, the quantity is capped
8
8
  # depending on the privileges of the user.
9
9
  #
10
- # @params [String] user The requesting user.
11
- # @params [String] target_user The target user to give points to.
12
- # @params [Integer] points Quantity of points to give.
10
+ # @param [String] user The requesting user.
11
+ # @param [String] target_user The target user to give points to.
12
+ # @param [Integer] points Quantity of points to give.
13
13
  # @example
14
14
  # points("basicxman", "mike_n_7")
15
15
  # points("basicxman", "mike_n_7", "50")
16
16
  def points(user, target_user, num_points = 1)
17
+ if user.downcase == target_user.downcase
18
+ @server.puts "say Did you just try to give yourself points? Sure, minus twenty."
19
+ @userpoints[target_user] ||= 0
20
+ @userpoints[target_user] -= 20
21
+ end
17
22
  num_points = [num_points.to_i, cap_points(user)].min
18
- @points[target_user] ||= 0
19
- @points[target_user] += num_points
20
- @server.puts "say #{user} has given #{target_user} #{num_points} points for a total of #{@points[target_user]}."
23
+ @userpoints[target_user] ||= 0
24
+ @userpoints[target_user] += num_points
25
+ @server.puts "say #{user} has given #{target_user} #{num_points} points for a total of #{@userpoints[target_user]}."
21
26
  end
22
27
 
23
28
  # Checks a users points or displays the leaderboard.
24
29
  #
25
- # @params [String] user The requesting user.
26
- # @params [String] target_user The user to check points of.
30
+ # @param [String] user The requesting user.
31
+ # @param [String] target_user The user to check points of.
27
32
  # @example
28
33
  # board("basicxman")
29
34
  # board("basicxman", "mike_n_7")
30
35
  def board(user, target_user = nil)
31
36
  if target_user.nil?
32
37
  leaderboard = {}
33
- @points.each do |u, p|
38
+ @userpoints.each do |u, p|
34
39
  leaderboard[p] ||= []
35
40
  leaderboard[p] << u
36
41
  end
37
42
  num_to_display = 5
38
- leaderboard.keys.sort.each do |points|
43
+ leaderboard.keys.sort.reverse.each do |points|
39
44
  leaderboard[points].each do |u|
40
45
  return unless num_to_display >= 1
41
46
  @server.puts "say #{u}: #{points}"
@@ -43,8 +48,8 @@ module Minecraft
43
48
  end
44
49
  end
45
50
  else
46
- if @points.has_key? target_user
47
- @server.puts "say #{u}: #{@points[u]}"
51
+ if @userpoints.has_key? target_user
52
+ @server.puts "say #{u}: #{@userpoints[u]}"
48
53
  end
49
54
  end
50
55
  end
@@ -65,8 +70,8 @@ module Minecraft
65
70
  # regular connected players cannot kick users they can initiate a vote
66
71
  # instead.
67
72
  #
68
- # @params [String] user The requesting user.
69
- # @params [String] target_user The target user to be kicked if the vote
73
+ # @param [String] user The requesting user.
74
+ # @param [String] target_user The target user to be kicked if the vote
70
75
  # succeeds.
71
76
  # @example
72
77
  # kickvote("basicxman", "blizzard4U")
@@ -88,7 +93,7 @@ module Minecraft
88
93
 
89
94
  # Votes for the last initiated kickvote.
90
95
  #
91
- # @params [String] user The requesting user.
96
+ # @param [String] user The requesting user.
92
97
  # @example
93
98
  # vote("basicxman")
94
99
  def vote(user)
@@ -99,8 +104,8 @@ module Minecraft
99
104
 
100
105
  # Cancels a kickvote initiation for a specific user.
101
106
  #
102
- # @params [String] user The requesting user.
103
- # @params [String] target_user The user which currently has a kickvote.
107
+ # @param [String] user The requesting user.
108
+ # @param [String] target_user The user which currently has a kickvote.
104
109
  # @example
105
110
  # cancelvote("basicxman", "blizzard4U")
106
111
  def cancelvote(user, target_user)
@@ -114,7 +119,7 @@ module Minecraft
114
119
 
115
120
  # Displays all current kickvote initiations.
116
121
  #
117
- # @params [String] user The requesting user.
122
+ # @param [String] user The requesting user.
118
123
  # @example
119
124
  # kickvotes("basicxman")
120
125
  def kickvotes(user)
@@ -125,8 +130,8 @@ module Minecraft
125
130
 
126
131
  # Submits a kickvote.
127
132
  #
128
- # @params [String] user The requesting user who is voting.
129
- # @params [String] target_user The user being voted against.
133
+ # @param [String] user The requesting user who is voting.
134
+ # @param [String] target_user The user being voted against.
130
135
  # @return [Boolean] Returns true if the kickvote has been initiated yet.
131
136
  # @example
132
137
  # submit_vote("basicxman", "blizzard4U")
@@ -175,7 +180,6 @@ module Minecraft
175
180
  # Checks to see if any kickvotes are expired.
176
181
  def expire_kickvotes
177
182
  @kickvotes.each do |target_user, data|
178
- puts "Checking #{Time.now} against #{data[:start] + @vote_expiration}}"
179
183
  if Time.now > data[:start] + @vote_expiration
180
184
  @server.puts "say The kickvote for #{target_user} has expired."
181
185
  @kickvotes.delete(target_user)
@@ -471,20 +475,23 @@ module Minecraft
471
475
  @server.puts "say Shortcuts for #{user}: #{labels}."
472
476
  end
473
477
 
474
- # Prints the help contents.
478
+ # Prints the available commands for the user.
475
479
  #
480
+ # @param [String] user The requesting user.
476
481
  # @example
477
- # help()
478
- def help(*args)
479
- @server.puts <<-eof
480
- say !tp target_user
481
- say !kit kit_name
482
- say !give item quantity
483
- say !nom
484
- say !list
485
- say !addtimer item frequency
486
- say !deltimer item
487
- eof
482
+ # help("basicxman")
483
+ def help(user)
484
+ commands = @commands.keys.inject([]) { |arr, key|
485
+ priv = @commands[key][:ops]
486
+ if is_op? user
487
+ arr << key
488
+ elsif is_hop? user
489
+ priv == :op ? arr : arr << key
490
+ else
491
+ priv == :none ? arr << key : arr
492
+ end
493
+ }.map { |s| "!" + s.to_s }
494
+ @server.puts "say Commands: #{commands.join(", ")}"
488
495
  end
489
496
 
490
497
  # Prints the list of available kits to the connected players.
@@ -16,7 +16,7 @@ module Minecraft
16
16
  get_json :timers
17
17
  get_json :shortcuts
18
18
  get_json :userlog
19
- get_json :points
19
+ get_json :userpoints
20
20
  @users = []
21
21
  @counter = 0
22
22
  @logon_time = {}
@@ -32,38 +32,38 @@ module Minecraft
32
32
 
33
33
  # Command set.
34
34
  @commands = {}
35
- add_command(:give, :ops => :hop, :all => true, :all_message => "is putting out.")
36
- add_command(:tp, :ops => :hop, :all => true, :all_message => "is teleporting all users to their location.")
37
- add_command(:kit, :ops => :hop, :all => true, :all_message => "is providing kits to all.")
38
- add_command(:kitlist, :ops => :hop, :all => false)
39
- add_command(:help, :ops => :none, :all => false)
40
- add_command(:rules, :ops => :none, :all => false)
41
- add_command(:nom, :ops => :hop, :all => true, :all_message => "is providing noms to all.")
42
- add_command(:om, :ops => :hop, :all => true, :all_message => "is noming everybody, gross.")
43
- add_command(:list, :ops => :none, :all => false)
44
- add_command(:s, :ops => :hop, :all => false)
45
- add_command(:shortcuts, :ops => :hop, :all => false)
46
- add_command(:hop, :ops => :op, :all => false)
47
- add_command(:dehop, :ops => :op, :all => false)
48
- add_command(:uptime, :ops => :none, :all => false)
49
- add_command(:addtimer, :ops => :hop, :all => false)
50
- add_command(:deltimer, :ops => :hop, :all => false)
51
- add_command(:printtimer, :ops => :hop, :all => false)
52
- add_command(:printtime, :ops => :op, :all => false)
53
- add_command(:property, :ops => :op, :all => false)
54
- add_command(:morning, :ops => :op, :all => false)
55
- add_command(:evening, :ops => :op, :all => false)
56
- add_command(:day, :ops => :op, :all => false)
57
- add_command(:night, :ops => :op, :all => false)
58
- add_command(:dawn, :ops => :op, :all => false)
59
- add_command(:dusk, :ops => :op, :all => false)
60
- add_command(:roulette, :ops => :op, :all => false)
61
- add_command(:kickvote, :ops => :none, :all => false)
62
- add_command(:vote, :ops => :none, :all => false)
63
- add_command(:cancelvote, :ops => :op, :all => false)
64
- add_command(:kickvotes, :ops => :op, :all => false)
65
- add_command(:points, :ops => :none, :all => false)
66
- add_command(:board, :ops => :none, :all => false)
35
+ add_command :give, :ops => :hop, :all => true, :all_message => "is putting out."
36
+ add_command :tp, :ops => :hop, :all => true, :all_message => "is teleporting all users to their location."
37
+ add_command :kit, :ops => :hop, :all => true, :all_message => "is providing kits to all."
38
+ add_command :kitlist, :ops => :hop, :all => false
39
+ add_command :help, :ops => :none, :all => false
40
+ add_command :rules, :ops => :none, :all => false
41
+ add_command :nom, :ops => :hop, :all => true, :all_message => "is providing noms to all."
42
+ add_command :om, :ops => :hop, :all => true, :all_message => "is noming everybody, gross."
43
+ add_command :list, :ops => :none, :all => false
44
+ add_command :s, :ops => :hop, :all => false
45
+ add_command :shortcuts, :ops => :hop, :all => false
46
+ add_command :hop, :ops => :op, :all => false
47
+ add_command :dehop, :ops => :op, :all => false
48
+ add_command :uptime, :ops => :none, :all => false
49
+ add_command :addtimer, :ops => :hop, :all => false
50
+ add_command :deltimer, :ops => :hop, :all => false
51
+ add_command :printtimer, :ops => :hop, :all => false
52
+ add_command :printtime, :ops => :op, :all => false
53
+ add_command :property, :ops => :op, :all => false
54
+ add_command :morning, :ops => :op, :all => false
55
+ add_command :evening, :ops => :op, :all => false
56
+ add_command :day, :ops => :op, :all => false
57
+ add_command :night, :ops => :op, :all => false
58
+ add_command :dawn, :ops => :op, :all => false
59
+ add_command :dusk, :ops => :op, :all => false
60
+ add_command :roulette, :ops => :op, :all => false
61
+ add_command :kickvote, :ops => :none, :all => false
62
+ add_command :vote, :ops => :none, :all => false
63
+ add_command :cancelvote, :ops => :op, :all => false
64
+ add_command :kickvotes, :ops => :op, :all => false
65
+ add_command :points, :ops => :none, :all => false
66
+ add_command :board, :ops => :none, :all => false
67
67
  end
68
68
 
69
69
  # Sets an instance variable with it's corresponding data file or a blank hash.
@@ -82,7 +82,7 @@ module Minecraft
82
82
  save_file :timers
83
83
  save_file :shortcuts
84
84
  save_file :hops
85
- save_file :points
85
+ save_file :userpoints
86
86
  end
87
87
 
88
88
  # Save an instance hash to it's associated data file.
@@ -116,7 +116,7 @@ module Minecraft
116
116
  return send(root, user, *args) unless @commands.include? root
117
117
 
118
118
  # Any `all` suffixed command requires ops.
119
- if @commands[root][:ops] == :ops or (is_all and @commands[root][:all])
119
+ if @commands[root][:ops] == :op or (is_all and @commands[root][:all])
120
120
  return unless validate_ops(user, command)
121
121
  elsif @commands[root][:ops] == :hop
122
122
  return unless validate_ops(user, command, false) or validate_hops(user, command)
@@ -1,5 +1,5 @@
1
1
  # Global Minecraft module.
2
2
  module Minecraft
3
3
  # Yay, keep these versions coming!
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -3,6 +3,8 @@ require "minecraft"
3
3
 
4
4
  class CommandsTest < Test
5
5
  include Minecraft::Commands
6
+
7
+ # Item resolution and quantifiers testing.
6
8
  test "should properly check quantifiers" do
7
9
  assert is_quantifier? "1"
8
10
  assert is_quantifier? "10"
@@ -50,6 +52,7 @@ class CommandsTest < Test
50
52
  assert_nil resolve_item("asdf")
51
53
  end
52
54
 
55
+ # Give command testing.
53
56
  test "give command should give a single slot worth" do
54
57
  @server = StringIO.new
55
58
  give("foo", "cobblestone", "64")
@@ -77,4 +80,151 @@ give foo 4 32
77
80
  eof
78
81
  assert_equal result, @server.string
79
82
  end
83
+
84
+ # User points system testing.
85
+ sandbox_test "should give a user points" do
86
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
87
+ @ext.users = ["basicxman", "mike_n_7", "blizzard4U", "Ian_zers"]
88
+ @ext.ops = ["basicxman"]
89
+ @ext.hops = ["mike_n_7"]
90
+ @ext.call_command("basicxman", "points", "Ian_zers", "1001")
91
+ assert_equal 1000, @ext.userpoints["Ian_zers"]
92
+ @ext.call_command("mike_n_7", "points", "Ian_zers", "501")
93
+ assert_equal 1500, @ext.userpoints["Ian_zers"]
94
+ @ext.call_command("blizzard4U", "points", "Ian_zers", "2")
95
+ assert_equal 1501, @ext.userpoints["Ian_zers"]
96
+ end
97
+
98
+ sandbox_test "should not a let a user give herself points" do
99
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
100
+ @ext.users = ["basicxman"]
101
+ @ext.userpoints = { "basicxman" => 0 }
102
+ @ext.call_command("basicxman", "points", "basicxman")
103
+ assert @ext.userpoints["basicxman"] < 0
104
+ end
105
+
106
+ sandbox_test "should print a users points" do
107
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
108
+ @ext.userpoints = { "basicxman" => 50 }
109
+ @ext.call_command("basicxman", "board")
110
+ assert_match "basicxman", @ext.server.string
111
+ assert_match "50", @ext.server.string
112
+ end
113
+
114
+ sandbox_test "should print a leaderboard" do
115
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
116
+ @ext.userpoints = {
117
+ "basicxman" => 150,
118
+ "mike_n_7" => 150,
119
+ "blizzard4U" => 20,
120
+ "Ian_zers" => 90,
121
+ "horsmanjarrett" => 50,
122
+ "someguy" => 10
123
+ }
124
+ @ext.board("basicxman")
125
+ leaderboard = @ext.server.string.split("\n")
126
+ assert_match "150", leaderboard[0]
127
+ assert_match "150", leaderboard[1]
128
+ assert_match "Ian_zers", leaderboard[2]
129
+ assert_match "horsmanjarrett", leaderboard[3]
130
+ assert_match "blizzard4U", leaderboard[4]
131
+ end
132
+
133
+ # Kickvote testing.
134
+ sandbox_test "should initiate a kickvote against a user" do
135
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
136
+ @ext.users = ["basicxman", "mike_n_7", "blizzard4U", "Ian_zers"]
137
+ @ext.ops = ["basicxman"]
138
+ @ext.hops = ["mike_n_7"]
139
+ @ext.call_command("basicxman", "kickvote", "blizzard4U")
140
+ assert_equal 3, @ext.kickvotes["blizzard4U"][:tally]
141
+ assert_equal "blizzard4U", @ext.last_kick_vote
142
+ end
143
+
144
+ sandbox_test "should expire a kickvote against a user" do
145
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
146
+ @ext.users = ["basicxman", "blizzard4U"]
147
+ @ext.call_command("basicxman", "kickvote", "blizzard4U")
148
+ @ext.counter = 9
149
+ @ext.kickvotes["blizzard4U"][:start] = Time.now - 300
150
+ @ext.periodic
151
+ assert_match "expire", @ext.server.string
152
+ end
153
+
154
+ sandbox_test "should add the correct number of votes per user type" do
155
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
156
+ @ext.users = ["basicxman", "mike_n_7", "blizzard4U", "Ian_zers"]
157
+ @ext.ops = ["basicxman"]
158
+ @ext.hops = ["mike_n_7"]
159
+ @ext.vote_threshold = 7
160
+ @ext.call_command("Ian_zers", "kickvote", "blizzard4U")
161
+ assert_equal 1, @ext.kickvotes["blizzard4U"][:tally]
162
+ @ext.call_command("mike_n_7", "vote")
163
+ assert_equal 3, @ext.kickvotes["blizzard4U"][:tally]
164
+ @ext.call_command("basicxman", "vote")
165
+ assert_equal 6, @ext.kickvotes["blizzard4U"][:tally]
166
+ end
167
+
168
+ sandbox_test "should kick a user who has enough votes" do
169
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
170
+ @ext.users = ["basicxman", "mike_n_7", "blizzard4U", "Ian_zers"]
171
+ @ext.ops = ["basicxman"]
172
+ @ext.hops = ["mike_n_7"]
173
+ @ext.call_command("basicxman", "kickvote", "Ian_zers")
174
+ @ext.call_command("mike_n_7", "vote")
175
+ assert_match "kick Ian_zers", @ext.server.string
176
+ end
177
+
178
+ # Time commands.
179
+ sandbox_test "should change time with time commands" do
180
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
181
+ @ext.ops = ["basicxman"]
182
+ %w( morning evening night dawn dusk day ).each do |time|
183
+ @ext.call_command("basicxman", time)
184
+ assert_match "time set #{Minecraft::Data::TIME[time.to_sym]}", @ext.server.string
185
+ @ext.server.string = ""
186
+ end
187
+ end
188
+
189
+ # Half op privileges and !list.
190
+ sandbox_test "should revoke and add half op privileges" do
191
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
192
+ @ext.users = ["basicxman", "blizzard4U", "mike_n_7"]
193
+ @ext.ops = ["basicxman"]
194
+ @ext.call_command("basicxman", "hop", "blizzard4U")
195
+ @ext.call_command("basicxman", "hop", "mike_n_7")
196
+ @ext.call_command("basicxman", "dehop", "blizzard4U")
197
+ @ext.call_command("basicxman", "list")
198
+ assert_match "[@basicxman], blizzard4U, %mike_n_7", @ext.server.string.split("\n").last
199
+ end
200
+
201
+ # Help command.
202
+ sandbox_test "should display help contents for regular users" do
203
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
204
+ @ext.users = ["blizzard4U"]
205
+ @ext.call_command("blizzard4U", "help")
206
+ assert_match "rules", @ext.server.string
207
+ assert_match "list", @ext.server.string
208
+ refute_match "give", @ext.server.string
209
+ end
210
+
211
+ sandbox_test "should display help contents for half ops" do
212
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
213
+ @ext.users = ["mike_n_7"]
214
+ @ext.hops = ["mike_n_7"]
215
+ @ext.call_command("mike_n_7", "help")
216
+ assert_match "rules", @ext.server.string
217
+ assert_match "give", @ext.server.string
218
+ refute_match "morning", @ext.server.string
219
+ end
220
+
221
+ sandbox_test "should display help contents for ops" do
222
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
223
+ @ext.users = ["basicxman"]
224
+ @ext.ops = ["basicxman"]
225
+ @ext.call_command("basicxman", "help")
226
+ assert_match "rules", @ext.server.string
227
+ assert_match "give", @ext.server.string
228
+ assert_match "morning", @ext.server.string
229
+ end
80
230
  end
@@ -0,0 +1,64 @@
1
+ require "helper"
2
+ require "minecraft"
3
+
4
+ class ExtensionsTest < Test
5
+ # call_comamnd testing.
6
+ sandbox_test "should call a command for a regular user" do
7
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
8
+ @ext.users = ["basicxman"]
9
+ @ext.call_command("basicxman", "list")
10
+ assert_equal 0, @ext.server.string.index("say")
11
+ end
12
+
13
+ sandbox_test "should not call an all command for a regular user" do
14
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
15
+ @ext.users = ["basicxman"]
16
+ @ext.call_command("basicxman", "giveall", "cobblestone")
17
+ assert_match "not a", @ext.server.string
18
+ end
19
+
20
+ sandbox_test "should not let regular users run privileged commands" do
21
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
22
+ @ext.users = ["blizzard4U"]
23
+ @ext.call_command("blizzard4U", "give", "cobblestone")
24
+ assert_match "not a", @ext.server.string
25
+ end
26
+
27
+ sandbox_test "should not call an all command if not available" do
28
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
29
+ @ext.users = ["basicxman", "blizzard4U", "mike_n_7"]
30
+ @ext.ops = ["basicxman"]
31
+ @ext.call_command("basicxman", "rouletteall")
32
+ assert_equal 2, @ext.server.string.split("\n").length
33
+ end
34
+
35
+ sandbox_test "should let ops execute an all command" do
36
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
37
+ @ext.users = ["basicxman", "blizzard4U", "mike_n_7"]
38
+ @ext.ops = ["basicxman"]
39
+ @ext.call_command("basicxman", "giveall", "cobblestone")
40
+ assert_match "basicxman is", @ext.server.string
41
+ end
42
+
43
+ sandbox_test "should not let hops or execute an all command" do
44
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
45
+ @ext.users = ["basicxman", "blizzard4U", "mike_n_7"]
46
+ @ext.hops = ["mike_n_7"]
47
+ @ext.call_command("mike_n_7", "giveall", "cobblestone")
48
+ assert_match "not a", @ext.server.string
49
+ end
50
+
51
+ sandbox_test "should not let hops run op commands" do
52
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
53
+ @ext.hops = ["mike_n_7"]
54
+ @ext.call_command("mike_n_7", "morning")
55
+ assert_match "not a", @ext.server.string
56
+ end
57
+
58
+ sandbox_test "should let ops run op privileged commands" do
59
+ @ext = Minecraft::Extensions.new(StringIO.new, {})
60
+ @ext.ops = ["basicxman"]
61
+ @ext.call_command("basicxman", "morning")
62
+ refute_match "not a", @ext.server.string
63
+ end
64
+ end
@@ -4,11 +4,30 @@ unless Object.const_defined? 'Minecraft'
4
4
  end
5
5
 
6
6
  require "minitest/autorun"
7
+ require "fileutils"
7
8
  require "stringio"
8
9
  require "turn"
9
10
 
11
+ module Minecraft
12
+ class Extensions
13
+ attr_accessor :commands, :users, :ops, :hops, :counter, :server, :kickvotes, :last_kick_vote, :uptime, :timers, :shortcuts, :userlog, :userpoints, :vote_threshold
14
+ end
15
+ end
16
+
10
17
  class Test < MiniTest::Unit::TestCase
11
18
  def self.test(name, &block)
12
19
  define_method("test_#{name.gsub(/\W/, '_')}", block)
13
20
  end
21
+
22
+ def self.sandbox_test(name, &block)
23
+ p = Proc.new do
24
+ FileUtils.mkdir("mc") unless File.exists? "mc"
25
+ FileUtils.cd("mc") do
26
+ FileUtils.touch("ops.txt")
27
+ FileUtils.touch("server.properties")
28
+ instance_eval(&block)
29
+ end
30
+ end
31
+ define_method("test_#{name.gsub(/\W/, '_')}", p)
32
+ end
14
33
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: minecraft
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Horsman
@@ -51,6 +51,7 @@ files:
51
51
  - lib/minecraft/version.rb
52
52
  - minecraft.gemspec
53
53
  - test/commands_test.rb
54
+ - test/extensions_test.rb
54
55
  - test/helper.rb
55
56
  - test/tools_test.rb
56
57
  has_rdoc: true