screeninator 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ 1.0.2 / 2011-04-04
2
+ ------------------
3
+
4
+ * 1 bugfix
5
+
6
+ * fix whitespace issue in status line
7
+
8
+ * 5 enhancements
9
+
10
+ * added help command. shows available commands and explanation
11
+ * broke list -v into its own command called info
12
+ * update command can now take a list of configs to update, leave blank to update all
13
+ * modified bash aliases to attach an already running screen config instead of starting a new one
14
+ * better support for custom default yml configs and screen config templates with the customize command
15
+
16
+ 1.0.1 / 2010-10-29
17
+ ------------------
18
+
19
+ * 2 enhancements
20
+
21
+ * Screeninator now does a better job of cleaning up after itself, removing screen configs when you delete projects
22
+ * re-factored some code into a helper making the CLI code much better to look at
23
+
24
+
1
25
  0.1.2 / 2010-10-12
2
26
  ------------------
3
27
 
data/README.md CHANGED
@@ -98,6 +98,13 @@ Remove a project
98
98
  Remove all screeninator configs, aliases and scripts.
99
99
 
100
100
 
101
+ Customization
102
+ -------------
103
+ In order to customize the starting screen configuration that is used as
104
+ the .screen template for each project create a file in
105
+ .screeninator/scripts/screen\_config.screen and copy your template info
106
+ (including ERB) in to it.
107
+
101
108
  Questions? Comments? Feature Request?
102
109
  -------------------------------------
103
110
 
data/Rakefile CHANGED
@@ -10,14 +10,16 @@ begin
10
10
  gem.email = "jon@jondruse.com"
11
11
  gem.homepage = "http://github.com/jondruse/screeninator"
12
12
  gem.authors = ["Jon Druse"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
13
+ gem.add_development_dependency "shoulda", ">= 0"
14
14
  gem.post_install_message = <<-Message
15
15
 
16
16
  Thanks for installing Screeninator!
17
17
 
18
+ UPGRADE WARNING - If you have a custom default config, move it to ~/.screeninator/defaults/
19
+
18
20
  Remember to add the following line to your .bashrc file
19
21
 
20
- if [[ -s $HOME/.screeninator/scripts/screeninator ]] ; then source $HOME/.screeninator/scripts/screeninator ; fi
22
+ [[ -s "$HOME/.screeninator/scripts/screeninator" ]] && source "$HOME/.screeninator/scripts/screeninator"
21
23
 
22
24
  Message
23
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -2,7 +2,7 @@
2
2
  # you can make as many tabs as you wish...
3
3
 
4
4
  escape: ``
5
- project_name: Screeninator
5
+ project_name: <%= @name %>
6
6
  project_root: ~/code/rails_project
7
7
  tabs:
8
8
  - shell: git pull
@@ -4,7 +4,7 @@ escape <%= @escape || "``" %>
4
4
  autodetach on
5
5
  defscrollback 10000
6
6
  hardstatus alwayslastline
7
- hardstatus string '%{= kg}[ %{G} <%= @project_name %> %{g}][%= %{= kw}%?%-Lw%?%{r} (%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]'
7
+ hardstatus string '%{= kg}[ %{G} <%= @project_name %> %{g}][%= %{= kw}%?%-Lw%?%{r} (%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]'
8
8
 
9
9
  chdir "<%= @project_root %>"
10
10
 
@@ -13,4 +13,4 @@ screen -t <%= tab.name %> <%= @tabs.index(tab) + 1 %>
13
13
  stuff "<%= tab.stuff %>\012"
14
14
  <% end %>
15
15
 
16
- select 1
16
+ select 1
@@ -1,6 +1,5 @@
1
1
  require 'fileutils'
2
2
 
3
- ##
4
3
  # Author:: Jon Druse (mailto:jon@jondruse.com)
5
4
  #
6
5
  # = Description
@@ -8,8 +7,8 @@ require 'fileutils'
8
7
  # This class is where each screeninator command is implemented.
9
8
  #
10
9
  # == Change History
11
- # 09/20/10:: created Jon Druse (mailto:jon@jondruse.com)
12
- ###
10
+ # * 09/20/10:: created Jon Druse (mailto:jon@jondruse.com)
11
+ # * 03/15/11:: renmaed usage to help. adding option parser
13
12
  module Screeninator
14
13
  class Cli
15
14
 
@@ -17,23 +16,23 @@ module Screeninator
17
16
  include Screeninator::Helper
18
17
 
19
18
  def start(*args)
20
-
21
- if args.empty?
22
- self.usage
23
- else
19
+
20
+ begin
24
21
  self.send(args.shift, *args)
22
+ rescue NoMethodError => e
23
+ puts e
24
+ self.help
25
25
  end
26
26
 
27
27
  end
28
28
 
29
29
  # print the usage string, this is a fall through method.
30
- def usage
31
- puts "Usage: screeninator ACTION [Arg]"
30
+ def help
31
+ puts HELP_TEXT
32
32
  end
33
33
 
34
34
  # Open a config file, it's created if it doesn't exist already.
35
35
  def open(*args)
36
- puts "warning: passing multiple arguments to open will be ignored" if args.size > 1
37
36
  @name = args.shift
38
37
  FileUtils.mkdir_p(root_dir+"scripts")
39
38
  config_path = "#{root_dir}#{@name}.yml"
@@ -42,8 +41,9 @@ module Screeninator
42
41
  erb = ERB.new(File.read(template)).result(binding)
43
42
  tmp = File.open(config_path, 'w') {|f| f.write(erb) }
44
43
  end
44
+
45
45
  system("$EDITOR #{config_path}")
46
- update_scripts
46
+ update(@name)
47
47
  end
48
48
 
49
49
  def copy(*args)
@@ -91,29 +91,67 @@ module Screeninator
91
91
  end
92
92
 
93
93
  def list(*args)
94
- verbose = args.include?("-v")
95
94
  puts "screeninator configs:"
96
- Dir["#{root_dir}**"].each do |path|
97
- next unless verbose || File.extname(path) == ".yml"
98
- path = path.gsub(root_dir, '').gsub('.yml','') unless verbose
99
- puts " #{path}"
100
- end
95
+ list
101
96
  end
102
97
 
103
- def update_scripts
104
- Dir["#{root_dir}*.screen"].each {|p| FileUtils.rm(p) }
98
+ def info(*args)
99
+ puts "screeninator configs:"
100
+ list(true)
101
+ end
102
+
103
+ def update(*args)
105
104
  aliases = []
106
- Dir["#{root_dir}*.yml"].each do |path|
107
- path = File.basename(path, '.yml')
108
- aliases << Screeninator::ConfigWriter.new(path).write!
105
+ Dir["#{root_dir}*.yml"].each do |path|
106
+ begin
107
+ path = File.basename(path, '.yml')
108
+ config_name = path.split("/").last
109
+ next unless args.empty? || args.include?(config_name)
110
+
111
+ begin; FileUtils.rm("#{path}.screen"); rescue; end
112
+
113
+ puts "updating #{config_name}"
114
+ aliases << Screeninator::ConfigWriter.new(path).write!
115
+ rescue ArgumentError => e
116
+ puts e
117
+ end
109
118
  end
110
119
  Screeninator::ConfigWriter.write_aliases(aliases)
111
120
  end
112
121
 
122
+ def customize(*args)
123
+ @type = args.shift
124
+ @action = args.shift
125
+ if !['config','template'].include?(@type)
126
+ puts "Usage: screeninator customize [config|template]"
127
+ puts "config - This is the default YAML config file to use."
128
+ puts "template - This is the default screen config template, complete with ERB"
129
+ exit
130
+ end
131
+
132
+ FileUtils.mkdir_p(root_dir+"defaults")
133
+
134
+ path = case @type
135
+ when "config"; USER_CONFIG
136
+ when "template"; USER_SCREEN_CONFIG
137
+ end
138
+
139
+ if @action.nil?
140
+ system("$EDITOR #{path}")
141
+ end
142
+
143
+ if @action == "delete"
144
+ confirm!("Are you sure you want to delete #{path}? (type yes or no):") do
145
+ FileUtils.rm(path)
146
+ puts "Deleted #{path}"
147
+ end
148
+ end
149
+ end
150
+
113
151
  private
114
152
 
115
153
  def root_dir
116
- "#{ENV["HOME"]}/.screeninator/"
154
+ dir = "#{ENV["HOME"]}/.screeninator/"
117
155
  end
118
156
 
119
157
  def sample_config
@@ -121,7 +159,19 @@ module Screeninator
121
159
  end
122
160
 
123
161
  def user_config
124
- @config_to_copy || "#{ENV["HOME"]}/.screeninator/default.yml"
162
+ @config_to_copy || USER_CONFIG
163
+ end
164
+
165
+ def user_screen_config
166
+ USER_SCREEN_CONFIG
167
+ end
168
+
169
+ def list(verbose=false)
170
+ Dir["#{root_dir}**"].each do |path|
171
+ next unless verbose || File.extname(path) == ".yml"
172
+ path = path.gsub(root_dir, '').gsub('.yml','') unless verbose
173
+ puts " #{path}"
174
+ end
125
175
  end
126
176
 
127
177
  end
@@ -15,12 +15,21 @@ module Screeninator
15
15
  end
16
16
 
17
17
  def write!
18
- template = "#{File.dirname(__FILE__)}/assets/screen_config.screen"
18
+ if File.exists?(USER_SCREEN_CONFIG)
19
+ template = USER_SCREEN_CONFIG
20
+ else
21
+ template = "#{File.dirname(__FILE__)}/assets/screen_config.screen"
22
+ end
19
23
  erb = ERB.new(IO.read(template)).result(binding)
20
24
  config_path = "#{root_dir}#{@filename}.screen"
21
25
  tmp = File.open(config_path, 'w') {|f| f.write(erb) }
22
-
23
- "alias start_#{@filename}='screen -c #{config_path} -S #{@project_name.gsub(" ", "_")}'"
26
+
27
+ @project_name.gsub!(" ", "_")
28
+
29
+ check = "screen -ls | grep #{@project_name}"
30
+ attch = "screen -dr #{@project_name}"
31
+ start = "screen -c #{config_path} -S #{@project_name}"
32
+ %Q{alias start_#{@filename}='if [[ -n `#{check}` ]] ; then `#{attch}` ; else `#{start}`; fi'}
24
33
  end
25
34
 
26
35
  private
@@ -30,11 +39,10 @@ module Screeninator
30
39
  end
31
40
 
32
41
  def process_config!
33
- yaml = YAML.load(File.read(@file_path))
34
-
35
- exit!("Your configuration file should include some tabs.") if yaml["tabs"].nil?
36
- exit!("Your configuration file didn't specify a 'project_root'") if yaml["project_root"].nil?
37
- exit!("Your configuration file didn't specify a 'project_name'") if yaml["project_name"].nil?
42
+ raise ArgumentError.new("#{@file_path} is not valid YAML!") unless yaml = YAML.load(File.read(@file_path))
43
+ raise ArgumentError.new("Your configuration file should include some tabs.") if yaml["tabs"].nil?
44
+ raise ArgumentError.new("Your configuration file didn't specify a 'project_root'") if yaml["project_root"].nil?
45
+ raise ArgumentError.new("Your configuration file didn't specify a 'project_name'") if yaml["project_name"].nil?
38
46
 
39
47
  @escape = yaml["escape"]
40
48
  @project_name = yaml["project_name"]
@@ -60,4 +68,4 @@ module Screeninator
60
68
  end
61
69
  end
62
70
 
63
- end
71
+ end
@@ -1,6 +1,18 @@
1
1
  module Screeninator
2
2
  module Helper
3
3
 
4
+ help = ["Usage: screeninator ACTION [Args]\n\n"]
5
+ help << "Available Commans:\n\n"
6
+ help << "open CONFIG_NAME".ljust(40) + "Open's the config file in $EDITOR. If it doesn't exist, it will be created."
7
+ help << "copy CONFIG_NAME NEW_CONFIG".ljust(40) + "Copy an existing config into a new one."
8
+ help << "list".ljust(40) + "List all your current config files."
9
+ help << "info".ljust(40) + "List full path of all config files, their compiled versions, and bash scripts."
10
+ help << "customize [config|template] [delete]".ljust(40) + "Write your own default YML config or screen template."
11
+ help << "update [CONFIG_NAME, CONFIG_NAME]".ljust(40) + "Recompile all config files. Helpful if you edit them without using 'screeninator open'."
12
+ help << "implode".ljust(40) + "Destroy all configs, compiled configs, and bash scripts."
13
+
14
+ HELP_TEXT = help.join("\n")
15
+
4
16
  def exit!(msg)
5
17
  puts msg
6
18
  Kernel.exit(1)
data/lib/screeninator.rb CHANGED
@@ -5,5 +5,7 @@ require 'screeninator/helper'
5
5
  require 'screeninator/cli'
6
6
  require 'screeninator/config_writer'
7
7
 
8
- module Screeninator
8
+ module Screeninator
9
+ USER_CONFIG = "#{ENV["HOME"]}/.screeninator/defaults/default.yml"
10
+ USER_SCREEN_CONFIG = "#{ENV["HOME"]}/.screeninator/defaults/screen_config.screen"
9
11
  end
data/screeninator.gemspec CHANGED
@@ -41,9 +41,11 @@ Gem::Specification.new do |s|
41
41
  s.post_install_message = %q{
42
42
  Thanks for installing Screeninator!
43
43
 
44
+ UPGRADE WARNING - If you have a custom default config, move it to ~/.screeninator/defaults/
45
+
44
46
  Remember to add the following line to your .bashrc file
45
47
 
46
- if [[ -s $HOME/.screeninator/scripts/screeninator ]] ; then source $HOME/.screeninator/scripts/screeninator ; fi
48
+ [[ -s "$HOME/.screeninator/scripts/screeninator" ]] && source "$HOME/.screeninator/scripts/screeninator"
47
49
 
48
50
  }
49
51
  s.rdoc_options = ["--charset=UTF-8"]
@@ -62,10 +64,10 @@ if [[ -s $HOME/.screeninator/scripts/screeninator ]] ; then source $HOME/.screen
62
64
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
63
65
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
64
66
  else
65
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
67
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
68
  end
67
69
  else
68
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
70
+ s.add_dependency(%q<shoulda>, [">= 0"])
69
71
  end
70
72
  end
71
73
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screeninator
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 1
9
- version: 1.0.1
4
+ prerelease:
5
+ version: 1.0.2
10
6
  platform: ruby
11
7
  authors:
12
8
  - Jon Druse
@@ -14,18 +10,17 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-10-29 00:00:00 -07:00
13
+ date: 2011-04-04 00:00:00 -07:00
18
14
  default_executable: screeninator
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
- name: thoughtbot-shoulda
17
+ name: shoulda
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
22
  - - ">="
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
24
  version: "0"
30
25
  type: :development
31
26
  version_requirements: *id001
@@ -40,7 +35,6 @@ extra_rdoc_files:
40
35
  - README.md
41
36
  files:
42
37
  - .document
43
- - .gitignore
44
38
  - CHANGELOG.md
45
39
  - LICENSE
46
40
  - README.md
@@ -64,33 +58,33 @@ post_install_message: |
64
58
 
65
59
  Thanks for installing Screeninator!
66
60
 
61
+ UPGRADE WARNING - If you have a custom default config, move it to ~/.screeninator/defaults/
62
+
67
63
  Remember to add the following line to your .bashrc file
68
64
 
69
- if [[ -s $HOME/.screeninator/scripts/screeninator ]] ; then source $HOME/.screeninator/scripts/screeninator ; fi
65
+ [[ -s "$HOME/.screeninator/scripts/screeninator" ]] && source "$HOME/.screeninator/scripts/screeninator"
70
66
 
71
67
 
72
- rdoc_options:
73
- - --charset=UTF-8
68
+ rdoc_options: []
69
+
74
70
  require_paths:
75
71
  - lib
76
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
77
74
  requirements:
78
75
  - - ">="
79
76
  - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
77
  version: "0"
83
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
84
80
  requirements:
85
81
  - - ">="
86
82
  - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
83
  version: "0"
90
84
  requirements: []
91
85
 
92
86
  rubyforge_project:
93
- rubygems_version: 1.3.6
87
+ rubygems_version: 1.5.1
94
88
  signing_key:
95
89
  specification_version: 3
96
90
  summary: Create and manage complex screen sessions easily.
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC