ruco 0.2.0.beta2 → 0.2.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,10 @@ describe Ruco::FileStore do
16
16
 
17
17
  let(:store){ Ruco::FileStore.new(@folder, :keep => 3) }
18
18
 
19
+ it "can get unstored stuff" do
20
+ store.get('xxx').should == nil
21
+ end
22
+
19
23
  it "can store stuff" do
20
24
  store.set('xxx', 1)
21
25
  store.get('xxx').should == 1
@@ -41,4 +45,45 @@ describe Ruco::FileStore do
41
45
  store.set('zzz', 1)
42
46
  store.get('xxx').should == 1
43
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
44
89
  end
@@ -3,7 +3,7 @@ require File.expand_path('spec/spec_helper')
3
3
  describe Ruco::Screen do
4
4
  describe :curses_style do
5
5
  it "is 'normal' for nothing" do
6
- Ruco::Screen.curses_style(:normal).should == Curses::A_NORMAL
6
+ Ruco::Screen.curses_style(:normal).should == 256
7
7
  end
8
8
 
9
9
  it "is red for red" do
@@ -12,7 +12,7 @@ describe Ruco::Screen do
12
12
  end
13
13
 
14
14
  it "is reverse for reverse" do
15
- Ruco::Screen.curses_style(:reverse).should == Curses::A_REVERSE
15
+ Ruco::Screen.curses_style(:reverse).should == 512
16
16
  end
17
17
 
18
18
  it "raises on unknown style" do
@@ -20,5 +20,42 @@ describe Ruco::Screen do
20
20
  Ruco::Screen.curses_style(:foo)
21
21
  }.should raise_error
22
22
  end
23
+
24
+ describe 'without colors' do
25
+ before do
26
+ Ruco::Screen.class_eval '@@styles = {}' # clear cache
27
+ $ruco_colors = false
28
+ end
29
+
30
+ after do
31
+ $ruco_colors = true
32
+ end
33
+
34
+ it "is 'normal' for normal" do
35
+ Ruco::Screen.curses_style(:normal).should == Curses::A_NORMAL
36
+ end
37
+
38
+ it "is reverse for reverse" do
39
+ Ruco::Screen.curses_style(:reverse).should == Curses::A_REVERSE
40
+ end
41
+
42
+ it "is normal for unknown style" do
43
+ Ruco::Screen.curses_style(:foo).should == Curses::A_NORMAL
44
+ end
45
+ end
46
+ end
47
+
48
+ describe :html_to_terminal_color do
49
+ # http://www.mudpedia.org/wiki/Xterm_256_colors
50
+ [
51
+ ['#ff0000', 196],
52
+ ['#00ff00', 46],
53
+ ['#0000ff', 21],
54
+ ['#ffffff', 231]
55
+ ].each do |html,term|
56
+ it "converts #{html} to #{term}" do
57
+ Ruco::Screen.html_to_terminal_color(html).should == term
58
+ end
59
+ end
23
60
  end
24
61
  end
@@ -0,0 +1,74 @@
1
+ require File.expand_path('spec/spec_helper')
2
+
3
+ describe Ruco::SyntaxParser do
4
+ def parse(text, languages=['ruby'])
5
+ Ruco::SyntaxParser.syntax_for_lines(text, languages)
6
+ end
7
+
8
+ describe :parse_lines do
9
+ it "shows positions for simple lines" do
10
+ parse(["class Foo","end"]).should == [[
11
+ ["keyword.control.class.ruby", 0...5],
12
+ ["entity.name.type.class.ruby", 6...9],
13
+ ["meta.class.ruby", 0...9]],
14
+ [["keyword.control.ruby", 0...3]
15
+ ]]
16
+ end
17
+
18
+ it "shows positions for complicated lines" do
19
+ parse(["class foo end blob else Foo"]).should == [[
20
+ ["keyword.control.class.ruby", 0...5],
21
+ ["entity.name.type.class.ruby", 6...9],
22
+ ["meta.class.ruby", 0...9],
23
+ ["keyword.control.ruby", 10...13],
24
+ ["keyword.control.ruby", 19...23],
25
+ ["variable.other.constant.ruby", 24...27]
26
+ ]]
27
+ end
28
+
29
+ it "does not show keywords in strings" do
30
+ parse(["Bar 'Bar' foo"]).should == [[
31
+ ["variable.other.constant.ruby", 0...3],
32
+ ["punctuation.definition.string.begin.ruby", 4...5],
33
+ ["punctuation.definition.string.end.ruby", 8...9],
34
+ ["string.quoted.single.ruby", 4...9]
35
+ ]]
36
+ end
37
+
38
+ it "does not show strings in comments" do
39
+ parse(["'Bar' # 'Bar'"]).should == [[
40
+ ["punctuation.definition.string.begin.ruby", 0...1],
41
+ ["punctuation.definition.string.end.ruby", 4...5],
42
+ ["string.quoted.single.ruby", 0...5],
43
+ ["punctuation.definition.comment.ruby", 6...7],
44
+ ["comment.line.number-sign.ruby", 6...13]
45
+ ]]
46
+ end
47
+
48
+ it "shows multiline comments" do
49
+ parse(["=begin","1 : 2","=end"]).should == [
50
+ [["punctuation.definition.comment.ruby", 0...6], ["comment.block.documentation.ruby", 0...7]],
51
+ [["comment.block.documentation.ruby", 0...6]],
52
+ [["punctuation.definition.comment.ruby", 0...4], ["comment.block.documentation.ruby", 0...4]]
53
+ ]
54
+ end
55
+
56
+ it "continues multiline on last line before closing it" do
57
+ parse(["%Q{\n\na }"]).should == [
58
+ [["punctuation.definition.string.begin.ruby", 0...3], ["string.quoted.double.ruby.mod", 0...4]],
59
+ [["string.quoted.double.ruby.mod", 0...1]],
60
+ [["punctuation.definition.string.end.ruby", 3...4], ["string.quoted.double.ruby.mod", 0...4]]
61
+ ]
62
+ end
63
+
64
+ it "can handle unfound syntaxes" do
65
+ parse('aaaa', ['fooo']).should == []
66
+ end
67
+ end
68
+
69
+ describe :syntax_nodes do
70
+ it "detects languages not present in ultraviolet" do
71
+ Ruco::SyntaxParser.syntax_node(['html+erb']).should_not == nil
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('spec/spec_helper')
2
+
3
+ describe Ruco::TMTheme do
4
+ let(:theme){ Ruco::TMTheme.new('spec/fixtures/test.tmTheme') }
5
+
6
+ it "parses foreground/background" do
7
+ theme.foreground.should == '#4D4D4C'
8
+ theme.background.should == '#FFFFFF'
9
+ end
10
+
11
+ it "parses rules" do
12
+ theme.styles["keyword.operator.class"].should == ['#666969', nil]
13
+ end
14
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  $LOAD_PATH.unshift 'lib'
2
+ $ruco_colors = true
3
+
2
4
  require 'ruco'
3
5
  require 'timeout'
4
-
5
6
  require 'tempfile'
7
+
8
+ silence_warnings{ Ruco::Editor::Colors::DEFAULT_THEME = 'spec/fixtures/test.tmTheme' }
9
+
6
10
  class Tempfile
7
11
  def self.string_as_file(data)
8
12
  result = nil
@@ -21,4 +25,4 @@ class Time
21
25
  yield
22
26
  Time.now.to_f - t
23
27
  end
24
- end
28
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196359
4
+ hash: 62196357
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
10
  - beta
11
- - 2
12
- version: 0.2.0.beta2
11
+ - 3
12
+ version: 0.2.0.beta3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Michael Grosser
@@ -21,7 +21,7 @@ date: 2011-09-24 00:00:00 +02:00
21
21
  default_executable: ruco
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
@@ -32,12 +32,12 @@ dependencies:
32
32
  - 9
33
33
  - 8
34
34
  version: 0.9.8
35
+ requirement: *id001
35
36
  type: :runtime
36
37
  name: clipboard
37
- version_requirements: *id001
38
38
  prerelease: false
39
39
  - !ruby/object:Gem::Dependency
40
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
@@ -46,12 +46,12 @@ dependencies:
46
46
  segments:
47
47
  - 0
48
48
  version: "0"
49
+ requirement: *id002
49
50
  type: :runtime
50
51
  name: ultraviolet1x
51
- version_requirements: *id002
52
52
  prerelease: false
53
53
  - !ruby/object:Gem::Dependency
54
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
57
  - - ">="
@@ -60,9 +60,9 @@ dependencies:
60
60
  segments:
61
61
  - 0
62
62
  version: "0"
63
+ requirement: *id003
63
64
  type: :runtime
64
65
  name: language_sniffer
65
- version_requirements: *id003
66
66
  prerelease: false
67
67
  description:
68
68
  email: michael@grosser.it
@@ -81,6 +81,7 @@ files:
81
81
  - bin/ruco
82
82
  - lib/ruco.rb
83
83
  - lib/ruco/application.rb
84
+ - lib/ruco/array_processor.rb
84
85
  - lib/ruco/command_bar.rb
85
86
  - lib/ruco/core_ext/array.rb
86
87
  - lib/ruco/core_ext/file.rb
@@ -89,6 +90,7 @@ files:
89
90
  - lib/ruco/core_ext/range.rb
90
91
  - lib/ruco/core_ext/string.rb
91
92
  - lib/ruco/editor.rb
93
+ - lib/ruco/editor/colors.rb
92
94
  - lib/ruco/editor/history.rb
93
95
  - lib/ruco/editor/line_numbers.rb
94
96
  - lib/ruco/editor_area.rb
@@ -101,12 +103,19 @@ files:
101
103
  - lib/ruco/screen.rb
102
104
  - lib/ruco/status_bar.rb
103
105
  - lib/ruco/style_map.rb
106
+ - lib/ruco/syntax_parser.rb
104
107
  - lib/ruco/text_area.rb
105
108
  - lib/ruco/text_field.rb
109
+ - lib/ruco/tm_theme.rb
106
110
  - lib/ruco/version.rb
107
111
  - lib/ruco/window.rb
112
+ - playground/benchmark_syntax_parser.rb
108
113
  - ruco.gemspec
114
+ - spec/fixtures/railscasts.tmTheme
115
+ - spec/fixtures/slow.js
116
+ - spec/fixtures/test.tmTheme
109
117
  - spec/ruco/application_spec.rb
118
+ - spec/ruco/array_processor_spec.rb
110
119
  - spec/ruco/command_bar_spec.rb
111
120
  - spec/ruco/core_ext/array_spec.rb
112
121
  - spec/ruco/core_ext/range_spec.rb
@@ -120,7 +129,9 @@ files:
120
129
  - spec/ruco/screen_spec.rb
121
130
  - spec/ruco/status_bar_spec.rb
122
131
  - spec/ruco/style_map_spec.rb
132
+ - spec/ruco/syntax_parser_spec.rb
123
133
  - spec/ruco/text_area_spec.rb
134
+ - spec/ruco/tm_theme_spec.rb
124
135
  - spec/ruco/window_spec.rb
125
136
  - spec/ruco_spec.rb
126
137
  - spec/spec_helper.rb
@@ -164,22 +175,5 @@ rubygems_version: 1.6.2
164
175
  signing_key:
165
176
  specification_version: 3
166
177
  summary: Commandline editor written in ruby
167
- test_files:
168
- - spec/ruco/application_spec.rb
169
- - spec/ruco/command_bar_spec.rb
170
- - spec/ruco/core_ext/array_spec.rb
171
- - spec/ruco/core_ext/range_spec.rb
172
- - spec/ruco/core_ext/string_spec.rb
173
- - spec/ruco/editor_spec.rb
174
- - spec/ruco/file_store_spec.rb
175
- - spec/ruco/form_spec.rb
176
- - spec/ruco/history_spec.rb
177
- - spec/ruco/keyboard_spec.rb
178
- - spec/ruco/option_accessor_spec.rb
179
- - spec/ruco/screen_spec.rb
180
- - spec/ruco/status_bar_spec.rb
181
- - spec/ruco/style_map_spec.rb
182
- - spec/ruco/text_area_spec.rb
183
- - spec/ruco/window_spec.rb
184
- - spec/ruco_spec.rb
185
- - spec/spec_helper.rb
178
+ test_files: []
179
+