battle-on 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Battle::On
1
+ # BattleOn
2
2
 
3
- TODO: Write a gem description
3
+ A little weapon to help fight Platform45's Battleship API
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,9 +16,38 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install battle-on
18
18
 
19
+ Now you're ready to attack!
20
+
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ When you're in the middle of game of Battleship you want to focus on
24
+ your attack - we help you do that.
25
+
26
+ First, require 'battle-on'
27
+
28
+ require 'battle_on'
29
+
30
+ Now you're ready to begin the game. To start a new game, all that's
31
+ required is your name and email:
32
+
33
+ BattleOn.begin("Johnny Johnson", "Johnny@example.com")
34
+
35
+ This will return a hash with your game id and Platform45's first attack:
36
+
37
+ {:id => 101, :x => 3, :y => 8}
38
+
39
+ Once you've started a game, you can launch your attacks. It expects your
40
+ game id and the attack coordinates as two arguments passed to the attack
41
+ method:
42
+
43
+ BattleOn.attack(101, {:x => 1, :y => 7})
44
+
45
+ This will return a hash with the status of your last attack, whether it
46
+ was a hit or miss, and Platform45's next attack. Expect it to look like
47
+ this:
48
+
49
+ {:status => "hit", :x => 5, :y => 5}
50
+
22
51
 
23
52
  ## Contributing
24
53
 
@@ -6,8 +6,8 @@ module BattleOn
6
6
  #Start the game
7
7
  #
8
8
  #mandatory parameters
9
- #email: my@email.com
10
9
  #name: My Name
10
+ #email: my@email.com
11
11
 
12
12
  class RegisterGame
13
13
  attr_reader :name, :email
@@ -31,5 +31,4 @@ module BattleOn
31
31
  end
32
32
 
33
33
  end
34
-
35
34
  end
@@ -1,3 +1,5 @@
1
+ require 'JSON'
2
+
1
3
  module BattleOn
2
4
 
3
5
  #mandatory parameters:
@@ -29,9 +31,11 @@ module BattleOn
29
31
  private
30
32
 
31
33
  def attack
32
- RestClient.post "http://battle.platform45.com/nuke", { x: x_axis,
33
- y: y_axis,
34
- id: game_id}.to_json
34
+ RestClient.post "http://battle.platform45.com/nuke", attack_params
35
+ end
36
+
37
+ def attack_params
38
+ { x: x_axis, y: y_axis, id: game_id}.to_json
35
39
  end
36
40
 
37
41
  def get_x(args)
@@ -41,5 +45,4 @@ module BattleOn
41
45
  end
42
46
 
43
47
  end
44
-
45
48
  end
@@ -1,3 +1,3 @@
1
1
  module BattleOn
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/battle_on.rb CHANGED
@@ -1,19 +1,15 @@
1
1
  require "battle_on/version"
2
-
3
- #module Battle
4
- #module On
2
+ require "battle_on/register_game"
3
+ require "battle_on/send_attack"
5
4
 
6
5
  module BattleOn
7
6
 
8
7
  def self.begin(name, email)
9
- RegisterGame.execute(name: name, email: email)
8
+ RegisterGame.execute(name, email)
10
9
  end
11
10
 
12
11
  def self.attack(game_id, attack={})
13
- SendAttack.execute(game_id: game_id, attack: attack)
12
+ SendAttack.execute(game_id, attack)
14
13
  end
15
14
 
16
15
  end
17
-
18
- #end
19
- #end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper_base'
2
+
3
+ describe BattleOn do
4
+
5
+ describe ".begin" do
6
+
7
+ it "delegates to RegisterGame" do
8
+ #expect
9
+ BattleOn::RegisterGame.should_receive(:execute).with("foo bar", "foo@bar.com")
10
+ #when
11
+ BattleOn.begin("foo bar", "foo@bar.com")
12
+ end
13
+ end
14
+
15
+ describe ".attack" do
16
+
17
+ it "delegates to SendAttack" do
18
+ #expect
19
+ BattleOn::SendAttack.should_receive(:execute).with(101, {:x_axis => 3, :y_axis => 2})
20
+ #when
21
+ BattleOn.attack(101, {:x_axis => 3, :y_axis => 2})
22
+ end
23
+ end
24
+
25
+ end
@@ -4,5 +4,6 @@ require 'webmock/rspec'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
6
6
 
7
+ require 'lib/battle_on'
7
8
  require 'lib/battle_on/register_game'
8
9
  require 'lib/battle_on/send_attack'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: battle-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-07 00:00:00.000000000 Z
12
+ date: 2013-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -77,10 +77,11 @@ files:
77
77
  - lib/battle_on/register_game.rb
78
78
  - lib/battle_on/send_attack.rb
79
79
  - lib/battle_on/version.rb
80
+ - spec/battle_on/register_game_spec.rb
81
+ - spec/battle_on/send_attack_spec.rb
82
+ - spec/battle_on_spec.rb
80
83
  - spec/helpers/register_game_spec_helper.rb
81
84
  - spec/helpers/send_attack_spec_helper.rb
82
- - spec/register_game_spec.rb
83
- - spec/send_attack_spec.rb
84
85
  - spec/spec_helper_base.rb
85
86
  homepage: ''
86
87
  licenses: []
@@ -107,8 +108,9 @@ signing_key:
107
108
  specification_version: 3
108
109
  summary: A little weapon to help fight Platform45's Battleship API.
109
110
  test_files:
111
+ - spec/battle_on/register_game_spec.rb
112
+ - spec/battle_on/send_attack_spec.rb
113
+ - spec/battle_on_spec.rb
110
114
  - spec/helpers/register_game_spec_helper.rb
111
115
  - spec/helpers/send_attack_spec_helper.rb
112
- - spec/register_game_spec.rb
113
- - spec/send_attack_spec.rb
114
116
  - spec/spec_helper_base.rb