vedeu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/Guardfile +15 -0
- data/Rakefile +18 -0
- data/features/.gitkeep +0 -0
- data/lib/vedeu.rb +1 -0
- data/lib/vedeu/buffer.rb +93 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/buffer_test.rb +114 -0
- data/test/test_helper.rb +20 -0
- data/vedeu.gemspec +13 -0
- metadata +195 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7dc331e1fb585d179a308db5dd6a215b137ab61
|
4
|
+
data.tar.gz: a380806ad198b429f83e5934143f8b45a6d6957e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18dfcd631845fdb9338c68402dff180d11aad2eae555ba4f6b1c2621738f9651785810a9995f87f23584b847f64a240e6aa09cb40e0fc88123e9b045e579c1a1
|
7
|
+
data.tar.gz: d92cf80a6c1ee4170b6b2428251e5aa21101480caf8a571b384a91252bf87f7ed06a3fc19f3dd847171806b55b94c6f248d0e9c0d2a1160c788e94733b89c6f4
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
guard 'cucumber' do
|
2
|
+
watch(%r{^features/.+\.feature$})
|
3
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
4
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
5
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
guard :minitest, all_after_pass: true do
|
10
|
+
watch(%r{^test/(.*)_test\.rb})
|
11
|
+
watch(%r{^lib/(.+)\.rb}) do |m|
|
12
|
+
"test/lib/#{m[1]}_test.rb"
|
13
|
+
end
|
14
|
+
watch(%r{^test/test_helper\.rb}) { 'test' }
|
15
|
+
end
|
data/Rakefile
CHANGED
@@ -1 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
7
|
+
t.cucumber_opts = "features --format progress"
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs << 'lib/vedeu'
|
12
|
+
t.test_files = FileList["test/lib/vedeu/*_test.rb",
|
13
|
+
"test/lib/vedeu/**/*_test.rb"]
|
14
|
+
t.verbose = false
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => :test
|
18
|
+
|
19
|
+
Rake::Task['cucumber'].execute
|
data/features/.gitkeep
ADDED
File without changes
|
data/lib/vedeu.rb
CHANGED
data/lib/vedeu/buffer.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class OutOfRangeError < StandardError; end
|
3
|
+
|
4
|
+
class Buffer
|
5
|
+
attr_accessor :buffer
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@options = options
|
9
|
+
@buffer = Array.new(height) { Array.new(width) { ' ' } }
|
10
|
+
end
|
11
|
+
|
12
|
+
def contents
|
13
|
+
print "\n"
|
14
|
+
buffer.map do |y|
|
15
|
+
y.map do |x|
|
16
|
+
print "'#{x}'"
|
17
|
+
end
|
18
|
+
print "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def cell(y, x)
|
25
|
+
raise OutOfRangeError if invalid_reference?(y, x)
|
26
|
+
buffer[y][x]
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_cell(y, x, v = '')
|
30
|
+
raise OutOfRangeError if invalid_reference?(y, x) || invalid_cell?(v)
|
31
|
+
buffer[y][x] = v
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_row(y = 0, v = '')
|
35
|
+
v.chars.each_with_index { |c, i| set_cell(y, i, c) }
|
36
|
+
row(y)
|
37
|
+
end
|
38
|
+
|
39
|
+
def row(y = 0)
|
40
|
+
buffer[y]
|
41
|
+
end
|
42
|
+
alias_method :y, :row
|
43
|
+
|
44
|
+
def set_column(x = 0, v = '')
|
45
|
+
v.chars.each_with_index { |c, i| set_cell(i, x, c) }
|
46
|
+
column(x)
|
47
|
+
end
|
48
|
+
|
49
|
+
def column(x = 0)
|
50
|
+
buffer.inject([]) { |a, e| a << e[x] }
|
51
|
+
end
|
52
|
+
alias_method :x, :column
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def invalid_cell?(v)
|
57
|
+
v.size != 1
|
58
|
+
end
|
59
|
+
|
60
|
+
def invalid_reference?(y, x)
|
61
|
+
invalid_line?(y) || invalid_column?(x)
|
62
|
+
end
|
63
|
+
|
64
|
+
def invalid_line?(y)
|
65
|
+
y < 0 || y > (height - 1)
|
66
|
+
end
|
67
|
+
|
68
|
+
def invalid_column?(x)
|
69
|
+
x < 0 || x > (width - 1)
|
70
|
+
end
|
71
|
+
|
72
|
+
def width
|
73
|
+
options.fetch(:width)
|
74
|
+
end
|
75
|
+
alias_method :columns, :width
|
76
|
+
|
77
|
+
def height
|
78
|
+
options.fetch(:height)
|
79
|
+
end
|
80
|
+
alias_method :lines, :height
|
81
|
+
|
82
|
+
def options
|
83
|
+
defaults.merge!(@options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def defaults
|
87
|
+
{
|
88
|
+
width: 4,
|
89
|
+
height: 3
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/vedeu/version.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
describe Buffer do
|
5
|
+
let(:klass) { Buffer }
|
6
|
+
let(:options) { { width: 4, height: 3 } }
|
7
|
+
let(:instance){ klass.new(options) }
|
8
|
+
|
9
|
+
it 'returns an instance of self' do
|
10
|
+
instance.must_be_instance_of(Vedeu::Buffer)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#contents' do
|
14
|
+
subject { capture_io { instance.contents }.join }
|
15
|
+
|
16
|
+
it 'returns the contents of the buffer' do
|
17
|
+
subject.must_equal("
|
18
|
+
' '' '' '' '
|
19
|
+
' '' '' '' '
|
20
|
+
' '' '' '' '
|
21
|
+
")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#cell' do
|
26
|
+
let(:y) { 1 }
|
27
|
+
let(:x) { 2 }
|
28
|
+
|
29
|
+
subject { instance.cell(y, x) }
|
30
|
+
|
31
|
+
context 'when the reference is in range' do
|
32
|
+
it 'returns the value at that location' do
|
33
|
+
subject.must_equal(' ')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the reference is out of range' do
|
38
|
+
let(:y) { 4 }
|
39
|
+
|
40
|
+
it 'raises an exception' do
|
41
|
+
proc { subject }.must_raise(OutOfRangeError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#set_cell' do
|
47
|
+
let(:y) { 1 }
|
48
|
+
let(:x) { 2 }
|
49
|
+
let(:v) { '*' }
|
50
|
+
|
51
|
+
subject { instance.set_cell(y, x, v) }
|
52
|
+
|
53
|
+
context 'when the reference is in range' do
|
54
|
+
it 'returns the value at that location' do
|
55
|
+
subject.must_equal('*')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'updates just that cell' do
|
59
|
+
subject
|
60
|
+
capture_io { instance.contents }.join.must_equal("
|
61
|
+
' '' '' '' '
|
62
|
+
' '' ''*'' '
|
63
|
+
' '' '' '' '
|
64
|
+
")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when the reference is out of range' do
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#set_row' do
|
73
|
+
let(:y) { 1 }
|
74
|
+
let(:v) { '****' }
|
75
|
+
let(:instance) { klass.new(options) }
|
76
|
+
|
77
|
+
subject { instance.set_row(y, v) }
|
78
|
+
|
79
|
+
it 'sets the row' do
|
80
|
+
subject.must_equal(['*', '*', '*', '*'])
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'updates just that row' do
|
84
|
+
subject
|
85
|
+
capture_io { instance.contents }.join.must_equal("
|
86
|
+
' '' '' '' '
|
87
|
+
'*''*''*''*'
|
88
|
+
' '' '' '' '
|
89
|
+
")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#set_column' do
|
94
|
+
let(:x) { 2 }
|
95
|
+
let(:v) { '***' }
|
96
|
+
let(:instance) { klass.new(options) }
|
97
|
+
|
98
|
+
subject { instance.set_column(x, v) }
|
99
|
+
|
100
|
+
it 'sets the row' do
|
101
|
+
subject.must_equal(['*', '*', '*'])
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'updates just that column' do
|
105
|
+
subject
|
106
|
+
capture_io { instance.contents }.join.must_equal("
|
107
|
+
' '' ''*'' '
|
108
|
+
' '' ''*'' '
|
109
|
+
' '' ''*'' '
|
110
|
+
")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/pride'
|
4
|
+
|
5
|
+
SimpleCov.start do
|
6
|
+
command_name 'MiniTest::Spec'
|
7
|
+
add_filter '/test/'
|
8
|
+
end
|
9
|
+
|
10
|
+
module MiniTest
|
11
|
+
class Spec
|
12
|
+
class << self
|
13
|
+
alias_method :context, :describe
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require_relative '../lib/vedeu.rb'
|
19
|
+
|
20
|
+
require 'mocha/setup'
|
data/vedeu.gemspec
CHANGED
@@ -17,6 +17,19 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_development_dependency "aruba"
|
20
21
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "cucumber"
|
23
|
+
spec.add_development_dependency "guard"
|
24
|
+
spec.add_development_dependency "guard-cucumber"
|
25
|
+
spec.add_development_dependency "guard-minitest"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "mocha"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "pry-nav"
|
21
30
|
spec.add_development_dependency "rake"
|
31
|
+
spec.add_development_dependency "rubocop"
|
32
|
+
spec.add_development_dependency "ruby-prof"
|
33
|
+
spec.add_development_dependency "simplecov"
|
34
|
+
spec.add_development_dependency "yard"
|
22
35
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aruba
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,118 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cucumber
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mocha
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-nav
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
27
153
|
- !ruby/object:Gem::Dependency
|
28
154
|
name: rake
|
29
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +164,62 @@ dependencies:
|
|
38
164
|
- - ">="
|
39
165
|
- !ruby/object:Gem::Version
|
40
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: ruby-prof
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: yard
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
41
223
|
description:
|
42
224
|
email:
|
43
225
|
- gavinlaking@gmail.com
|
@@ -46,12 +228,19 @@ extensions: []
|
|
46
228
|
extra_rdoc_files: []
|
47
229
|
files:
|
48
230
|
- ".gitignore"
|
231
|
+
- ".rubocop.yml"
|
232
|
+
- ".ruby-version"
|
49
233
|
- Gemfile
|
234
|
+
- Guardfile
|
50
235
|
- LICENSE.txt
|
51
236
|
- README.md
|
52
237
|
- Rakefile
|
238
|
+
- features/.gitkeep
|
53
239
|
- lib/vedeu.rb
|
240
|
+
- lib/vedeu/buffer.rb
|
54
241
|
- lib/vedeu/version.rb
|
242
|
+
- test/lib/vedeu/buffer_test.rb
|
243
|
+
- test/test_helper.rb
|
55
244
|
- vedeu.gemspec
|
56
245
|
homepage: http://www.gavinlaking.name/
|
57
246
|
licenses:
|
@@ -77,5 +266,8 @@ rubygems_version: 2.2.2
|
|
77
266
|
signing_key:
|
78
267
|
specification_version: 4
|
79
268
|
summary: A terminal case of wonderland.
|
80
|
-
test_files:
|
269
|
+
test_files:
|
270
|
+
- features/.gitkeep
|
271
|
+
- test/lib/vedeu/buffer_test.rb
|
272
|
+
- test/test_helper.rb
|
81
273
|
has_rdoc:
|