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/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --format doc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3
data/.screenrc ADDED
@@ -0,0 +1,8 @@
1
+ source $HOME/.screenrc
2
+
3
+ screen -t vim 0
4
+ stuff "\${PROJECT_EDITOR-\$EDITOR}\012"
5
+ screen -t zsh 1
6
+ screen -t spec 2
7
+ stuff "rake"
8
+ select vim
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
5
+ - 2.0.0
data/Gemfile CHANGED
@@ -3,22 +3,21 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem 'upoj-rb', '~> 0.0.4'
6
+ gem 'commander', '~> 4.1.3'
7
+ gem 'paint', '~> 0.8.6'
7
8
  gem 'which_works', '~> 0.1.0'
8
9
 
9
10
  # Add dependencies to develop your gem here.
10
11
  # Include everything needed to run rake, tests, features, etc.
11
12
  group :development do
12
- gem 'rspec'
13
- gem 'shoulda'
14
13
  gem 'bundler'
15
- gem 'jeweler', '~> 1.6.4'
14
+ gem 'rake'
15
+ gem 'rspec'
16
+ gem 'fakefs', require: 'fakefs/safe', git: 'git@github.com:AlphaHydrae/fakefs.git', branch: 'executable-bug'
17
+ gem 'jeweler'
18
+ gem 'gemcutter'
19
+ gem 'gem-release'
20
+ gem 'rake-version'
16
21
  gem 'simplecov'
17
- gem 'yard'
18
- gem 'rdiscount'
19
- gem 'travis-lint', '~> 1.3.0'
20
- end
21
-
22
- group :test do
23
- gem 'active_support', '>= 2'
22
+ gem 'travis-lint'
24
23
  end
data/Gemfile.lock CHANGED
@@ -1,57 +1,64 @@
1
+ GIT
2
+ remote: git@github.com:AlphaHydrae/fakefs.git
3
+ revision: f4814af1ce3970b4b7eba383717c0e10dec7b5e8
4
+ branch: executable-bug
5
+ specs:
6
+ fakefs (0.4.2)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
4
- active_support (3.0.0)
5
- activesupport (= 3.0.0)
6
- activesupport (3.0.0)
7
- diff-lcs (1.1.3)
11
+ commander (4.1.3)
12
+ highline (~> 1.6.11)
13
+ diff-lcs (1.2.4)
14
+ gem-release (0.5.5)
15
+ gemcutter (0.7.1)
8
16
  git (1.2.5)
9
- hashr (0.0.19)
10
- jeweler (1.6.4)
17
+ hashr (0.0.22)
18
+ highline (1.6.18)
19
+ jeweler (1.8.4)
11
20
  bundler (~> 1.0)
12
21
  git (>= 1.2.5)
13
22
  rake
14
- multi_json (1.1.0)
15
- paint (0.8.4)
16
- rake (0.9.2.2)
17
- rdiscount (1.6.8)
18
- rspec (2.8.0)
19
- rspec-core (~> 2.8.0)
20
- rspec-expectations (~> 2.8.0)
21
- rspec-mocks (~> 2.8.0)
22
- rspec-core (2.8.0)
23
- rspec-expectations (2.8.0)
24
- diff-lcs (~> 1.1.2)
25
- rspec-mocks (2.8.0)
26
- shoulda (3.0.1)
27
- shoulda-context (~> 1.0.0)
28
- shoulda-matchers (~> 1.0.0)
29
- shoulda-context (1.0.0)
30
- shoulda-matchers (1.0.0)
31
- simplecov (0.6.1)
23
+ rdoc
24
+ json (1.7.7)
25
+ multi_json (1.7.2)
26
+ paint (0.8.6)
27
+ rake (10.0.4)
28
+ rake-version (0.3.1)
29
+ rake (~> 10)
30
+ rdoc (4.0.1)
31
+ json (~> 1.4)
32
+ rspec (2.13.0)
33
+ rspec-core (~> 2.13.0)
34
+ rspec-expectations (~> 2.13.0)
35
+ rspec-mocks (~> 2.13.0)
36
+ rspec-core (2.13.1)
37
+ rspec-expectations (2.13.0)
38
+ diff-lcs (>= 1.1.3, < 2.0)
39
+ rspec-mocks (2.13.1)
40
+ simplecov (0.7.1)
32
41
  multi_json (~> 1.0)
33
- simplecov-html (~> 0.5.3)
34
- simplecov-html (0.5.3)
35
- travis-lint (1.3.0)
36
- hashr (>= 0.0.19)
37
- upoj-rb (0.0.5)
38
- active_support (>= 2)
39
- paint
42
+ simplecov-html (~> 0.7.1)
43
+ simplecov-html (0.7.1)
44
+ travis-lint (1.7.0)
45
+ hashr (~> 0.0.22)
40
46
  which_works (0.1.0)
41
- yard (0.7.5)
42
47
 
43
48
  PLATFORMS
44
49
  ruby
45
50
 
46
51
  DEPENDENCIES
47
- active_support (>= 2)
48
52
  bundler
49
- jeweler (~> 1.6.4)
50
- rdiscount
53
+ commander (~> 4.1.3)
54
+ fakefs!
55
+ gem-release
56
+ gemcutter
57
+ jeweler
58
+ paint (~> 0.8.6)
59
+ rake
60
+ rake-version
51
61
  rspec
52
- shoulda
53
62
  simplecov
54
- travis-lint (~> 1.3.0)
55
- upoj-rb (~> 0.0.4)
63
+ travis-lint
56
64
  which_works (~> 0.1.0)
57
- yard
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 AlphaHydrae
1
+ Copyright (c) 2011 Simon Oulevay (AlphaHydrae)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,171 +1,63 @@
1
- # scide
1
+ # scide [![Build Status](https://secure.travis-ci.org/AlphaHydrae/scide.png?branch=develop)](http://travis-ci.org/AlphaHydrae/scide)
2
2
 
3
- GNU Screen IDE.
3
+ **[GNU Screen](http://www.gnu.org/software/screen/) IDE.**
4
4
 
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.
5
+ The `scide` command wraps `screen` to automatically use `.screenrc` files in the current directory or in project directories.
7
6
 
8
- Tested with <a href="https://www.relishapp.com/rspec">RSpec</a>, <a href="https://github.com/thoughtbot/shoulda">shoulda</a> and <a href="http://travis-ci.org/#!/AlphaHydrae/scide">Travis CI</a>.
9
-
10
- * master [![Build Status](https://secure.travis-ci.org/AlphaHydrae/scide.png?branch=master)](http://travis-ci.org/AlphaHydrae/scide)
11
- * develop [![Build Status](https://secure.travis-ci.org/AlphaHydrae/scide.png?branch=develop)](http://travis-ci.org/AlphaHydrae/scide)
12
-
13
- ## Using
14
-
15
- You can install scide with:
7
+ ## Installation
16
8
 
17
9
  gem install scide
18
10
 
19
- Then use it on the command line:
20
-
21
- scide --version
22
- scide my_project
23
-
24
- __Interactive configuration will be introduced in v0.2.*.__
25
- __Until then, the configuration file must be prepared manually before using scide.__
26
-
27
- ## Configuration File
28
-
29
- The configuration file is expected to be at the following location by default:
30
-
31
- $HOME/.scide/config.yml
32
-
33
- You can load another file by running scide with the `-c` flag:
34
-
35
- scide -c my_config.yml
36
-
37
- ### Basics
38
-
39
- This is a simple scide configuration file:
40
-
41
- projects:
42
- mywebsite:
43
- path: /home/jdoe/projects/mywebsite
44
- windows:
45
- - 'project EDIT'
46
- - 'db-log TAIL log/db.log'
47
- - 'server RUN rails server'
48
- - 'shell'
49
- default_window: project
50
-
51
- By running `scide mywebsite`, screen would open with four windows:
52
-
53
- * a __project__ window with your favorite `$EDITOR` launched;
54
- * a __db-log__ window with a tail of the project's database log;
55
- * a __server__ window with your Ruby on Rails server launched;
56
- * a __shell__ window with your shell running.
57
-
58
- The __project__ window would be opened as specified by the
59
- `default_window` option.
60
-
61
- The format for a window is `NAME [COMMAND] [CONTENTS]`.
62
- This opens a window with the given name. An optional command
63
- can be run in the window, which can receive arguments/contents.
64
-
65
- ### Options
66
-
67
- Projects can have a hash of options that commands can use:
68
-
69
- projects:
70
- mywebsite:
71
- path: /home/jdoe/projects/mywebsite
72
- options:
73
- log_dir: /var/log
74
- server: thin
75
- windows:
76
- - 'project EDIT'
77
- - 'db-log TAIL %{log_dir}/db.log'
78
- - 'app-log TAIL %{log_dir}/development.log'
79
- - 'server RUN %{server} start'
80
- - 'shell'
81
-
82
- ### Globals
83
-
84
- You can configure a base path and options for all projects.
85
-
86
- global:
87
- path: /home/jdoe/projects
88
- options:
89
- log_dir: /var/log
90
- projects:
91
- mywebsite:
92
- path: mywebsite # this is now relative to the global path
93
- options:
94
- server: thin
95
- windows:
96
- - 'project EDIT'
97
- - 'db-log TAIL %{log_dir}/db.log'
98
- - 'app-log TAIL %{log_dir}/development.log'
99
- - 'server RUN %{server} start'
100
- - 'shell'
101
-
102
- Options at the project level override global options if they have the same name.
103
-
104
- ### Commands
105
-
106
- Scide currently provides four commands.
107
-
108
- #### RUN
11
+ ## Usage
109
12
 
110
- Runs the given contents in the window.
13
+ Assuming your project screen configuration is in `~/src/my-project/.screenrc`.
111
14
 
112
- For example, `RUN rails server` launches a Ruby on Rails server in the project folder.
15
+ cd ~/src/my-project
16
+ scide
113
17
 
114
- #### EDIT
18
+ With the **-p, --projects PROJECTS_DIR** option, `scide` will know your project directory so you can open from elsewhere.
115
19
 
116
- Simply runs `$EDITOR`, your preferred editor.
20
+ cd /elsewhere
21
+ scide -p ~/src my-project
117
22
 
118
- If the `edit` option is present, it will be used as arguments to the editor.
23
+ You can also set the `$SCIDE_PROJECTS` environment variable:
119
24
 
120
- # project configuration:
121
- mywebsite:
122
- options:
123
- edit: '-c MyVimCommand'
124
- windows:
125
- - 'project EDIT app/controllers/application_controller.erb'
25
+ export SCIDE_PROJECTS=~/src
26
+ scide my-project
126
27
 
127
- # resulting command in "project" window:
128
- $EDITOR -c MyVimCommand app/controllers/application_controller.erb
28
+ ### Without a .screenrc file
129
29
 
130
- #### TAIL
30
+ If you don't already have a .screenrc configuration file, `scide` can open your project with a default configuration.
131
31
 
132
- Runs the `tail` command with the given file as the `-f` argument.
32
+ cd ~/other-project
33
+ scide --auto
133
34
 
134
- For example, `TAIL log/db.log` would generate the following command:
35
+ This will open `screen` with two named windows:
135
36
 
136
- tail -f log/db.log
37
+ * **editor** will launch your favorite editor (`$PROJECT_EDITOR` or `$EDITOR`);
38
+ * **shell** will launch a new shell.
137
39
 
138
- If the `tail` option is present, it will be used as arguments to tail.
40
+ ### Add a .screenrc file
139
41
 
140
- # project configuration:
141
- mywebsite:
142
- options:
143
- tail: '-n 1000'
144
- windows:
145
- - 'db.log TAIL log/db.log'
42
+ To add a .screenrc file to your project:
146
43
 
147
- # resulting command in "project" window:
148
- tail -n 1000 -f log/db.log
44
+ cd ~/other-project
45
+ scide setup
46
+ cat .screenrc
149
47
 
150
- #### SHOW
48
+ ## Screen options
151
49
 
152
- Shows the given contents in the window, without running them.
50
+ * **-b BIN, --bin BIN**
153
51
 
154
- For example, `SHOW ssh example.com` would pre-type this ssh command in the window, but not run it.
155
- That way, you can have special commands ready to run in a separate window.
52
+ Use the bin option to give the path to your screen binary if it's not in the PATH or has a different name.
53
+ This can also be set with the `$SCIDE_BIN` environment variable.
156
54
 
157
- ## Contributing to scide
158
-
159
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
160
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
161
- * Fork the project
162
- * Start a feature/bugfix branch
163
- * Commit and push until you are happy with your contribution
164
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
165
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
55
+ * **-s OPTIONS, --screen OPTIONS**
166
56
 
167
- ## Copyright
57
+ Customize screen options (`-U` by default).
58
+ This can also be set with the `$SCIDE_SCREEN` environment variable.
168
59
 
169
- Copyright (c) 2011 AlphaHydrae. See LICENSE.txt for
170
- further details.
60
+ ## Meta
171
61
 
62
+ * **Author:** Simon Oulevay (Alpha Hydrae)
63
+ * **License:** MIT (see [LICENSE.txt](https://raw.github.com/AlphaHydrae/scide/master/LICENSE.txt))
data/Rakefile CHANGED
@@ -17,14 +17,30 @@ Jeweler::Tasks.new do |gem|
17
17
  gem.name = "scide"
18
18
  gem.homepage = "http://github.com/AlphaHydrae/scide"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{GNU Screen IDE.}
21
- gem.description = %Q{Utility to generate GNU screen configuration files.}
20
+ gem.summary = %Q{GNU Screen IDE}
21
+ gem.description = %Q{GNU screen wrapper to open projects with a .screenrc file.}
22
22
  gem.email = "hydrae.alpha@gmail.com"
23
- gem.authors = ["AlphaHydrae"]
23
+ gem.authors = ["Simon Oulevay (AlphaHydrae)"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
27
27
 
28
+ Rake::TaskManager.class_eval do
29
+ def remove_task(task_name)
30
+ @tasks.delete(task_name.to_s)
31
+ end
32
+ end
33
+
34
+ [ 'version', 'version:bump:major', 'version:bump:minor', 'version:bump:patch', 'version:write' ].each do |task|
35
+ Rake.application.remove_task task
36
+ end
37
+
38
+ # version tasks
39
+ require 'rake-version'
40
+ RakeVersion::Tasks.new do |v|
41
+ v.copy 'lib/scide.rb'
42
+ end
43
+
28
44
  require 'rspec/core/rake_task'
29
45
  desc "Run specs"
30
46
  RSpec::Core::RakeTask.new do |t|
@@ -33,26 +49,3 @@ RSpec::Core::RakeTask.new do |t|
33
49
  end
34
50
 
35
51
  task :default => :spec
36
-
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'
42
-
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
58
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.1.0
data/bin/scide CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.join(File.dirname(__FILE__), '..', 'lib', 'scide')
3
-
4
- Scide::Overmind.new.brood.dominate
3
+ Scide::Program.new.run!
data/lib/scide/auto.rb ADDED
@@ -0,0 +1,33 @@
1
+
2
+ module Scide
3
+
4
+ def self.auto_config
5
+ # TODO: option to specify custom default configuration file
6
+ String.new.tap do |c|
7
+ c << %|source $HOME/.screenrc\n\n| if File.exists? home_config_file
8
+ c << %|screen -t editor 0\n|
9
+ c << %|stuff "\\${PROJECT_EDITOR-\\$EDITOR}\\012"\n|
10
+ c << %|screen -t shell 1\n|
11
+ c << %|select editor|
12
+ end
13
+ end
14
+
15
+ def self.auto_config_file
16
+ file = Tempfile.new 'scide'
17
+ file.write auto_config
18
+ file.rewind
19
+ file.close
20
+ yield file
21
+ file.unlink
22
+ end
23
+
24
+ def self.auto? options = {}
25
+ options[:auto] or (ENV['SCIDE_AUTO'] and ENV['SCIDE_AUTO'].match(/\A(1|y|yes|t|true)\Z/i))
26
+ end
27
+
28
+ private
29
+
30
+ def self.home_config_file
31
+ File.join File.expand_path('~'), '.screenrc'
32
+ end
33
+ end
data/lib/scide/list.rb ADDED
@@ -0,0 +1,33 @@
1
+
2
+ module Scide
3
+
4
+ def self.list options = {}
5
+
6
+ dir = projects_dir options
7
+
8
+ projects = []
9
+
10
+ config_file = '.screenrc'
11
+ projects << '.' if Dir.pwd != File.expand_path('~') and File.file?(config_file)
12
+
13
+ if File.directory? dir
14
+
15
+ Dir.entries(dir).each do |project|
16
+
17
+ next if project.match /\A\.+\Z/
18
+ project_dir = File.join dir, project
19
+
20
+ next unless File.directory? project_dir
21
+ config_file = File.join project_dir, '.screenrc'
22
+
23
+ next unless File.file? config_file
24
+ projects << project
25
+ end
26
+
27
+ elsif projects.empty?
28
+ error %/No such directory "#{dir}"/
29
+ end
30
+
31
+ projects
32
+ end
33
+ end
data/lib/scide/open.rb ADDED
@@ -0,0 +1,57 @@
1
+
2
+ module Scide
3
+ SCREEN_BIN = 'screen'
4
+ SCREEN_OPTIONS = '-U'
5
+
6
+ def self.open *args
7
+
8
+ error "screen must be in the path" unless Which.which 'screen'
9
+
10
+ options = args.last.kind_of?(Hash) ? args.pop : {}
11
+ dir = current_project_dir args, options
12
+
13
+ file = File.join dir, '.screenrc'
14
+ exists = File.exists? file
15
+
16
+ if auto?(options) and !exists
17
+ auto_config_file do |auto_file|
18
+ return run dir, options.merge(screenrc: auto_file.path)
19
+ end
20
+ end
21
+
22
+ error %/No such configuration "#{file}"/ unless exists
23
+ error %/"#{file}" is not a file/ unless File.file? file
24
+
25
+ run dir, options
26
+ end
27
+
28
+ private
29
+
30
+ def self.run dir, options = {}
31
+ if options[:noop]
32
+ command dir, options
33
+ else
34
+ error "Could not open project" unless Kernel.system command(dir, options)
35
+ true
36
+ end
37
+ end
38
+
39
+ def self.command dir, options = {}
40
+ # TODO: look for other config file names (e.g. "screenrc") or add option to customize?
41
+ command = "#{screen_bin(options)} #{screen_options(options)} -c #{screen_config(options)}"
42
+ command = "cd #{Shellwords.escape dir} && #{command}" if dir != Dir.pwd
43
+ command
44
+ end
45
+
46
+ def self.screen_config options = {}
47
+ options[:screenrc] || '.screenrc'
48
+ end
49
+
50
+ def self.screen_bin options = {}
51
+ options[:bin] || ENV['SCIDE_BIN'] || SCREEN_BIN
52
+ end
53
+
54
+ def self.screen_options options = {}
55
+ options[:screen] || ENV['SCIDE_SCREEN'] || SCREEN_OPTIONS
56
+ end
57
+ end