ruco 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE.txt +20 -0
  3. data/bin/ruco +24 -30
  4. data/lib/ruco.rb +1 -3
  5. data/lib/ruco/command_bar.rb +1 -1
  6. data/lib/ruco/core_ext/range.rb +1 -1
  7. data/lib/ruco/core_ext/string.rb +2 -15
  8. data/lib/ruco/editor/colors.rb +2 -2
  9. data/lib/ruco/status_bar.rb +1 -1
  10. data/lib/ruco/syntax_parser.rb +1 -1
  11. data/lib/ruco/version.rb +1 -1
  12. data/lib/ruco/window.rb +1 -1
  13. metadata +34 -64
  14. data/.gitignore +0 -2
  15. data/.travis.yml +0 -7
  16. data/Gemfile +0 -8
  17. data/Gemfile.lock +0 -39
  18. data/Rakefile +0 -32
  19. data/Readme.md +0 -164
  20. data/lib/ruco/keyboard.rb +0 -206
  21. data/lib/ruco/screen.rb +0 -148
  22. data/lib/ruco/style_map.rb +0 -108
  23. data/playground/benchmark_syntax_parser.rb +0 -23
  24. data/ruco.gemspec +0 -22
  25. data/spec/fixtures/slow.js +0 -4
  26. data/spec/fixtures/test.tmTheme +0 -186
  27. data/spec/ruco/application_spec.rb +0 -433
  28. data/spec/ruco/array_processor_spec.rb +0 -46
  29. data/spec/ruco/command_bar_spec.rb +0 -127
  30. data/spec/ruco/core_ext/array_spec.rb +0 -31
  31. data/spec/ruco/core_ext/range_spec.rb +0 -37
  32. data/spec/ruco/core_ext/string_spec.rb +0 -36
  33. data/spec/ruco/editor_spec.rb +0 -1261
  34. data/spec/ruco/file_store_spec.rb +0 -102
  35. data/spec/ruco/form_spec.rb +0 -83
  36. data/spec/ruco/history_spec.rb +0 -143
  37. data/spec/ruco/keyboard_spec.rb +0 -136
  38. data/spec/ruco/option_accessor_spec.rb +0 -26
  39. data/spec/ruco/screen_spec.rb +0 -52
  40. data/spec/ruco/status_bar_spec.rb +0 -49
  41. data/spec/ruco/style_map_spec.rb +0 -124
  42. data/spec/ruco/syntax_parser_spec.rb +0 -78
  43. data/spec/ruco/text_area_spec.rb +0 -183
  44. data/spec/ruco/tm_theme_spec.rb +0 -14
  45. data/spec/ruco/window_spec.rb +0 -170
  46. data/spec/ruco_spec.rb +0 -7
  47. data/spec/spec_helper.rb +0 -36
@@ -1,102 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Ruco::FileStore do
4
- def mark_all_as_old
5
- store.send(:entries).each{|e| File.utime(1,1,e) }
6
- end
7
-
8
- before do
9
- @folder = 'spec/sessions'
10
- `rm -rf #{@folder}`
11
- end
12
-
13
- after do
14
- `rm -rf #{@folder}`
15
- end
16
-
17
- let(:store){ Ruco::FileStore.new(@folder, :keep => 3) }
18
-
19
- it "can get unstored stuff" do
20
- store.get('xxx').should == nil
21
- end
22
-
23
- it "can store stuff" do
24
- store.set('xxx', 1)
25
- store.get('xxx').should == 1
26
- end
27
-
28
- it "can store :keep keys" do
29
- store.set('xxx', 1)
30
- store.set('yyy', 1)
31
- store.set('zzz', 1)
32
- mark_all_as_old
33
- store.set('aaa', 2)
34
- store.get('aaa').should == 2
35
- ['xxx','yyy','zzz'].map{|f| store.get(f) }.should =~ [1,1,nil]
36
- end
37
-
38
- it "does not drop if used multiple times" do
39
- store.set('xxx', 1)
40
- store.set('yyy', 1)
41
- store.set('zzz', 1)
42
- store.set('zzz', 1)
43
- mark_all_as_old
44
- store.set('zzz', 1)
45
- store.set('zzz', 1)
46
- store.get('xxx').should == 1
47
- end
48
-
49
- it "can cache" do
50
- store.cache('x'){ 1 }.should == 1
51
- store.cache('x'){ 2 }.should == 1
52
- end
53
-
54
- it "can cache false" do
55
- store.cache('x'){ false }.should == false
56
- store.cache('x'){ 2 }.should == false
57
- end
58
-
59
- it "does not cache nil" do
60
- store.cache('x'){ nil }.should == nil
61
- store.cache('x'){ 2 }.should == 2
62
- end
63
-
64
- it "can delete" do
65
- store.set('x', 1)
66
- store.set('y', 2)
67
- store.delete('x')
68
- store.get('x').should == nil
69
- store.get('y').should == 2
70
- end
71
-
72
- it "can delete uncached" do
73
- store.set('x', 1)
74
- store.delete('z')
75
- store.get('x').should == 1
76
- store.get('z').should == nil
77
- end
78
-
79
- it "can clear" do
80
- store.set('x', 1)
81
- store.clear
82
- store.get('x').should == nil
83
- end
84
-
85
- it "can clear unstored" do
86
- store.clear
87
- store.get('x').should == nil
88
- end
89
-
90
- it "can store pure strings" do
91
- store = Ruco::FileStore.new(@folder, :keep => 3, :string => true)
92
- store.set('xxx','yyy')
93
- File.read(store.file('xxx')).should == 'yyy'
94
- store.get('xxx').should == 'yyy'
95
- end
96
-
97
- it "works without colors" do
98
- store = Ruco::FileStore.new(@folder)
99
- store.set('xxx',1)
100
- store.get('xxx').should == 1
101
- end
102
- end
@@ -1,83 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Ruco::Form do
4
- let(:form){ Ruco::Form.new('Test', :columns => 30){|value| @result = value } }
5
-
6
- it "positions cursor in text field" do
7
- form.cursor.should == [0, 5]
8
- end
9
-
10
- describe :insert do
11
- it "adds label size and input size" do
12
- form.insert('abc')
13
- form.cursor.should == [0, 8]
14
- end
15
-
16
- it "does not return result on normal insert" do
17
- form.insert('abc')
18
- @result.should == nil
19
- end
20
-
21
- it "returns result on enter" do
22
- form.insert('abc')
23
- form.insert("d\n")
24
- @result.should == "abcd"
25
- end
26
-
27
- it "returns result on normal insert when auto_enter is given" do
28
- form.instance_eval{ @options[:auto_enter] = true }
29
- form.insert('a')
30
- @result.should == 'a'
31
- end
32
- end
33
-
34
- describe :move do
35
- it "moves in text-field" do
36
- form.insert('abc')
37
- form.move(:relative, 0, -1)
38
- form.cursor.should == [0,7]
39
- end
40
-
41
- it "cannot move out of left side" do
42
- form.move(:relative, 0, -3)
43
- form.cursor.should == [0,5]
44
- end
45
-
46
- it "cannot move out of right side" do
47
- form.move(:relative, 0, 4)
48
- form.cursor.should == [0,5]
49
- form.insert('abc')
50
- form.move(:relative, 0, 4)
51
- form.cursor.should == [0,8]
52
- end
53
- end
54
-
55
- describe :delete do
56
- it "removes characters forward" do
57
- form.insert('abc')
58
- form.move(:relative, 0, -2)
59
- form.delete(1)
60
- form.view.should == 'Test ac'
61
- end
62
-
63
- it "removes characters backward" do
64
- form.insert('abc')
65
- form.move(:relative, 0, -1)
66
- form.delete(-1)
67
- form.view.should == 'Test ac'
68
- end
69
-
70
- it "moves the cursor backward" do
71
- form.insert('abc')
72
- form.move(:relative, 0, -1)
73
- form.delete(-1)
74
- form.cursor.should == [0,6]
75
- end
76
- end
77
-
78
- describe :view do
79
- it "can be viewed" do
80
- form.view.should == "Test "
81
- end
82
- end
83
- end
@@ -1,143 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Ruco::History do
4
- let(:history){ Ruco::History.new(:state => {:x => 1}, :track => [:x], :entries => 3) }
5
-
6
- it "knows its state" do
7
- history.state.should == {:x => 1}
8
- end
9
-
10
- it "can add a state" do
11
- history.add :x => 2
12
- history.state.should == {:x => 2}
13
- end
14
-
15
- it "can undo a state" do
16
- history.add :x => 2
17
- history.undo
18
- history.state.should == {:x => 1}
19
- end
20
-
21
- it "can undo-redo-undo a state" do
22
- history.add :x => 2
23
- history.undo
24
- history.redo
25
- history.state.should == {:x => 2}
26
- end
27
-
28
- it "cannot redo a modified stack" do
29
- history.add :x => 2
30
- history.undo
31
- history.add :x => 3
32
- history.redo
33
- history.state.should == {:x => 3}
34
- history.redo
35
- history.state.should == {:x => 3}
36
- end
37
-
38
- it "cannot undo into nirvana" do
39
- history.add :x => 2
40
- history.undo
41
- history.undo
42
- history.state.should == {:x => 1}
43
- end
44
-
45
- it "cannot redo into nirvana" do
46
- history.add :x => 2
47
- history.redo
48
- history.state.should == {:x => 2}
49
- end
50
-
51
- it "cannot undo unimportant changes" do
52
- history.add(:x => 1, :y => 1)
53
- history.undo
54
- history.state.should == {:x => 1}
55
- end
56
-
57
- it "tracks unimportant fields when an important one changes" do
58
- history.add(:x => 2, :y => 1)
59
- history.add(:x => 3)
60
- history.undo
61
- history.state.should == {:x => 2, :y => 1}
62
- history.undo
63
- history.state.should == {:x => 1}
64
- end
65
-
66
- it "does not track more than x states" do
67
- history.add(:x => 2)
68
- history.add(:x => 3)
69
- history.add(:x => 4)
70
- history.add(:x => 5)
71
- history.undo
72
- history.undo
73
- history.undo
74
- history.undo
75
- history.state.should == {:x => 3}
76
- end
77
-
78
- describe 'with strings' do
79
- let(:history){ Ruco::History.new(:state => {:x => 'a'}, :track => [:x], :timeout => 0.1) }
80
-
81
- it "triggers a new state on insertion and deletion" do
82
- %w{ab abc ab a a}.each{|state| history.add(:x => state)}
83
-
84
- history.undo
85
- history.state.should == {:x => "abc"}
86
-
87
- history.undo
88
- history.state.should == {:x => "a"}
89
- end
90
- end
91
-
92
- describe 'with timeout' do
93
- let(:history){ Ruco::History.new(:state => {:x => 1}, :track => [:x], :entries => 3, :timeout => 0.1) }
94
-
95
- it "adds fast changes" do
96
- history.add(:x => 2)
97
- history.add(:x => 3)
98
- history.add(:x => 4)
99
- history.undo
100
- history.state.should == {:x => 1}
101
- end
102
-
103
- it "does not modify undone states" do
104
- history.undo
105
- history.state.should == {:x => 1}
106
- history.add(:x => 4)
107
- history.undo
108
- history.state.should == {:x => 1}
109
- end
110
-
111
- it "does not modify redone states" do
112
- history.add(:x => 2)
113
- history.undo
114
- sleep 0.2
115
- history.redo
116
- history.state.should == {:x => 2}
117
- history.add(:x => 3)
118
- history.undo
119
- history.state.should == {:x => 2}
120
- end
121
-
122
- it "does not add slow changes" do
123
- history.add(:x => 2)
124
- history.add(:x => 3)
125
- sleep 0.2
126
- history.add(:x => 4)
127
- history.undo
128
- history.state.should == {:x => 3}
129
- end
130
- end
131
-
132
- describe 'with no entry limit' do
133
- let(:history){ Ruco::History.new(:state => {:x => 1}, :track => [:x], :entries => 0, :timeout => 0) }
134
-
135
- it "should track unlimited states" do
136
- 200.times do |i|
137
- history.add(:x => i+5)
138
- end
139
- history.stack.length.should == 201
140
- end
141
- end
142
-
143
- end
@@ -1,136 +0,0 @@
1
- # encoding: UTF-8
2
- require "spec_helper"
3
-
4
- describe Keyboard do
5
- def output
6
- keys = []
7
- Timeout.timeout(0.3) do
8
- Keyboard.output do |key|
9
- keys << key
10
- end
11
- end
12
- keys
13
- rescue Timeout::Error
14
- keys
15
- end
16
-
17
- def type(chars)
18
- Keyboard.input do
19
- char = chars.shift
20
- if char == :sleep_long
21
- sleep 0.1
22
- nil
23
- else
24
- char
25
- end
26
- end
27
- end
28
-
29
- it "can listen to simple keys" do
30
- type [32]
31
- output.should == [' ']
32
- end
33
-
34
- it "can listen to multiple keys" do
35
- type [32, :sleep_long, 97]
36
- output.should == [' ','a']
37
- end
38
-
39
- it "can listen ctrl+x" do
40
- type [26]
41
- output.should == [:'Ctrl+z']
42
- end
43
-
44
- it "can listen to enter" do
45
- type [13]
46
- output.should == [:enter]
47
- end
48
-
49
- it "does not listen to nil / NOTHING" do
50
- type [nil, Keyboard::NOTHING, 13]
51
- output.should == [:enter]
52
- end
53
-
54
- it "can fetch uft8-chars" do
55
- type [195, 164]
56
- output.should == ['ä']
57
- end
58
-
59
- it "cannot fetch long sequences" do
60
- type [195, :sleep_long, 164]
61
- output.map{|s|s.bytes.to_a}.should == [[195], [164]]
62
- end
63
-
64
- it "fetches pastes between normal key strokes" do
65
- type [32, :sleep_long, 32, 13, 32, :sleep_long, 32]
66
- output.should == [' '," \n ",' ']
67
- end
68
-
69
- it "returns pastes that do not need indentation fix as normal chars" do
70
- type [32, :sleep_long, 32, 32, 32, :sleep_long, 32]
71
- output.should == [' ',' ',' ',' ',' ']
72
- end
73
-
74
- it "returns control chars separately" do
75
- type [260, 127, 127, 261, 260, 195, 164, 261, 260, 195, 164]
76
- output.should == [:left, :backspace, :backspace, :right, :left, "ä", :right, :left, "ä"]
77
- end
78
-
79
- it "ignores wtf number that is entered when using via ssh" do
80
- type [2**64-1, 2**32-1]
81
- output.should == []
82
- end
83
-
84
- it "returns key-code for unprintable keys" do
85
- type [11121, 324234]
86
- output.should == [11121, 324234]
87
- end
88
-
89
- it "recognises escape sequence for Shift+down" do
90
- type [27, 91, 49, 59, 50, 66]
91
- output.should == [:"Shift+down"]
92
- end
93
-
94
- it "ignores to long escape sequences" do
95
- type [27, 91, 49, 59, 50, 66, 59, 50, 66, 59, 50, 66]
96
- output.should == [:escape, "[", "1", ";", "2", "B", ";", "2", "B", ";", "2", "B"]
97
- end
98
-
99
- it "recognises escape sequence for Shift+up" do
100
- type [27, 91, 49, 59, 50, 65]
101
- output.should == [:"Shift+up"]
102
- end
103
-
104
- it "recognises escape sequence for mac iterm Ctrl+Shift+right" do
105
- type [27, 91, 67]
106
- output.should == [:"Ctrl+Shift+right"]
107
- end
108
-
109
- it "recognises escape sequence for mac iterm Ctrl+Shift+left" do
110
- type [27, 27, 91, 68]
111
- output.should == [:"Ctrl+Shift+left"]
112
- end
113
-
114
- if RUBY_VERSION > '1.9.0'
115
- it "can handle strings from 1.9" do
116
- type ['a']
117
- output.should == ["a"]
118
- end
119
- end
120
-
121
- it "can handle Alt+x codes" do
122
- type [27,103]
123
- output.should == [:"Alt+g"]
124
- end
125
-
126
- it "can return normal escape" do
127
- type [27]
128
- output.should == [:escape]
129
- end
130
-
131
- it "can paste quickly" do
132
- t = Time.now.to_f
133
- type Array.new(999).map{ 27 }
134
- (Time.now.to_f - t).should <= 0.01
135
- end
136
- end