scide 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.rspec +0 -1
  2. data/.ruby-version +1 -0
  3. data/.screenrc +8 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile +10 -11
  6. data/Gemfile.lock +46 -39
  7. data/LICENSE.txt +1 -1
  8. data/README.md +36 -144
  9. data/Rakefile +19 -26
  10. data/VERSION +1 -1
  11. data/bin/scide +1 -2
  12. data/lib/scide/auto.rb +33 -0
  13. data/lib/scide/list.rb +33 -0
  14. data/lib/scide/open.rb +57 -0
  15. data/lib/scide/program.rb +109 -0
  16. data/lib/scide/setup.rb +16 -0
  17. data/lib/scide.rb +25 -57
  18. data/scide.gemspec +51 -59
  19. data/spec/auto_spec.rb +72 -0
  20. data/spec/cli/list_spec.rb +81 -0
  21. data/spec/cli/open_spec.rb +131 -0
  22. data/spec/cli/setup_spec.rb +82 -0
  23. data/spec/helper.rb +12 -24
  24. data/spec/list_spec.rb +113 -0
  25. data/spec/open_spec.rb +228 -0
  26. data/spec/setup_spec.rb +106 -0
  27. data/spec/version_spec.rb +3 -5
  28. metadata +150 -72
  29. data/.document +0 -5
  30. data/.rvmrc +0 -41
  31. data/TODO.md +0 -21
  32. data/lib/scide/command.rb +0 -124
  33. data/lib/scide/commands/edit.rb +0 -37
  34. data/lib/scide/commands/run.rb +0 -25
  35. data/lib/scide/commands/show.rb +0 -29
  36. data/lib/scide/commands/tail.rb +0 -37
  37. data/lib/scide/config.rb +0 -105
  38. data/lib/scide/global.rb +0 -30
  39. data/lib/scide/opts.rb +0 -35
  40. data/lib/scide/overmind.rb +0 -70
  41. data/lib/scide/project.rb +0 -93
  42. data/lib/scide/screen.rb +0 -77
  43. data/lib/scide/window.rb +0 -88
  44. data/spec/command_spec.rb +0 -86
  45. data/spec/commands/edit_spec.rb +0 -19
  46. data/spec/commands/run_spec.rb +0 -9
  47. data/spec/commands/show_spec.rb +0 -15
  48. data/spec/commands/tail_spec.rb +0 -14
  49. data/spec/config_spec.rb +0 -113
  50. data/spec/global_spec.rb +0 -38
  51. data/spec/opts_spec.rb +0 -42
  52. data/spec/project_spec.rb +0 -171
  53. data/spec/results/config1.yml +0 -14
  54. data/spec/results/malformed_config.yml +0 -2
  55. data/spec/results/project1.screen +0 -10
  56. data/spec/results/screen1.screen +0 -14
  57. data/spec/scide_spec.rb +0 -38
  58. data/spec/screen_spec.rb +0 -90
  59. data/spec/window_spec.rb +0 -122
data/lib/scide/config.rb DELETED
@@ -1,105 +0,0 @@
1
- require 'yaml'
2
-
3
- module Scide
4
-
5
- # Complete scide configuration as an object graph.
6
- class Config
7
-
8
- # The file from which the configuration is normally loaded.
9
- # This defaults to <tt>$HOME/.scide/config.yml</tt>.
10
- DEFAULT_CONFIG_FILE = File.join File.expand_path('~'), '.scide', 'config.yml'
11
-
12
- # The file from which this configuration will be loaded.
13
- attr_accessor :file
14
-
15
- # GNU Screen options. Accessible after calling {#load!}.
16
- attr_reader :screen
17
-
18
- # The global configuration. Accessible after calling {#load!}.
19
- attr_reader :global
20
-
21
- # The project definitions (windows, option overrides, etc). Accessible
22
- # after calling {#load!}.
23
- attr_reader :projects
24
-
25
- # Returns an empty configuration.
26
- #
27
- # == Arguments
28
- # * <tt>file</tt> - The file from which to load the configuration. If not
29
- # given, this defaults to {DEFAULT_CONFIG_FILE}.
30
- def initialize file = nil
31
- @file = file.try(:to_s) || DEFAULT_CONFIG_FILE
32
- end
33
-
34
- # Loads this configuration. This will read from {#file} and parse the contents
35
- # as YAML. Configuration elements can then be retrieved with #global,
36
- # #projects and #screen.
37
- #
38
- # == Errors
39
- # * <tt>config_not_found</tt> - {#file} does not exist.
40
- # * <tt>config_not_readable</tt> - {#file} cannot be read by the user running scide.
41
- # * <tt>malformed_config</tt> - {#file} contains malformed YAML.
42
- # * <tt>invalid_config</tt> - {#file} contains invalid configuration (see README).
43
- # * <tt>unexpected</tt> - {#file} could not be read.
44
- def load!
45
- check_config
46
-
47
- begin
48
- raw_config = load_config
49
- rescue StandardError => err
50
- Scide.fail :unexpected, "ERROR: could not read configuration #{@file}"
51
- end
52
-
53
- begin
54
- @config = parse_config raw_config
55
- rescue SyntaxError, ArgumentError => err
56
- Scide.fail :malformed_config, "ERROR: could not parse configuration #{@file}\n #{err}"
57
- end
58
-
59
- invalid_config 'configuration must be a hash' unless @config.kind_of? Hash
60
-
61
- # laziness
62
- @config = HashWithIndifferentAccess.new @config
63
-
64
- invalid_config 'screen configuration must be a hash' unless @config[:screen].nil? or @config[:screen].kind_of?(Hash)
65
- invalid_config 'projects configuration must be a hash' unless @config[:projects].nil? or @config[:projects].kind_of?(Hash)
66
-
67
- begin
68
- @screen = @config[:screen] || HashWithIndifferentAccess.new
69
- @global = Scide::Global.new @config[:global]
70
- @projects = (@config[:projects] || {}).inject(HashWithIndifferentAccess.new) do |memo,obj|
71
- memo[obj[0]] = Scide::Project.new @global, obj[0], obj[1]; memo
72
- end
73
- rescue ArgumentError => err
74
- invalid_config err
75
- end
76
- end
77
-
78
- private
79
-
80
- # Causes scide to fail with a <tt>config_not_found</tt> error if the configuration
81
- # file does not exist, or with a <tt>config_not_readable</tt> error if it is not
82
- # readable (see {Scide.fail}).
83
- def check_config
84
- Scide.fail :config_not_found, "ERROR: expected to find configuration at #{@file}" unless File.exists? @file
85
- Scide.fail :config_not_readable, "ERROR: configuration #{@file} is not readable" unless File.readable? @file
86
- end
87
-
88
- # Returns the contents of {#file}.
89
- def load_config
90
- File.open(@file, 'r').read
91
- end
92
-
93
- # Returns the parsed configuration.
94
- def parse_config raw
95
- YAML::load raw
96
- end
97
-
98
- # Causes scide to fail with an <tt>invalid_config</tt> error (see {Scide.fail}).
99
- # Builds a complete error message containing the full path to the
100
- # configuration file and the given message.
101
- def invalid_config msg
102
- Scide.fail :invalid_config, "ERROR: configuration #{@file} is invalid.\n #{msg}"
103
- end
104
- end
105
- end
data/lib/scide/global.rb DELETED
@@ -1,30 +0,0 @@
1
- module Scide
2
-
3
- # Global scide options (base path for all projects,
4
- # shared options).
5
- class Global
6
-
7
- # The path under which all projects reside by default.
8
- # (Can be overriden at the project level.)
9
- attr_reader :path
10
-
11
- # Global options shared by all projects.
12
- attr_reader :options
13
-
14
- # Builds global options.
15
- #
16
- # == Arguments
17
- # * <tt>contents</tt> - The global options hash.
18
- def initialize contents
19
- raise ArgumentError, 'global configuration must be a hash' unless contents.kind_of? Hash
20
- raise ArgumentError, 'global options must be a hash' unless contents[:options].nil? or contents[:options].kind_of?(Hash)
21
-
22
- @options = contents[:options].try(:dup) || {}
23
-
24
- # default to home directory
25
- @path = contents[:path].try(:to_s) || File.expand_path('~')
26
- # expand from home directory unless absolute
27
- @path = File.join File.expand_path('~'), @path unless @path.match /^\//
28
- end
29
- end
30
- end
data/lib/scide/opts.rb DELETED
@@ -1,35 +0,0 @@
1
- module Scide
2
-
3
- # Pre-configured scide option parser.
4
- class Opts < Upoj::Opts
5
-
6
- # Returns the scide option parser. Run scide with <tt>--usage</tt>
7
- # to see available options.
8
- def initialize
9
- super({
10
- :banner => {
11
- :usage => '[OPTION]... PROJECT',
12
- :description => 'generates GNU Screen configuration files.'
13
- }
14
- })
15
-
16
- on '-c', '--config FILE', 'load configuration from FILE'
17
- on '--dry-run', 'show what would be run but do not execute'
18
- on('--version', 'show version and exit'){ puts "#{program_name} #{Scide::VERSION}"; exit 0 }
19
-
20
- help!.usage!
21
- end
22
-
23
- # Parses the given arguments.
24
- #
25
- # Causes scide to fail with an <tt>invalid_argument</tt> error (see {Scide.fail})
26
- # if an argument is invalid.
27
- def parse! args
28
- begin
29
- super args
30
- rescue StandardError => err
31
- Scide.fail :invalid_argument, err
32
- end
33
- end
34
- end
35
- end
@@ -1,70 +0,0 @@
1
- require 'tempfile'
2
-
3
- module Scide
4
-
5
- # Utility class to run scide in a script.
6
- class Overmind
7
-
8
- # Awakens the overmind. Use at your own risk.
9
- def initialize
10
- @cli = Scide::Opts.new
11
- @config = Scide::Config.new
12
- end
13
-
14
- # Parses command-line arguments and loads the configuration file.
15
- # Any error will be run through {Scide.fail}.
16
- def brood
17
- @cli.parse! ARGV
18
- @config.file = @cli.funnel[:config] if @cli.funnel.key? :config
19
- @config.load!
20
- @initialized = true
21
- self
22
- end
23
-
24
- # Runs GNU Screen with the project given as argument.
25
- # The <tt>--dry-run</tt> option will cause scide to print the
26
- # resulting configuration instead of running it.
27
- #
28
- # == Errors
29
- # * <tt>not_initialized</tt> - If {#brood} was not called.
30
- # * <tt>unknown_project</tt> - If the given project is not found
31
- # in the configuration file.
32
- # * <tt>screen_not_found</tt> - If the GNU Screen binary is not
33
- # found with <tt>which</tt>.
34
- def dominate
35
-
36
- Scide.fail :not_initialized, 'ERROR: call #brood to initialize.' unless @initialized
37
-
38
- project_key = ARGV.shift
39
-
40
- if project_key.blank?
41
- available_projects = @config.projects.keys.join(', ')
42
- Scide.fail :invalid_argument, "You must choose a project. Available projects: #{available_projects}."
43
- end
44
-
45
- unless @config.projects.key? project_key
46
- Scide.fail :unknown_project, "ERROR: there is no project '#{project_key}' in configuration #{@config.file}."
47
- end
48
-
49
- screen = Scide::Screen.new @config.projects[project_key], @config.screen
50
- screen.check_binary
51
-
52
- if @cli.funnel[:'dry-run']
53
- puts
54
- puts Paint['COMMAND', :bold]
55
- puts " #{screen.to_command}"
56
- puts
57
- puts Paint['SCREEN CONFIGURATION', :bold]
58
- puts screen.to_s.gsub(/^/, ' ')
59
- puts
60
- else
61
- file = Tempfile.new 'scide'
62
- file.write screen.to_s
63
- file.rewind
64
- file.close
65
- system screen.to_command(file.path)
66
- file.unlink
67
- end
68
- end
69
- end
70
- end
data/lib/scide/project.rb DELETED
@@ -1,93 +0,0 @@
1
- module Scide
2
-
3
- # Scide configuration for one project.
4
- class Project
5
-
6
- # The project key in the projects configuration hash.
7
- attr_reader :key
8
-
9
- # The path where the project is located. See {#initialize}.
10
- attr_reader :path
11
-
12
- # Project-specific options. Can be used by commands. See {#initialize}.
13
- attr_reader :options
14
-
15
- # The GNU Screen windows of this project.
16
- attr_reader :windows
17
-
18
- # The name or index of the window that should be displayed by default for
19
- # this project (defaults to the last window).
20
- attr_reader :default_window
21
-
22
- # Returns a project configuration.
23
- #
24
- # If not given in the project hash, {#path} is built by joining
25
- # the global path and <tt>key</tt>.
26
- #
27
- # == Arguments
28
- # * <tt>global</tt> - The global configuration.
29
- # * <tt>key</tt> - The key identifying the project. This is the
30
- # key in the projects hash.
31
- # * <tt>contents</tt> - The project hash.
32
- #
33
- # == Project Options
34
- #
35
- # {#options} is built by merging the options given in the project
36
- # hash with the global options.
37
- #
38
- # The following default options are added if not given:
39
- # * <tt>name</tt> - Defaults to the project key.
40
- # * <tt>path</tt> - The path where the project is located.
41
- def initialize global, key, contents
42
- raise ArgumentError, "project '#{key}' must be a hash" unless contents.kind_of? Hash
43
- raise ArgumentError, "windows of project '#{key}' must be an array" unless contents[:windows].kind_of?(Array)
44
- raise ArgumentError, "options of project '#{key}' must be a hash" unless contents[:options].nil? or contents[:options].kind_of?(Hash)
45
-
46
- @key = key
47
-
48
- # path defaults to project key
49
- @path = contents[:path].try(:to_s) || key.to_s
50
- unless path.match /^\//
51
- # if not absolute
52
- if global.path
53
- # expand from global directory
54
- @path = File.join global.path, @path
55
- else
56
- # or from home directory
57
- @path = File.join File.expand_path('~'), @path
58
- end
59
- end
60
-
61
- @options = global.options.dup
62
- @options[:name] = key
63
- @options[:path] = @path
64
- @options.merge!(contents[:options] || {})
65
-
66
- @windows = contents[:windows].collect{ |w| Scide::Window.new self, w }
67
-
68
- # find default window if specified
69
- @default_window = if contents[:default_window].kind_of? Fixnum
70
- @windows[contents[:default_window]]
71
- elsif contents[:default_window].kind_of?(String) or contents[:default_window].kind_of?(Symbol)
72
- @windows.find{ |w| w.name == contents[:default_window].to_s }
73
- elsif !contents[:default_window].nil?
74
- raise ArgumentError, "default window of project '#{key}' should be an integer, string or symbol"
75
- end
76
- raise ArgumentError, "default window of project '#{key}' must be the name or index of one of its windows" if !contents[:default_window].nil? and @default_window.nil?
77
- end
78
-
79
- # Returns a representation of this project as a GNU Screen
80
- # configuration fragment. Returns nil if this project has
81
- # no configured windows.
82
- def to_screen
83
- return nil if @windows.blank?
84
- String.new.tap do |s|
85
- @windows.each_with_index do |w,i|
86
- s << w.to_screen(i)
87
- s << "\n" if i != (@windows.length - 1)
88
- end
89
- s << "\nselect #{@default_window.name}" if @default_window
90
- end
91
- end
92
- end
93
- end
data/lib/scide/screen.rb DELETED
@@ -1,77 +0,0 @@
1
- require 'which_works'
2
-
3
- module Scide
4
-
5
- # Configuration of a GNU Screen session (windows for a specific project).
6
- #
7
- # The configuration will disable the startup message and display a hardstatus line.
8
- # It will also display the windows of the given project.
9
- class Screen
10
-
11
- # The default screen hardstatus line.
12
- DEFAULT_HARDSTATUS = '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
13
-
14
- # Options for this screen.
15
- attr_accessor :options
16
-
17
- # Returns a screen configuration for the given project.
18
- #
19
- # == Arguments
20
- # * <tt>project</tt> - The project.
21
- # * <tt>options</tt> - Screen-specific options (see below).
22
- #
23
- # == Options
24
- # * <tt>binary</tt> - Screen binary (defaults to <tt>screen</tt>).
25
- # * <tt>args</tt> - Command-line arguments that will be given to screen (e.g. <tt>-U</tt> for unicode).
26
- # * <tt>hardstatus</tt> - Hardstatus line configuration (defaults to {DEFAULT_HARDSTATUS}).
27
- def initialize project, options
28
- raise ArgumentError, 'screen configuration must be a hash' unless options.nil? or options.kind_of?(Hash)
29
-
30
- @project = project
31
- @options = options.try(:dup) || {}
32
- end
33
-
34
- # Returns the command that will be used to run screen with this configuration.
35
- #
36
- # == Arguments
37
- # * <tt>tmp_file</tt> - The temporary file in which the configuration will be stored.
38
- # (Optional for dry-run.)
39
- def to_command tmp_file = 'TEMPORARY_FILE'
40
- [ "cd #{@project.path} &&", binary, args, "-c #{tmp_file}" ].select(&:present?).join(' ')
41
- end
42
-
43
- # Verifies that the screen binary is there. If not, causes scide
44
- # to fail with a <tt>screen_not_found</tt> error (see {Scide.fail}).
45
- def check_binary
46
- Scide.fail :screen_not_found, "ERROR: #{binary} not found" unless Which.which(binary)
47
- end
48
-
49
- # Returns a representation of this configuration as a string.
50
- def to_s
51
- String.new.tap do |s|
52
- s << "startup_message off\n"
53
- s << "hardstatus on\n"
54
- s << "hardstatus alwayslastline\n"
55
- s << "hardstatus string '#{hardstatus}'\n\n"
56
- s << @project.to_screen
57
- end
58
- end
59
-
60
- # Returns the screen hardstatus line given as option, or
61
- # the default {DEFAULT_HARDSTATUS}.
62
- def hardstatus
63
- @options[:hardstatus].try(:to_s) || DEFAULT_HARDSTATUS
64
- end
65
-
66
- # Returns the screen binary given as option, or the
67
- # default (<tt>screen</tt>).
68
- def binary
69
- @options[:binary].try(:to_s) || 'screen'
70
- end
71
-
72
- # Returns the screen command-line arguments given as options.
73
- def args
74
- @options[:args].try(:to_s)
75
- end
76
- end
77
- end
data/lib/scide/window.rb DELETED
@@ -1,88 +0,0 @@
1
- module Scide
2
-
3
- # Configuration of a GNU Screen window (name, command).
4
- class Window
5
-
6
- # The name of the window as it will shown in GNU Screen.
7
- # See {#initialize}.
8
- attr_reader :name
9
-
10
- # The optional command that will be shown in this window.
11
- attr_reader :command
12
-
13
- # Window-specific options. Can be used by commands. See {#initialize}.
14
- attr_reader :options
15
-
16
- # Returns a window for the given project.
17
- #
18
- # == Arguments
19
- # * <tt>project</tt> - The project owning this window.
20
- # * <tt>contents</tt> - The window configuration (String or Hash).
21
- #
22
- # == String Initialization
23
- # The string must be in the format <tt>NAME [COMMAND]</tt> where
24
- # <tt>NAME</tt> is the window name and <tt>COMMAND</tt> (optional)
25
- # is the command configuration (see {Scide::Command}).
26
- #
27
- # == Hash Initialization
28
- # The following options can be given:
29
- # * <tt>:name => string</tt> - The window name.
30
- # * <tt>:options => hash</tt> - Window-specific options (will be
31
- # merged to the project options).
32
- # * <tt>:command => string</tt> - The command to use for this window
33
- # (will be built using {Scide::Command.resolve}).
34
- # * <tt>:string => string</tt> - If given, <tt>:name</tt> and <tt>:command</tt>
35
- # are ignored and string initialization will be performed with <tt>string</tt>.
36
- # <tt>:options</tt> can still be used to override project options.
37
- def initialize project, contents
38
- @project = project
39
-
40
- if contents.kind_of? Hash
41
- init_from_hash! contents
42
- elsif contents.kind_of? String
43
- init_from_string! contents
44
- else
45
- raise ArgumentError, "window '#{contents}' must be a string or a hash"
46
- end
47
- end
48
-
49
- # Returns a representation of this window as a GNU Screen
50
- # configuration frament.
51
- #
52
- # == Arguments
53
- # * <tt>index</tt> - The position of the window (zero-based).
54
- def to_screen index
55
- String.new.tap do |s|
56
- s << "screen -t #{@name} #{index}"
57
- s << "\n#{@command.to_screen}" if @command
58
- end
59
- end
60
-
61
- private
62
-
63
- # Initializes this window from a hash. See {#initialize} for options.
64
- def init_from_hash! contents
65
- raise ArgumentError, "options of window '#{@name}' must be a hash" unless contents[:options].nil? or contents[:options].kind_of?(Hash)
66
- @options = @project.options.dup.merge(contents[:options] || {})
67
-
68
- if contents[:string].present?
69
- init_from_string! contents[:string]
70
- else
71
- raise ArgumentError, "window '#{contents}' must have a name" unless contents[:name].present?
72
- @name = contents[:name]
73
- @command = Command.resolve self, contents if contents.key? :command
74
- end
75
- end
76
-
77
- # Initializes this window from a string. See {#initialize} for format.
78
- def init_from_string! contents
79
- raise ArgumentError, "window '#{contents}' must not be an empty string" unless contents.present?
80
- content_parts = contents.split /\s+/, 2
81
- @name = content_parts[0]
82
- @options ||= @project.options.dup
83
- if content_parts.length == 2
84
- @command = Command.resolve self, content_parts[1]
85
- end
86
- end
87
- end
88
- end
data/spec/command_spec.rb DELETED
@@ -1,86 +0,0 @@
1
- require 'helper'
2
-
3
- module Scide
4
- module Commands
5
- class FuBar < Scide::Commands::Show
6
- end
7
- end
8
- end
9
-
10
- describe Scide::Command do
11
-
12
- it "should be abstract" do
13
- com = Scide::Command.new 'fubar'
14
- lambda{ com.to_screen }.should raise_error(StandardError)
15
- end
16
-
17
- it "should use given contents as text" do
18
- com = Scide::Command.new 'fubar'
19
- com.text_with_options.should == 'fubar'
20
- end
21
-
22
- it "should take options" do
23
- com = Scide::Command.new 'fubar %{foo} %{bar}', :foo => 1, :bar => 2
24
- com.text_with_options.should == 'fubar 1 2'
25
- end
26
-
27
- describe 'Class' do
28
- before :each do
29
- @options = { :a => 1, :b => true }
30
- @window = double('window')
31
- @window.stub(:options){ @options }
32
- end
33
-
34
- it "should resolve command with a string" do
35
- com = Scide::Command.resolve @window, 'SHOW fubar'
36
- com.should be_a(Scide::Commands::Show)
37
- end
38
-
39
- it "should use second part of string as contents when resolving a command with a string" do
40
- com = Scide::Command.resolve @window, 'SHOW fubar'
41
- com.text_with_options.should == 'fubar'
42
- end
43
-
44
- it "should resolve command with a hash" do
45
- com = Scide::Command.resolve @window, :command => 'SHOW', :contents => 'fubar'
46
- com.should be_a(Scide::Commands::Show)
47
- end
48
-
49
- it "should give duplicated window options to the resolved string command" do
50
- @window.should_receive :options
51
- com = Scide::Command.resolve @window, 'SHOW fubar'
52
- com.options.should == @options
53
- com.options.should_not equal(@options)
54
- end
55
-
56
- it "should give duplicated window options to the resolved hash command" do
57
- @window.should_receive :options
58
- com = Scide::Command.resolve @window, :command => 'SHOW', :contents => 'fubar'
59
- com.options.should == @options
60
- com.options.should_not equal(@options)
61
- end
62
-
63
- it "should resolve camel-case command class names with a string" do
64
- com = Scide::Command.resolve @window, 'FU_BAR'
65
- com.should be_a(Scide::Commands::FuBar)
66
- end
67
-
68
- it "should resolve camel-case command class names with a hash" do
69
- com = Scide::Command.resolve @window, :command => 'FU_BAR'
70
- com.should be_a(Scide::Commands::FuBar)
71
- end
72
-
73
- it "should raise an error when type of contents is unknown" do
74
- lambda{ Scide::Command.resolve(@window, []) }.should raise_error(ArgumentError)
75
- end
76
-
77
- it "should raise an error when trying to resolve a blank string" do
78
- lambda{ Scide::Command.resolve(@window, ' ') }.should raise_error(ArgumentError)
79
- end
80
-
81
- it "should raise an error when trying to resolve an unknown command" do
82
- lambda{ Scide::Command.resolve(@window, 'SHW fubar') }.should raise_error(ArgumentError)
83
- lambda{ Scide::Command.resolve(@window, :command => 'SHW', :contents => 'fubar') }.should raise_error(ArgumentError)
84
- end
85
- end
86
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Commands::Edit do
4
-
5
- it "should use the preferred editor" do
6
- com = Scide::Commands::Edit.new nil
7
- com.text_with_options.should == '$EDITOR\012'
8
- end
9
-
10
- it "should use given contents as arguments to the editor" do
11
- com = Scide::Commands::Edit.new 'fubar'
12
- com.text_with_options.should == '$EDITOR fubar\012'
13
- end
14
-
15
- it "should use the :edit option as arguments to the editor" do
16
- com = Scide::Commands::Edit.new 'fubar', :edit => '-c MyCommand'
17
- com.text_with_options.should == '$EDITOR -c MyCommand fubar\012'
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Commands::Run do
4
-
5
- it "should use given contents and a carriage return as text" do
6
- com = Scide::Commands::Run.new 'fubar'
7
- com.text_with_options.should == 'fubar\012'
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Commands::Show do
4
-
5
- it "should produce a GNU Screen stuff command" do
6
- com = Scide::Commands::Show.new 'fubar'
7
- com.to_screen.should == 'stuff "fubar"'
8
- end
9
-
10
- it "should use #text_with_options as argument to stuff" do
11
- com = Scide::Commands::Show.new 'fubar'
12
- text_with_options = com.text_with_options
13
- com.to_screen.should == %|stuff "#{text_with_options}"|
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Commands::Tail do
4
-
5
- it "should use given contents as argument -f of tail" do
6
- com = Scide::Commands::Tail.new 'fubar'
7
- com.text_with_options.should == 'tail -f fubar\012'
8
- end
9
-
10
- it "should use the :tail option as arguments to tail" do
11
- com = Scide::Commands::Tail.new 'fubar', :tail => '-n 1000'
12
- com.text_with_options.should == 'tail -n 1000 -f fubar\012'
13
- end
14
- end