scide 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -2
- data/README.md +142 -1
- data/Rakefile +20 -7
- data/VERSION +1 -1
- data/lib/scide/command.rb +14 -14
- data/lib/scide/commands/edit.rb +3 -3
- data/lib/scide/commands/run.rb +1 -1
- data/lib/scide/commands/show.rb +2 -2
- data/lib/scide/commands/tail.rb +3 -3
- data/lib/scide/config.rb +14 -14
- data/lib/scide/global.rb +1 -1
- data/lib/scide/opts.rb +1 -1
- data/lib/scide/overmind.rb +6 -6
- data/lib/scide/project.rb +6 -6
- data/lib/scide/screen.rb +7 -7
- data/lib/scide/window.rb +10 -10
- data/lib/scide.rb +6 -15
- data/scide.gemspec +8 -5
- metadata +29 -18
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
multi_json (1.0.3)
|
14
14
|
paint (0.8.3)
|
15
15
|
rake (0.9.2)
|
16
|
-
|
16
|
+
rdiscount (1.6.8)
|
17
17
|
rspec (2.6.0)
|
18
18
|
rspec-core (~> 2.6.0)
|
19
19
|
rspec-expectations (~> 2.6.0)
|
@@ -30,6 +30,7 @@ GEM
|
|
30
30
|
upoj-rb (0.0.5)
|
31
31
|
active_support (>= 2)
|
32
32
|
paint
|
33
|
+
yard (0.7.2)
|
33
34
|
|
34
35
|
PLATFORMS
|
35
36
|
ruby
|
@@ -38,8 +39,9 @@ DEPENDENCIES
|
|
38
39
|
active_support (>= 2)
|
39
40
|
bundler (~> 1.0.0)
|
40
41
|
jeweler (~> 1.6.4)
|
41
|
-
|
42
|
+
rdiscount
|
42
43
|
rspec
|
43
44
|
shoulda
|
44
45
|
simplecov
|
45
46
|
upoj-rb (~> 0.0.4)
|
47
|
+
yard
|
data/README.md
CHANGED
@@ -2,7 +2,148 @@
|
|
2
2
|
|
3
3
|
GNU Screen IDE.
|
4
4
|
|
5
|
-
|
5
|
+
The purpose of this tool is to generate several GNU screen configurations from a single YAML configuration file.
|
6
|
+
This can be used to easily setup a multi-windows development environment with screen.
|
7
|
+
|
8
|
+
## Using
|
9
|
+
|
10
|
+
You can install scide with:
|
11
|
+
|
12
|
+
gem install scide
|
13
|
+
|
14
|
+
Then use it on the command line:
|
15
|
+
|
16
|
+
scide --version
|
17
|
+
scide my_project
|
18
|
+
|
19
|
+
__Interactive configuration will be introduced in v0.2.*.__
|
20
|
+
__Until then, the configuration file must be prepared manually before using scide.__
|
21
|
+
|
22
|
+
## Configuration File
|
23
|
+
|
24
|
+
The configuration file is expected to be at the following location by default:
|
25
|
+
|
26
|
+
$HOME/.scide/config.yml
|
27
|
+
|
28
|
+
You can load another file by running scide with the `-c` flag:
|
29
|
+
|
30
|
+
scide -c my_config.yml
|
31
|
+
|
32
|
+
### Basics
|
33
|
+
|
34
|
+
This is a simple scide configuration file:
|
35
|
+
|
36
|
+
projects:
|
37
|
+
mywebsite:
|
38
|
+
path: /home/jdoe/projects/mywebsite
|
39
|
+
windows:
|
40
|
+
- 'project EDIT'
|
41
|
+
- 'db-log TAIL log/db.log'
|
42
|
+
- 'server RUN rails server'
|
43
|
+
- 'shell'
|
44
|
+
|
45
|
+
By running `scide mywebsite`, screen would open with four windows:
|
46
|
+
|
47
|
+
* a __project__ window with your favorite `$EDITOR` launched;
|
48
|
+
* a __db-log__ window with a tail of the project's database log;
|
49
|
+
* a __server__ window with your Ruby on Rails server launched;
|
50
|
+
* a __shell__ window with your shell running.
|
51
|
+
|
52
|
+
The format for a window is `NAME [COMMAND] [CONTENTS]`.
|
53
|
+
This opens a window with the given name. An optional command
|
54
|
+
can be run in the window, which can receive arguments/contents.
|
55
|
+
|
56
|
+
### Options
|
57
|
+
|
58
|
+
Projects can have a hash of options that commands can use:
|
59
|
+
|
60
|
+
projects:
|
61
|
+
mywebsite:
|
62
|
+
path: /home/jdoe/projects/mywebsite
|
63
|
+
options:
|
64
|
+
log_dir: /var/log
|
65
|
+
server: thin
|
66
|
+
windows:
|
67
|
+
- 'project EDIT'
|
68
|
+
- 'db-log TAIL %{log_dir}/db.log'
|
69
|
+
- 'app-log TAIL %{log_dir}/development.log'
|
70
|
+
- 'server RUN %{server} start'
|
71
|
+
- 'shell'
|
72
|
+
|
73
|
+
### Globals
|
74
|
+
|
75
|
+
You can configure a base path and options for all projects.
|
76
|
+
|
77
|
+
global:
|
78
|
+
path: /home/jdoe/projects
|
79
|
+
options:
|
80
|
+
log_dir: /var/log
|
81
|
+
projects:
|
82
|
+
mywebsite:
|
83
|
+
path: mywebsite # this is now relative to the global path
|
84
|
+
options:
|
85
|
+
server: thin
|
86
|
+
windows:
|
87
|
+
- 'project EDIT'
|
88
|
+
- 'db-log TAIL %{log_dir}/db.log'
|
89
|
+
- 'app-log TAIL %{log_dir}/development.log'
|
90
|
+
- 'server RUN %{server} start'
|
91
|
+
- 'shell'
|
92
|
+
|
93
|
+
Options at the project level override global options if they have the same name.
|
94
|
+
|
95
|
+
### Commands
|
96
|
+
|
97
|
+
Scide currently provides four commands.
|
98
|
+
|
99
|
+
#### RUN
|
100
|
+
|
101
|
+
Runs the given contents in the window.
|
102
|
+
|
103
|
+
For example, `RUN rails server` launches a Ruby on Rails server in the project folder.
|
104
|
+
|
105
|
+
#### EDIT
|
106
|
+
|
107
|
+
Simply runs `$EDITOR`, your preferred editor.
|
108
|
+
|
109
|
+
If the `edit` option is present, it will be used as arguments to the editor.
|
110
|
+
|
111
|
+
# project configuration:
|
112
|
+
mywebsite:
|
113
|
+
options:
|
114
|
+
edit: '-c MyVimCommand'
|
115
|
+
windows:
|
116
|
+
- 'project EDIT app/controllers/application_controller.erb'
|
117
|
+
|
118
|
+
# resulting command in "project" window:
|
119
|
+
$EDITOR -c MyVimCommand app/controllers/application_controller.erb
|
120
|
+
|
121
|
+
#### TAIL
|
122
|
+
|
123
|
+
Runs the `tail` command with the given file as the `-f` argument.
|
124
|
+
|
125
|
+
For example, `TAIL log/db.log` would generate the following command:
|
126
|
+
|
127
|
+
tail -f log/db.log
|
128
|
+
|
129
|
+
If the `tail` option is present, it will be used as arguments to tail.
|
130
|
+
|
131
|
+
# project configuration:
|
132
|
+
mywebsite:
|
133
|
+
options:
|
134
|
+
tail: '-n 1000'
|
135
|
+
windows:
|
136
|
+
- 'db.log TAIL log/db.log'
|
137
|
+
|
138
|
+
# resulting command in "project" window:
|
139
|
+
tail -n 1000 -f log/db.log
|
140
|
+
|
141
|
+
#### SHOW
|
142
|
+
|
143
|
+
Shows the given contents in the window, without running them.
|
144
|
+
|
145
|
+
For example, `SHOW ssh example.com` would pre-type this ssh command in the window, but not run it.
|
146
|
+
That way, you can have special commands ready to run in a separate window.
|
6
147
|
|
7
148
|
## Contributing to scide
|
8
149
|
|
data/Rakefile
CHANGED
@@ -34,12 +34,25 @@ end
|
|
34
34
|
|
35
35
|
task :default => :test
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
desc "Generate documentation"
|
38
|
+
task :doc => ['doc:generate']
|
39
|
+
namespace :doc do
|
40
|
+
project_root = File.dirname __FILE__
|
41
|
+
doc_destination = File.join project_root, 'doc'
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
begin
|
44
|
+
require 'yard'
|
45
|
+
require 'yard/rake/yardoc_task'
|
46
|
+
|
47
|
+
YARD::Rake::YardocTask.new(:generate) do |yt|
|
48
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
49
|
+
[ File.join(project_root, 'README.md') ]
|
50
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md', '--private', '--protected']
|
51
|
+
end
|
52
|
+
rescue LoadError
|
53
|
+
desc "Generate YARD Documentation"
|
54
|
+
task :generate do
|
55
|
+
abort "Please install the YARD gem to generate rdoc."
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/scide/command.rb
CHANGED
@@ -2,7 +2,7 @@ module Scide
|
|
2
2
|
|
3
3
|
# A command to be used in a GNU Screen window. There are several
|
4
4
|
# command implementations (show command, run command, tail file, etc).
|
5
|
-
# See under Scide::Commands.
|
5
|
+
# See under {Scide::Commands}.
|
6
6
|
class Command
|
7
7
|
|
8
8
|
# The options given to this command. These are built by merging
|
@@ -11,23 +11,23 @@ module Scide
|
|
11
11
|
|
12
12
|
# Returns a new command for the given window.
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# == Arguments
|
15
15
|
# * <tt>window</tt> - The window in which the command will be used.
|
16
|
-
# Command options are retrieved from Scide::Window#options. See
|
17
|
-
# #initialize.
|
16
|
+
# Command options are retrieved from {Scide::Window#options}. See
|
17
|
+
# {#initialize}.
|
18
18
|
# * <tt>contents</tt> - The command configuration (String or Hash).
|
19
19
|
#
|
20
|
-
#
|
20
|
+
# == String Initialization
|
21
21
|
# The string must be in the format <tt>COMMAND [CONTENTS]</tt>.
|
22
22
|
#
|
23
23
|
# <tt>TYPE</tt> is the name of the command class under
|
24
|
-
# Scide::Commands, in uppercase camelcase. For example, <tt>TAIL</tt>
|
25
|
-
# corresponds to Scide::Commands::Tail, <tt>MY_COMMAND</tt> would
|
26
|
-
# correspond to Scide::Commands::MyCommand
|
24
|
+
# {Scide::Commands}, in uppercase camelcase. For example, <tt>TAIL</tt>
|
25
|
+
# corresponds to {Scide::Commands::Tail}, <tt>MY_COMMAND</tt> would
|
26
|
+
# correspond to <tt>Scide::Commands::MyCommand</tt>.
|
27
27
|
#
|
28
28
|
# <tt>CONTENTS</tt> is the contents of the command.
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# == Hash Initialization
|
31
31
|
# The following options can be given:
|
32
32
|
# * <tt>:command => string</tt> is the same <tt>COMMAND</tt> as
|
33
33
|
# for string initialization above.
|
@@ -47,11 +47,11 @@ module Scide
|
|
47
47
|
|
48
48
|
# Returns a new command with the given options.
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# == Arguments
|
51
51
|
# * <tt>contents</tt> - The contents of the command. Typically this
|
52
52
|
# is only a string, but more advanced commands might be initialized
|
53
53
|
# with arrays or hashes. By default, the contents can be retrieved
|
54
|
-
# as a string with #text_with_options.
|
54
|
+
# as a string with {#text_with_options}.
|
55
55
|
# * <tt>options</tt> - Options that can be used in the string contents
|
56
56
|
# of the command. See #text_with_options.
|
57
57
|
def initialize contents, options = {}
|
@@ -75,7 +75,7 @@ module Scide
|
|
75
75
|
|
76
76
|
# Returns the text of this command with filtered option placeholders.
|
77
77
|
#
|
78
|
-
#
|
78
|
+
# == Examples
|
79
79
|
# com_text = 'tail %{tail} -f file.txt -c %{foo}'
|
80
80
|
# com = Scide::Command.new com_text, :tail => '-n 1000', :foo => 400
|
81
81
|
#
|
@@ -91,7 +91,7 @@ module Scide
|
|
91
91
|
private
|
92
92
|
|
93
93
|
# Returns a new command for the given window. The given
|
94
|
-
# contents are a hash. See Scide::Command.resolve.
|
94
|
+
# contents are a hash. See {Scide::Command.resolve}.
|
95
95
|
def self.resolve_from_hash window, contents
|
96
96
|
begin
|
97
97
|
klass = Scide::Commands.const_get contents[:command].downcase.camelize
|
@@ -102,7 +102,7 @@ module Scide
|
|
102
102
|
end
|
103
103
|
|
104
104
|
# Returns a new command for the given window. The given
|
105
|
-
# contents are a string. See Scide::Command.resolve.
|
105
|
+
# contents are a string. See {Scide::Command.resolve}.
|
106
106
|
def self.resolve_from_string window, contents
|
107
107
|
klass_name, text = contents.split /\s+/, 2
|
108
108
|
begin
|
data/lib/scide/commands/edit.rb
CHANGED
@@ -4,7 +4,7 @@ module Scide
|
|
4
4
|
|
5
5
|
# Edits a file with the default editor (<tt>$EDITOR</tt>).
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# == Configuration Example
|
8
8
|
# # this YAML configuration,
|
9
9
|
# projects:
|
10
10
|
# project1:
|
@@ -21,12 +21,12 @@ module Scide
|
|
21
21
|
#
|
22
22
|
# See class definition for examples.
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# == Arguments
|
25
25
|
# * <tt>contents</tt> - The file to edit.
|
26
26
|
# * <tt>options</tt> - Options that can be used in the contents
|
27
27
|
# of the command.
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# == Options
|
30
30
|
# * <tt>:edit => string</tt> - Arguments to the editor.
|
31
31
|
def initialize contents, options = {}
|
32
32
|
super contents, options
|
data/lib/scide/commands/run.rb
CHANGED
data/lib/scide/commands/show.rb
CHANGED
@@ -4,7 +4,7 @@ module Scide
|
|
4
4
|
|
5
5
|
# Prepares and shows a command but do not run it.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# == Configuration Example
|
8
8
|
# # this YAML configuration,
|
9
9
|
# projects:
|
10
10
|
# project1:
|
@@ -18,7 +18,7 @@ module Scide
|
|
18
18
|
class Show < Scide::Command
|
19
19
|
|
20
20
|
# Returns a configuration fragment that will show
|
21
|
-
# this command in a GNU
|
21
|
+
# this command in a GNU Screen window without running it.
|
22
22
|
# This will use screen's <tt>stuff</tt> command to
|
23
23
|
# put the text in the window.
|
24
24
|
def to_screen
|
data/lib/scide/commands/tail.rb
CHANGED
@@ -4,7 +4,7 @@ module Scide
|
|
4
4
|
|
5
5
|
# Tails a file.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# == Configuration Example
|
8
8
|
# # this YAML configuration,
|
9
9
|
# projects:
|
10
10
|
# project1:
|
@@ -21,12 +21,12 @@ module Scide
|
|
21
21
|
#
|
22
22
|
# See class definition for examples.
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# == Arguments
|
25
25
|
# * <tt>contents</tt> - The file to tail.
|
26
26
|
# * <tt>options</tt> - Options that can be used in the
|
27
27
|
# contents of the command.
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# == Options
|
30
30
|
# * <tt>tail => string</tt> - Arguments to tail.
|
31
31
|
def initialize contents, options = {}
|
32
32
|
super contents, options
|
data/lib/scide/config.rb
CHANGED
@@ -12,35 +12,35 @@ module Scide
|
|
12
12
|
# The file from which this configuration will be loaded.
|
13
13
|
attr_accessor :file
|
14
14
|
|
15
|
-
# GNU Screen options. Accessible after calling #load
|
15
|
+
# GNU Screen options. Accessible after calling {#load!}.
|
16
16
|
attr_reader :screen
|
17
17
|
|
18
|
-
# The global configuration. Accessible after calling #load
|
18
|
+
# The global configuration. Accessible after calling {#load!}.
|
19
19
|
attr_reader :global
|
20
20
|
|
21
21
|
# The project definitions (windows, option overrides, etc). Accessible
|
22
|
-
# after calling #load
|
22
|
+
# after calling {#load!}.
|
23
23
|
attr_reader :projects
|
24
24
|
|
25
25
|
# Returns an empty configuration.
|
26
26
|
#
|
27
|
-
#
|
27
|
+
# == Arguments
|
28
28
|
# * <tt>file</tt> - The file from which to load the configuration. If not
|
29
|
-
# given, this defaults to DEFAULT_CONFIG_FILE.
|
29
|
+
# given, this defaults to {DEFAULT_CONFIG_FILE}.
|
30
30
|
def initialize file = nil
|
31
31
|
@file = file.try(:to_s) || DEFAULT_CONFIG_FILE
|
32
32
|
end
|
33
33
|
|
34
|
-
# Loads this configuration. This will read from #file and parse the contents
|
34
|
+
# Loads this configuration. This will read from {#file} and parse the contents
|
35
35
|
# as YAML. Configuration elements can then be retrieved with #global,
|
36
36
|
# #projects and #screen.
|
37
37
|
#
|
38
|
-
#
|
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.
|
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
44
|
def load!
|
45
45
|
|
46
46
|
Scide.fail :config_not_found, "ERROR: expected to find configuration at #{@file}" unless File.exists? @file
|
@@ -79,7 +79,7 @@ module Scide
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
-
# Returns the contents of #file.
|
82
|
+
# Returns the contents of {#file}.
|
83
83
|
def load_config
|
84
84
|
File.open(@file, 'r').read
|
85
85
|
end
|
@@ -89,7 +89,7 @@ module Scide
|
|
89
89
|
YAML::load raw
|
90
90
|
end
|
91
91
|
|
92
|
-
# Causes scide to fail with an <tt>invalid_config</tt> error (see Scide
|
92
|
+
# Causes scide to fail with an <tt>invalid_config</tt> error (see {Scide.fail}).
|
93
93
|
# Builds a complete error message containing the full path to the
|
94
94
|
# configuration file and the given message.
|
95
95
|
def invalid_config msg
|
data/lib/scide/global.rb
CHANGED
data/lib/scide/opts.rb
CHANGED
@@ -22,7 +22,7 @@ module Scide
|
|
22
22
|
|
23
23
|
# Parses the given arguments.
|
24
24
|
#
|
25
|
-
# Causes scide to fail with an <tt>invalid_argument</tt> error (see Scide
|
25
|
+
# Causes scide to fail with an <tt>invalid_argument</tt> error (see {Scide.fail})
|
26
26
|
# if an argument is invalid.
|
27
27
|
def parse! args
|
28
28
|
begin
|
data/lib/scide/overmind.rb
CHANGED
@@ -5,14 +5,14 @@ module Scide
|
|
5
5
|
# Utility class to run scide in a script.
|
6
6
|
class Overmind
|
7
7
|
|
8
|
-
# Awakens the overmind.
|
8
|
+
# Awakens the overmind. Use at your own risk.
|
9
9
|
def initialize
|
10
10
|
@cli = Scide::Opts.new
|
11
11
|
@config = Scide::Config.new
|
12
12
|
end
|
13
13
|
|
14
14
|
# Parses command-line arguments and loads the configuration file.
|
15
|
-
# Any error will be run through Scide.fail.
|
15
|
+
# Any error will be run through {Scide.fail}.
|
16
16
|
def brood
|
17
17
|
@cli.parse! ARGV
|
18
18
|
@config.file = @cli.funnel[:config] if @cli.funnel.key? :config
|
@@ -21,15 +21,15 @@ module Scide
|
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
|
-
# Runs GNU
|
24
|
+
# Runs GNU Screen with the project given as argument.
|
25
25
|
# The <tt>--dry-run</tt> option will cause scide to print the
|
26
26
|
# resulting configuration instead of running it.
|
27
27
|
#
|
28
|
-
#
|
29
|
-
# * <tt>not_initialized</tt> - If #brood was not called.
|
28
|
+
# == Errors
|
29
|
+
# * <tt>not_initialized</tt> - If {#brood} was not called.
|
30
30
|
# * <tt>unknown_project</tt> - If the given project is not found
|
31
31
|
# in the configuration file.
|
32
|
-
# * <tt>screen_not_found</tt> - If the GNU
|
32
|
+
# * <tt>screen_not_found</tt> - If the GNU Screen binary is not
|
33
33
|
# found with <tt>which</tt>.
|
34
34
|
def dominate
|
35
35
|
|
data/lib/scide/project.rb
CHANGED
@@ -6,10 +6,10 @@ module Scide
|
|
6
6
|
# The project key in the projects configuration hash.
|
7
7
|
attr_reader :key
|
8
8
|
|
9
|
-
# The path where the project is located. See #initialize.
|
9
|
+
# The path where the project is located. See {#initialize}.
|
10
10
|
attr_reader :path
|
11
11
|
|
12
|
-
# Project-specific options. Can be used by commands. See #initialize.
|
12
|
+
# Project-specific options. Can be used by commands. See {#initialize}.
|
13
13
|
attr_reader :options
|
14
14
|
|
15
15
|
# The GNU Screen windows of this project.
|
@@ -17,18 +17,18 @@ module Scide
|
|
17
17
|
|
18
18
|
# Returns a project configuration.
|
19
19
|
#
|
20
|
-
# If not given in the project hash, #path is built by joining
|
20
|
+
# If not given in the project hash, {#path} is built by joining
|
21
21
|
# the global path and <tt>key</tt>.
|
22
22
|
#
|
23
|
-
#
|
23
|
+
# == Arguments
|
24
24
|
# * <tt>global</tt> - The global configuration.
|
25
25
|
# * <tt>key</tt> - The key identifying the project. This is the
|
26
26
|
# key in the projects hash.
|
27
27
|
# * <tt>contents</tt> - The project hash.
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# == Project Options
|
30
30
|
#
|
31
|
-
# #options is built by merging the options given in the project
|
31
|
+
# {#options} is built by merging the options given in the project
|
32
32
|
# hash with the global options.
|
33
33
|
#
|
34
34
|
# The following default options are added if not given:
|
data/lib/scide/screen.rb
CHANGED
@@ -14,14 +14,14 @@ module Scide
|
|
14
14
|
|
15
15
|
# Returns a screen configuration for the given project.
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# == Arguments
|
18
18
|
# * <tt>project</tt> - The project.
|
19
19
|
# * <tt>options</tt> - Screen-specific options (see below).
|
20
20
|
#
|
21
|
-
#
|
21
|
+
# == Options
|
22
22
|
# * <tt>binary</tt> - Screen binary (defaults to <tt>screen</tt>).
|
23
23
|
# * <tt>args</tt> - Command-line arguments that will be given to screen (e.g. <tt>-U</tt> for unicode).
|
24
|
-
# * <tt>hardstatus</tt> - Hardstatus line configuration (defaults to
|
24
|
+
# * <tt>hardstatus</tt> - Hardstatus line configuration (defaults to {DEFAULT_HARDSTATUS}).
|
25
25
|
def initialize project, options
|
26
26
|
raise ArgumentError, 'screen configuration must be a hash' unless options.nil? or options.kind_of?(Hash)
|
27
27
|
|
@@ -31,7 +31,7 @@ module Scide
|
|
31
31
|
|
32
32
|
# Returns the command that will be used to run screen with this configuration.
|
33
33
|
#
|
34
|
-
#
|
34
|
+
# == Arguments
|
35
35
|
# * <tt>tmp_file</tt> - The temporary file in which the configuration will be stored.
|
36
36
|
# (Optional for dry-run.)
|
37
37
|
def to_command tmp_file = 'TEMPORARY_FILE'
|
@@ -39,9 +39,9 @@ module Scide
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Verifies that the screen binary is there. If not, causes scide
|
42
|
-
# to fail with a <tt>screen_not_found</tt> error (see Scide
|
42
|
+
# to fail with a <tt>screen_not_found</tt> error (see {Scide.fail}).
|
43
43
|
def check_binary
|
44
|
-
Scide.fail :screen_not_found, "ERROR: #{binary} not found" unless system("which #{binary}"
|
44
|
+
Scide.fail :screen_not_found, "ERROR: #{binary} not found" unless system("which #{binary} &>/dev/null")
|
45
45
|
end
|
46
46
|
|
47
47
|
# Returns a representation of this configuration as a string.
|
@@ -56,7 +56,7 @@ module Scide
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Returns the screen hardstatus line given as option, or
|
59
|
-
# the default
|
59
|
+
# the default {DEFAULT_HARDSTATUS}.
|
60
60
|
def hardstatus
|
61
61
|
@options[:hardstatus].try(:to_s) || DEFAULT_HARDSTATUS
|
62
62
|
end
|
data/lib/scide/window.rb
CHANGED
@@ -4,33 +4,33 @@ module Scide
|
|
4
4
|
class Window
|
5
5
|
|
6
6
|
# The name of the window as it will shown in GNU Screen.
|
7
|
-
# See #initialize.
|
7
|
+
# See {#initialize}.
|
8
8
|
attr_reader :name
|
9
9
|
|
10
10
|
# The optional command that will be shown in this window.
|
11
11
|
attr_reader :command
|
12
12
|
|
13
|
-
# Window-specific options. Can be used by commands. See #initialize.
|
13
|
+
# Window-specific options. Can be used by commands. See {#initialize}.
|
14
14
|
attr_reader :options
|
15
15
|
|
16
16
|
# Returns a window for the given project.
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# == Arguments
|
19
19
|
# * <tt>project</tt> - The project owning this window.
|
20
20
|
# * <tt>contents</tt> - The window configuration (String or Hash).
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# == String Initialization
|
23
23
|
# The string must be in the format <tt>NAME [COMMAND]</tt> where
|
24
24
|
# <tt>NAME</tt> is the window name and <tt>COMMAND</tt> (optional)
|
25
|
-
# is the command configuration (see Scide::Command).
|
25
|
+
# is the command configuration (see {Scide::Command}).
|
26
26
|
#
|
27
|
-
#
|
27
|
+
# == Hash Initialization
|
28
28
|
# The following options can be given:
|
29
29
|
# * <tt>:name => string</tt> - The window name.
|
30
30
|
# * <tt>:options => hash</tt> - Window-specific options (will be
|
31
31
|
# merged to the project options).
|
32
32
|
# * <tt>:command => string</tt> - The command to use for this window
|
33
|
-
# (will be built using Scide::Command
|
33
|
+
# (will be built using {Scide::Command.resolve}).
|
34
34
|
# * <tt>:string => string</tt> - If given, <tt>:name</tt> and <tt>:command</tt>
|
35
35
|
# are ignored and string initialization will be performed with <tt>string</tt>.
|
36
36
|
# <tt>:options</tt> can still be used to override project options.
|
@@ -49,7 +49,7 @@ module Scide
|
|
49
49
|
# Returns a representation of this window as a GNU Screen
|
50
50
|
# configuration frament.
|
51
51
|
#
|
52
|
-
#
|
52
|
+
# == Arguments
|
53
53
|
# * <tt>index</tt> - The position of the window (zero-based).
|
54
54
|
def to_screen index
|
55
55
|
String.new.tap do |s|
|
@@ -60,7 +60,7 @@ module Scide
|
|
60
60
|
|
61
61
|
private
|
62
62
|
|
63
|
-
# Initializes this window from a hash. See #initialize for options.
|
63
|
+
# Initializes this window from a hash. See {#initialize} for options.
|
64
64
|
def init_from_hash! contents
|
65
65
|
raise ArgumentError, "options of window '#{@name}' must be a hash" unless contents[:options].nil? or contents[:options].kind_of?(Hash)
|
66
66
|
@options = @project.options.dup.merge(contents[:options] || {})
|
@@ -74,7 +74,7 @@ module Scide
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
# Initializes this window from a string. See #initialize for format.
|
77
|
+
# Initializes this window from a string. See {#initialize} for format.
|
78
78
|
def init_from_string! contents
|
79
79
|
raise ArgumentError, "window '#{contents}' must not be an empty string" unless contents.present?
|
80
80
|
content_parts = contents.split /\s+/, 2
|
data/lib/scide.rb
CHANGED
@@ -8,17 +8,6 @@ module Scide
|
|
8
8
|
VERSION = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r').read
|
9
9
|
|
10
10
|
# Exit status codes.
|
11
|
-
#
|
12
|
-
# ==== Codes
|
13
|
-
# * <tt>unexpected</tt> - 1.
|
14
|
-
# * <tt>invalid_argument</tt> - 2.
|
15
|
-
# * <tt>not_initialized</tt> - 3.
|
16
|
-
# * <tt>screen_not_found</tt> - 4.
|
17
|
-
# * <tt>config_not_found</tt> - 10.
|
18
|
-
# * <tt>config_not_readable</tt> - 11.
|
19
|
-
# * <tt>malformed_config</tt> - 12.
|
20
|
-
# * <tt>invalid_config</tt> - 13.
|
21
|
-
# * <tt>unknown_project</tt> - 14.
|
22
11
|
EXIT = {
|
23
12
|
:unexpected => 1,
|
24
13
|
:invalid_argument => 2,
|
@@ -32,7 +21,7 @@ module Scide
|
|
32
21
|
}
|
33
22
|
|
34
23
|
# Prints a message on <tt>stderr</tt> and exits.
|
35
|
-
# If
|
24
|
+
# If <tt>condition</tt> is a key from {EXIT}, the corresponding value
|
36
25
|
# will be used as the exit code. Otherwise, scide exits with
|
37
26
|
# status 1.
|
38
27
|
def self.fail condition, msg
|
@@ -48,20 +37,22 @@ module Scide
|
|
48
37
|
|
49
38
|
# By default, scide is meant to be used as a standalone script
|
50
39
|
# and exits if an error occurs. If <tt>exit_on_fail</tt> is
|
51
|
-
# false, a Scide::Error will be raised instead. Scide can then
|
40
|
+
# false, a {Scide::Error} will be raised instead. Scide can then
|
52
41
|
# be used by another script.
|
53
42
|
def self.exit_on_fail= exit_on_fail
|
54
43
|
@@exit_on_fail = exit_on_fail
|
55
44
|
end
|
56
45
|
|
57
46
|
# Indicates whether scide is configured to exit on failure.
|
58
|
-
# See Scide.exit_on_fail
|
47
|
+
# See {Scide.exit_on_fail=}.
|
59
48
|
def self.exit_on_fail
|
60
49
|
@@exit_on_fail
|
61
50
|
end
|
62
51
|
|
63
|
-
# Scide error. Can be raised if
|
52
|
+
# Scide error. Can be raised if {exit_on_fail} is set to false.
|
64
53
|
class Error < StandardError
|
54
|
+
|
55
|
+
# A symbol indicating the error type. See {EXIT}.
|
65
56
|
attr_reader :condition
|
66
57
|
|
67
58
|
# Returns a new error.
|
data/scide.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "scide"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["AlphaHydrae"]
|
12
|
-
s.date = "2011-10-
|
12
|
+
s.date = "2011-10-20"
|
13
13
|
s.description = "Utility to generate GNU screen configuration files."
|
14
14
|
s.email = "hydrae.alpha@gmail.com"
|
15
15
|
s.executables = ["scide"]
|
@@ -78,7 +78,8 @@ Gem::Specification.new do |s|
|
|
78
78
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
79
79
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
80
80
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
81
|
-
s.add_development_dependency(%q<
|
81
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
82
83
|
else
|
83
84
|
s.add_dependency(%q<upoj-rb>, ["~> 0.0.4"])
|
84
85
|
s.add_dependency(%q<rspec>, [">= 0"])
|
@@ -86,7 +87,8 @@ Gem::Specification.new do |s|
|
|
86
87
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
87
88
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
88
89
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
89
|
-
s.add_dependency(%q<
|
90
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
91
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
90
92
|
end
|
91
93
|
else
|
92
94
|
s.add_dependency(%q<upoj-rb>, ["~> 0.0.4"])
|
@@ -95,7 +97,8 @@ Gem::Specification.new do |s|
|
|
95
97
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
96
98
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
97
99
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
98
|
-
s.add_dependency(%q<
|
100
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
101
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
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.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: upoj-rb
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154306940 !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: *2154306940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154306460 !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: *2154306460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154305980 !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: *2154305980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154305480 !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: *2154305480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154305000 !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: *2154305000
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &2154304460 !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: *2154304460
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
requirement: &
|
81
|
+
name: yard
|
82
|
+
requirement: &2154303920 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,18 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2154303920
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rdiscount
|
93
|
+
requirement: &2154303400 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2154303400
|
91
102
|
description: Utility to generate GNU screen configuration files.
|
92
103
|
email: hydrae.alpha@gmail.com
|
93
104
|
executables:
|
@@ -155,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
166
|
version: '0'
|
156
167
|
segments:
|
157
168
|
- 0
|
158
|
-
hash:
|
169
|
+
hash: -2236574170899638765
|
159
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
171
|
none: false
|
161
172
|
requirements:
|