godo 1.0.2 → 1.0.3

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.
Files changed (7) hide show
  1. data.tar.gz.sig +0 -0
  2. data/Rakefile +1 -0
  3. data/bin/godo +3 -0
  4. data/lib/finder.rb +45 -15
  5. data/lib/godo.rb +1 -1
  6. metadata +10 -1
  7. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -9,6 +9,7 @@ Hoe.new('godo', Godo::VERSION) do |p|
9
9
  p.developer( 'Matt Mower', 'self@mattmower.com' )
10
10
  p.extra_deps << ['trollop','>= 1.7']
11
11
  p.extra_deps << ['rb-appscript','>= 0.5.1']
12
+ p.extra_deps << ['ick','>= 0.2.2']
12
13
  p.remote_rdoc_dir = 'godo'
13
14
  end
14
15
 
data/bin/godo CHANGED
@@ -3,6 +3,9 @@
3
3
  require 'rubygems'
4
4
  require 'trollop'
5
5
  require 'godo'
6
+ require 'ick'
7
+
8
+ Ick.sugarize
6
9
 
7
10
  opts = Trollop::options do
8
11
  opt :install, "Create a fresh ~/.godo configuration file"
@@ -4,27 +4,46 @@ module Godo
4
4
 
5
5
  class Finder
6
6
 
7
+ # Find, if possible, a single project path matching the query string.
8
+ #
7
9
  def self.find( query, options )
8
- finder = Finder.new( options["projects"], options["ignores"] )
9
- paths = finder.find( Regexp.escape( query ) )
10
-
11
- if paths.size > 1
12
- paths = strip_inexact_matches( query, paths )
13
- if paths.size > 1
14
- if base_match( paths )
15
- paths[0,1]
16
- end
17
- end
10
+ let( Finder.new( options["projects"], options["ignores"] ) ) do |finder|
11
+ finder.find( Regexp.escape( query ) )
18
12
  end
19
-
20
- paths
21
13
  end
22
14
 
15
+ # Create a Finder which will search under the given root folders, ignoring
16
+ # folders that match any of the specified 'ignore' patterns.
17
+ #
23
18
  def initialize( roots, ignores )
24
19
  @roots = roots.map { |root| File.expand_path( root ) }
25
20
  @ignores = ignores.map { |ignore| Regexp.compile( "/#{ignore}" ) }
26
21
  end
27
22
 
23
+ # Search for a folder matching the query.
24
+ #
25
+ # 1) If a single folder is found it is returned.
26
+ #
27
+ # 2) If multiple folders are found then an attempt is made to strip any folders
28
+ # that are not an exact match for the query string.
29
+ #
30
+ # For example with the query 'reeplay' returning the following paths
31
+ #
32
+ # Paths:
33
+ # /root/reeplay.it
34
+ # /root/reeplay.it/reeplay
35
+ # /root/reeplay.it/reeplay/app
36
+ #
37
+ # The first path would be stripped because none of it's components are an exact
38
+ # match for the query term.
39
+ #
40
+ # 3) If there are still multiple folders then the remaining folders are checked
41
+ # to see if they contain the first folder as a base path. If so the first
42
+ # path is returned.
43
+ #
44
+ # In this case because the second of the two remaining paths has the first as a
45
+ # base path, the first path would be returned.
46
+ #
28
47
  def find( query )
29
48
  matches = []
30
49
  @roots.each do |root|
@@ -38,8 +57,20 @@ module Godo
38
57
  end
39
58
  end
40
59
 
41
- # puts "Found: #{matches.inspect}"
42
- matches
60
+ if matches.size > 1
61
+ matches = strip_inexact_matches( query, matches )
62
+ if matches.size > 1
63
+ if base_match( matches )
64
+ matches[0,1]
65
+ else
66
+ matches
67
+ end
68
+ else
69
+ matches
70
+ end
71
+ else
72
+ matches
73
+ end
43
74
  end
44
75
 
45
76
  def matches?( path, query )
@@ -52,7 +83,6 @@ module Godo
52
83
 
53
84
  def excluded?( path )
54
85
  ignore = !!@ignores.detect { |ignore| ignore.match( path ) }
55
- #puts "Ignore: #{path.inspect} -> #{ignore.inspect}"
56
86
  ignore
57
87
  end
58
88
 
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Godo
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
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
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mower
@@ -51,6 +51,15 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.5.1
53
53
  version:
54
+ - !ruby/object:Gem::Dependency
55
+ name: ick
56
+ version_requirement:
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.2
62
+ version:
54
63
  - !ruby/object:Gem::Dependency
55
64
  name: hoe
56
65
  version_requirement:
metadata.gz.sig CHANGED
Binary file