roversim_abrophy 1.0.0 → 1.2.0

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
  SHA256:
3
- metadata.gz: 139cf4733fa5c2d21d2a906e687233e8063f052b8fb77798cf0b7ba4f992f02f
4
- data.tar.gz: 65e52dba05cc0bccd5a24479e07f0f6ff94b9afc0b7edcb54917917017814676
3
+ metadata.gz: d2cc74a57ccc874e8adb7b70b9cafb96abc367dc6ae977c53856f5d8376ea1ed
4
+ data.tar.gz: b57e32374a0db08fd04258b7ab28339927157d8af79f4e642a42c53cd9a7dede
5
5
  SHA512:
6
- metadata.gz: c52bad1e3526f0eb415ba02cc6f05783327d5110297a4589eaa33f82859adfa13495d76a7d11048a2f0153dcf58244492c82d17b68024dcdd33c01e973578cfa
7
- data.tar.gz: eeccf05bbc946b996c677209054b7e350c3ed0d123d3ed7af91da30f93cc3883c38015c704e0e2dd9438ece8cb38abe55ff90790818c532a3ed3f8a47ffd4730
6
+ metadata.gz: c89943f0af11e2afedb5670f84a048115b1e00ae674dd9be480a1eba3935279d2b107099b771438e64797f6674c93148201c42999903588f421d437ac63e6e20
7
+ data.tar.gz: bba2621eacacb7dc8619b8603c7d5ca44edf87f30d8f00c64659bb29cc6a28d4e8a2c2dd2594093c5bf5d80c9e529081ca1d998afbcff876d7a076cf33c007a9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roversim_abrophy (0.1.0)
4
+ roversim_abrophy (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,43 +1,113 @@
1
1
  # RoversimAbrophy
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/roversim_abrophy`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem serves as a solution to an OOP problem where it is required to
4
+ build out a class heirarchy to simulate and predict the movement of a
5
+ rover on mars
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
7
+ ## Installation and Usage
6
8
 
7
- ## Installation
9
+ There are three ways to install and use the gem:
8
10
 
9
- Add this line to your application's Gemfile:
11
+ ### clone from github
12
+
13
+ ```
14
+ git clone https://github.com/abrophy/roversim.git
15
+ ```
16
+
17
+ after cloning the repo onto your computer, enter the directory and run:
18
+ ```
19
+ bundle install
20
+ ```
21
+ To install the dev dependencies.
22
+
23
+ A sample input file has been provided with the repo as
24
+ `roversim_input.example`.
25
+
26
+ You can then use rake to process this sample input file:
27
+
28
+ ```
29
+ rake run roversim_input.example
30
+ ```
31
+
32
+ simply replace the sample input filename with your own if desired.
33
+
34
+ ### install gem for command line usage
35
+
36
+ The gem is hosted on rubygems so it can be installed to your environment
37
+ through a simple gem install:
38
+
39
+ ```
40
+ gem install roversim_abrophy
41
+ ```
42
+
43
+ to process an input file call from command line via
44
+
45
+ ```
46
+ roversim abrophy input_file_name
47
+ ```
48
+
49
+ ### requiring it into an existing ruby project
50
+
51
+ Add the gem to your gemfile:
52
+
53
+ ```ruby
54
+ gem 'roversim_abrophy', '1.2.0'
55
+ ```
56
+
57
+ it can then be required and used to process inputs already split into an
58
+ array:
10
59
 
11
60
  ```ruby
12
- gem 'roversim_abrophy'
61
+ require 'roversim_abrophy'
62
+
63
+ input_array = [
64
+ '88',
65
+ '12 E',
66
+ 'MMLMRMMRRMML'
67
+ ]
68
+
69
+ RoversimAbrophy.process(input_array)
70
+ #=>'3 3 S'
13
71
  ```
14
72
 
15
- And then execute:
73
+ ## Testing
16
74
 
17
- $ bundle
75
+ After cloning the repo and installing dev dependencies with bundle, you can run tests against the codebase through:
18
76
 
19
- Or install it yourself as:
77
+ ```
78
+ rake test
79
+ ```
20
80
 
21
- $ gem install roversim_abrophy
81
+ ## Notes on Design and testing
22
82
 
23
- ## Usage
83
+ While working out the design for these classes the most interesting
84
+ relationship I found was between the tracers and the rover class. I
85
+ inject the rover class into the tracers when moving so that the tracers
86
+ are responsible for knowing how to update the coordinates of the rover.
24
87
 
25
- TODO: Write usage instructions here
88
+ The Tracer class is called when performing turns and returns the correct
89
+ new tracer class depending on the turn which also holds the correct
90
+ movement behavior for the new direction.
26
91
 
27
- ## Development
92
+ Actually generating the correct tracer for the rover class on
93
+ initialization is done with a case statement, though I know this is an
94
+ OOP smell, given the time constraint and the class heirarchy ( there
95
+ will likely be no new cardinal directions added anytime soon and the
96
+ rover operates on a two dimensional grid ), I don't see anything wrong
97
+ with the implementation.
28
98
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
99
+ I used RSpec to cover unit and integration tests, and used rubocop to test
100
+ code style across the project.
30
101
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
102
+ The only complaint from rubocop I haven't dealt with is the length of
103
+ the #process_instructions method in the controller.
32
104
 
33
- ## Contributing
105
+ This is due to the message parsing happening in the controller class.
34
106
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/roversim_abrophy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
107
+ If the message structure or nature of the input were to change in the
108
+ future I would implement a new message parsing class to deal with this
109
+ issue, but for now am happy with the implementation.
36
110
 
37
111
  ## License
38
112
 
39
113
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the RoversimAbrophy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/roversim_abrophy/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:test)
5
5
 
6
6
  task :run do
7
- sh "ruby bin/roversim_abrophy.rb roversim_input"
7
+ sh "ruby bin/roversim_abrophy #{ARGV[1]}"
8
8
  end
9
9
 
10
10
  task default: :test
data/lib/rover.rb CHANGED
@@ -2,7 +2,7 @@ require 'roversim_abrophy/version'
2
2
 
3
3
  # Rover class that stores rover position state
4
4
  class Rover
5
- attr_accessor :direction, :x, :y
5
+ attr_accessor :x, :y
6
6
 
7
7
  def initialize(zone, position_string)
8
8
  @zone = zone
@@ -8,8 +8,8 @@ require_relative './tracers/east'
8
8
  require_relative './tracers/south'
9
9
  require_relative './tracers/west'
10
10
 
11
+ # Generates classes from input and returns destination
11
12
  module RoversimAbrophy
12
- # Generates classes from input and returns destination
13
13
  def self.process(input_array)
14
14
  zone = Zone.new(input_array[0])
15
15
  rover = Rover.new(zone, input_array[1])
@@ -1,3 +1,3 @@
1
1
  module RoversimAbrophy
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
data/lib/tracers/east.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Tracers
2
+ # Handles Eastern travel by rover
2
3
  class East
3
4
  def turn_left
4
5
  Tracers::North.new
data/lib/tracers/north.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Tracers
2
+ # Handles Northern travel by rover
2
3
  class North
3
4
  def turn_left
4
5
  Tracers::West.new
data/lib/tracers/south.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Tracers
2
+ # Handles Southern travel by rover
2
3
  class South
3
4
  def turn_left
4
5
  Tracers::East.new
data/lib/tracers/west.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Tracers
2
+ # Handles Western travel by rover
2
3
  class West
3
4
  def turn_left
4
5
  Tracers::South.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roversim_abrophy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Brophy