ruco 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -28,9 +28,25 @@ module Ruco
28
28
 
29
29
  def move(where, *args)
30
30
  case where
31
- when :relative then
32
- self.line += args.first
33
- self.column += args.last
31
+ when :relative
32
+ line_change, column_change = args
33
+ new_column = column + column_change
34
+
35
+ # user moves right on end of line -> next line
36
+ if line_change == 0 and line != lines.size - 1 and new_column > current_line.size
37
+ self.column = 0
38
+ self.line += 1
39
+
40
+ # user moves left on start of line -> prev line
41
+ elsif line_change == 0 and line != 0 and new_column <= 0
42
+ self.line -= 1
43
+ self.column = current_line.size
44
+
45
+ # normal movement
46
+ else
47
+ self.line += line_change
48
+ self.column += column_change
49
+ end
34
50
  when :to then
35
51
  self.line, self.column = args
36
52
  when :to_bol then move_to_bol(*args)
data/ruco.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-05-20}
12
+ s.date = %q{2011-05-22}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -182,8 +182,36 @@ describe Ruco::Editor do
182
182
  editor.cursor.should == [0,0]
183
183
  end
184
184
 
185
- it "cannot move right of characters" do
186
- editor.move(:relative, 2,6)
185
+ it "does not move lines when jumping right" do
186
+ editor.move(:relative, 1, 5)
187
+ editor.cursor.should == [1,4]
188
+ end
189
+
190
+ it "does not move lines when jumping left" do
191
+ editor.move(:to, 2, 2)
192
+ editor.move(:relative, -1, -5)
193
+ editor.cursor.should == [1,0]
194
+ end
195
+
196
+ it "moves to next line when moving right of characters" do
197
+ editor.move(:relative, 0, 5)
198
+ editor.cursor.should == [1,0]
199
+ end
200
+
201
+ it "moves to prev line when moving left of characters" do
202
+ editor.move(:relative, 1, 0)
203
+ editor.move(:relative, 0, -1)
204
+ editor.cursor.should == [0,4]
205
+ end
206
+
207
+ it "stays at origin when moving left" do
208
+ editor.move(:relative, 0, -1)
209
+ editor.cursor.should == [0,0]
210
+ end
211
+
212
+ it "stays at eof when moving right" do
213
+ editor.move(:to, 2, 4)
214
+ editor.move(:relative, 0, 1)
187
215
  editor.cursor.should == [2,4]
188
216
  end
189
217
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-20 00:00:00 +02:00
18
+ date: 2011-05-22 00:00:00 +02:00
19
19
  default_executable: ruco
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency