godo 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
@@ -18,3 +18,7 @@
18
18
  * Max depth in Finder
19
19
  * Terminal.app sessions
20
20
  * Nice job Lee!
21
+
22
+ === 1.0.8 / 2008-05-30
23
+
24
+ * Lots of small improvements including more from Lee Marlow
data/README.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  = godo
2
2
 
3
- * version: 1.0.7
4
- * released: 2008-05-21
3
+ * version: 1.0.8
4
+ * released: 2008-05-28
5
5
  * http://simplyruby.rubyforge.org/godo
6
6
 
7
7
  == DESCRIPTION:
@@ -69,6 +69,10 @@ a project level .godo file):
69
69
 
70
70
  godo -o <matcher> <project>
71
71
 
72
+ To see what project types are available:
73
+
74
+ godo --list-types
75
+
72
76
  == REQUIREMENTS:
73
77
 
74
78
  * Trollop
data/bin/godo CHANGED
@@ -8,8 +8,21 @@ require 'ick'
8
8
  Ick.sugarize
9
9
 
10
10
  opts = Trollop::options do
11
+ version "godo (#{Godo::VERSION})"
12
+ banner <<EOS
13
+ go (to project) do (stuffs)
14
+
15
+ godo provides a smart way of opening a project folder in multiple terminal tabs and, in each tab,
16
+ invoking a commands appropriate to that project
17
+
18
+ Usage:
19
+ godo [options] <project>
20
+
21
+ where [options] are:
22
+ EOS
11
23
  opt :install, "Create a fresh ~/.godo configuration file"
12
24
  opt :override, "Override heuristics to specify project type", :short => 'o', :type => :string
25
+ opt :list_types, "List available project types", :short => 'l'
13
26
  end
14
27
 
15
28
  if opts[:install]
@@ -1,4 +1,5 @@
1
1
  require 'find'
2
+ require 'set'
2
3
 
3
4
  module Godo
4
5
 
@@ -48,7 +49,12 @@ module Godo
48
49
  # base path, the first path would be returned.
49
50
  #
50
51
  def find( query )
51
- matches = @roots.inject( [] ) { |results,root| results.concat( find_in_root( root, query ) ) }
52
+ matches = []
53
+ searched = Set.new
54
+ @roots.each do |root|
55
+ find_in_path( root, root, query, matches, searched )
56
+ end
57
+
52
58
  if matches.size > 1
53
59
  matches = strip_inexact_matches( query, matches )
54
60
  if matches.size > 1
@@ -65,37 +71,36 @@ module Godo
65
71
  end
66
72
  end
67
73
 
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
74
+ def find_in_path( root, start_path, query, matches, searched )
75
+ Find.find( start_path ) do |path|
76
+ Find.prune unless File.directory?(path) # only look at directories
77
+ Find.prune unless searched.add?(path) # prevent infinite recursions from symlinks
78
+ Find.prune if past_max_depth?(root, path)
79
+ Find.prune if ignored?(path)
78
80
 
79
- if filtered?( path )
80
- Find.prune
81
- elsif matches?( path, query )
81
+ if path.match( query )
82
82
  matches << path
83
+ elsif File.symlink?( path )
84
+ # Find.find does not recurse into symlinked directories, so do it manually
85
+ find_in_path( root, File.join(path, '/'), query, matches, searched )
83
86
  end
84
87
  end
85
88
  matches
86
89
  end
87
-
88
- def matches?( path, query )
89
- path.match( query )
90
- end
91
90
 
92
- def filtered?( path )
93
- !File.directory?( path ) || excluded?( path )
91
+ # is path more than @max_depth levels below root?
92
+ def past_max_depth?( root, path )
93
+ if @max_depth > 0
94
+ partial_path = path.gsub(root, '')
95
+ return true if partial_path =~ /\A\.+\Z/
96
+ depth = partial_path.split('/').length
97
+ return true if depth > @max_depth + 1
98
+ end
99
+ false
94
100
  end
95
101
 
96
- def excluded?( path )
97
- ignore = !!@ignores.detect { |ignore| ignore.match( path ) }
98
- ignore
102
+ def ignored?( path )
103
+ @ignores.any? { |ignore| path.match( ignore ) }
99
104
  end
100
105
 
101
106
  def strip_inexact_matches( query, paths )
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Godo
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.8'
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
@@ -35,6 +35,20 @@ module Godo
35
35
  # project and invoke the appropriate actions.
36
36
  def self.godo( query, options )
37
37
  config = YAML::load( File.read( File.expand_path( "~/.godo" ) ) )
38
+
39
+ if options[:list_types]
40
+ matchers = config["matchers"]
41
+ if matchers && !matchers.empty?
42
+ puts "Available project types:"
43
+ config["matchers"].each do |matcher|
44
+ puts " - #{matcher['name']}"
45
+ end
46
+ else
47
+ puts "No available matchers found, please check your ~/.godo file"
48
+ end
49
+ return
50
+ end
51
+
38
52
  require 'finder'
39
53
  paths = Finder.find( query, config )
40
54
  found_path = if paths.empty?
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.7
4
+ version: 1.0.8
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-05-21 00:00:00 +01:00
33
+ date: 2008-05-30 00:00:00 +01:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -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.7"
106
+ homepage: "version: 1.0.8"
107
107
  post_install_message:
108
108
  rdoc_options:
109
109
  - --main
metadata.gz.sig CHANGED
Binary file