godo 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  = godo
2
2
 
3
- * version: 1.0.5
4
- * released: 2008-03-11
3
+ * version: 1.0.7
4
+ * released: 2008-05-21
5
5
  * http://simplyruby.rubyforge.org/godo
6
6
 
7
7
  == DESCRIPTION:
@@ -18,27 +18,15 @@ paths found in one or more configured project roots. It will make some straightf
18
18
  disambiguate among multiple matches to find the one you want.
19
19
 
20
20
  godo then uses configurable heuristics to figure out what type of project it is, for example "a RoR
21
- project using RSpec and Subversion". From that it will invokes a series of action appropriate to the
22
- type of project detected with each action being run, from the project folder, in its own terminal
23
- session.
21
+ project using RSpec and Subversion". From that it will invokes a series of action appropriate to the type of project detected with each action being run, from the project folder, in its own terminal session.
24
22
 
25
- godo is entirely configured by a YAML file (~/.godo) that contains project types, heuristics, actions,
26
- project paths, and a session controller. A sample configuration file is provided that can be installed
27
- using godo --install.
23
+ godo is entirely configured by a YAML file (~/.godo) that contains project types, heuristics, actions, project paths, and a session controller. A sample configuration file is provided that can be installed using godo --install.
28
24
 
29
- godo comes with an iTerm session controller for MacOSX that uses the rb-appscript gem to control iTerm
30
- (see lib/session.rb and lib/sessions/iterm_session.rb). It should be relatively straightforward to add
31
- new controller (e.g. for Leopard Terminal.app), or a controller that works in a different way (e.g. by
32
- creating new windows instead of new tabs). There is nothing MacOSX specific about the rest of godo so
33
- creating controllers for other unixen should be straightforward if they can be controlled from ruby.
34
-
35
- godo is a rewrite of my original 'gp' script (http://matt.blogs.it/entries/00002674.html) which fixes
36
- a number of the deficiencies of that script, turns it into a gem, has a better name, and steals the
37
- idea of using heuristics to detect project types from Solomon White's gp variant (http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal).
25
+ godo comes with an iTerm session controller for MacOSX that uses the rb-appscript gem to control iTerm (see lib/session.rb and lib/sessions/iterm_session.rb). It should be relatively straightforward to add new controller (e.g. for Leopard Terminal.app), or a controller that works in a different way (e.g. by creating new windows instead of new tabs). There is nothing MacOSX specific about the rest of godo so creating controllers for other unixen should be straightforward if they can be controlled from ruby.
26
+
27
+ godo is a rewrite of my original 'gp' script (http://matt.blogs.it/entries/00002674.html) which fixes a number of the deficiencies of that script, turns it into a gem, has a better name, and steals the idea of using heuristics to detect project types from Solomon White's gp variant (http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal).
38
28
 
39
- godo now includes contributions from Lee Marlow <lee.marlow@gmail.com> including support for project
40
- level .godo files to override the global configuration, support for Terminal.app, and maximum depth
41
- support to speed up the finder.
29
+ godo now includes contributions from Lee Marlow <lee.marlow@gmail.com> including support for project level .godo files to override the global configuration, support for Terminal.app, and maximum depth support to speed up the finder.
42
30
 
43
31
  godo lives at the excellent GitHub: http://github.com/mmower/godo/ and accepts patches and forks.
44
32
 
data/bin/godo CHANGED
File without changes
@@ -48,26 +48,7 @@ module Godo
48
48
  # base path, the first path would be returned.
49
49
  #
50
50
  def find( query )
51
- matches = []
52
- @roots.each do |root|
53
- # puts "Searching for #{query} in #{root}"
54
- Find.find( root ) do |path|
55
- if @max_depth > 0
56
- # limit to @max_depth
57
- partial_path = path.gsub(root, '')
58
- Find.prune if partial_path =~ /\A\.+\Z/
59
- depth = partial_path.split('/').length
60
- Find.prune if depth > @max_depth + 1
61
- end
62
-
63
- if filtered?( path )
64
- Find.prune
65
- elsif matches?( path, query )
66
- matches << path
67
- end
68
- end
69
- end
70
-
51
+ matches = @roots.inject( [] ) { |results,root| results.concat( find_in_root( root, query ) ) }
71
52
  if matches.size > 1
72
53
  matches = strip_inexact_matches( query, matches )
73
54
  if matches.size > 1
@@ -84,6 +65,26 @@ module Godo
84
65
  end
85
66
  end
86
67
 
68
+ def find_in_root( root, query )
69
+ matches = []
70
+ Find.find( root ) do |path|
71
+ if @max_depth > 0
72
+ # limit to @max_depth
73
+ partial_path = path.gsub(root, '')
74
+ Find.prune if partial_path =~ /\A\.+\Z/
75
+ depth = partial_path.split('/').length
76
+ Find.prune if depth > @max_depth + 1
77
+ end
78
+
79
+ if filtered?( path )
80
+ Find.prune
81
+ elsif matches?( path, query )
82
+ matches << path
83
+ end
84
+ end
85
+ matches
86
+ end
87
+
87
88
  def matches?( path, query )
88
89
  path.match( query )
89
90
  end
@@ -113,6 +114,34 @@ module Godo
113
114
  paths[1..-1].all? { |path| path.match( path_match ) }
114
115
  end
115
116
 
117
+ def find_with_caching( query )
118
+ cache = if File.exist?( cache_file )
119
+ YAML::load( File.read( cache_file ) )
120
+ else
121
+ {}
122
+ end
123
+
124
+ if cache[query]
125
+ results = cache[query]
126
+ puts "Using cached entry from #{cache_file}"
127
+ else
128
+ results = find_without_caching( query )
129
+ if results.size == 1
130
+ cache[query] = [results.first]
131
+ File.open( cache_file, 'w' ) { |f| YAML::dump( cache, f ) }
132
+ end
133
+ end
134
+
135
+ results
136
+ end
137
+
138
+ def cache_file
139
+ @@cache_file ||= File.expand_path( "~/.godo_cache" )
140
+ end
141
+
142
+ alias_method :find_without_caching, :find
143
+ alias_method :find, :find_with_caching
144
+
116
145
  end
117
146
 
118
147
  end
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Godo
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.7'
5
5
  LIBPATH = File.expand_path( File.dirname( __FILE__ ) )
6
6
 
7
7
  # When called with no arguments this will return the path to the gem
@@ -9,7 +9,7 @@ module Godo
9
9
  @heuristics = config["heuristics"]
10
10
  @actions = config["actions"]
11
11
  @matchers = config["matchers"]
12
- @session_class = Godo.const_get( config["sessions"] )
12
+ @session_class = Session.klass( config["sessions"] )
13
13
  end
14
14
 
15
15
  def invoke( path )
@@ -23,6 +23,7 @@ module Godo
23
23
  end
24
24
 
25
25
  private
26
+
26
27
  def invoke_actions( path, action_group )
27
28
  @session ||= @session_class.new( path )
28
29
 
@@ -62,7 +63,7 @@ module Godo
62
63
  false
63
64
  end
64
65
 
65
- puts "\trunning: #{action["label"]} (exit: #{exit})"
66
+ puts "\trunning: #{action["label"] || action["command"]} (exit: #{exit})"
66
67
  @session.create( action["label"], action["command"], exit )
67
68
  else
68
69
  puts "\tMissing action: #{action_item.inspect}"
@@ -3,6 +3,22 @@ module Godo
3
3
  class Session
4
4
  attr_reader :path
5
5
 
6
+ def self.klass( name = nil )
7
+ klass = if name
8
+ Godo.const_get( name )
9
+ else
10
+ case ENV['TERM_PROGRAM']
11
+ when "iTerm.app"
12
+ Godo.const_get( "ITermSession" )
13
+ when "Apple_Terminal"
14
+ Godo.const_get( "TerminalSession" )
15
+ end
16
+ end
17
+
18
+ raise "No session specified in config and cannot auto-detect from TERM_PROGRAM environment variable (#{ENV['TERM_PROGRAM'].inspect})." unless klass
19
+ klass
20
+ end
21
+
6
22
  def initialize( path )
7
23
  @path = path
8
24
  @counters = Hash.new { 0 }
@@ -196,7 +196,8 @@ projects:
196
196
  # defaults to unlimited depth.
197
197
  # max_depth: 2
198
198
 
199
- # The session controller to use. Right now iTerm and Terminal are the
200
- # only options.
201
- sessions: ITermSession
199
+ # The session controller to use. Will autodetect iTerm and Apple Terminal
200
+ # using the TERM_PROGRAM environment variable. Specify to use a custom class
201
+ # or to override for a specific project.
202
+ # sessions: ITermSession
202
203
  # sessions: TerminalSession
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: godo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mower
@@ -30,7 +30,7 @@ cert_chain:
30
30
  yMQ/kUco
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-03-11 00:00:00 +00:00
33
+ date: 2008-05-21 00:00:00 +01:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ dependencies:
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 1.5.1
79
+ version: 1.5.3
80
80
  version:
81
81
  description: "go (to project) do (stuffs) godo provides a smart way of opening a project folder in multiple terminal tabs and, in each tab, invoking a commands appropriate to that project. For example if the folder contains a Rails project the actions might include: starting mongrel, tailing one or more logs, starting consoles or IRB sessions, tailing production logs, opening an editor, running autospec, or gitk. godo works by searching your project paths for a given search string and trying to match it against paths found in one or more configured project roots. It will make some straightforward efforts to disambiguate among multiple matches to find the one you want. godo then uses configurable heuristics to figure out what type of project it is, for example \"a RoR project using RSpec and Subversion\". From that it will invokes a series of action appropriate to the type of project detected with each action being run, from the project folder, in its own terminal session. godo is entirely configured by a YAML file (~/.godo) that contains project types, heuristics, actions, project paths, and a session controller. A sample configuration file is provided that can be installed using godo --install. godo comes with an iTerm session controller for MacOSX that uses the rb-appscript gem to control iTerm (see lib/session.rb and lib/sessions/iterm_session.rb). It should be relatively straightforward to add new controller (e.g. for Leopard Terminal.app), or a controller that works in a different way (e.g. by creating new windows instead of new tabs). There is nothing MacOSX specific about the rest of godo so creating controllers for other unixen should be straightforward if they can be controlled from ruby. godo is a rewrite of my original 'gp' script (http://matt.blogs.it/entries/00002674.html) which fixes a number of the deficiencies of that script, turns it into a gem, has a better name, and steals the idea of using heuristics to detect project types from Solomon White's gp variant (http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal). godo now includes contributions from Lee Marlow <lee.marlow@gmail.com> including support for project level .godo files to override the global configuration, support for Terminal.app, and maximum depth support to speed up the finder. godo lives at the excellent GitHub: http://github.com/mmower/godo/ and accepts patches and forks."
82
82
  email:
@@ -103,7 +103,7 @@ files:
103
103
  - lib/sessions/iterm_session.rb
104
104
  - lib/sessions/terminal_session.rb
105
105
  has_rdoc: true
106
- homepage: "version: 1.0.5"
106
+ homepage: "version: 1.0.7"
107
107
  post_install_message:
108
108
  rdoc_options:
109
109
  - --main
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements: []
126
126
 
127
127
  rubyforge_project: simplyruby
128
- rubygems_version: 1.0.1
128
+ rubygems_version: 1.1.1
129
129
  signing_key:
130
130
  specification_version: 2
131
131
  summary: go (to project) do (stuffs) godo provides a smart way of opening a project folder in multiple terminal tabs and, in each tab, invoking a commands appropriate to that project
metadata.gz.sig CHANGED
Binary file