ruco 0.0.47 → 0.0.48

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -15,6 +15,7 @@ Features:
15
15
  - opens file at line with `ruco foo/bar.rb:32` syntax
16
16
  - keeps whatever newline format you use (\r \n \r\n)
17
17
  - (optional) remove trailing whitespace on save
18
+ - (optional) blank line before eof on save
18
19
 
19
20
  Install
20
21
  =======
@@ -32,7 +33,8 @@ Customize
32
33
  # set options
33
34
  options.window_line_scroll_offset = 5 # default 1
34
35
  options.history_entries = 10 # default 100
35
- options.editor_remove_trailing_whitespace_on_save = true # default false
36
+ options.editor_remove_trailing_whitespace_on_save = true # default false
37
+ options.editor_blank_line_before_eof_on_save = true # default false
36
38
  ...
37
39
 
38
40
  # bind a key
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.47
1
+ 0.0.48
@@ -178,7 +178,7 @@ module Ruco
178
178
  move(:to, 9999, 9999)
179
179
  end
180
180
  end
181
-
181
+
182
182
  action :find do
183
183
  ask("Find: ", :cache => true){|result| editor.find(result) }
184
184
  end
@@ -258,7 +258,7 @@ module Ruco
258
258
  end
259
259
 
260
260
  def parse_file_and_line(file)
261
- if not File.exist?(file)
261
+ if file.to_s.include?(':') and not File.exist?(file)
262
262
  short_file, go_to_line = file.split(':',2)
263
263
  if File.exist?(short_file)
264
264
  file = short_file
data/lib/ruco/editor.rb CHANGED
@@ -48,6 +48,7 @@ module Ruco
48
48
  def save
49
49
  lines = text_area.send(:lines)
50
50
  lines.each(&:rstrip!) if @options[:remove_trailing_whitespace_on_save]
51
+ lines << '' if @options[:blank_line_before_eof_on_save] and lines.last.to_s !~ /^\s*$/
51
52
  content = lines * @newline
52
53
 
53
54
  File.open(@file,'w'){|f| f.write(content) }
@@ -74,4 +75,4 @@ module Ruco
74
75
  FileStore.new(File.expand_path('~/.ruco/sessions'), :keep => 20)
75
76
  end
76
77
  end
77
- end
78
+ end
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.47"
8
+ s.version = "0.0.48"
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-14}
12
+ s.date = %q{2011-02-19}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -70,6 +70,57 @@ describe Ruco::Editor do
70
70
  editor.modified?.should == false
71
71
  end
72
72
  end
73
+
74
+ describe 'blank line before end of file on save' do
75
+ it "adds a newline" do
76
+ write("aaa")
77
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
78
+ editor.save
79
+ read.should == "aaa\n"
80
+ end
81
+
82
+ it "does not add a newline without option" do
83
+ write("aaa")
84
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5)
85
+ editor.save
86
+ read.should == "aaa"
87
+ end
88
+
89
+ it "adds weird newline" do
90
+ write("aaa\r\nbbb")
91
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
92
+ editor.save
93
+ read.should == "aaa\r\nbbb\r\n"
94
+ end
95
+
96
+ it "does not add a newline for empty lines" do
97
+ write("aaa\n ")
98
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
99
+ editor.save
100
+ read.should == "aaa\n "
101
+ end
102
+
103
+ it "does not add a newline when one is there" do
104
+ write("aaa\n")
105
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
106
+ editor.save
107
+ read.should == "aaa\n"
108
+ end
109
+
110
+ it "does not add a weird newline when one is there" do
111
+ write("aaa\r\n")
112
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
113
+ editor.save
114
+ read.should == "aaa\r\n"
115
+ end
116
+
117
+ it "does not add a newline when many are there" do
118
+ write("aaa\n\n")
119
+ editor = Ruco::Editor.new(@file, :lines => 3, :columns => 5, :blank_line_before_eof_on_save => true)
120
+ editor.save
121
+ read.should == "aaa\n\n"
122
+ end
123
+ end
73
124
 
74
125
  describe 'convert tabs' do
75
126
  before do
@@ -908,4 +959,4 @@ describe Ruco::Editor do
908
959
  editor.view.should == "yyy\n\n\n"
909
960
  end
910
961
  end
911
- end
962
+ end
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: 65
4
+ hash: 127
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 47
10
- version: 0.0.47
9
+ - 48
10
+ version: 0.0.48
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-02-14 00:00:00 +01:00
18
+ date: 2011-02-19 00:00:00 +01:00
19
19
  default_executable: ruco
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency