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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +90 -20
- data/Rakefile +1 -1
- data/lib/rover.rb +1 -1
- data/lib/roversim_abrophy.rb +1 -1
- data/lib/roversim_abrophy/version.rb +1 -1
- data/lib/tracers/east.rb +1 -0
- data/lib/tracers/north.rb +1 -0
- data/lib/tracers/south.rb +1 -0
- data/lib/tracers/west.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2cc74a57ccc874e8adb7b70b9cafb96abc367dc6ae977c53856f5d8376ea1ed
|
|
4
|
+
data.tar.gz: b57e32374a0db08fd04258b7ab28339927157d8af79f4e642a42c53cd9a7dede
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c89943f0af11e2afedb5670f84a048115b1e00ae674dd9be480a1eba3935279d2b107099b771438e64797f6674c93148201c42999903588f421d437ac63e6e20
|
|
7
|
+
data.tar.gz: bba2621eacacb7dc8619b8603c7d5ca44edf87f30d8f00c64659bb29cc6a28d4e8a2c2dd2594093c5bf5d80c9e529081ca1d998afbcff876d7a076cf33c007a9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,43 +1,113 @@
|
|
|
1
1
|
# RoversimAbrophy
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
## Installation and Usage
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
There are three ways to install and use the gem:
|
|
8
10
|
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
+
## Testing
|
|
16
74
|
|
|
17
|
-
|
|
75
|
+
After cloning the repo and installing dev dependencies with bundle, you can run tests against the codebase through:
|
|
18
76
|
|
|
19
|
-
|
|
77
|
+
```
|
|
78
|
+
rake test
|
|
79
|
+
```
|
|
20
80
|
|
|
21
|
-
|
|
81
|
+
## Notes on Design and testing
|
|
22
82
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
+
I used RSpec to cover unit and integration tests, and used rubocop to test
|
|
100
|
+
code style across the project.
|
|
30
101
|
|
|
31
|
-
|
|
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
|
-
|
|
105
|
+
This is due to the message parsing happening in the controller class.
|
|
34
106
|
|
|
35
|
-
|
|
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
data/lib/rover.rb
CHANGED
data/lib/roversim_abrophy.rb
CHANGED
|
@@ -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])
|
data/lib/tracers/east.rb
CHANGED
data/lib/tracers/north.rb
CHANGED
data/lib/tracers/south.rb
CHANGED
data/lib/tracers/west.rb
CHANGED