scide 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/Gemfile.lock +7 -2
- data/Rakefile +0 -8
- data/TODO.md +21 -0
- data/VERSION +1 -1
- data/lib/scide/commands/show.rb +2 -6
- data/lib/scide/config.rb +15 -5
- data/lib/scide/global.rb +2 -1
- data/lib/scide/overmind.rb +8 -1
- data/lib/scide/project.rb +20 -8
- data/lib/scide/screen.rb +8 -24
- data/lib/scide/window.rb +7 -0
- data/lib/scide.rb +6 -0
- data/scide.gemspec +18 -5
- data/spec/command_spec.rb +4 -5
- data/spec/config_spec.rb +109 -0
- data/spec/global_spec.rb +38 -0
- data/spec/helper.rb +29 -0
- data/spec/opts_spec.rb +42 -0
- data/spec/project_spec.rb +122 -0
- data/spec/results/config1.yml +14 -0
- data/spec/results/malformed_config.yml +2 -0
- data/spec/results/project1.screen +9 -0
- data/spec/results/screen1.screen +14 -0
- data/spec/scide_spec.rb +38 -0
- data/spec/screen_spec.rb +83 -0
- data/spec/version_spec.rb +8 -0
- data/spec/window_spec.rb +122 -0
- metadata +30 -17
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,9 +10,9 @@ GEM
|
|
10
10
|
bundler (~> 1.0)
|
11
11
|
git (>= 1.2.5)
|
12
12
|
rake
|
13
|
+
multi_json (1.0.3)
|
13
14
|
paint (0.8.3)
|
14
15
|
rake (0.9.2)
|
15
|
-
rcov (0.9.10)
|
16
16
|
rdoc (3.9.4)
|
17
17
|
rspec (2.6.0)
|
18
18
|
rspec-core (~> 2.6.0)
|
@@ -23,6 +23,10 @@ GEM
|
|
23
23
|
diff-lcs (~> 1.1.2)
|
24
24
|
rspec-mocks (2.6.0)
|
25
25
|
shoulda (2.11.3)
|
26
|
+
simplecov (0.5.3)
|
27
|
+
multi_json (~> 1.0.3)
|
28
|
+
simplecov-html (~> 0.5.3)
|
29
|
+
simplecov-html (0.5.3)
|
26
30
|
upoj-rb (0.0.5)
|
27
31
|
active_support (>= 2)
|
28
32
|
paint
|
@@ -31,10 +35,11 @@ PLATFORMS
|
|
31
35
|
ruby
|
32
36
|
|
33
37
|
DEPENDENCIES
|
38
|
+
active_support (>= 2)
|
34
39
|
bundler (~> 1.0.0)
|
35
40
|
jeweler (~> 1.6.4)
|
36
|
-
rcov
|
37
41
|
rdoc
|
38
42
|
rspec
|
39
43
|
shoulda
|
44
|
+
simplecov
|
40
45
|
upoj-rb (~> 0.0.4)
|
data/Rakefile
CHANGED
@@ -32,14 +32,6 @@ RSpec::Core::RakeTask.new do |t|
|
|
32
32
|
# Put spec opts in a file named .rspec in root
|
33
33
|
end
|
34
34
|
|
35
|
-
#require 'rcov/rcovtask'
|
36
|
-
#Rcov::RcovTask.new do |test|
|
37
|
-
# test.libs << 'test'
|
38
|
-
# test.pattern = 'test/**/test_*.rb'
|
39
|
-
# test.verbose = true
|
40
|
-
# test.rcov_opts << '--exclude "gems/*"'
|
41
|
-
#end
|
42
|
-
|
43
35
|
task :default => :test
|
44
36
|
|
45
37
|
require 'rdoc/task'
|
data/TODO.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
## Improvements/Maintenance
|
4
|
+
|
5
|
+
* check format of keys, names, etc.
|
6
|
+
* ensure that all data from configuration is duplicated
|
7
|
+
* replace default hashes by HashWithIndifferentAccess
|
8
|
+
* make all options/contents parameters optional
|
9
|
+
* extract tempfile management into separate runner class
|
10
|
+
* find a way to check whether a path is absolute (cross-platform)
|
11
|
+
|
12
|
+
## New Features
|
13
|
+
|
14
|
+
* allow to load configuration from hash
|
15
|
+
* interactive configuration generation
|
16
|
+
* save generated configurations
|
17
|
+
|
18
|
+
## Specifications
|
19
|
+
|
20
|
+
* find a way to stub puts (opts version & banner)
|
21
|
+
* use rspec 2 shared examples
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/scide/commands/show.rb
CHANGED
@@ -17,12 +17,8 @@ module Scide
|
|
17
17
|
# ssh 127.0.0.1
|
18
18
|
class Show < Scide::Command
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns a configuration fragment that will put
|
25
|
-
# this command GNU \Screen window without running it.
|
20
|
+
# Returns a configuration fragment that will show
|
21
|
+
# this command in a GNU \Screen window without running it.
|
26
22
|
# This will use screen's <tt>stuff</tt> command to
|
27
23
|
# put the text in the window.
|
28
24
|
def to_screen
|
data/lib/scide/config.rb
CHANGED
@@ -47,14 +47,14 @@ module Scide
|
|
47
47
|
Scide.fail :config_not_readable, "ERROR: configuration #{@file} is not readable" unless File.readable? @file
|
48
48
|
|
49
49
|
begin
|
50
|
-
raw_config =
|
50
|
+
raw_config = load_config
|
51
51
|
rescue StandardError => err
|
52
52
|
Scide.fail :unexpected, "ERROR: could not read configuration #{@file}"
|
53
53
|
end
|
54
54
|
|
55
55
|
begin
|
56
|
-
@config =
|
57
|
-
rescue
|
56
|
+
@config = parse_config raw_config
|
57
|
+
rescue SyntaxError => err
|
58
58
|
Scide.fail :malformed_config, "ERROR: could not parse configuration #{@file}\n #{err}"
|
59
59
|
end
|
60
60
|
|
@@ -67,9 +67,9 @@ module Scide
|
|
67
67
|
invalid_config 'projects configuration must be a hash' unless @config[:projects].nil? or @config[:projects].kind_of?(Hash)
|
68
68
|
|
69
69
|
begin
|
70
|
-
@screen = @config[:screen]
|
70
|
+
@screen = @config[:screen] || HashWithIndifferentAccess.new
|
71
71
|
@global = Scide::Global.new @config[:global]
|
72
|
-
@projects = @config[:projects].inject(HashWithIndifferentAccess.new) do |memo,obj|
|
72
|
+
@projects = (@config[:projects] || {}).inject(HashWithIndifferentAccess.new) do |memo,obj|
|
73
73
|
memo[obj[0]] = Scide::Project.new @global, obj[0], obj[1]; memo
|
74
74
|
end
|
75
75
|
rescue ArgumentError => err
|
@@ -79,6 +79,16 @@ module Scide
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
+
# Returns the contents of #file.
|
83
|
+
def load_config
|
84
|
+
File.open(@file, 'r').read
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns the parsed configuration.
|
88
|
+
def parse_config raw
|
89
|
+
YAML::load raw
|
90
|
+
end
|
91
|
+
|
82
92
|
# Causes scide to fail with an <tt>invalid_config</tt> error (see Scide#fail).
|
83
93
|
# Builds a complete error message containing the full path to the
|
84
94
|
# configuration file and the given message.
|
data/lib/scide/global.rb
CHANGED
@@ -17,8 +17,9 @@ module Scide
|
|
17
17
|
# * <tt>contents</tt> - The global options hash.
|
18
18
|
def initialize contents
|
19
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)
|
20
21
|
|
21
|
-
@options = contents[:options] || {}
|
22
|
+
@options = contents[:options].try(:dup) || {}
|
22
23
|
|
23
24
|
# default to home directory
|
24
25
|
@path = contents[:path].try(:to_s) || File.expand_path('~')
|
data/lib/scide/overmind.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
module Scide
|
2
4
|
|
3
5
|
# Utility class to run scide in a script.
|
@@ -56,7 +58,12 @@ module Scide
|
|
56
58
|
puts screen.to_s.gsub(/^/, ' ')
|
57
59
|
puts
|
58
60
|
else
|
59
|
-
|
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
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|
data/lib/scide/project.rb
CHANGED
@@ -12,6 +12,9 @@ module Scide
|
|
12
12
|
# Project-specific options. Can be used by commands. See #initialize.
|
13
13
|
attr_reader :options
|
14
14
|
|
15
|
+
# The GNU Screen windows of this project.
|
16
|
+
attr_reader :windows
|
17
|
+
|
15
18
|
# Returns a project configuration.
|
16
19
|
#
|
17
20
|
# If not given in the project hash, #path is built by joining
|
@@ -33,19 +36,28 @@ module Scide
|
|
33
36
|
# * <tt>path</tt> - The path where the project is located.
|
34
37
|
def initialize global, key, contents
|
35
38
|
raise ArgumentError, "project '#{key}' must be a hash" unless contents.kind_of? Hash
|
36
|
-
raise ArgumentError, "windows of project '#{key}' must be an array" unless contents[:windows].
|
39
|
+
raise ArgumentError, "windows of project '#{key}' must be an array" unless contents[:windows].kind_of?(Array)
|
37
40
|
raise ArgumentError, "options of project '#{key}' must be a hash" unless contents[:options].nil? or contents[:options].kind_of?(Hash)
|
38
41
|
|
39
|
-
@
|
42
|
+
@key = key
|
40
43
|
|
41
44
|
# path defaults to project key
|
42
45
|
@path = contents[:path].try(:to_s) || key.to_s
|
43
|
-
|
44
|
-
|
46
|
+
unless path.match /^\//
|
47
|
+
# if not absolute
|
48
|
+
if global.path
|
49
|
+
# expand from global directory
|
50
|
+
@path = File.join global.path, @path
|
51
|
+
else
|
52
|
+
# or from home directory
|
53
|
+
@path = File.join File.expand_path('~'), @path
|
54
|
+
end
|
55
|
+
end
|
45
56
|
|
46
|
-
@options = global.options.dup
|
47
|
-
@options[:name]
|
48
|
-
@options[:path]
|
57
|
+
@options = global.options.dup
|
58
|
+
@options[:name] = key
|
59
|
+
@options[:path] = @path
|
60
|
+
@options.merge!(contents[:options] || {})
|
49
61
|
|
50
62
|
@windows = contents[:windows].collect{ |w| Scide::Window.new self, w }
|
51
63
|
end
|
@@ -58,7 +70,7 @@ module Scide
|
|
58
70
|
String.new.tap do |s|
|
59
71
|
@windows.each_with_index do |w,i|
|
60
72
|
s << w.to_screen(i)
|
61
|
-
s << "\n" if i != @windows.length - 1
|
73
|
+
s << "\n" if i != (@windows.length - 1)
|
62
74
|
end
|
63
75
|
end
|
64
76
|
end
|
data/lib/scide/screen.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
1
|
module Scide
|
4
2
|
|
5
3
|
# Configuration of a GNU Screen session (windows for a specific project).
|
@@ -11,6 +9,9 @@ module Scide
|
|
11
9
|
# The default screen hardstatus line.
|
12
10
|
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
11
|
|
12
|
+
# Options for this screen.
|
13
|
+
attr_accessor :options
|
14
|
+
|
14
15
|
# Returns a screen configuration for the given project.
|
15
16
|
#
|
16
17
|
# ==== Arguments
|
@@ -25,17 +26,7 @@ module Scide
|
|
25
26
|
raise ArgumentError, 'screen configuration must be a hash' unless options.nil? or options.kind_of?(Hash)
|
26
27
|
|
27
28
|
@project = project
|
28
|
-
@options = options || {}
|
29
|
-
end
|
30
|
-
|
31
|
-
# Runs screen with this configuration.
|
32
|
-
#
|
33
|
-
# The configuration is saved to a temporary file, then removed.
|
34
|
-
def run
|
35
|
-
file = Tempfile.new 'scide'
|
36
|
-
save file.path
|
37
|
-
system to_command(file.path)
|
38
|
-
file.unlink
|
29
|
+
@options = options.try(:dup) || {}
|
39
30
|
end
|
40
31
|
|
41
32
|
# Returns the command that will be used to run screen with this configuration.
|
@@ -44,7 +35,7 @@ module Scide
|
|
44
35
|
# * <tt>tmp_file</tt> - The temporary file in which the configuration will be stored.
|
45
36
|
# (Optional for dry-run.)
|
46
37
|
def to_command tmp_file = 'TEMPORARY_FILE'
|
47
|
-
"cd #{@project.path} &&
|
38
|
+
[ "cd #{@project.path} &&", binary, args, "-c #{tmp_file}" ].select(&:present?).join(' ')
|
48
39
|
end
|
49
40
|
|
50
41
|
# Verifies that the screen binary is there. If not, causes scide
|
@@ -64,28 +55,21 @@ module Scide
|
|
64
55
|
end
|
65
56
|
end
|
66
57
|
|
67
|
-
private
|
68
|
-
|
69
58
|
# Returns the screen hardstatus line given as option, or
|
70
59
|
# the default #DEFAULT_HARDSTATUS.
|
71
60
|
def hardstatus
|
72
|
-
@options[:hardstatus] || DEFAULT_HARDSTATUS
|
61
|
+
@options[:hardstatus].try(:to_s) || DEFAULT_HARDSTATUS
|
73
62
|
end
|
74
63
|
|
75
64
|
# Returns the screen binary given as option, or the
|
76
65
|
# default (<tt>screen</tt>).
|
77
66
|
def binary
|
78
|
-
@options[:binary] || 'screen'
|
67
|
+
@options[:binary].try(:to_s) || 'screen'
|
79
68
|
end
|
80
69
|
|
81
70
|
# Returns the screen command-line arguments given as options.
|
82
71
|
def args
|
83
|
-
@options[:args]
|
84
|
-
end
|
85
|
-
|
86
|
-
# Saves this configuration to the file at the given path.
|
87
|
-
def save file
|
88
|
-
File.open(file, 'w'){ |f| f.write to_s }
|
72
|
+
@options[:args].try(:to_s)
|
89
73
|
end
|
90
74
|
end
|
91
75
|
end
|
data/lib/scide/window.rb
CHANGED
@@ -3,6 +3,13 @@ module Scide
|
|
3
3
|
# Configuration of a GNU Screen window (name, command).
|
4
4
|
class Window
|
5
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
|
+
|
6
13
|
# Window-specific options. Can be used by commands. See #initialize.
|
7
14
|
attr_reader :options
|
8
15
|
|
data/lib/scide.rb
CHANGED
@@ -54,6 +54,12 @@ module Scide
|
|
54
54
|
@@exit_on_fail = exit_on_fail
|
55
55
|
end
|
56
56
|
|
57
|
+
# Indicates whether scide is configured to exit on failure.
|
58
|
+
# See Scide.exit_on_fail=.
|
59
|
+
def self.exit_on_fail
|
60
|
+
@@exit_on_fail
|
61
|
+
end
|
62
|
+
|
57
63
|
# Scide error. Can be raised if #exit_on_fail is set to false.
|
58
64
|
class Error < StandardError
|
59
65
|
attr_reader :condition
|
data/scide.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "scide"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["AlphaHydrae"]
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"LICENSE.txt",
|
27
27
|
"README.md",
|
28
28
|
"Rakefile",
|
29
|
+
"TODO.md",
|
29
30
|
"VERSION",
|
30
31
|
"bin/scide",
|
31
32
|
"lib/scide.rb",
|
@@ -47,7 +48,19 @@ Gem::Specification.new do |s|
|
|
47
48
|
"spec/commands/run_spec.rb",
|
48
49
|
"spec/commands/show_spec.rb",
|
49
50
|
"spec/commands/tail_spec.rb",
|
50
|
-
"spec/
|
51
|
+
"spec/config_spec.rb",
|
52
|
+
"spec/global_spec.rb",
|
53
|
+
"spec/helper.rb",
|
54
|
+
"spec/opts_spec.rb",
|
55
|
+
"spec/project_spec.rb",
|
56
|
+
"spec/results/config1.yml",
|
57
|
+
"spec/results/malformed_config.yml",
|
58
|
+
"spec/results/project1.screen",
|
59
|
+
"spec/results/screen1.screen",
|
60
|
+
"spec/scide_spec.rb",
|
61
|
+
"spec/screen_spec.rb",
|
62
|
+
"spec/version_spec.rb",
|
63
|
+
"spec/window_spec.rb"
|
51
64
|
]
|
52
65
|
s.homepage = "http://github.com/AlphaHydrae/scide"
|
53
66
|
s.licenses = ["MIT"]
|
@@ -64,7 +77,7 @@ Gem::Specification.new do |s|
|
|
64
77
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
65
78
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
66
79
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
67
|
-
s.add_development_dependency(%q<
|
80
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
68
81
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
69
82
|
else
|
70
83
|
s.add_dependency(%q<upoj-rb>, ["~> 0.0.4"])
|
@@ -72,7 +85,7 @@ Gem::Specification.new do |s|
|
|
72
85
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
73
86
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
87
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
75
|
-
s.add_dependency(%q<
|
88
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
76
89
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
77
90
|
end
|
78
91
|
else
|
@@ -81,7 +94,7 @@ Gem::Specification.new do |s|
|
|
81
94
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
82
95
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
83
96
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
84
|
-
s.add_dependency(%q<
|
97
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
85
98
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
86
99
|
end
|
87
100
|
end
|
data/spec/command_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe Scide::Command do
|
|
33
33
|
|
34
34
|
it "should resolve command with a string" do
|
35
35
|
com = Scide::Command.resolve @window, 'SHOW fubar'
|
36
|
-
com.should
|
36
|
+
com.should be_a(Scide::Commands::Show)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should use second part of string as contents when resolving a command with a string" do
|
@@ -43,7 +43,7 @@ describe Scide::Command do
|
|
43
43
|
|
44
44
|
it "should resolve command with a hash" do
|
45
45
|
com = Scide::Command.resolve @window, :command => 'SHOW', :contents => 'fubar'
|
46
|
-
com.should
|
46
|
+
com.should be_a(Scide::Commands::Show)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should give duplicated window options to the resolved string command" do
|
@@ -61,14 +61,13 @@ describe Scide::Command do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should resolve camel-case command class names with a string" do
|
64
|
-
puts Scide::Commands::FuBar
|
65
64
|
com = Scide::Command.resolve @window, 'FU_BAR'
|
66
|
-
com.should
|
65
|
+
com.should be_a(Scide::Commands::FuBar)
|
67
66
|
end
|
68
67
|
|
69
68
|
it "should resolve camel-case command class names with a hash" do
|
70
69
|
com = Scide::Command.resolve @window, :command => 'FU_BAR'
|
71
|
-
com.should
|
70
|
+
com.should be_a(Scide::Commands::FuBar)
|
72
71
|
end
|
73
72
|
|
74
73
|
it "should raise an error when type of contents is unknown" do
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe Scide::Config do
|
5
|
+
|
6
|
+
it "should use the default config file if not given" do
|
7
|
+
conf = Scide::Config.new
|
8
|
+
conf.file.should == Scide::Config::DEFAULT_CONFIG_FILE
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should use the given config file" do
|
12
|
+
conf = Scide::Config.new '/tmp/fubar'
|
13
|
+
conf.file.should == '/tmp/fubar'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be empty when not loaded" do
|
17
|
+
conf = Scide::Config.new
|
18
|
+
conf.screen.should be_nil
|
19
|
+
conf.global.should be_nil
|
20
|
+
conf.projects.should be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be filled when loaded" do
|
24
|
+
file = File.join File.dirname(__FILE__), 'results', 'config1.yml'
|
25
|
+
conf = Scide::Config.new file
|
26
|
+
make_load conf
|
27
|
+
conf.screen.should be_a(HashWithIndifferentAccess)
|
28
|
+
conf.global.should be_a(Scide::Global)
|
29
|
+
conf.projects.should be_a(HashWithIndifferentAccess)
|
30
|
+
conf.projects[:project1].should be_a(Scide::Project)
|
31
|
+
end
|
32
|
+
|
33
|
+
[ true, false ].each do |exit_on_fail|
|
34
|
+
describe "Errors with exit on fail #{exit_on_fail}" do
|
35
|
+
before :each do
|
36
|
+
Scide.exit_on_fail = exit_on_fail
|
37
|
+
end
|
38
|
+
|
39
|
+
after :each do
|
40
|
+
Scide.exit_on_fail = true
|
41
|
+
end
|
42
|
+
|
43
|
+
it SpecHelper.should_fail(exit_on_fail, :config_not_found, "when the config file does not exist") do
|
44
|
+
bad_file = "/tmp/IHateYouIfYouAddedThisFileJustToMakeMyTestFail"
|
45
|
+
conf = Scide::Config.new bad_file
|
46
|
+
load_should_fail(conf, :config_not_found)
|
47
|
+
end
|
48
|
+
|
49
|
+
it SpecHelper.should_fail(exit_on_fail, :config_not_readable, "if the config file is not readable") do
|
50
|
+
unreadable_file = Tempfile.new 'scide-unreadable'
|
51
|
+
FileUtils.chmod 0200, unreadable_file.path
|
52
|
+
conf = Scide::Config.new unreadable_file.path
|
53
|
+
load_should_fail(conf, :config_not_readable)
|
54
|
+
unreadable_file.unlink
|
55
|
+
end
|
56
|
+
|
57
|
+
it SpecHelper.should_fail(exit_on_fail, :unexpected, "if the config file cannot be read") do
|
58
|
+
file = File.join File.dirname(__FILE__), 'results', 'config1.yml'
|
59
|
+
conf = Scide::Config.new file
|
60
|
+
conf.stub!(:load_config){ raise 'bug' }
|
61
|
+
load_should_fail(conf, :unexpected)
|
62
|
+
end
|
63
|
+
|
64
|
+
it SpecHelper.should_fail(exit_on_fail, :malformed_config, "if the config file is not valid YAML") do
|
65
|
+
file = File.join File.dirname(__FILE__), 'results', 'malformed_config.yml'
|
66
|
+
conf = Scide::Config.new file
|
67
|
+
load_should_fail(conf, :malformed_config)
|
68
|
+
end
|
69
|
+
|
70
|
+
it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the configuration is not a hash") do
|
71
|
+
conf = Scide::Config.new
|
72
|
+
conf.stub!(:load_config){ "- 'a'\n- 'b'" }
|
73
|
+
load_should_fail(conf, :invalid_config)
|
74
|
+
end
|
75
|
+
|
76
|
+
it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the screen configuration is not a hash") do
|
77
|
+
conf = Scide::Config.new
|
78
|
+
conf.stub!(:load_config){ "screen:\n- 'a'\n- 'b'" }
|
79
|
+
load_should_fail(conf, :invalid_config)
|
80
|
+
end
|
81
|
+
|
82
|
+
it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the projects configuration is not a hash") do
|
83
|
+
conf = Scide::Config.new
|
84
|
+
conf.stub!(:load_config){ "projects:\n- 'a'\n- 'b'" }
|
85
|
+
load_should_fail(conf, :invalid_config)
|
86
|
+
end
|
87
|
+
|
88
|
+
it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the configuration is otherwise invalid") do
|
89
|
+
conf = Scide::Config.new
|
90
|
+
conf.stub!(:load_config){ "global:\n a: true\nprojects:\n a:\n - 'a'\n - 'b'" }
|
91
|
+
load_should_fail(conf, :invalid_config)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def make_load conf
|
99
|
+
SpecHelper.silence{ conf.load! }
|
100
|
+
end
|
101
|
+
|
102
|
+
def load_should_fail conf, condition
|
103
|
+
if Scide.exit_on_fail
|
104
|
+
lambda{ make_load conf }.should raise_error(SystemExit){ |err| err.status.should == Scide::EXIT[condition] }
|
105
|
+
else
|
106
|
+
lambda{ make_load conf }.should raise_error(Scide::Error){ |err| err.condition.should == condition }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/spec/global_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide::Global do
|
4
|
+
|
5
|
+
it "should take the given path if absolute" do
|
6
|
+
global = Scide::Global.new :path => '/tmp'
|
7
|
+
global.path.should == '/tmp'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should expand the given path from the home directory if relative" do
|
11
|
+
global = Scide::Global.new :path => 'fubar'
|
12
|
+
global.path.should == File.join(File.expand_path('~'), 'fubar')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should use the home directory if no path is given" do
|
16
|
+
global = Scide::Global.new({})
|
17
|
+
global.path.should == File.expand_path('~')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should duplicate the given options" do
|
21
|
+
options = { :a => 1, :b => true }
|
22
|
+
global = Scide::Global.new :options => options
|
23
|
+
global.options.should == options
|
24
|
+
global.options.should_not equal(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise an error if the contents are not a hash" do
|
28
|
+
[ nil, ' ', [] ].each do |not_hash|
|
29
|
+
lambda{ Scide::Global.new not_hash }.should raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise an error if its options are not nil and not a hash" do
|
34
|
+
[ ' ', [] ].each do |not_hash|
|
35
|
+
lambda{ Scide::Global.new :options => not_hash }.should raise_error(ArgumentError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
+
require 'simplecov'
|
4
|
+
|
5
|
+
# to silence streams
|
6
|
+
require 'active_support/core_ext/kernel/reporting'
|
7
|
+
|
8
|
+
# test coverage
|
9
|
+
SimpleCov.start
|
3
10
|
|
4
11
|
begin
|
5
12
|
Bundler.setup(:default, :development)
|
@@ -12,6 +19,28 @@ end
|
|
12
19
|
require 'rspec'
|
13
20
|
require 'shoulda'
|
14
21
|
|
22
|
+
class SpecHelper
|
23
|
+
def self.result name
|
24
|
+
File.open(File.join(File.dirname(__FILE__), 'results', "#{name}.screen"), 'r').read
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.silence
|
28
|
+
silence_stream(STDOUT) do
|
29
|
+
silence_stream(STDERR) do
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.should_fail exit_on_fail, condition, msg
|
36
|
+
if exit_on_fail
|
37
|
+
"should exit with status #{Scide::EXIT[condition]} #{msg}"
|
38
|
+
else
|
39
|
+
"should raise an error with condition #{condition} #{msg}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
15
44
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
45
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
46
|
require 'scide'
|
data/spec/opts_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide::Opts do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@opts = Scide::Opts.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add the help flag" do
|
10
|
+
[ '-h', '--help' ].each do |flag|
|
11
|
+
lambda{ parse!([flag]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should add the usage flag" do
|
16
|
+
[ '-u', '--usage' ].each do |flag|
|
17
|
+
lambda{ parse!([flag]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add the version flag" do
|
22
|
+
expected_version = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r').read
|
23
|
+
lambda{ parse!([ '--version' ]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should add the dry run flag" do
|
27
|
+
parse!([ '--dry-run' ])
|
28
|
+
@opts.funnel[:'dry-run'].should == true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should exit with status 2 for unknown arguments" do
|
32
|
+
[ '-x', '--fubar', '-4' ].each do |unknown|
|
33
|
+
lambda{ parse!([unknown]) }.should raise_error(SystemExit){ |err| err.status.should == 2 }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def parse! args
|
40
|
+
silence_stream(STDOUT){ silence_stream(STDERR){ @opts.parse! args } }
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide::Project do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@path = '/tmp'
|
7
|
+
@options = { :a => 1, :b => true }
|
8
|
+
@global = double('global')
|
9
|
+
@global.stub(:path){ @path }
|
10
|
+
@global.stub(:options){ @options }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should add the project key to the global path by default" do
|
14
|
+
pro = Scide::Project.new @global, 'fubar', :windows => []
|
15
|
+
pro.path.should == File.join(@path, pro.key)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should add its path to the global path if relative" do
|
19
|
+
pro = Scide::Project.new @global, 'fubar', :windows => [], :path => 'foo'
|
20
|
+
pro.path.should == File.join(@path, 'foo')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should use its path if absolute" do
|
24
|
+
pro = Scide::Project.new @global, 'fubar', :windows => [], :path => '/foo'
|
25
|
+
pro.path.should == '/foo'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should use its path if there is no global path" do
|
29
|
+
global_no_path = double('global')
|
30
|
+
global_no_path.stub(:path){ nil }
|
31
|
+
global_no_path.stub(:options){ { :a => 1, :b => true } }
|
32
|
+
pro = Scide::Project.new global_no_path, 'fubar', :windows => [], :path => '/foo'
|
33
|
+
pro.path.should == '/foo'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should expand its path if relative" do
|
37
|
+
global_relative = double('global')
|
38
|
+
global_relative.stub(:path){ nil }
|
39
|
+
global_relative.stub(:options){ { :a => 1, :b => true } }
|
40
|
+
pro = Scide::Project.new global_relative, 'fubar', :windows => []
|
41
|
+
pro.path.should == File.join(File.expand_path('~'), 'fubar')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should duplicate global options" do
|
45
|
+
@global.should_receive :path
|
46
|
+
@global.should_receive :options
|
47
|
+
pro = Scide::Project.new @global, 'fubar', :windows => []
|
48
|
+
pro.options.should_not equal(@options)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should add name and path to options" do
|
52
|
+
additional_options = { :name => 'fubar', :path => File.join(@path, 'fubar') }
|
53
|
+
pro = Scide::Project.new @global, 'fubar', :windows => []
|
54
|
+
pro.options.should == @options.merge(additional_options)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should override global name and path" do
|
58
|
+
global_with_name_and_path = double('global')
|
59
|
+
global_with_name_and_path.stub(:path){ @path }
|
60
|
+
global_with_name_and_path.stub(:options){ { :name => 'global', :path => '/global' } }
|
61
|
+
pro = Scide::Project.new global_with_name_and_path, 'fubar', :windows => []
|
62
|
+
pro.options[:name].should_not == 'global'
|
63
|
+
pro.options[:path].should_not == '/global'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should merge given options" do
|
67
|
+
additional_options = { :name => 'fubar', :path => File.join(@path, 'fubar') }
|
68
|
+
new_options = { :name => 'fubar2', :path => '/tmp2', :b => false, :c => 'foo' }
|
69
|
+
pro = Scide::Project.new @global, 'fubar', :windows => [], :options => new_options
|
70
|
+
pro.options.should == @options.merge(additional_options).merge(new_options)
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'Sample Configuration' do
|
74
|
+
before :each do
|
75
|
+
contents = {
|
76
|
+
:windows => [
|
77
|
+
'window1 EDIT',
|
78
|
+
{ :name => 'window2', :command => 'SHOW', :contents => 'ssh example.com' },
|
79
|
+
'window3 TAIL file.txt',
|
80
|
+
{ :string => 'window4 RUN ls -la' },
|
81
|
+
'window5'
|
82
|
+
]
|
83
|
+
}
|
84
|
+
@project = Scide::Project.new @global, 'fubar', contents
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should create five windows" do
|
88
|
+
@project.windows.length.should == 5
|
89
|
+
@project.windows.each{ |w| w.should be_a(Scide::Window) }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should create the correct commands" do
|
93
|
+
@project.windows[0].command.should be_a(Scide::Commands::Edit)
|
94
|
+
@project.windows[1].command.should be_a(Scide::Commands::Show)
|
95
|
+
@project.windows[2].command.should be_a(Scide::Commands::Tail)
|
96
|
+
@project.windows[3].command.should be_a(Scide::Commands::Run)
|
97
|
+
@project.windows[4].command.should be_nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should create a GNU Screen configuration" do
|
101
|
+
@project.to_screen.should == SpecHelper.result(:project1)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should raise an error if the contents are not a hash" do
|
106
|
+
[ nil, ' ', [] ].each do |not_hash|
|
107
|
+
lambda{ Scide::Project.new @global, 'fubar', not_hash }.should raise_error(ArgumentError)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should raise an error if its windows are nil or not an array" do
|
112
|
+
[ nil, ' ', {} ].each do |not_array|
|
113
|
+
lambda{ Scide::Project.new @global, 'fubar', :windows => not_array }.should raise_error(ArgumentError)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should raise an error if its options are not nil and not a hash" do
|
118
|
+
[ ' ', [] ].each do |not_hash|
|
119
|
+
lambda{ Scide::Project.new @global, 'fubar', :windows => [], :options => not_hash }.should raise_error(ArgumentError)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
screen:
|
2
|
+
hardstatus: 'dummy'
|
3
|
+
global:
|
4
|
+
path: '/tmp'
|
5
|
+
projects:
|
6
|
+
project1:
|
7
|
+
windows:
|
8
|
+
- 'window1 EDIT'
|
9
|
+
- name: 'window2'
|
10
|
+
command: 'SHOW'
|
11
|
+
contents: 'ssh example.com'
|
12
|
+
- 'window3 TAIL file.txt'
|
13
|
+
- string: 'window4 RUN ls -la'
|
14
|
+
- 'window5'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
startup_message off
|
2
|
+
hardstatus on
|
3
|
+
hardstatus alwayslastline
|
4
|
+
hardstatus string 'dummy'
|
5
|
+
|
6
|
+
screen -t window1 0
|
7
|
+
stuff "$EDITOR\012"
|
8
|
+
screen -t window2 1
|
9
|
+
stuff "ssh example.com"
|
10
|
+
screen -t window3 2
|
11
|
+
stuff "tail -f file.txt\012"
|
12
|
+
screen -t window4 3
|
13
|
+
stuff "ls -la\012"
|
14
|
+
screen -t window5 4
|
data/spec/scide_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
Scide.exit_on_fail = true
|
7
|
+
end
|
8
|
+
|
9
|
+
after :each do
|
10
|
+
Scide.exit_on_fail = true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have the correct version" do
|
14
|
+
Scide::VERSION.should == File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r').read
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should exit on fail by default" do
|
18
|
+
lambda{ SpecHelper.silence{ Scide.fail nil, 'fubar' } }.should raise_error(SystemExit)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should exit with the correct status code" do
|
22
|
+
Scide::EXIT.each_pair do |condition,code|
|
23
|
+
lambda{ SpecHelper.silence{ Scide.fail condition, 'fubar' } }.should raise_error(SystemExit){ |err| err.status.should == code }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise an error on fail if configured to do so" do
|
28
|
+
Scide.exit_on_fail = false
|
29
|
+
lambda{ Scide.fail nil, 'fubar' }.should raise_error(Scide::Error)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise an error with the correct condition" do
|
33
|
+
Scide.exit_on_fail = false
|
34
|
+
Scide::EXIT.each_pair do |condition|
|
35
|
+
lambda{ Scide.fail condition, 'fubar' }.should raise_error(Scide::Error){ |err| err.condition.should == condition }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/screen_spec.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide::Screen do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@project = double('project')
|
7
|
+
@project.stub(:path){ '/tmp' }
|
8
|
+
@project.stub(:to_screen){ 'fubar' }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should generate a command to run screen at the given project's path" do
|
12
|
+
screen = Scide::Screen.new(@project, {})
|
13
|
+
@project.should_receive :path
|
14
|
+
screen.to_command('fubar').should == 'cd /tmp && screen -c fubar'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should generate a command to run screen with the given options" do
|
18
|
+
screen = Scide::Screen.new @project, :binary => '/usr/bin/screen', :args => '-U'
|
19
|
+
@project.should_receive :path
|
20
|
+
screen.to_command('fubar').should == 'cd /tmp && /usr/bin/screen -U -c fubar'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should generate a screen configuration file" do
|
24
|
+
global = double('global')
|
25
|
+
global.stub(:path){ nil }
|
26
|
+
global.stub(:options){ {} }
|
27
|
+
contents = {
|
28
|
+
:windows => [
|
29
|
+
'window1 EDIT',
|
30
|
+
{ :name => 'window2', :command => 'SHOW', :contents => 'ssh example.com' },
|
31
|
+
'window3 TAIL file.txt',
|
32
|
+
{ :string => 'window4 RUN ls -la' },
|
33
|
+
'window5'
|
34
|
+
]
|
35
|
+
}
|
36
|
+
project = Scide::Project.new(global, 'fubar', contents)
|
37
|
+
screen = Scide::Screen.new project, :hardstatus => 'dummy'
|
38
|
+
screen.to_s.should == SpecHelper.result(:screen1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should use the default hardstatus line if not given" do
|
42
|
+
screen = Scide::Screen.new(@project, {})
|
43
|
+
screen.hardstatus.should == Scide::Screen::DEFAULT_HARDSTATUS
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should use the given hardstatus line" do
|
47
|
+
screen = Scide::Screen.new @project, :hardstatus => 'fubar'
|
48
|
+
screen.hardstatus.should == 'fubar'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should use the default binary if not given" do
|
52
|
+
screen = Scide::Screen.new(@project, {})
|
53
|
+
screen.binary.should == 'screen'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should use the given binary" do
|
57
|
+
screen = Scide::Screen.new @project, :binary => '/usr/bin/screen'
|
58
|
+
screen.binary.should == '/usr/bin/screen'
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should use the given args" do
|
62
|
+
screen = Scide::Screen.new @project, :args => '-U'
|
63
|
+
screen.args.should == '-U'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should duplicate the given options" do
|
67
|
+
options = { :a => 1, :b => true }
|
68
|
+
screen = Scide::Screen.new @project, options
|
69
|
+
screen.options.should == options
|
70
|
+
screen.options.should_not equal(options)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should exit with status 4 if the screen binary is not found" do
|
74
|
+
bad_binary = "IHateYouIfYouAddedThisBinaryJustToMakeMyTestFail"
|
75
|
+
lambda{ SpecHelper.silence{ Scide::Screen.new(@project, :binary => bad_binary).check_binary } }.should raise_error(SystemExit){ |err| err.status.should == 4 }
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should raise an error if the options are not nil and not a hash" do
|
79
|
+
[ ' ', [] ].each do |not_hash|
|
80
|
+
lambda{ Scide::Screen.new @project, not_hash }.should raise_error(ArgumentError)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/window_spec.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Scide::Window do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@options = { :a => 1, :b => true }
|
7
|
+
@project = double('project')
|
8
|
+
@project.stub(:options){ @options }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "String Initialization" do
|
12
|
+
it "should take the given name" do
|
13
|
+
win = Scide::Window.new @project, 'fubar'
|
14
|
+
win.name.should == 'fubar'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create the correct command" do
|
18
|
+
win = Scide::Window.new @project, 'fubar EDIT'
|
19
|
+
win.command.should be_a(Scide::Commands::Edit)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be initializable with a name and a command with no contents" do
|
23
|
+
lambda{ Scide::Window.new @project, 'fubar EDIT' }.should_not raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be initializable with a name and a command with contents" do
|
27
|
+
lambda{ Scide::Window.new @project, 'fubar TAIL file.txt' }.should_not raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should raise an error when initialized without a name" do
|
31
|
+
lambda{ Scide::Window.new @project, ' ' }.should raise_error(ArgumentError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise an error for unknown commands" do
|
35
|
+
lambda{ Scide::Window.new @project, 'fubar EDT' }.should raise_error(ArgumentError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "Hash Initialization" do
|
40
|
+
it "should take the given name" do
|
41
|
+
win = Scide::Window.new @project, :name => 'fubar'
|
42
|
+
win.name.should == 'fubar'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should create the correct command" do
|
46
|
+
win = Scide::Window.new @project, :name => 'fubar', :command => 'EDIT'
|
47
|
+
win.command.should be_a(Scide::Commands::Edit)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be initializable with a name and a command with no contents" do
|
51
|
+
lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDIT' }.should_not raise_error(ArgumentError)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be initializable with a name and a command with contents" do
|
55
|
+
lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDIT', :contents => 'file.txt' }.should_not raise_error(ArgumentError)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should raise an error when initialized without a name" do
|
59
|
+
lambda{ Scide::Window.new @project, :fubar => true }.should raise_error(ArgumentError)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should raise an error for unknown commands" do
|
63
|
+
lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDT' }.should raise_error(ArgumentError)
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "String Option" do
|
67
|
+
|
68
|
+
it "should take the given name" do
|
69
|
+
win = Scide::Window.new @project, :string => 'fubar'
|
70
|
+
win.name.should == 'fubar'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should create the correct command" do
|
74
|
+
win = Scide::Window.new @project, :string => 'fubar EDIT'
|
75
|
+
win.command.should be_a(Scide::Commands::Edit)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should be initializable with a name and a command with no contents" do
|
79
|
+
lambda{ Scide::Window.new @project, :string => 'fubar EDIT' }.should_not raise_error(ArgumentError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be initializable with a name and a command with contents" do
|
83
|
+
lambda{ Scide::Window.new @project, :string => 'fubar EDIT file.txt' }.should_not raise_error(ArgumentError)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should raise an error when initialized without a name" do
|
87
|
+
lambda{ Scide::Window.new @project, :string => ' ' }.should raise_error(ArgumentError)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should raise an error for unknown commands" do
|
91
|
+
lambda{ Scide::Window.new @project, :string => 'fubar EDT' }.should raise_error(ArgumentError)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should raise an error when type of contents is unknown" do
|
97
|
+
lambda{ Scide::Window.new(@project, []) }.should raise_error(ArgumentError)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should duplicate project options" do
|
101
|
+
@project.should_receive :options
|
102
|
+
win = Scide::Window.new @project, 'fubar'
|
103
|
+
win.options.should == @options
|
104
|
+
win.options.should_not equal(@options)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should merge its options to project options" do
|
108
|
+
window_options = { :b => false, :c => 'foo' }
|
109
|
+
@project.should_receive :options
|
110
|
+
win = Scide::Window.new @project, :name => 'fubar', :options => window_options
|
111
|
+
win.options.should == @options.merge(window_options)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should generate a GNU Screen window" do
|
115
|
+
# without a command, hash initialization
|
116
|
+
win = Scide::Window.new @project, :name => 'fubar'
|
117
|
+
win.to_screen(0).should == 'screen -t fubar 0'
|
118
|
+
# with a command, string initialization
|
119
|
+
win = Scide::Window.new @project, 'fubar EDIT file.txt'
|
120
|
+
win.to_screen(0).should == %|screen -t fubar 0\n#{win.command.to_screen}|
|
121
|
+
end
|
122
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: upoj-rb
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157640360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157640360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157639760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157639760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157639160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157639160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157638560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157638560
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157637960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157637960
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: &
|
70
|
+
name: simplecov
|
71
|
+
requirement: &2157637360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2157637360
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rdoc
|
82
|
-
requirement: &
|
82
|
+
requirement: &2157636760 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2157636760
|
91
91
|
description: Utility to generate GNU screen configuration files.
|
92
92
|
email: hydrae.alpha@gmail.com
|
93
93
|
executables:
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- LICENSE.txt
|
106
106
|
- README.md
|
107
107
|
- Rakefile
|
108
|
+
- TODO.md
|
108
109
|
- VERSION
|
109
110
|
- bin/scide
|
110
111
|
- lib/scide.rb
|
@@ -126,7 +127,19 @@ files:
|
|
126
127
|
- spec/commands/run_spec.rb
|
127
128
|
- spec/commands/show_spec.rb
|
128
129
|
- spec/commands/tail_spec.rb
|
130
|
+
- spec/config_spec.rb
|
131
|
+
- spec/global_spec.rb
|
129
132
|
- spec/helper.rb
|
133
|
+
- spec/opts_spec.rb
|
134
|
+
- spec/project_spec.rb
|
135
|
+
- spec/results/config1.yml
|
136
|
+
- spec/results/malformed_config.yml
|
137
|
+
- spec/results/project1.screen
|
138
|
+
- spec/results/screen1.screen
|
139
|
+
- spec/scide_spec.rb
|
140
|
+
- spec/screen_spec.rb
|
141
|
+
- spec/version_spec.rb
|
142
|
+
- spec/window_spec.rb
|
130
143
|
homepage: http://github.com/AlphaHydrae/scide
|
131
144
|
licenses:
|
132
145
|
- MIT
|
@@ -142,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
155
|
version: '0'
|
143
156
|
segments:
|
144
157
|
- 0
|
145
|
-
hash:
|
158
|
+
hash: 1323190818279805743
|
146
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
160
|
none: false
|
148
161
|
requirements:
|