hike 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Hike
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
 
4
4
  autoload :DirectoryIndex, "hike/directory_index"
5
5
  autoload :Extensions, "hike/extensions"
@@ -1,44 +1,31 @@
1
1
  module Hike
2
2
  class DirectoryIndex
3
3
  def initialize
4
- expire
4
+ expire_cache
5
5
  end
6
6
 
7
- def expire
8
- expire_mtimes
9
- expire_files
10
- end
11
-
12
- def expire_mtimes
13
- @mtimes = {}
14
- true
15
- end
16
-
17
- def expire_files
7
+ def expire_cache
8
+ @entries = {}
18
9
  @files = {}
19
10
  true
20
11
  end
21
12
 
22
- def mtime(dirname)
23
- @mtimes[dirname] ||= File.directory?(dirname) && File.mtime(dirname)
13
+ def entries(dirname)
14
+ dirname = File.expand_path(dirname)
15
+ @entries[dirname] ||= if File.directory?(dirname)
16
+ Dir.entries(dirname).reject do |entry|
17
+ entry =~ /^\.\.?$/
18
+ end.sort
19
+ else
20
+ []
21
+ end
24
22
  end
25
23
 
26
24
  def files(dirname)
27
- if current_mtime = mtime(dirname)
28
- cached_mtime, files = @files[dirname]
29
- if current_mtime == cached_mtime
30
- return files
31
- else
32
- files = Dir.entries(dirname).select do |entry|
33
- File.file?(File.join(dirname, entry))
34
- end
35
- end
36
- else
37
- files = []
25
+ dirname = File.expand_path(dirname)
26
+ @files[dirname] ||= entries(dirname).select do |entry|
27
+ File.file?(File.join(dirname, entry))
38
28
  end
39
-
40
- @files[dirname] = [current_mtime, files]
41
- files
42
29
  end
43
30
  end
44
31
  end
@@ -13,7 +13,7 @@ module Hike
13
13
  value = normalize_element(value)
14
14
  end
15
15
 
16
- super *args.concat([value])
16
+ super(*args.concat([value]))
17
17
  end
18
18
 
19
19
  def <<(element)
@@ -34,7 +34,7 @@ module Hike
34
34
  end
35
35
 
36
36
  def push(*elements)
37
- super *normalize_elements(elements)
37
+ super(*normalize_elements(elements))
38
38
  end
39
39
 
40
40
  def replace(elements)
@@ -42,7 +42,7 @@ module Hike
42
42
  end
43
43
 
44
44
  def unshift(*elements)
45
- super *normalize_elements(elements)
45
+ super(*normalize_elements(elements))
46
46
  end
47
47
 
48
48
  def normalize_elements(elements)
@@ -2,7 +2,7 @@ module Hike
2
2
  class Trail
3
3
  attr_reader :root, :paths, :extensions
4
4
 
5
- def initialize(root)
5
+ def initialize(root = ".")
6
6
  @root = File.expand_path(root)
7
7
  @index = DirectoryIndex.new
8
8
  @paths = Paths.new(@root)
@@ -10,7 +10,7 @@ module Hike
10
10
  end
11
11
 
12
12
  def find(*logical_paths)
13
- index.expire_mtimes
13
+ index.expire_cache
14
14
 
15
15
  logical_paths.each do |logical_path|
16
16
  if result = find_path(logical_path)
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
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: 2010-11-07 01:00:00 -05:00
18
+ date: 2010-11-22 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21