merrol 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +7 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/LICENSE +23 -0
- data/README.md +58 -0
- data/ROADMAP.md +22 -0
- data/Rakefile +63 -0
- data/autotest/discover.rb +2 -0
- data/bin/m +9 -0
- data/config/commands.yml +150 -0
- data/config/language.yml +47 -0
- data/config/messages.yml +3 -0
- data/config/settings.yml +3 -0
- data/config/snippets/rails.yml +22 -0
- data/config/snippets/rspec.yml +35 -0
- data/config/snippets/ruby.yml +97 -0
- data/config/styles/Railscasts.xml +121 -0
- data/config/templates/rails.yml +21 -0
- data/config/templates/rspec.yml +6 -0
- data/data/images/merrol.svg +412 -0
- data/data/images/merrol2.svg +531 -0
- data/data/images/modified.svg +156 -0
- data/data/images/saved.svg +156 -0
- data/lib/merrol/controllers/controller.rb +26 -0
- data/lib/merrol/controllers/edit_controller.rb +24 -0
- data/lib/merrol/controllers/file_controller.rb +61 -0
- data/lib/merrol/controllers/help_controller.rb +6 -0
- data/lib/merrol/controllers/main_controller.rb +26 -0
- data/lib/merrol/controllers/search_controller.rb +5 -0
- data/lib/merrol/controllers/tools_controller.rb +28 -0
- data/lib/merrol/gtk/bin.rb +11 -0
- data/lib/merrol/gtk/image.rb +8 -0
- data/lib/merrol/gtk/list_view.rb +43 -0
- data/lib/merrol/gtk/source_view.rb +22 -0
- data/lib/merrol/gtk/widget.rb +12 -0
- data/lib/merrol/gtk/window.rb +18 -0
- data/lib/merrol/keyboard_map.rb +136 -0
- data/lib/merrol/lib/application.rb +29 -0
- data/lib/merrol/lib/commands.rb +40 -0
- data/lib/merrol/lib/file.rb +6 -0
- data/lib/merrol/lib/shortcut.rb +35 -0
- data/lib/merrol/lib/widget_builder.rb +49 -0
- data/lib/merrol/lib/yaml.rb +10 -0
- data/lib/merrol/models/source_model.rb +44 -0
- data/lib/merrol/views/edit.yml +50 -0
- data/lib/merrol/views/file_list.yml +11 -0
- data/lib/merrol/views/file_path.yml +8 -0
- data/lib/merrol/views/file_status.yml +6 -0
- data/lib/merrol/views/hbox.yml +6 -0
- data/lib/merrol/views/main.yml +9 -0
- data/lib/merrol/views/scroll_bars.yml +15 -0
- data/lib/merrol/views/status_bar.yml +7 -0
- data/lib/merrol.rb +16 -0
- data/lib/prerequisites.rb +54 -0
- data/merrol.gemspec +24 -0
- data/spec/controllers/controller_spec.rb +27 -0
- data/spec/controllers/edit_controller_spec.rb +38 -0
- data/spec/controllers/file_controller_spec.rb +209 -0
- data/spec/controllers/main_controller_spec.rb +20 -0
- data/spec/gtk/bin_spec.rb +13 -0
- data/spec/gtk/list_view_spec.rb +114 -0
- data/spec/gtk/source_view_spec.rb +41 -0
- data/spec/gtk/widget_spec.rb +37 -0
- data/spec/gtk/window_spec.rb +28 -0
- data/spec/integration/000_startup_spec.rb +14 -0
- data/spec/integration/001_load_from_commandline_spec.rb +25 -0
- data/spec/integration/002_loading_and_saving_spec.rb +35 -0
- data/spec/integration/003_tab_file_switching_spec.rb +49 -0
- data/spec/integration/ideas_spec.rb +23 -0
- data/spec/integration_helper.rb +11 -0
- data/spec/lib/application_spec.rb +57 -0
- data/spec/lib/commands_spec.rb +63 -0
- data/spec/lib/file_spec.rb +9 -0
- data/spec/lib/shortcut_spec.rb +59 -0
- data/spec/lib/widget_builder_spec.rb +77 -0
- data/spec/lib/yaml_spec.rb +26 -0
- data/spec/models/source_model_spec.rb +80 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/actions.rb +28 -0
- data/spec/support/expectations.rb +46 -0
- data/spec/support/setup.rb +32 -0
- metadata +224 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Commands do
|
4
|
+
before(:each) do
|
5
|
+
@mock_accel_group = mock Gtk::AccelGroup
|
6
|
+
Gtk::AccelGroup.stub!(:new).and_return @mock_accel_group
|
7
|
+
Gtk::AccelMap.stub!(:add_entry)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'adds an entry for a given shortcut key' do
|
11
|
+
command_file = {'category' => {'command' => {'help' => '', 'key' => 'CTRL+ALT+SHIFT+A'}}}
|
12
|
+
YAML.stub!(:load_config).with('commands').and_return(command_file)
|
13
|
+
ctrl_alt_shift = Gdk::Window::CONTROL_MASK | Gdk::Window::MOD1_MASK | Gdk::Window::SHIFT_MASK
|
14
|
+
Gtk::AccelMap.stub!(:add_entry).with('<Merrol>/category/command', Gdk::Keyval::GDK_A, ctrl_alt_shift)
|
15
|
+
Commands.new(mock(Gtk::Window, :add_accel_group => nil))
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'accel group is added to the window' do
|
19
|
+
YAML.stub!(:load_config).and_return []
|
20
|
+
mock_window = mock Gtk::Window
|
21
|
+
mock_window.should_receive(:add_accel_group).with @mock_accel_group
|
22
|
+
Commands.new(mock_window)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can be registered' do
|
26
|
+
YAML.stub!(:load_config).and_return({'main' => {'a_command' => {'help' => '', 'key' => 'CTRL+O'}, 'another_command' => {'help' => '', 'key' => 'CTRL+T'}} })
|
27
|
+
@mock_accel_group.should_receive(:connect).with('<Merrol>/main/a_command').and_yield
|
28
|
+
@mock_accel_group.should_receive(:connect).with('<Merrol>/main/another_command').and_yield
|
29
|
+
Gtk::AccelGroup.stub!(:new).and_return @mock_accel_group
|
30
|
+
commands = Commands.new(mock(Gtk::Window, :add_accel_group => nil))
|
31
|
+
mock_controller = mock MainController, :class => MainController, :name => :main
|
32
|
+
mock_controller.should_receive :a_command
|
33
|
+
mock_controller.should_receive :another_command
|
34
|
+
commands.register mock_controller
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'registers special TAB case' do
|
38
|
+
YAML.stub!(:load_config).and_return({'main' => {'a_command' => {'help' => '', 'key' => 'CTRL+TAB'}} })
|
39
|
+
Gtk::Window.stub_chain(:toplevels, :first, :signal_connect).with('key_press_event')
|
40
|
+
mock_controller = mock MainController, :class => MainController, :name => :main
|
41
|
+
commands = Commands.new(mock(Gtk::Window, :add_accel_group => nil))
|
42
|
+
commands.register mock_controller
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'command sent when special TAB shortcut pressed' do
|
46
|
+
YAML.stub!(:load_config).and_return({'main' => {'a_command' => {'help' => '', 'key' => 'CTRL+TAB'}} })
|
47
|
+
Gtk::Window.stub_chain(:toplevels, :first, :signal_connect).with('key_press_event').and_yield(nil, Shortcut.to_event('CTRL+TAB'))
|
48
|
+
mock_controller = mock MainController, :class => MainController, :name => :main
|
49
|
+
mock_controller.should_receive(:send).with('a_command')
|
50
|
+
commands = Commands.new(mock(Gtk::Window, :add_accel_group => nil))
|
51
|
+
commands.register mock_controller
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'key ignored if not special case shortcut' do
|
55
|
+
YAML.stub!(:load_config).and_return({'main' => {'a_command' => {'help' => '', 'key' => 'CTRL+TAB'}} })
|
56
|
+
Gtk::Window.stub_chain(:toplevels, :first, :signal_connect).with('key_press_event').and_yield(nil, Shortcut.to_event('CTRL+A'))
|
57
|
+
mock_controller = mock MainController, :class => MainController, :name => :main
|
58
|
+
mock_controller.should_not_receive(:send).with('a_command')
|
59
|
+
commands = Commands.new(mock(Gtk::Window, :add_accel_group => nil))
|
60
|
+
commands.register mock_controller
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shortcut do
|
4
|
+
def self.build_events modifiers, key
|
5
|
+
{
|
6
|
+
:press => build_event(Gdk::Event::KEY_PRESS, modifiers, key),
|
7
|
+
:release => build_event(Gdk::Event::KEY_RELEASE, modifiers, key)
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build_event type, modifiers, key
|
12
|
+
e = Gdk::EventKey.new(type)
|
13
|
+
e.state = modifiers ? modifiers : e.state
|
14
|
+
e.keyval = key
|
15
|
+
e
|
16
|
+
end
|
17
|
+
|
18
|
+
class Gdk::EventKey
|
19
|
+
def inspect
|
20
|
+
modifiers = (state.control_mask? ? 1 : 0) |
|
21
|
+
(state.mod1_mask? ? 2 : 0) |
|
22
|
+
(state.shift_mask? ? 4 : 0)
|
23
|
+
"#<Gdk::EventKey #{event_type.name} with state: #{modifiers}, keyval: #{keyval}, keycode: #{hardware_keycode}>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def == other
|
27
|
+
inspect == other.inspect
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
S_KEY = Gdk::Keyval::GDK_S
|
32
|
+
CTRL_KEY = Gdk::Window::CONTROL_MASK
|
33
|
+
ALT_KEY = Gdk::Window::MOD1_MASK
|
34
|
+
SHIFT_KEY = Gdk::Window::SHIFT_MASK
|
35
|
+
|
36
|
+
@keys_events = {
|
37
|
+
'CTRL' => build_events(nil, Gdk::Keyval::GDK_Control_L),
|
38
|
+
'ESC' => build_events(nil, Gdk::Keyval::GDK_Escape),
|
39
|
+
'ALT+ENTER' => build_events(ALT_KEY, Gdk::Keyval::GDK_Return),
|
40
|
+
'CTRL+S' => build_events(CTRL_KEY, S_KEY),
|
41
|
+
'CTRL+TAB' => build_events(CTRL_KEY, Gdk::Keyval::GDK_Tab),
|
42
|
+
'CTRL+SHIFT+S' => build_events(CTRL_KEY | SHIFT_KEY, S_KEY),
|
43
|
+
'CTRL+ALT+SHIFT+S' => build_events(CTRL_KEY | ALT_KEY | SHIFT_KEY, S_KEY)
|
44
|
+
}.each do |key, event|
|
45
|
+
it "returns #{key} from a #{event[:press].inspect}" do
|
46
|
+
Shortcut.from(event[:press]).should == key
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns #{event[:press].inspect} from #{key}" do
|
50
|
+
Shortcut.to_event(key).should == event[:press]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns #{event[:release].inspect} from #{key}" do
|
54
|
+
Shortcut.to_event(key, :release).should == event[:release]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WidgetBuilder do
|
4
|
+
before(:each) do
|
5
|
+
@mock_window = mock Gtk::Window
|
6
|
+
Gtk::Window.stub!(:new).and_return @mock_window
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'creates widgets' do
|
10
|
+
YAML.stub!(:load_view).with('view1').and_return({'layout' => {'type' => 'Window'}})
|
11
|
+
YAML.stub!(:load_view).with('view2').and_return({'layout' => {'type' => 'VBox'}})
|
12
|
+
mock_vbox = mock Gtk::VBox
|
13
|
+
Gtk::VBox.stub!(:new).and_return mock_vbox
|
14
|
+
|
15
|
+
widgets = WidgetBuilder.build :view1, :view2
|
16
|
+
widgets.should == {:view1 => @mock_window, :view2 => mock_vbox}
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'handles typed values e.g. Gtk::TextTag::WRAP_WORD' do
|
20
|
+
options = {'wrap_mode' => {'type' => 'TextTag', 'value' => 'WRAP_WORD'}}
|
21
|
+
YAML.stub!(:load_view).with('a_view').and_return({'layout' => {'type' => 'Window'}, 'options' => options})
|
22
|
+
@mock_window.should_receive(:wrap_mode=).with Gtk::TextTag::WRAP_WORD
|
23
|
+
|
24
|
+
widgets = WidgetBuilder.build :a_view
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'packs widget with expand, fill and padding' do
|
28
|
+
YAML.stub!(:load_view).with('parent').and_return({'layout' => {'type' => 'VBox'}})
|
29
|
+
YAML.stub!(:load_view).with('child').and_return({'layout' => {'type' => 'Label', 'add_to' => 'parent', 'expand' => true, 'fill' => true, 'padding' => 1}})
|
30
|
+
mock_vbox = mock Gtk::VBox
|
31
|
+
mock_label = mock Gtk::Label
|
32
|
+
Gtk::VBox.stub!(:new).and_return mock_vbox
|
33
|
+
Gtk::Label.stub!(:new).and_return mock_label
|
34
|
+
mock_vbox.should_receive(:pack_start).with(mock_label, true, true, 1)
|
35
|
+
|
36
|
+
widgets = WidgetBuilder.build :parent, :child
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'packs widget with default options' do
|
40
|
+
YAML.stub!(:load_view).with('parent').and_return({'layout' => {'type' => 'VBox'}})
|
41
|
+
YAML.stub!(:load_view).with('child').and_return({'layout' => {'type' => 'Label', 'add_to' => 'parent'}})
|
42
|
+
mock_vbox = mock Gtk::VBox
|
43
|
+
mock_label = mock Gtk::Label
|
44
|
+
Gtk::VBox.stub!(:new).and_return mock_vbox
|
45
|
+
Gtk::Label.stub!(:new).and_return mock_label
|
46
|
+
mock_vbox.should_receive(:pack_start).with(mock_label, false, false, 0)
|
47
|
+
|
48
|
+
widgets = WidgetBuilder.build :parent, :child
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'packs a widget that has a container' do
|
52
|
+
YAML.stub!(:load_view).with('parent').and_return({'layout' => {'type' => 'Window', 'container' => 'VBox'}})
|
53
|
+
YAML.stub!(:load_view).with('child').and_return({'layout' => {'type' => 'Label', 'add_to' => 'parent'}})
|
54
|
+
mock_vbox = mock Gtk::VBox
|
55
|
+
mock_label = mock Gtk::Label
|
56
|
+
Gtk::VBox.stub!(:new).and_return mock_vbox
|
57
|
+
Gtk::Label.stub!(:new).and_return mock_label
|
58
|
+
@mock_window.should_receive(:container=).with 'VBox'
|
59
|
+
@mock_window.should_receive(:container).and_return mock_vbox
|
60
|
+
mock_vbox.should_receive(:pack_start).with(mock_label, false, false, 0)
|
61
|
+
|
62
|
+
widgets = WidgetBuilder.build :parent, :child
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'adds a widget to a single container parent (Gtk::Bin)' do
|
66
|
+
YAML.stub!(:load_view).with('parent').and_return({'layout' => {'type' => 'Window'}})
|
67
|
+
YAML.stub!(:load_view).with('child').and_return({'layout' => {'type' => 'Label', 'add_to' => 'parent'}})
|
68
|
+
@mock_window.stub!(:is_a?).and_return Gtk::Bin
|
69
|
+
mock_label = mock Gtk::Label
|
70
|
+
Gtk::Label.stub!(:new).and_return mock_label
|
71
|
+
@mock_window.should_receive(:add).with mock_label
|
72
|
+
|
73
|
+
widgets = WidgetBuilder.build :parent, :child
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe YAML do
|
4
|
+
it 'loads a configuration file' do
|
5
|
+
File.should_receive(:app_relative).with('config/file.yml')
|
6
|
+
mock_file = mock File
|
7
|
+
File.stub!(:open).and_return mock_file
|
8
|
+
YAML.stub!(:load).with(mock_file)
|
9
|
+
|
10
|
+
YAML.load_config('file')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'loads a view' do
|
14
|
+
File.should_receive(:app_relative).with('lib/merrol/views/file.yml')
|
15
|
+
mock_file = mock File
|
16
|
+
File.stub!(:open).and_return mock_file
|
17
|
+
YAML.stub!(:load).with(mock_file)
|
18
|
+
|
19
|
+
YAML.load_view('file')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'raises method not found exception when unknown load method specified' do
|
23
|
+
lambda{ YAML.load_something('file') }.should raise_error NoMethodError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SourceModel do
|
4
|
+
before(:each) do
|
5
|
+
YAML.stub!(:load_config).with('language').and_return []
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'loads file' do
|
9
|
+
File.stub!(:exist?).with('path').and_return true
|
10
|
+
File.stub!(:read).with('path').and_return 'text'
|
11
|
+
model = SourceModel.new 'path'
|
12
|
+
model.text.should == 'text'
|
13
|
+
model.can_undo?.should be_false
|
14
|
+
model.modified?.should be_false
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'saves a file' do
|
18
|
+
File.stub!(:exist?).with('path').and_return false
|
19
|
+
model = SourceModel.new 'path'
|
20
|
+
mock_file = mock File
|
21
|
+
mock_file.should_receive(:write).with 'text'
|
22
|
+
File.should_receive(:open).with('path', 'w').and_yield(mock_file)
|
23
|
+
|
24
|
+
model.text = 'text'
|
25
|
+
model.save
|
26
|
+
model.modified?.should be_false
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'language' do
|
30
|
+
before(:each) do
|
31
|
+
File.stub!(:exist?).and_return true
|
32
|
+
File.stub!(:read).and_return 'text'
|
33
|
+
YAML.stub!(:load_config).with('language').and_return({'ruby' => {'pattern' => '.rb Rakefile', 'bang' => 'ruby'} })
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'set based on extension' do
|
37
|
+
model = SourceModel.new 'path/file.rb'
|
38
|
+
model.language.name.should == 'Ruby'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'set based on filename' do
|
42
|
+
model = SourceModel.new 'Rakefile'
|
43
|
+
model.language.name.should == 'Ruby'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'set based on bang line (#!/usr/bin/env ruby)' do
|
47
|
+
File.stub!(:read).and_return "#!/usr/bin/env ruby\ncontent"
|
48
|
+
model = SourceModel.new 'some_script'
|
49
|
+
model.language.name.should == 'Ruby'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'does not set based on bang line that accidentally matches' do
|
53
|
+
File.stub!(:read).with('path').and_return "# I love ruby"
|
54
|
+
model = SourceModel.new 'some_script'
|
55
|
+
model.language.should be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'set based on existence of a file and pattern' do
|
59
|
+
File.stub!(:exist?).with('file.rb').and_return true
|
60
|
+
File.stub!(:exist?).with('config/routes.rb').and_return true
|
61
|
+
YAML.stub!(:load_config).with('language').and_return({'rubyonrails' => {'pattern' => '.rb', 'exists' => 'config/routes.rb'} })
|
62
|
+
model = SourceModel.new 'file.rb'
|
63
|
+
model.language.name.should == 'RubyOnRails'
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'set based on pattern and file not existing' do
|
67
|
+
File.stub!(:exist?).with('file.rb').and_return true
|
68
|
+
File.stub!(:exist?).with('config/routes.rb').and_return false
|
69
|
+
yaml = {'rubyonrails' => {'pattern' => '.rb', 'exists' => 'config/routes.rb'}, 'ruby' => {'pattern' => '.rb Rakefile'} }
|
70
|
+
YAML.stub!(:load_config).with('language').and_return yaml
|
71
|
+
model = SourceModel.new 'file.rb'
|
72
|
+
model.language.name.should == 'Ruby'
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
if ENV['COVERAGE']
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter '/spec/'
|
5
|
+
add_filter '/autotest/'
|
6
|
+
add_filter '/bin/'
|
7
|
+
|
8
|
+
add_group 'Controllers', 'controllers/'
|
9
|
+
add_group 'Models', 'models/'
|
10
|
+
add_group 'GTK', 'gtk/'
|
11
|
+
add_group 'Lib', 'lib/merrol/lib/'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$LOAD_PATH << 'lib'
|
16
|
+
require 'merrol'
|
17
|
+
include Merrol
|
18
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# e.g. pressing 'CTRL+S'
|
2
|
+
def pressing key, options = {}
|
3
|
+
widget = options[:in] || find_widget(:main, options[:test_against])
|
4
|
+
widget.grab_focus
|
5
|
+
|
6
|
+
event = Shortcut.to_event(key)
|
7
|
+
keycode, group, level = Gdk::Keymap.default.get_entries_for_keyval(event.keyval).first
|
8
|
+
event.hardware_keycode = keycode
|
9
|
+
widget.signal_emit('key_press_event', event)
|
10
|
+
process_events
|
11
|
+
end
|
12
|
+
|
13
|
+
def releasing key, options = {}
|
14
|
+
widget = options[:in] || find_widget(:main, options[:test_against])
|
15
|
+
event = Shortcut.to_event(key, :release)
|
16
|
+
keycode, group, level = Gdk::Keymap.default.get_entries_for_keyval(event.keyval).first
|
17
|
+
event.hardware_keycode = keycode
|
18
|
+
widget.signal_emit('key_release_event', event)
|
19
|
+
process_events
|
20
|
+
end
|
21
|
+
|
22
|
+
# e.g. entering 'the_file', :into => 'open.search_field'
|
23
|
+
def entering text, options = {}
|
24
|
+
widget = find_widget options[:into]
|
25
|
+
widget.insert_text text, widget.position
|
26
|
+
process_events
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
def shows widget_name
|
2
|
+
find_widget(widget_name).should be_visible
|
3
|
+
end
|
4
|
+
|
5
|
+
def does_not_show widget_name
|
6
|
+
find_widget(widget_name).should_not be_visible
|
7
|
+
end
|
8
|
+
alias hides does_not_show
|
9
|
+
|
10
|
+
def displays expected, options = {}
|
11
|
+
widget = find_widget(options[:in] || options[:into], options[:test_against])
|
12
|
+
|
13
|
+
if widget.is_a?(Gtk::Image)
|
14
|
+
text = widget.file
|
15
|
+
elsif widget.is_a?(Gtk::TextView)
|
16
|
+
text = widget.buffer.text
|
17
|
+
elsif widget.is_a?(Gtk::ListView)
|
18
|
+
text = []
|
19
|
+
widget.model.each { |model, path, iter| text << iter[0] }
|
20
|
+
text = text.join(',')
|
21
|
+
expected = expected.join(',')
|
22
|
+
else
|
23
|
+
text = widget.text
|
24
|
+
end
|
25
|
+
text.should match expected
|
26
|
+
end
|
27
|
+
|
28
|
+
def highlights item, options = {}
|
29
|
+
widget = find_widget(options[:in] || options[:into], options[:test_against])
|
30
|
+
widget.selection.selected[0].should == item
|
31
|
+
end
|
32
|
+
|
33
|
+
def loads contents, options = {}
|
34
|
+
displays contents, options
|
35
|
+
end
|
36
|
+
|
37
|
+
def saves contents, options = {}
|
38
|
+
File.read(options[:in]).should == contents
|
39
|
+
end
|
40
|
+
|
41
|
+
def quits_by_pressing key
|
42
|
+
$application.controllers['main'].should_receive(:quit)
|
43
|
+
pressing key, :in => find_widget(:main)
|
44
|
+
process_events
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
def process_events
|
2
|
+
while Gtk.events_pending?
|
3
|
+
Gtk.main_iteration
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
def find_widget name, application = nil
|
8
|
+
widget = (application || $application).views[name]
|
9
|
+
raise "Cannot find widget: #{name}." unless widget
|
10
|
+
widget
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_file name
|
14
|
+
$application.controllers['file'].load name
|
15
|
+
end
|
16
|
+
|
17
|
+
# e.g. create_file 'the_file', :containing => @the_contents
|
18
|
+
def create_file name, options
|
19
|
+
File.open(name, "w") do |f|
|
20
|
+
f.print options[:containing]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy_file name
|
25
|
+
File.delete(name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def some_text_in filename
|
29
|
+
"some text in #{filename}"
|
30
|
+
end
|
31
|
+
alias some_text_from some_text_in
|
32
|
+
|
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merrol
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Phil Thompson
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-28 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: autotest
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: simplecov
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - "="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 2
|
69
|
+
- 0
|
70
|
+
- 0
|
71
|
+
version: 2.0.0
|
72
|
+
type: :development
|
73
|
+
version_requirements: *id004
|
74
|
+
description: An editor for Ruby, Rails and supporting langauges, written in pure Ruby with an open design to allow customization and improvement.
|
75
|
+
email: phil@electricvisions.com
|
76
|
+
executables:
|
77
|
+
- m
|
78
|
+
extensions: []
|
79
|
+
|
80
|
+
extra_rdoc_files: []
|
81
|
+
|
82
|
+
files:
|
83
|
+
- .autotest
|
84
|
+
- .gitignore
|
85
|
+
- .rspec
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
- ROADMAP.md
|
89
|
+
- Rakefile
|
90
|
+
- autotest/discover.rb
|
91
|
+
- bin/m
|
92
|
+
- config/commands.yml
|
93
|
+
- config/language.yml
|
94
|
+
- config/messages.yml
|
95
|
+
- config/settings.yml
|
96
|
+
- config/snippets/rails.yml
|
97
|
+
- config/snippets/rspec.yml
|
98
|
+
- config/snippets/ruby.yml
|
99
|
+
- config/styles/Railscasts.xml
|
100
|
+
- config/templates/rails.yml
|
101
|
+
- config/templates/rspec.yml
|
102
|
+
- data/images/merrol.svg
|
103
|
+
- data/images/merrol2.svg
|
104
|
+
- data/images/modified.svg
|
105
|
+
- data/images/saved.svg
|
106
|
+
- lib/merrol.rb
|
107
|
+
- lib/merrol/controllers/controller.rb
|
108
|
+
- lib/merrol/controllers/edit_controller.rb
|
109
|
+
- lib/merrol/controllers/file_controller.rb
|
110
|
+
- lib/merrol/controllers/help_controller.rb
|
111
|
+
- lib/merrol/controllers/main_controller.rb
|
112
|
+
- lib/merrol/controllers/search_controller.rb
|
113
|
+
- lib/merrol/controllers/tools_controller.rb
|
114
|
+
- lib/merrol/gtk/bin.rb
|
115
|
+
- lib/merrol/gtk/image.rb
|
116
|
+
- lib/merrol/gtk/list_view.rb
|
117
|
+
- lib/merrol/gtk/source_view.rb
|
118
|
+
- lib/merrol/gtk/widget.rb
|
119
|
+
- lib/merrol/gtk/window.rb
|
120
|
+
- lib/merrol/keyboard_map.rb
|
121
|
+
- lib/merrol/lib/application.rb
|
122
|
+
- lib/merrol/lib/commands.rb
|
123
|
+
- lib/merrol/lib/file.rb
|
124
|
+
- lib/merrol/lib/shortcut.rb
|
125
|
+
- lib/merrol/lib/widget_builder.rb
|
126
|
+
- lib/merrol/lib/yaml.rb
|
127
|
+
- lib/merrol/models/source_model.rb
|
128
|
+
- lib/merrol/views/edit.yml
|
129
|
+
- lib/merrol/views/file_list.yml
|
130
|
+
- lib/merrol/views/file_path.yml
|
131
|
+
- lib/merrol/views/file_status.yml
|
132
|
+
- lib/merrol/views/hbox.yml
|
133
|
+
- lib/merrol/views/main.yml
|
134
|
+
- lib/merrol/views/scroll_bars.yml
|
135
|
+
- lib/merrol/views/status_bar.yml
|
136
|
+
- lib/prerequisites.rb
|
137
|
+
- merrol.gemspec
|
138
|
+
- spec/controllers/controller_spec.rb
|
139
|
+
- spec/controllers/edit_controller_spec.rb
|
140
|
+
- spec/controllers/file_controller_spec.rb
|
141
|
+
- spec/controllers/main_controller_spec.rb
|
142
|
+
- spec/gtk/bin_spec.rb
|
143
|
+
- spec/gtk/list_view_spec.rb
|
144
|
+
- spec/gtk/source_view_spec.rb
|
145
|
+
- spec/gtk/widget_spec.rb
|
146
|
+
- spec/gtk/window_spec.rb
|
147
|
+
- spec/integration/000_startup_spec.rb
|
148
|
+
- spec/integration/001_load_from_commandline_spec.rb
|
149
|
+
- spec/integration/002_loading_and_saving_spec.rb
|
150
|
+
- spec/integration/003_tab_file_switching_spec.rb
|
151
|
+
- spec/integration/ideas_spec.rb
|
152
|
+
- spec/integration_helper.rb
|
153
|
+
- spec/lib/application_spec.rb
|
154
|
+
- spec/lib/commands_spec.rb
|
155
|
+
- spec/lib/file_spec.rb
|
156
|
+
- spec/lib/shortcut_spec.rb
|
157
|
+
- spec/lib/widget_builder_spec.rb
|
158
|
+
- spec/lib/yaml_spec.rb
|
159
|
+
- spec/models/source_model_spec.rb
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
- spec/support/actions.rb
|
162
|
+
- spec/support/expectations.rb
|
163
|
+
- spec/support/setup.rb
|
164
|
+
has_rdoc: true
|
165
|
+
homepage: http://merrol.com
|
166
|
+
licenses: []
|
167
|
+
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
version: "0"
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
segments:
|
187
|
+
- 1
|
188
|
+
- 3
|
189
|
+
- 6
|
190
|
+
version: 1.3.6
|
191
|
+
requirements: []
|
192
|
+
|
193
|
+
rubyforge_project: merrol
|
194
|
+
rubygems_version: 1.3.7
|
195
|
+
signing_key:
|
196
|
+
specification_version: 3
|
197
|
+
summary: MERROL - Minimalist Editor for Ruby, Rails and Other Languages
|
198
|
+
test_files:
|
199
|
+
- spec/controllers/controller_spec.rb
|
200
|
+
- spec/controllers/edit_controller_spec.rb
|
201
|
+
- spec/controllers/file_controller_spec.rb
|
202
|
+
- spec/controllers/main_controller_spec.rb
|
203
|
+
- spec/gtk/bin_spec.rb
|
204
|
+
- spec/gtk/list_view_spec.rb
|
205
|
+
- spec/gtk/source_view_spec.rb
|
206
|
+
- spec/gtk/widget_spec.rb
|
207
|
+
- spec/gtk/window_spec.rb
|
208
|
+
- spec/integration/000_startup_spec.rb
|
209
|
+
- spec/integration/001_load_from_commandline_spec.rb
|
210
|
+
- spec/integration/002_loading_and_saving_spec.rb
|
211
|
+
- spec/integration/003_tab_file_switching_spec.rb
|
212
|
+
- spec/integration/ideas_spec.rb
|
213
|
+
- spec/integration_helper.rb
|
214
|
+
- spec/lib/application_spec.rb
|
215
|
+
- spec/lib/commands_spec.rb
|
216
|
+
- spec/lib/file_spec.rb
|
217
|
+
- spec/lib/shortcut_spec.rb
|
218
|
+
- spec/lib/widget_builder_spec.rb
|
219
|
+
- spec/lib/yaml_spec.rb
|
220
|
+
- spec/models/source_model_spec.rb
|
221
|
+
- spec/spec_helper.rb
|
222
|
+
- spec/support/actions.rb
|
223
|
+
- spec/support/expectations.rb
|
224
|
+
- spec/support/setup.rb
|