bitmapped 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -18
- data/bitmapped.gemspec +6 -1
- data/lib/bitmapped/bitmap.rb +28 -100
- data/lib/bitmapped/cli.rb +1 -1
- data/lib/bitmapped/commands/base_command.rb +13 -0
- data/lib/bitmapped/commands/clear_command.rb +17 -0
- data/lib/bitmapped/commands/commands_helper.rb +25 -0
- data/lib/bitmapped/commands/exit_command.rb +16 -0
- data/lib/bitmapped/commands/fill_command.rb +44 -0
- data/lib/bitmapped/commands/horizontal_line_command.rb +29 -0
- data/lib/bitmapped/commands/initialiser_command.rb +18 -0
- data/lib/bitmapped/commands/invert_command.rb +26 -0
- data/lib/bitmapped/commands/mirror_command.rb +17 -0
- data/lib/bitmapped/commands/pixel_fill_command.rb +27 -0
- data/lib/bitmapped/commands/print_fancy_table_command.rb +22 -0
- data/lib/bitmapped/commands/print_table_command.rb +19 -0
- data/lib/bitmapped/commands/rotate_command.rb +17 -0
- data/lib/bitmapped/commands/vertical_line_command.rb +29 -0
- data/lib/bitmapped/exceptions.rb +1 -0
- data/lib/bitmapped/validators/validate_bitmap_initialised.rb +15 -0
- data/lib/bitmapped/validators/validate_column_row_input.rb +1 -0
- data/lib/bitmapped/validators/validate_coordinates.rb +20 -0
- data/lib/bitmapped/validators/validated_bitmap_size.rb +19 -0
- data/lib/bitmapped/validators/validation_helper.rb +4 -1
- data/lib/bitmapped/version.rb +1 -1
- data/spec/bitmap_spec.rb +129 -27
- data/spec/command/base_command_spec.rb +13 -0
- data/spec/validators/validate_bitmap_initialised_spec.rb +30 -0
- data/spec/validators/validate_column_row_input_spec.rb +5 -2
- data/spec/validators/validate_fill_input_spec.rb +5 -2
- data/spec/validators/validate_helper_spec.rb +5 -2
- data/spec/validators/validate_segment_input_spec.rb +5 -2
- metadata +93 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae854b185764fafcc2611572e5f81ea11b88208
|
4
|
+
data.tar.gz: 018fab67547caaa3b04b021a37ed220c055623f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52a23053a021241a06f78f5b8b73a2458a79d4ee5717762416915b06781ef354fcc05f908d0033395103a70b45758e605c1d42689e41032d11b0db4bf4af17c
|
7
|
+
data.tar.gz: 832a3211254842a262d95d5819312b383cc50d45c44f30c0827882c5f361c6a05866bad1b70c77394a19eefb6bca79cdc4b61f5317248fb7cf2655b67901769d
|
data/README.md
CHANGED
@@ -18,6 +18,11 @@ Bitmapped accepts various commands to create and edit bitmap-like text images:
|
|
18
18
|
| Vertically Line | Colors multiple cells on specified column between rows X Y | V | Column:Int, Row:X, Row:Y, Color:String |
|
19
19
|
| Horizontal Line | Colors multiple cells on specified row between rows X Y | H | Row:X, Row:Y, Row:Int, Color:String |
|
20
20
|
| Fill (Paint Bucket) | Fills a given cell and surrounding cells of the same color | F | Column:Int, Row:Int, Color:String |
|
21
|
+
| Show Table | Displays the table on the CLI | S | |
|
22
|
+
| Show Pretty Table | Displays a pretty table on the CLI | T | |
|
23
|
+
| Mirror | Mirrors the image along the vertical axis | M | |
|
24
|
+
| Rotate | Rotates the image 90 degrees clockwise | R | |
|
25
|
+
| Invert | Inverts image swapping colors with opposites (Z>A, Y>B, X>C etc)| N | |
|
21
26
|
| Exit | Exits the program | X | |
|
22
27
|
|
23
28
|
|
@@ -26,26 +31,51 @@ Bitmapped accepts various commands to create and edit bitmap-like text images:
|
|
26
31
|
> I 5 6
|
27
32
|
> L 2 3 A
|
28
33
|
> S
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
| 0 | 0 | 0 | 0 | 0 |
|
36
|
-
+---+---+---+---+---+
|
34
|
+
OOOOO
|
35
|
+
OOOOO
|
36
|
+
OAOOO
|
37
|
+
OOOOO
|
38
|
+
OOOOO
|
39
|
+
OOOOO
|
37
40
|
> F 3 3 J
|
38
41
|
> V 2 3 4 W
|
39
42
|
> H 3 4 2 Z
|
40
43
|
> S
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
JJJJJ
|
45
|
+
JJZZJ
|
46
|
+
JWJJJ
|
47
|
+
JWJJJ
|
48
|
+
JJJJJ
|
49
|
+
JJJJJ
|
50
|
+
> R
|
51
|
+
> S
|
52
|
+
JJJJJJ
|
53
|
+
JJWWJJ
|
54
|
+
JJJJZJ
|
55
|
+
JJJJZJ
|
56
|
+
JJJJJJ
|
57
|
+
> M
|
58
|
+
> S
|
59
|
+
JJJJJJ
|
60
|
+
JJWWJJ
|
61
|
+
JZJJJJ
|
62
|
+
JZJJJJ
|
63
|
+
JJJJJJ
|
64
|
+
> N
|
65
|
+
> S
|
66
|
+
QQQQQQ
|
67
|
+
QQDDQQ
|
68
|
+
QAQQQQ
|
69
|
+
QAQQQQ
|
70
|
+
QQQQQQ
|
71
|
+
> T
|
72
|
+
+---+---+---+---+---+---+
|
73
|
+
| Q | Q | Q | Q | Q | Q |
|
74
|
+
| Q | Q | D | D | Q | Q |
|
75
|
+
| Q | A | Q | Q | Q | Q |
|
76
|
+
| Q | A | Q | Q | Q | Q |
|
77
|
+
| Q | Q | Q | Q | Q | Q |
|
78
|
+
+---+---+---+---+---+---+
|
49
79
|
|
50
80
|
## Requirements
|
51
81
|
Ruby 2.0+
|
@@ -55,8 +85,7 @@ Bitmapped accepts various commands to create and edit bitmap-like text images:
|
|
55
85
|
|
56
86
|
## TODO
|
57
87
|
|
58
|
-
*
|
59
|
-
* Refactor Bitmap commands into objects with tests
|
88
|
+
* Refactor tests
|
60
89
|
|
61
90
|
### Copyright
|
62
91
|
|
data/bitmapped.gemspec
CHANGED
@@ -5,7 +5,7 @@ require File.expand_path('../lib/bitmapped/version', __FILE__)
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "bitmapped"
|
7
7
|
gem.version = Bitmapped::VERSION
|
8
|
-
gem.platform
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
9
|
gem.summary = %q{Bitmap CLI program}
|
10
10
|
gem.description = %q{Bitmap CLI program}
|
11
11
|
gem.license = "MIT"
|
@@ -19,5 +19,10 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ['lib']
|
20
20
|
|
21
21
|
gem.required_ruby_version = ">= 2.0.0"
|
22
|
+
gem.add_development_dependency 'bundler', '~> 1.0'
|
23
|
+
gem.add_development_dependency 'rake', '~> 0.8'
|
24
|
+
gem.add_development_dependency 'rdoc', '~> 3.0'
|
25
|
+
gem.add_development_dependency 'rspec', '~> 2.4'
|
26
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
22
27
|
gem.add_runtime_dependency 'terminal-table', '~> 1.4', '>= 1.4.5'
|
23
28
|
end
|
data/lib/bitmapped/bitmap.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Dir[File.join(File.dirname(__FILE__), 'validators', '*.rb')].each {|file| require file }
|
2
|
+
Dir[File.join(File.dirname(__FILE__), 'commands', '*.rb')].each {|file| require file }
|
2
3
|
|
3
|
-
require 'terminal-table'
|
4
4
|
require 'bitmapped/exceptions'
|
5
5
|
|
6
6
|
module Bitmapped
|
@@ -12,111 +12,39 @@ module Bitmapped
|
|
12
12
|
begin
|
13
13
|
case input.shift
|
14
14
|
when "I"
|
15
|
-
self
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
when
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
when
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
15
|
+
Commands::InitialiserCommand.new.process_command(self, input)
|
16
|
+
when "X", "exit"
|
17
|
+
Commands::ExitCommand.new.process_command(self, input)
|
18
|
+
when "C"
|
19
|
+
Commands::ClearCommand.new.process_command(self, input)
|
20
|
+
when "L"
|
21
|
+
Commands::PixelFillCommand.new.process_command(self, input)
|
22
|
+
when "V"
|
23
|
+
Commands::VerticalLineCommand.new.process_command(self, input)
|
24
|
+
when "H"
|
25
|
+
Commands::HorizontalLineCommand.new.process_command(self, input)
|
26
|
+
when "F"
|
27
|
+
Commands::FillCommand.new.process_command(self, input)
|
28
|
+
when "S"
|
29
|
+
Commands::PrintTableCommand.new.process_command(self, input)
|
30
|
+
when "T"
|
31
|
+
Commands::PrintFancyTableCommand.new.process_command(self, input)
|
32
|
+
when "R"
|
33
|
+
Commands::RotateCommand.new.process_command(self, input)
|
34
|
+
when "M"
|
35
|
+
Commands::MirrorCommand.new.process_command(self, input)
|
36
|
+
when "N"
|
37
|
+
Commands::InvertCommand.new.process_command(self, input)
|
37
38
|
else
|
38
39
|
"Invalid Command"
|
39
40
|
end
|
40
|
-
rescue
|
41
|
+
rescue BitmapNotInitialised => bni
|
42
|
+
"Bitmap has not been initialised, run command 'I' with valid arguments"
|
43
|
+
rescue ParsingError => pe
|
41
44
|
"Invalid parameters"
|
42
|
-
rescue InvalidCoordinatesError =>
|
45
|
+
rescue InvalidCoordinatesError => ice
|
43
46
|
"Invalid co-ordinates"
|
44
47
|
end
|
45
48
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
def populate_pixels(x, y)
|
49
|
-
Array.new(self.rows) { Array.new(self.columns) { "0" } }
|
50
|
-
end
|
51
|
-
|
52
|
-
def bitmap_available(command)
|
53
|
-
lambda { |option| option == command && self.pixels }
|
54
|
-
end
|
55
|
-
|
56
|
-
def formatted_table
|
57
|
-
self.table ||= Terminal::Table.new
|
58
|
-
self.table.rows = self.pixels
|
59
|
-
self.table
|
60
|
-
# self.pixels.each { |row| puts row.join("") } # no fancy table
|
61
|
-
end
|
62
|
-
|
63
|
-
def color_command(x, y, color)
|
64
|
-
x, y = coordinates_to_array_indexes(x, y)
|
65
|
-
self.pixels[y][x] = color
|
66
|
-
end
|
67
|
-
|
68
|
-
def vertical_command(column, x, y, color)
|
69
|
-
raise InvalidCoordinatesError unless (0 < column && column <= self.columns)
|
70
|
-
x, y = coordinates_to_array_indexes(x, y)
|
71
|
-
column = column - 1
|
72
|
-
self.pixels[x..y].each { |row| row[column] = color }
|
73
|
-
end
|
74
|
-
|
75
|
-
def horizontal_command(x, y, row, color)
|
76
|
-
raise InvalidCoordinatesError unless (0 < row && row <= self.rows)
|
77
|
-
x, y = coordinates_to_array_indexes(x, y)
|
78
|
-
row = row - 1
|
79
|
-
self.pixels[row][x..y] = Array.new((x..y).size, color)
|
80
|
-
end
|
81
|
-
|
82
|
-
def fill_command(x, y, replacement_color)
|
83
|
-
x, y = coordinates_to_array_indexes(x, y)
|
84
|
-
target_color = self.pixels[x][y]
|
85
|
-
queue = [[x,y]]
|
86
|
-
|
87
|
-
until queue.empty?
|
88
|
-
x, y = queue.pop
|
89
|
-
next if (!valid_cooridinates(x+1, y+1) || self.pixels[x][y] != target_color)
|
90
|
-
self.pixels[x][y] = replacement_color
|
91
|
-
queue << [x+1, y] # east
|
92
|
-
queue << [x-1, y] # west
|
93
|
-
queue << [x, y+1] # south
|
94
|
-
queue << [x, y-1] # north
|
95
|
-
|
96
|
-
# and if we are doing 8-direction flood-fill...
|
97
|
-
# queue << [x+1, y-1] # north-east
|
98
|
-
# queue << [x-1, y-1] # north-west
|
99
|
-
# queue << [x+1, y+1] # south-east
|
100
|
-
# queue << [x-1, y+1] # south-west
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def valid_cooridinates(x, y)
|
105
|
-
if (0 <= x && x <= self.columns) && (0 <= y && y <= self.rows)
|
106
|
-
true
|
107
|
-
else
|
108
|
-
false
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def coordinates_to_array_indexes(x, y)
|
113
|
-
x = x.to_i - 1
|
114
|
-
y = y.to_i - 1
|
115
|
-
if valid_cooridinates(x, y)
|
116
|
-
[x, y]
|
117
|
-
else
|
118
|
-
raise InvalidCoordinatesError
|
119
|
-
end
|
120
|
-
end
|
121
49
|
end
|
122
50
|
end
|
data/lib/bitmapped/cli.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Bitmapped
|
2
|
+
module Commands
|
3
|
+
class BaseCommand
|
4
|
+
def command_id
|
5
|
+
raise NotImplementedError.new("You must implement command_id.")
|
6
|
+
end
|
7
|
+
|
8
|
+
def process_command(pixels, args)
|
9
|
+
raise NotImplementedError.new("You must implement process_command.")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class ClearCommand < BaseCommand
|
6
|
+
|
7
|
+
def command_id
|
8
|
+
"C"
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_command(bitmap, input)
|
12
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
13
|
+
bitmap.pixels = Array.new(bitmap.rows) { Array.new(bitmap.columns) { "O" } }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
module CommandsHelper
|
6
|
+
def valid_cooridinates(bitmap, x, y)
|
7
|
+
if (0 <= x && x <= bitmap.columns) && (0 <= y && y <= bitmap.rows)
|
8
|
+
true
|
9
|
+
else
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def coordinates_to_array_indexes(bitmap, x, y)
|
15
|
+
x = x.to_i - 1
|
16
|
+
y = y.to_i - 1
|
17
|
+
if valid_cooridinates(bitmap, x, y)
|
18
|
+
[x, y]
|
19
|
+
else
|
20
|
+
raise InvalidCoordinatesError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
require 'bitmapped/commands/commands_helper'
|
3
|
+
require 'bitmapped/exceptions'
|
4
|
+
|
5
|
+
module Bitmapped
|
6
|
+
module Commands
|
7
|
+
class FillCommand < BaseCommand
|
8
|
+
include CommandsHelper
|
9
|
+
|
10
|
+
def command_id
|
11
|
+
"F"
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_command(bitmap, input)
|
15
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
16
|
+
column, row, color = Validators::ValidateFillInput.parse_and_validate(input)
|
17
|
+
fill_command(bitmap, column, row, color)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def fill_command(bitmap, x, y, replacement_color)
|
22
|
+
x, y = coordinates_to_array_indexes(bitmap, x, y)
|
23
|
+
target_color = bitmap.pixels[x][y]
|
24
|
+
queue = [[x,y]]
|
25
|
+
|
26
|
+
until queue.empty?
|
27
|
+
x, y = queue.pop
|
28
|
+
next if (!valid_cooridinates(bitmap, x+1, y+1) || bitmap.pixels[x][y] != target_color)
|
29
|
+
bitmap.pixels[x][y] = replacement_color
|
30
|
+
queue << [x+1, y] # east
|
31
|
+
queue << [x-1, y] # west
|
32
|
+
queue << [x, y+1] # south
|
33
|
+
queue << [x, y-1] # north
|
34
|
+
|
35
|
+
# and if we are doing 8-direction flood-fill...
|
36
|
+
# queue << [x+1, y-1] # north-east
|
37
|
+
# queue << [x-1, y-1] # north-west
|
38
|
+
# queue << [x+1, y+1] # south-east
|
39
|
+
# queue << [x-1, y+1] # south-west
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
require 'bitmapped/commands/commands_helper'
|
3
|
+
require 'bitmapped/exceptions'
|
4
|
+
|
5
|
+
module Bitmapped
|
6
|
+
module Commands
|
7
|
+
class HorizontalLineCommand < BaseCommand
|
8
|
+
include CommandsHelper
|
9
|
+
|
10
|
+
def command_id
|
11
|
+
"H"
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_command(bitmap, input)
|
15
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
16
|
+
column, start, finish, color = Validators::ValidateSegmentInput.parse_and_validate(input)
|
17
|
+
horizontal_command(bitmap, column, start, finish, color)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def horizontal_command(bitmap, x, y, row, color)
|
22
|
+
raise InvalidCoordinatesError unless (0 < row && row <= bitmap.rows)
|
23
|
+
x, y = coordinates_to_array_indexes(bitmap, x, y)
|
24
|
+
row = row - 1
|
25
|
+
bitmap.pixels[row][x..y] = Array.new((x..y).size, color)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class InitialiserCommand < BaseCommand
|
6
|
+
|
7
|
+
def command_id
|
8
|
+
"I"
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_command(bitmap, input)
|
12
|
+
Validators::ValidateBitmapSize.parse_and_validate(input)
|
13
|
+
bitmap.columns, bitmap.rows = Validators::ValidateColumnRowInput.parse_and_validate(input)
|
14
|
+
bitmap.pixels = Array.new(bitmap.rows) { Array.new(bitmap.columns) { "O" } }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class InvertCommand < BaseCommand
|
6
|
+
|
7
|
+
ALPHABET = [*'A'..'Z']
|
8
|
+
|
9
|
+
def command_id
|
10
|
+
"N"
|
11
|
+
end
|
12
|
+
|
13
|
+
def process_command(bitmap, input)
|
14
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
15
|
+
bitmap.pixels.each_with_index do |row, index|
|
16
|
+
bitmap.pixels[index] = row.collect{ |color| invert_color(color) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def invert_color(color)
|
22
|
+
ALPHABET[-(ALPHABET.index(color)+1)]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class MirrorCommand < BaseCommand
|
6
|
+
|
7
|
+
def command_id
|
8
|
+
"R"
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_command(bitmap, input)
|
12
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
13
|
+
bitmap = bitmap.pixels.collect { |row| row.reverse! }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
require 'bitmapped/commands/commands_helper'
|
3
|
+
require 'bitmapped/exceptions'
|
4
|
+
|
5
|
+
module Bitmapped
|
6
|
+
module Commands
|
7
|
+
class PixelFillCommand < BaseCommand
|
8
|
+
include CommandsHelper
|
9
|
+
|
10
|
+
def command_id
|
11
|
+
"L"
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_command(bitmap, input)
|
15
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
16
|
+
column, row, color = Validators::ValidateFillInput.parse_and_validate(input)
|
17
|
+
color_command(bitmap, column, row, color)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def color_command(bitmap, x, y, color)
|
22
|
+
x, y = coordinates_to_array_indexes(bitmap, x, y)
|
23
|
+
bitmap.pixels[y][x] = color
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
require 'terminal-table'
|
4
|
+
|
5
|
+
module Bitmapped
|
6
|
+
module Commands
|
7
|
+
class PrintFancyTableCommand < BaseCommand
|
8
|
+
|
9
|
+
def command_id
|
10
|
+
"T"
|
11
|
+
end
|
12
|
+
|
13
|
+
def process_command(bitmap, input)
|
14
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
15
|
+
bitmap.table ||= Terminal::Table.new
|
16
|
+
bitmap.table.rows = bitmap.pixels
|
17
|
+
puts bitmap.table
|
18
|
+
bitmap.table
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class PrintTableCommand < BaseCommand
|
6
|
+
|
7
|
+
def command_id
|
8
|
+
"S"
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_command(bitmap, input)
|
12
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
13
|
+
table = bitmap.pixels.collect { |row| row.join("") }.join("\n")
|
14
|
+
puts table
|
15
|
+
table
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
|
3
|
+
module Bitmapped
|
4
|
+
module Commands
|
5
|
+
class RotateCommand < BaseCommand
|
6
|
+
|
7
|
+
def command_id
|
8
|
+
"R"
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_command(bitmap, _)
|
12
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
13
|
+
bitmap.pixels = bitmap.pixels.transpose.map &:reverse
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'bitmapped/commands/base_command'
|
2
|
+
require 'bitmapped/commands/commands_helper'
|
3
|
+
require 'bitmapped/exceptions'
|
4
|
+
|
5
|
+
module Bitmapped
|
6
|
+
module Commands
|
7
|
+
class VerticalLineCommand < BaseCommand
|
8
|
+
include CommandsHelper
|
9
|
+
|
10
|
+
def command_id
|
11
|
+
"V"
|
12
|
+
end
|
13
|
+
|
14
|
+
def process_command(bitmap, input)
|
15
|
+
Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
|
16
|
+
column, start, finish, color = Validators::ValidateSegmentInput.parse_and_validate(input)
|
17
|
+
vertical_command(bitmap, column, start, finish, color)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def vertical_command(bitmap, column, x, y, color)
|
22
|
+
raise InvalidCoordinatesError unless (0 < column && column <= bitmap.columns)
|
23
|
+
x, y = coordinates_to_array_indexes(bitmap, x, y)
|
24
|
+
column = column - 1
|
25
|
+
bitmap.pixels[x..y].each { |row| row[column] = color }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/bitmapped/exceptions.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bitmapped/exceptions'
|
2
|
+
require 'bitmapped/validators/validation_helper'
|
3
|
+
|
4
|
+
module Bitmapped
|
5
|
+
module Validators
|
6
|
+
class ValidateBitmapInitialised
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def parse_and_validate(bitmap)
|
10
|
+
raise BitmapNotInitialised unless bitmap.pixels
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bitmapped/exceptions'
|
2
|
+
require 'bitmapped/validators/validation_helper'
|
3
|
+
|
4
|
+
module Bitmapped
|
5
|
+
module Validators
|
6
|
+
class ValidateCoordinates
|
7
|
+
class << self
|
8
|
+
def parse_and_validate(bitmap, input)
|
9
|
+
begin
|
10
|
+
row = Integer(input[0])
|
11
|
+
column = Integer(input[1])
|
12
|
+
raise InvalidCoordinatesError unless bitmap.pixels[row][column]
|
13
|
+
rescue NoMethodError => nme
|
14
|
+
raise InvalidCoordinatesError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bitmapped/exceptions'
|
2
|
+
require 'bitmapped/validators/validation_helper'
|
3
|
+
|
4
|
+
module Bitmapped
|
5
|
+
module Validators
|
6
|
+
class ValidateBitmapSize
|
7
|
+
class << self
|
8
|
+
def parse_and_validate(input)
|
9
|
+
begin
|
10
|
+
columns, rows = Validators::ValidateColumnRowInput.parse_and_validate(input)
|
11
|
+
raise ArgumentError unless ((0 < columns && columns <= 250) && (0 < rows && rows <= 250))
|
12
|
+
rescue ArgumentError => ae
|
13
|
+
raise ParsingError
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,10 +3,13 @@ require 'bitmapped/exceptions'
|
|
3
3
|
module Bitmapped
|
4
4
|
module Validators
|
5
5
|
module ValidationHelper
|
6
|
+
|
7
|
+
ALPHABET = [*'A'..'Z']
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def parse_color(color)
|
8
11
|
color = color.strip
|
9
|
-
if
|
12
|
+
if ALPHABET.include?(color)
|
10
13
|
color
|
11
14
|
else
|
12
15
|
raise ParsingError
|
data/lib/bitmapped/version.rb
CHANGED
data/spec/bitmap_spec.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Since the refactoring this is more intergration test than unit test
|
2
|
+
# I'm going to leave this as is but if I had time it would be broken
|
3
|
+
# into indidual command unit tests, with all operations done in a few
|
4
|
+
# integration tests
|
5
|
+
|
1
6
|
require 'spec_helper'
|
2
7
|
|
3
8
|
require 'bitmapped/bitmap'
|
@@ -13,11 +18,13 @@ describe Bitmap do
|
|
13
18
|
end
|
14
19
|
|
15
20
|
describe 'the I command' do
|
21
|
+
let(:args) { ["I", "2", "3"] }
|
22
|
+
let(:second_args) { ["I", "3", "2"] }
|
23
|
+
|
16
24
|
it 'initializes a grid of that size' do
|
17
|
-
|
18
|
-
|
19
|
-
["
|
20
|
-
["0", "0"]]
|
25
|
+
pixels = [["O", "O"],
|
26
|
+
["O", "O"],
|
27
|
+
["O", "O"]]
|
21
28
|
|
22
29
|
subject.command(args)
|
23
30
|
|
@@ -27,12 +34,10 @@ describe Bitmap do
|
|
27
34
|
end
|
28
35
|
|
29
36
|
it 'overwrites the old bitmap given the I command again' do
|
30
|
-
|
31
|
-
|
32
|
-
pixels = [["0", "0", "0"],
|
33
|
-
["0", "0", "0"]]
|
37
|
+
pixels = [["O", "O", "O"],
|
38
|
+
["O", "O", "O"]]
|
34
39
|
|
35
|
-
subject.command(
|
40
|
+
subject.command(args)
|
36
41
|
subject.command(second_args)
|
37
42
|
|
38
43
|
expect(subject.columns).to eq(3)
|
@@ -55,8 +60,8 @@ describe Bitmap do
|
|
55
60
|
setup_pixels(subject, 3, 2, "X")
|
56
61
|
subject.command(["C"])
|
57
62
|
|
58
|
-
expect(subject.pixels).to eq([["
|
59
|
-
["
|
63
|
+
expect(subject.pixels).to eq([["O", "O", "O"],
|
64
|
+
["O", "O", "O"]])
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
@@ -73,8 +78,8 @@ describe Bitmap do
|
|
73
78
|
subject.command(["L", "1", "2", "Z"])
|
74
79
|
subject.command(["L", "2", "1", "Z"])
|
75
80
|
|
76
|
-
expect(subject.pixels).to eq([["
|
77
|
-
["Z", "
|
81
|
+
expect(subject.pixels).to eq([["O", "Z", "O"],
|
82
|
+
["Z", "O", "O"]])
|
78
83
|
end
|
79
84
|
|
80
85
|
it 'returns an error when the coordinates are not valid' do
|
@@ -95,10 +100,10 @@ describe Bitmap do
|
|
95
100
|
subject.command(["V", "3", "2", "4", "X"])
|
96
101
|
subject.command(["V", "1", "1", "3", "Z"])
|
97
102
|
|
98
|
-
expect(subject.pixels).to eq([["Z","
|
99
|
-
["Z","
|
100
|
-
["Z","
|
101
|
-
["
|
103
|
+
expect(subject.pixels).to eq([["Z","O","O","O"],
|
104
|
+
["Z","O","X","O"],
|
105
|
+
["Z","O","X","O"],
|
106
|
+
["O","O","X","O"]]
|
102
107
|
)
|
103
108
|
end
|
104
109
|
|
@@ -128,9 +133,9 @@ describe Bitmap do
|
|
128
133
|
subject.command(["H", "2", "4", "2", "X"])
|
129
134
|
subject.command(["H", "1", "4", "4", "Z"])
|
130
135
|
|
131
|
-
expect(subject.pixels).to eq([["
|
132
|
-
["
|
133
|
-
["
|
136
|
+
expect(subject.pixels).to eq([["O","O","O","O"],
|
137
|
+
["O","X","X","X"],
|
138
|
+
["O","O","O","O"],
|
134
139
|
["Z","Z","Z","Z"]]
|
135
140
|
)
|
136
141
|
end
|
@@ -171,16 +176,46 @@ describe Bitmap do
|
|
171
176
|
describe 'the S command' do
|
172
177
|
it_should_behave_like "a command requiring an initialised bitmap", "S"
|
173
178
|
|
179
|
+
context 'when the bitmap is initialised' do
|
180
|
+
before(:example) do
|
181
|
+
setup_pixels(subject, 4, 4)
|
182
|
+
end
|
183
|
+
|
184
|
+
let(:formatted_table) { %{OOOO
|
185
|
+
OOOO
|
186
|
+
OOOO
|
187
|
+
OOOO}.gsub(/[^\S\n]{2,}/, '')}
|
188
|
+
|
189
|
+
let(:filled_formatted_table) {%{JJJJ
|
190
|
+
JJJJ
|
191
|
+
JJJJ
|
192
|
+
JJJJ}.gsub(/[^\S\n]{2,}/, '')}
|
193
|
+
|
194
|
+
it 'should output a formatted table' do
|
195
|
+
expect(subject.command(["S"]).to_s).to eq(formatted_table)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should output a correctly formatted table after fill command' do
|
199
|
+
subject.command(["F", "3", "3", "J"])
|
200
|
+
|
201
|
+
expect(subject.command(["S"]).to_s).to eq(filled_formatted_table)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe 'the T command' do
|
207
|
+
it_should_behave_like "a command requiring an initialised bitmap", "T"
|
208
|
+
|
174
209
|
context 'when the bitmap is initialised' do
|
175
210
|
before(:example) do
|
176
211
|
setup_pixels(subject, 4, 4)
|
177
212
|
end
|
178
213
|
|
179
214
|
let(:formatted_table) { %{+---+---+---+---+
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
215
|
+
| O | O | O | O |
|
216
|
+
| O | O | O | O |
|
217
|
+
| O | O | O | O |
|
218
|
+
| O | O | O | O |
|
184
219
|
+---+---+---+---+}.gsub(/[^\S\n]{2,}/, '')}
|
185
220
|
|
186
221
|
let(:filled_formatted_table) {%{+---+---+---+---+
|
@@ -191,18 +226,85 @@ describe Bitmap do
|
|
191
226
|
+---+---+---+---+}.gsub(/[^\S\n]{2,}/, '')}
|
192
227
|
|
193
228
|
it 'should output a formatted table' do
|
194
|
-
expect(subject.command(["
|
229
|
+
expect(subject.command(["T"]).to_s).to eq(formatted_table)
|
195
230
|
end
|
196
231
|
|
197
232
|
it 'should output a correctly formatted table after fill command' do
|
198
233
|
subject.command(["F", "3", "3", "J"])
|
199
234
|
|
200
|
-
expect(subject.command(["
|
235
|
+
expect(subject.command(["T"]).to_s).to eq(filled_formatted_table)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe 'the rotate command' do
|
241
|
+
it_should_behave_like "a command requiring an initialised bitmap", "R"
|
242
|
+
|
243
|
+
context 'when the bitmap is initialised' do
|
244
|
+
before(:example) do
|
245
|
+
setup_pixels(subject, 4, 4)
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should rotate the bitmap 90 degrees clockwise' do
|
249
|
+
subject.command(["H", "1", "4", "1", "X"])
|
250
|
+
subject.command(["H", "1", "4", "4", "Z"])
|
251
|
+
subject.command(["R"])
|
252
|
+
|
253
|
+
expect(subject.pixels).to eq([["Z","O","O","X"],
|
254
|
+
["Z","O","O","X"],
|
255
|
+
["Z","O","O","X"],
|
256
|
+
["Z","O","O","X"]])
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe 'the mirror command' do
|
262
|
+
it_should_behave_like "a command requiring an initialised bitmap", "M"
|
263
|
+
|
264
|
+
context 'when the bitmap is initialised' do
|
265
|
+
before(:example) do
|
266
|
+
setup_pixels(subject, 4, 4)
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should mirror the bitmap on the vertical axis' do
|
270
|
+
subject.command(["H", "1", "4", "1", "W"])
|
271
|
+
subject.command(["H", "1", "4", "4", "X"])
|
272
|
+
subject.command(["V", "1", "1", "4", "Y"])
|
273
|
+
subject.command(["V", "4", "1", "4", "Z"])
|
274
|
+
subject.command(["M"])
|
275
|
+
|
276
|
+
expect(subject.pixels).to eq([["Z","W","W","Y"],
|
277
|
+
["Z","O","O","Y"],
|
278
|
+
["Z","O","O","Y"],
|
279
|
+
["Z","X","X","Y"]])
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe 'the invert command' do
|
285
|
+
it_should_behave_like "a command requiring an initialised bitmap", "N"
|
286
|
+
|
287
|
+
context 'when the bitmap is initialised' do
|
288
|
+
before(:example) do
|
289
|
+
setup_pixels(subject, 4, 4)
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'should mirror the bitmap on the vertical axis' do
|
293
|
+
subject.command(["H", "1", "4", "1", "W"])
|
294
|
+
subject.command(["H", "1", "4", "4", "X"])
|
295
|
+
subject.command(["V", "1", "1", "4", "Y"])
|
296
|
+
subject.command(["V", "4", "1", "4", "Z"])
|
297
|
+
subject.command(["N"])
|
298
|
+
|
299
|
+
expect(subject.pixels).to eq([["B","D","D","A"],
|
300
|
+
["B","L","L","A"],
|
301
|
+
["B","L","L","A"],
|
302
|
+
["B","C","C","A"]])
|
201
303
|
end
|
202
304
|
end
|
203
305
|
end
|
204
306
|
|
205
|
-
def setup_pixels(subject, columns, rows, color="
|
307
|
+
def setup_pixels(subject, columns, rows, color="O")
|
206
308
|
subject.columns = columns
|
207
309
|
subject.rows = rows
|
208
310
|
subject.pixels = Array.new(rows) { Array.new(columns) { color } }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'BaseCommand' do
|
4
|
+
|
5
|
+
subject { Commands::BaseCommand.new }
|
6
|
+
|
7
|
+
context 'as an abstract class' do
|
8
|
+
it 'raises a NotImplementedError on any methods called' do
|
9
|
+
expect{subject.command_id}.to raise_error(NotImplementedError)
|
10
|
+
expect{subject.process_command(nil, nil)}.to raise_error(NotImplementedError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'bitmapped/exceptions'
|
4
|
+
|
5
|
+
describe Validators::ValidateBitmapInitialised do
|
6
|
+
|
7
|
+
subject { Validators::ValidateBitmapInitialised }
|
8
|
+
|
9
|
+
context 'given an initialised bitmap' do
|
10
|
+
|
11
|
+
let(:bitmap) { Bitmap.new }
|
12
|
+
|
13
|
+
it 'should not raise a BitmapNotInitialised error' do
|
14
|
+
bitmap.command(["I", "4", "4"])
|
15
|
+
|
16
|
+
expect{subject.parse_and_validate(bitmap)}.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'given an uninitialised bitmap' do
|
21
|
+
|
22
|
+
let(:invalid_inputs) { [["A", "2"], ["2", "Z"], ["99"]] }
|
23
|
+
|
24
|
+
it 'should raise a BitmapNotInitialised error' do
|
25
|
+
invalid_inputs.each do |input|
|
26
|
+
expect{Validators::ValidateColumnRowInput.parse_and_validate(input)}.to raise_error(ParsingError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -3,6 +3,9 @@ require 'spec_helper'
|
|
3
3
|
require 'bitmapped/exceptions'
|
4
4
|
|
5
5
|
describe Validators::ValidateColumnRowInput do
|
6
|
+
|
7
|
+
subject { Validators::ValidateColumnRowInput }
|
8
|
+
|
6
9
|
context 'given valid input' do
|
7
10
|
|
8
11
|
let(:valid_inputs) { [["2", "2"], ["2", "3"], ["10", "99"]] }
|
@@ -10,7 +13,7 @@ describe Validators::ValidateColumnRowInput do
|
|
10
13
|
|
11
14
|
it 'should return an array of parsed values' do
|
12
15
|
valid_inputs.each_with_index do |input, index|
|
13
|
-
expect(
|
16
|
+
expect(subject.parse_and_validate(input)).to eq(outputs[index])
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -21,7 +24,7 @@ describe Validators::ValidateColumnRowInput do
|
|
21
24
|
|
22
25
|
it 'should return an error' do
|
23
26
|
invalid_inputs.each do |input|
|
24
|
-
expect{
|
27
|
+
expect{subject.parse_and_validate(input)}.to raise_error(ParsingError)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -3,6 +3,9 @@ require 'spec_helper'
|
|
3
3
|
require 'bitmapped/exceptions'
|
4
4
|
|
5
5
|
describe Validators::ValidateFillInput do
|
6
|
+
|
7
|
+
subject { Validators::ValidateFillInput }
|
8
|
+
|
6
9
|
context 'given valid input' do
|
7
10
|
|
8
11
|
let(:valid_inputs) { [["2", "2", "C"], ["2", "3", "X"], ["10", "99", "Y"]] }
|
@@ -10,7 +13,7 @@ describe Validators::ValidateFillInput do
|
|
10
13
|
|
11
14
|
it 'should return an array of parsed values' do
|
12
15
|
valid_inputs.each_with_index do |input, index|
|
13
|
-
expect(
|
16
|
+
expect(subject.parse_and_validate(input)).to eq(outputs[index])
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -21,7 +24,7 @@ describe Validators::ValidateFillInput do
|
|
21
24
|
|
22
25
|
it 'should return an error' do
|
23
26
|
invalid_inputs.each do |input|
|
24
|
-
expect{
|
27
|
+
expect{subject.parse_and_validate(input)}.to raise_error(ParsingError)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -3,6 +3,9 @@ require 'spec_helper'
|
|
3
3
|
require 'bitmapped/exceptions'
|
4
4
|
|
5
5
|
describe Validators::ValidationHelper do
|
6
|
+
|
7
|
+
subject { Validators::ValidationHelper }
|
8
|
+
|
6
9
|
context 'given valid input' do
|
7
10
|
|
8
11
|
let(:valid_inputs) { [" A", "B", "C "] }
|
@@ -10,7 +13,7 @@ describe Validators::ValidationHelper do
|
|
10
13
|
|
11
14
|
it 'should return an array of parsed values' do
|
12
15
|
valid_inputs.each_with_index do |input, index|
|
13
|
-
expect(
|
16
|
+
expect(subject.parse_color(input)).to eq(outputs[index])
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -21,7 +24,7 @@ describe Validators::ValidationHelper do
|
|
21
24
|
|
22
25
|
it 'should return an error' do
|
23
26
|
invalid_inputs.each do |input|
|
24
|
-
expect{
|
27
|
+
expect{subject.parse_color(input)}.to raise_error(ParsingError)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -3,6 +3,9 @@ require 'spec_helper'
|
|
3
3
|
require 'bitmapped/exceptions'
|
4
4
|
|
5
5
|
describe Validators::ValidateSegmentInput do
|
6
|
+
|
7
|
+
subject { Validators::ValidateSegmentInput }
|
8
|
+
|
6
9
|
context 'given valid input' do
|
7
10
|
|
8
11
|
let(:valid_inputs) { [["2", "2", "2", "C"], ["2", "3", "3", "X"], ["10", "99", "1000", "Y"]] }
|
@@ -10,7 +13,7 @@ describe Validators::ValidateSegmentInput do
|
|
10
13
|
|
11
14
|
it 'should return an array of parsed values' do
|
12
15
|
valid_inputs.each_with_index do |input, index|
|
13
|
-
expect(
|
16
|
+
expect(subject.parse_and_validate(input)).to eq(outputs[index])
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -21,7 +24,7 @@ describe Validators::ValidateSegmentInput do
|
|
21
24
|
|
22
25
|
it 'should return an error' do
|
23
26
|
invalid_inputs.each do |input|
|
24
|
-
expect{
|
27
|
+
expect{subject.parse_and_validate(input)}.to raise_error(ParsingError)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
metadata
CHANGED
@@ -1,15 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitmapped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashley Connor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubygems-tasks
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
13
83
|
- !ruby/object:Gem::Dependency
|
14
84
|
name: terminal-table
|
15
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,16 +121,35 @@ files:
|
|
51
121
|
- lib/bitmapped.rb
|
52
122
|
- lib/bitmapped/bitmap.rb
|
53
123
|
- lib/bitmapped/cli.rb
|
124
|
+
- lib/bitmapped/commands/base_command.rb
|
125
|
+
- lib/bitmapped/commands/clear_command.rb
|
126
|
+
- lib/bitmapped/commands/commands_helper.rb
|
127
|
+
- lib/bitmapped/commands/exit_command.rb
|
128
|
+
- lib/bitmapped/commands/fill_command.rb
|
129
|
+
- lib/bitmapped/commands/horizontal_line_command.rb
|
130
|
+
- lib/bitmapped/commands/initialiser_command.rb
|
131
|
+
- lib/bitmapped/commands/invert_command.rb
|
132
|
+
- lib/bitmapped/commands/mirror_command.rb
|
133
|
+
- lib/bitmapped/commands/pixel_fill_command.rb
|
134
|
+
- lib/bitmapped/commands/print_fancy_table_command.rb
|
135
|
+
- lib/bitmapped/commands/print_table_command.rb
|
136
|
+
- lib/bitmapped/commands/rotate_command.rb
|
137
|
+
- lib/bitmapped/commands/vertical_line_command.rb
|
54
138
|
- lib/bitmapped/exceptions.rb
|
139
|
+
- lib/bitmapped/validators/validate_bitmap_initialised.rb
|
55
140
|
- lib/bitmapped/validators/validate_column_row_input.rb
|
141
|
+
- lib/bitmapped/validators/validate_coordinates.rb
|
56
142
|
- lib/bitmapped/validators/validate_fill_input.rb
|
57
143
|
- lib/bitmapped/validators/validate_segment_input.rb
|
144
|
+
- lib/bitmapped/validators/validated_bitmap_size.rb
|
58
145
|
- lib/bitmapped/validators/validation_helper.rb
|
59
146
|
- lib/bitmapped/version.rb
|
60
147
|
- spec/bitmap_spec.rb
|
61
148
|
- spec/bitmapped_spec.rb
|
149
|
+
- spec/command/base_command_spec.rb
|
62
150
|
- spec/exceptions_spec.rb
|
63
151
|
- spec/spec_helper.rb
|
152
|
+
- spec/validators/validate_bitmap_initialised_spec.rb
|
64
153
|
- spec/validators/validate_column_row_input_spec.rb
|
65
154
|
- spec/validators/validate_fill_input_spec.rb
|
66
155
|
- spec/validators/validate_helper_spec.rb
|
@@ -92,8 +181,10 @@ summary: Bitmap CLI program
|
|
92
181
|
test_files:
|
93
182
|
- spec/bitmap_spec.rb
|
94
183
|
- spec/bitmapped_spec.rb
|
184
|
+
- spec/command/base_command_spec.rb
|
95
185
|
- spec/exceptions_spec.rb
|
96
186
|
- spec/spec_helper.rb
|
187
|
+
- spec/validators/validate_bitmap_initialised_spec.rb
|
97
188
|
- spec/validators/validate_column_row_input_spec.rb
|
98
189
|
- spec/validators/validate_fill_input_spec.rb
|
99
190
|
- spec/validators/validate_helper_spec.rb
|