ruco 0.0.45 → 0.0.46
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.
- data/Readme.md +2 -1
- data/VERSION +1 -1
- data/bin/ruco +0 -2
- data/lib/ruco/editor.rb +7 -8
- data/ruco.gemspec +4 -3
- data/spec/ruco/editor_spec.rb +41 -17
- metadata +8 -11
data/Readme.md
CHANGED
@@ -3,7 +3,7 @@ Simple, extendable, test-driven commandline editor written in ruby.
|
|
3
3
|
Features:
|
4
4
|
|
5
5
|
- **Intuitive interface**
|
6
|
-
- selecting via Shift+left/right/up/down and Ctrl+a(all)
|
6
|
+
- selecting via Shift+left/right/up/down (only on Linux) and Ctrl+a(all)
|
7
7
|
- Tab -> indent / Shift+Tab -> unindent
|
8
8
|
- keeps indentation (+ paste-detection e.g. via Cmd+v)
|
9
9
|
- change (*) + writable (!) indicators
|
@@ -12,6 +12,7 @@ Features:
|
|
12
12
|
- cut, copy and paste -> Ctrl+x/c/v
|
13
13
|
- undo / redo
|
14
14
|
- stays at last position when reopening a file
|
15
|
+
- keeps whatever newline format you use (\r \n \r\n)
|
15
16
|
- (optional) remove trailing whitespace on save
|
16
17
|
|
17
18
|
Install
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.46
|
data/bin/ruco
CHANGED
@@ -20,7 +20,6 @@ Usage:
|
|
20
20
|
Options:
|
21
21
|
BANNER
|
22
22
|
opts.on("-c", "--convert-tabs","Convert tabs to spaces") { options[:convert_tabs] = true }
|
23
|
-
opts.on("--convert-return","Convert \\r characters to \\n") { options[:convert_return] = true }
|
24
23
|
opts.on("--debug-cache","Show caching in action") { options[:debug_cache] = true }
|
25
24
|
opts.on("--debug-keys", "Show pressed keys") { options[:debug_keys] = true }
|
26
25
|
opts.on("-v", "--version","Show Version"){
|
@@ -117,7 +116,6 @@ require 'ruco'
|
|
117
116
|
|
118
117
|
app = Ruco::Application.new(ARGV[0],
|
119
118
|
:convert_tabs => @options[:convert_tabs],
|
120
|
-
:convert_return => @options[:convert_return],
|
121
119
|
:lines => Curses.stdscr.maxy, :columns => Curses.stdscr.maxx
|
122
120
|
)
|
123
121
|
|
data/lib/ruco/editor.rb
CHANGED
@@ -21,12 +21,11 @@ module Ruco
|
|
21
21
|
|
22
22
|
content = (File.exist?(@file) ? File.read(@file) : '')
|
23
23
|
content.tabs_to_spaces! if @options[:convert_tabs]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
24
|
+
|
25
|
+
# cleanup newline formats
|
26
|
+
@newline = content.match("\r\n|\r|\n")
|
27
|
+
@newline = (@newline ? @newline[0] : "\n")
|
28
|
+
content.gsub!(/\r\n?/,"\n")
|
30
29
|
|
31
30
|
@saved_content = content
|
32
31
|
@text_area = EditorArea.new(content, @options)
|
@@ -49,10 +48,10 @@ module Ruco
|
|
49
48
|
def save
|
50
49
|
lines = text_area.send(:lines)
|
51
50
|
lines.each(&:rstrip!) if @options[:remove_trailing_whitespace_on_save]
|
52
|
-
content = lines *
|
51
|
+
content = lines * @newline
|
53
52
|
|
54
53
|
File.open(@file,'w'){|f| f.write(content) }
|
55
|
-
@saved_content = content
|
54
|
+
@saved_content = content.gsub(/\r?\n/, "\n")
|
56
55
|
|
57
56
|
true
|
58
57
|
rescue Object => e
|
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.0.
|
8
|
+
s.version = "0.0.46"
|
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-02-
|
12
|
+
s.date = %q{2011-02-13}
|
13
13
|
s.default_executable = %q{ruco}
|
14
14
|
s.email = %q{michael@grosser.it}
|
15
15
|
s.executables = ["ruco"]
|
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
|
|
63
63
|
]
|
64
64
|
s.homepage = %q{http://github.com/grosser/ruco}
|
65
65
|
s.require_paths = ["lib"]
|
66
|
-
s.rubygems_version = %q{1.
|
66
|
+
s.rubygems_version = %q{1.3.7}
|
67
67
|
s.summary = %q{Commandline editor written in ruby}
|
68
68
|
s.test_files = [
|
69
69
|
"spec/ruco/application_spec.rb",
|
@@ -85,6 +85,7 @@ Gem::Specification.new do |s|
|
|
85
85
|
]
|
86
86
|
|
87
87
|
if s.respond_to? :specification_version then
|
88
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
88
89
|
s.specification_version = 3
|
89
90
|
|
90
91
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/spec/ruco/editor_spec.rb
CHANGED
@@ -5,6 +5,10 @@ describe Ruco::Editor do
|
|
5
5
|
File.open(@file,'w'){|f| f.write(content) }
|
6
6
|
end
|
7
7
|
|
8
|
+
def read
|
9
|
+
File.read(@file)
|
10
|
+
end
|
11
|
+
|
8
12
|
let(:editor){
|
9
13
|
editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5)
|
10
14
|
# only scroll when we reach end of lines/columns <-> able to test with smaller area
|
@@ -24,26 +28,46 @@ describe Ruco::Editor do
|
|
24
28
|
@file = 'spec/temp.txt'
|
25
29
|
end
|
26
30
|
|
27
|
-
describe "
|
28
|
-
it
|
29
|
-
write("\r")
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it "raises on \r\n" do
|
34
|
-
write("\r\n")
|
35
|
-
lambda{editor}.should raise_error
|
31
|
+
describe "strange newline formats" do
|
32
|
+
it 'views \r normally' do
|
33
|
+
write("a\rb\rc\r")
|
34
|
+
editor.view.should == "a\nb\nc\n"
|
36
35
|
end
|
37
|
-
|
38
|
-
it
|
39
|
-
write("a\nb\
|
40
|
-
editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :convert_return => true)
|
36
|
+
|
37
|
+
it 'views \r\n normally' do
|
38
|
+
write("a\r\nb\r\nc\r\n")
|
41
39
|
editor.view.should == "a\nb\nc\n"
|
42
40
|
end
|
43
|
-
|
44
|
-
it
|
45
|
-
write("\
|
46
|
-
editor
|
41
|
+
|
42
|
+
it 'saves \r as \r' do
|
43
|
+
write("a\rb\rc\r")
|
44
|
+
editor.save
|
45
|
+
read.should == "a\rb\rc\r"
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'saves \r\n as \r\n' do
|
49
|
+
write("a\r\nb\r\nc\r\n")
|
50
|
+
editor.save
|
51
|
+
read.should == "a\r\nb\r\nc\r\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "converts mixed formats to first" do
|
55
|
+
write("a\rb\r\nc\n")
|
56
|
+
editor.save
|
57
|
+
read.should == "a\rb\rc\r"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "converts newline-free to \n" do
|
61
|
+
write("a")
|
62
|
+
editor.insert("\n")
|
63
|
+
editor.save
|
64
|
+
read.should == "\na"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "is not modified after saving strange newline format" do
|
68
|
+
write("a\r\nb\r\nc\r\n")
|
69
|
+
editor.save
|
70
|
+
editor.modified?.should == false
|
47
71
|
end
|
48
72
|
end
|
49
73
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 46
|
9
|
+
version: 0.0.46
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Michael Grosser
|
@@ -15,25 +14,24 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-13 00:00:00 +01:00
|
19
18
|
default_executable: ruco
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
21
|
+
name: clipboard
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 51
|
28
27
|
segments:
|
29
28
|
- 0
|
30
29
|
- 9
|
31
30
|
- 4
|
32
31
|
version: 0.9.4
|
32
|
+
type: :runtime
|
33
33
|
prerelease: false
|
34
34
|
version_requirements: *id001
|
35
|
-
type: :runtime
|
36
|
-
name: clipboard
|
37
35
|
description:
|
38
36
|
email: michael@grosser.it
|
39
37
|
executables:
|
@@ -103,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
101
|
requirements:
|
104
102
|
- - ">="
|
105
103
|
- !ruby/object:Gem::Version
|
106
|
-
hash:
|
104
|
+
hash: -1048497741
|
107
105
|
segments:
|
108
106
|
- 0
|
109
107
|
version: "0"
|
@@ -112,14 +110,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
110
|
requirements:
|
113
111
|
- - ">="
|
114
112
|
- !ruby/object:Gem::Version
|
115
|
-
hash: 3
|
116
113
|
segments:
|
117
114
|
- 0
|
118
115
|
version: "0"
|
119
116
|
requirements: []
|
120
117
|
|
121
118
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.
|
119
|
+
rubygems_version: 1.3.7
|
123
120
|
signing_key:
|
124
121
|
specification_version: 3
|
125
122
|
summary: Commandline editor written in ruby
|