hike 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/hike.rb +1 -1
  2. data/lib/hike/index.rb +15 -6
  3. metadata +5 -5
data/lib/hike.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Hike
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
 
4
4
  autoload :Extensions, "hike/extensions"
5
5
  autoload :Index, "hike/index"
data/lib/hike/index.rb CHANGED
@@ -2,18 +2,27 @@ require 'pathname'
2
2
 
3
3
  module Hike
4
4
  class Index
5
- attr_reader :root, :paths, :extensions
5
+ attr_reader :paths, :extensions
6
6
 
7
7
  def initialize(root, paths, extensions)
8
- @root = Pathname.new(root).expand_path
9
- @paths = paths.map { |path| Pathname.new(path).expand_path }
10
- @extensions = extensions.to_a
8
+ @root = root
9
+ @paths = paths.dup.freeze
10
+ @extensions = extensions.dup.freeze
11
+ @pathnames = paths.map { |path| Pathname.new(path) }
11
12
 
12
13
  @stats = {}
13
14
  @entries = {}
14
15
  @patterns = {}
15
16
  end
16
17
 
18
+ def root
19
+ @root.to_s
20
+ end
21
+
22
+ def index
23
+ self
24
+ end
25
+
17
26
  def find(*logical_paths, &block)
18
27
  if block_given?
19
28
  options = extract_options!(logical_paths)
@@ -48,7 +57,7 @@ module Hike
48
57
 
49
58
  def find_in_paths(logical_path, &block)
50
59
  dirname, basename = logical_path.split
51
- paths.each do |base_path|
60
+ @pathnames.each do |base_path|
52
61
  match(base_path.join(dirname), basename, &block)
53
62
  end
54
63
  end
@@ -94,7 +103,7 @@ module Hike
94
103
  end
95
104
 
96
105
  def paths_contain?(dirname)
97
- paths.any? { |path| dirname.to_s[0, path.to_s.length] == path.to_s }
106
+ paths.any? { |path| dirname.to_s[0, path.length] == path }
98
107
  end
99
108
 
100
109
  def pattern_for(basename)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hike
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Stephenson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-03 00:00:00 -05:00
18
+ date: 2011-04-05 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements: []
66
66
 
67
67
  rubyforge_project:
68
- rubygems_version: 1.5.0
68
+ rubygems_version: 1.6.2
69
69
  signing_key:
70
70
  specification_version: 3
71
71
  summary: Find files in a set of paths