another_toy_robot 0.1.9 → 0.1.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43ea9ed6146a026f2e64bf8fb0c9190950f8ae76
4
- data.tar.gz: ea3faa443089ea8a429f6f8305b5c3fcb7a99873
3
+ metadata.gz: fbbb001b13b2aece8fbc3472fde61dbd182f15a2
4
+ data.tar.gz: f082074f51a05499991610fa313020112bd53cf8
5
5
  SHA512:
6
- metadata.gz: 556f6c6f940b2079d8be8c87d7ac853541d1ed2aadc097f3a5ef665f2950289e4b64891ffe0f477110571edafa1998dfd4e8dbba53db875766a042566c6e6b1b
7
- data.tar.gz: f1a887cfa16bdd63a2bd36429f43904db8bb0829e255b11a2296fbb357d231d06c6a9c0f4824b828d0c652670af2ff49334830597088a22a5b881074a3200279
6
+ metadata.gz: a3aca4553c6b12365fc69f971d998570d020a314df936462cfac410db436498b84d0817426bead5838029731b6799a5057597353856d7d03ae6e2f603764ed87
7
+ data.tar.gz: 2be5502641219c8bd3a7d102a154ca06043cded28d02aebae3cf0fc3ec699dc35572f55fdbf39abde4fa3a25b0d86bbd75def000f3769cf2645c84dc8f82c5b0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in toy_robot.gemspec
3
+ # Specify your gem's dependencies in another_toy_robot.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/another_toy_robot.svg)](https://badge.fury.io/rb/another_toy_robot)
2
- [![Code Climate](https://codeclimate.com/github/drzel/toy_robot/badges/gpa.svg)](https://codeclimate.com/github/drzel/toy_robot)
3
- [![Test Coverage](https://codeclimate.com/github/drzel/toy_robot/badges/coverage.svg)](https://codeclimate.com/github/drzel/toy_robot/coverage)
4
- [![Build Status](https://travis-ci.org/drzel/toy_robot.svg?branch=master)](https://travis-ci.org/drzel/toy_robot)
2
+ [![Code Climate](https://codeclimate.com/github/drzel/another_toy_robot/badges/gpa.svg)](https://codeclimate.com/github/drzel/another_toy_robot)
3
+ [![Test Coverage](https://codeclimate.com/github/drzel/another_toy_robot/badges/coverage.svg)](https://codeclimate.com/github/drzel/another_toy_robot/coverage)
4
+ [![Build Status](https://travis-ci.org/drzel/another_toy_robot.svg?branch=master)](https://travis-ci.org/drzel/another_toy_robot)
5
5
 
6
6
  # Another Toy Robot Simulator
7
7
  The application is a simulation of a toy robot moving on a 5 x 5 unit tabletop. It is an example of a well tested, object oriented design, employing the command design pattern. It is commonly used as an code-test. See specifications below for the full text of the test.
@@ -24,8 +24,8 @@ $ gem install another_toy_robot
24
24
 
25
25
  Alternatively it can be built from source:
26
26
  ```
27
- $ git clone https://github.com/drzel/toy_robot.git
28
- $ cd toy_robot
27
+ $ git clone https://github.com/drzel/another_toy_robot.git
28
+ $ cd another_toy_robot
29
29
  $ bundle install
30
30
  ```
31
31
 
@@ -39,7 +39,7 @@ Unit tests are written to [Sandi Metz' Unit Testing Minimalist](https://youtu.be
39
39
 
40
40
  ### Usage
41
41
  ```
42
- $ toy_robot
42
+ $ another_toy_robot
43
43
  ```
44
44
 
45
45
  This will present a prompt:
@@ -66,32 +66,29 @@ The app implements:
66
66
  - The [null-object pattern](https://en.wikipedia.org/wiki/Null_Object_pattern) (for positions)
67
67
  - The [singleton pattern](https://en.wikipedia.org/wiki/Singleton_pattern) (for directions)
68
68
 
69
- `toy_robot` is an executable in your load path. It is a Ruby script that calls the main function:
69
+ `another_toy_robot` is an executable in your load path. It is a Ruby script that calls the main function:
70
70
  ```
71
71
  #!/usr/bin/env ruby
72
72
 
73
- require "toy_robot"
74
- ToyRobot.main
73
+ require "another_toy_robot"
74
+ AnotherToyRobot.main
75
75
  ```
76
76
 
77
- `ToyRobot#main` instantiates a new `Client`. The `Client` instantiates an `Arena` and `Robot` objects. The new `Robot` is initialised with `NullPosition` in the `Arena`.
77
+ `AnotherToyRobot#main` instantiates a new `Client`. The `Client` instantiates an `Arena` and `Robot` objects. The new `Robot` is initialised with `NullPosition` in the `Arena`.
78
+
79
+ The main loop does the following:
78
80
 
79
- - The main loop does the following:
80
81
  - Requests user input
81
82
  - Instantiates a new `Input` object
82
- - Passes the new `Input` object to the client
83
+ - Passes the new `Input` object to the client's `#command_for` method
83
84
 
84
85
  The `Input` class contains methods to parse the user input and determine the correct `Command` class for the given command. E.g. `"move"` will resolve a the `MoveCommand` while `"derp"` will resolve `InvalidCommand`.
85
86
 
86
- The client calls the `Input#new_command` method, passing the `@robot` as the target.
87
+ The `Client#command_for` method calls the `Input#new_command` method, passing the `@robot` as the target.
87
88
 
88
89
  The `xCommand` object will parse any arguments provided and call the appropriate action on the `@robot`.
89
90
 
90
- When receiving a `place` method the robot will check with its `@arena` to see if the position is `#inbounds` before assigning the new `Position` to itself.
91
-
92
- When receiving `#left`, `#right` or `#move`, the robot will pass the request to its `@position` which will respond with the new position.
93
-
94
- The `Robot` will then check with its `@arena` to see if the position is `#inbounds` before assigning the new position to itself.
91
+ When receiving `#left`, `#right` or `#move`, the robot will pass the request to its `@position` which will respond with the new position. The `#place` method obtains it's position from the commands parameters. Then `Robot` will then check with its `@arena` to see if the position is `#inbounds` before assigning the new position to itself.
95
92
 
96
93
  When receiving a `#left`, `#right` or `#move` message the `NullPosition` will return itself.
97
94
 
@@ -102,7 +99,7 @@ This process continues until an `"exit"` command is received, breaking the loop.
102
99
  ### Considerations
103
100
  Given the requirement for a command line interface to interact with the robot, I settled on the well established and widely used command pattern.
104
101
 
105
- The `Input` wrapper allows new commands to be easily added. E.g. Creating a new file `lib/toy_robot/random_command.rb` and requiring it, would be all that is required for the application to accept the `"random"` command, and it would have access to an array of parameters. Validations can also be added by defining a `valid?` method on the command object. See the `lib/toy_robot/place_command.rb` for an example.
102
+ The `Input` wrapper allows new commands to be easily added. E.g. Creating a new file `lib/another_toy_robot/random_command.rb` and requiring it, would be all that is required for the application to accept the `"random"` command, and it would have access to an array of parameters. Validations can also be added by defining a `valid?` method on the command object. See the `lib/another_toy_robot/place_command.rb` for an example.
106
103
 
107
104
  I'm particularly happy with the `Position` class and the `Direction` modules. Together as a unit they have absolutely no dependencies and could be easily reused with new features, new objects, or with changing specifications. It would be reasonably straight forward to add a second robot, or a third dimension.
108
105
 
@@ -1,15 +1,15 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "toy_robot/version"
4
+ require "another_toy_robot/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "another_toy_robot"
8
- spec.version = ToyRobot::VERSION
8
+ spec.version = AnotherToyRobot::VERSION
9
9
  spec.date = "2016-12-05"
10
10
  spec.authors = "Sheldon J. Johnson"
11
11
  spec.email = "sheldon.j.johnson@outlook.com"
12
- spec.homepage = "https://github.com/drzel/toy_robot"
12
+ spec.homepage = "https://github.com/drzel/another_toy_robot"
13
13
  spec.summary = "Another toy robot demonstration app"
14
14
  spec.required_ruby_version = ">= 2.3"
15
15
  spec.license = "MIT"
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  end
24
24
 
25
25
  spec.bindir = "bin"
26
- spec.executables << "toy_robot"
26
+ spec.executables << "another_toy_robot"
27
27
 
28
28
  spec.add_development_dependency "rspec", "~> 3.5"
29
29
  spec.add_development_dependency "rake", "~> 11.3"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "another_toy_robot"
4
+ AnotherToyRobot.main
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "toy_robot"
4
+ require "another_toy_robot"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,7 +1,7 @@
1
- require "toy_robot/client"
2
- require "toy_robot/input"
1
+ require "another_toy_robot/client"
2
+ require "another_toy_robot/input"
3
3
 
4
- module ToyRobot
4
+ module AnotherToyRobot
5
5
  def self.main
6
6
  client = Client.new
7
7
 
File without changes
@@ -1,5 +1,5 @@
1
- require "toy_robot/arena"
2
- require "toy_robot/robot"
1
+ require "another_toy_robot/arena"
2
+ require "another_toy_robot/robot"
3
3
 
4
4
  class Client
5
5
  def initialize
File without changes
File without changes
@@ -1,9 +1,9 @@
1
- require "toy_robot/move_command"
2
- require "toy_robot/left_command"
3
- require "toy_robot/right_command"
4
- require "toy_robot/place_command"
5
- require "toy_robot/report_command"
6
- require "toy_robot/invalid_command"
1
+ require "another_toy_robot/move_command"
2
+ require "another_toy_robot/left_command"
3
+ require "another_toy_robot/right_command"
4
+ require "another_toy_robot/place_command"
5
+ require "another_toy_robot/report_command"
6
+ require "another_toy_robot/invalid_command"
7
7
 
8
8
  class Input
9
9
  def initialize(input)
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class InvalidCommand < Command
4
4
  def execute
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class LeftCommand < Command
4
4
  def issue_command
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class MoveCommand < Command
4
4
  def issue_command
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class PlaceCommand < Command
4
4
  def post_initialize
@@ -1,4 +1,4 @@
1
- require "toy_robot/direction"
1
+ require "another_toy_robot/direction"
2
2
 
3
3
  class Position
4
4
  attr_reader :x_coord, :y_coord, :direction
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class ReportCommand < Command
4
4
  def issue_command
@@ -1,4 +1,4 @@
1
- require "toy_robot/command"
1
+ require "another_toy_robot/command"
2
2
 
3
3
  class RightCommand < Command
4
4
  def issue_command
@@ -1,6 +1,6 @@
1
- require "toy_robot/position"
2
- require "toy_robot/null_position"
3
- require "toy_robot/arena"
1
+ require "another_toy_robot/position"
2
+ require "another_toy_robot/null_position"
3
+ require "another_toy_robot/arena"
4
4
 
5
5
  class Robot
6
6
  attr_reader :position, :arena
@@ -0,0 +1,3 @@
1
+ module AnotherToyRobot
2
+ VERSION = "0.1.10".freeze
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: another_toy_robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon J. Johnson
@@ -85,7 +85,7 @@ description: The application is a simulation of a toy robot moving on a square t
85
85
  pattern.
86
86
  email: sheldon.j.johnson@outlook.com
87
87
  executables:
88
- - toy_robot
88
+ - another_toy_robot
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
@@ -97,27 +97,27 @@ files:
97
97
  - LICENSE.txt
98
98
  - README.md
99
99
  - Rakefile
100
+ - another_toy_robot.gemspec
101
+ - bin/another_toy_robot
100
102
  - bin/console
101
103
  - bin/setup
102
- - bin/toy_robot
103
- - lib/toy_robot.rb
104
- - lib/toy_robot/arena.rb
105
- - lib/toy_robot/client.rb
106
- - lib/toy_robot/command.rb
107
- - lib/toy_robot/direction.rb
108
- - lib/toy_robot/input.rb
109
- - lib/toy_robot/invalid_command.rb
110
- - lib/toy_robot/left_command.rb
111
- - lib/toy_robot/move_command.rb
112
- - lib/toy_robot/null_position.rb
113
- - lib/toy_robot/place_command.rb
114
- - lib/toy_robot/position.rb
115
- - lib/toy_robot/report_command.rb
116
- - lib/toy_robot/right_command.rb
117
- - lib/toy_robot/robot.rb
118
- - lib/toy_robot/version.rb
119
- - toy_robot.gemspec
120
- homepage: https://github.com/drzel/toy_robot
104
+ - lib/another_toy_robot.rb
105
+ - lib/another_toy_robot/arena.rb
106
+ - lib/another_toy_robot/client.rb
107
+ - lib/another_toy_robot/command.rb
108
+ - lib/another_toy_robot/direction.rb
109
+ - lib/another_toy_robot/input.rb
110
+ - lib/another_toy_robot/invalid_command.rb
111
+ - lib/another_toy_robot/left_command.rb
112
+ - lib/another_toy_robot/move_command.rb
113
+ - lib/another_toy_robot/null_position.rb
114
+ - lib/another_toy_robot/place_command.rb
115
+ - lib/another_toy_robot/position.rb
116
+ - lib/another_toy_robot/report_command.rb
117
+ - lib/another_toy_robot/right_command.rb
118
+ - lib/another_toy_robot/robot.rb
119
+ - lib/another_toy_robot/version.rb
120
+ homepage: https://github.com/drzel/another_toy_robot
121
121
  licenses:
122
122
  - MIT
123
123
  metadata: {}
data/bin/toy_robot DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "toy_robot"
4
- ToyRobot.main
@@ -1,3 +0,0 @@
1
- module ToyRobot
2
- VERSION = "0.1.9".freeze
3
- end