ruco 0.0.37 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -63,8 +63,7 @@ TIPS
63
63
 
64
64
  TODO
65
65
  =====
66
- - big warning when editing a not-writeable file
67
- - nice warning when failing to write a write-only file
66
+ - big warning when editing a not-writable file
68
67
  - find next (Alt+n)
69
68
  - add selection colors to forms in command_bar
70
69
  - session storage (stay at same line/column when reopening)
@@ -77,7 +76,7 @@ TODO
77
76
  - add auto-confirm to 'replace?' dialog -> type s == skip, no enter needed
78
77
  - 1.8: unicode support <-> already finished but unusable due to Curses (see encoding branch)
79
78
  - support Alt+Fx keys
80
- - (later) extract keyboard and html-style components into seperate project
79
+ - (later) extract keyboard and html-style components into separate project
81
80
 
82
81
  Author
83
82
  ======
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.37
1
+ 0.0.38
@@ -141,7 +141,10 @@ module Ruco
141
141
  end
142
142
 
143
143
  action :save do
144
- editor.save
144
+ result = editor.save
145
+ if result != true
146
+ ask("#{result.slice(0,100)} -- Enter=Retry Esc=Cancel "){ @actions[:save].call }
147
+ end
145
148
  end
146
149
 
147
150
  action :quit do
@@ -50,6 +50,9 @@ module Ruco
50
50
  content = text_area.content
51
51
  File.open(@file,'w'){|f| f.write(content) }
52
52
  @saved_content = content
53
+ true
54
+ rescue Object => e
55
+ e.message
53
56
  end
54
57
  end
55
58
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.0.37"
8
+ s.version = "0.0.38"
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"]
@@ -11,6 +11,11 @@ describe Ruco::Application do
11
11
  File.open(@file,'w'){|f| f.write(content) }
12
12
  end
13
13
 
14
+ def read
15
+ File.read(@file)
16
+ end
17
+
18
+
14
19
  def editor_part(view)
15
20
  view.naive_split("\n")[1..-2].join("\n")
16
21
  end
@@ -251,4 +256,27 @@ describe Ruco::Application do
251
256
  end
252
257
  end
253
258
  end
259
+
260
+ describe :save do
261
+ it "just saves" do
262
+ write('')
263
+ app.key('x')
264
+ app.key(:'Ctrl+s')
265
+ read.should == 'x'
266
+ end
267
+
268
+ it "warns when saving failed" do
269
+ begin
270
+ `chmod -w #{@file}`
271
+ app.key(:'Ctrl+s')
272
+ app.view.should include('Permission denied')
273
+ app.key(:enter) # retry ?
274
+ app.view.should include('Permission denied')
275
+ app.key(:escape)
276
+ app.view.should_not include('Permission denied')
277
+ ensure
278
+ `chmod +w #{@file}`
279
+ end
280
+ end
281
+ end
254
282
  end
@@ -631,16 +631,25 @@ describe Ruco::Editor do
631
631
  it 'stores the file' do
632
632
  write('xxx')
633
633
  editor.insert('a')
634
- editor.save
634
+ editor.save.should == true
635
635
  File.read(@file).should == 'axxx'
636
636
  end
637
637
 
638
638
  it 'creates the file' do
639
639
  `rm #{@file}`
640
640
  editor.insert('a')
641
- editor.save
641
+ editor.save.should == true
642
642
  File.read(@file).should == 'a'
643
643
  end
644
+
645
+ it 'does not crash when it cannot save a file' do
646
+ begin
647
+ `chmod -w #{@file}`
648
+ editor.save.should == "Permission denied - #{@file}"
649
+ ensure
650
+ `chmod +w #{@file}`
651
+ end
652
+ end
644
653
  end
645
654
 
646
655
  describe :delete do
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: 85
4
+ hash: 83
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 37
10
- version: 0.0.37
9
+ - 38
10
+ version: 0.0.38
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser