hike 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hike.rb +1 -1
- data/lib/hike/directory_index.rb +15 -28
- data/lib/hike/normalized_array.rb +3 -3
- data/lib/hike/trail.rb +2 -2
- metadata +4 -4
data/lib/hike.rb
CHANGED
data/lib/hike/directory_index.rb
CHANGED
@@ -1,44 +1,31 @@
|
|
1
1
|
module Hike
|
2
2
|
class DirectoryIndex
|
3
3
|
def initialize
|
4
|
-
|
4
|
+
expire_cache
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
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
|
23
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
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
|
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
|
45
|
+
super(*normalize_elements(elements))
|
46
46
|
end
|
47
47
|
|
48
48
|
def normalize_elements(elements)
|
data/lib/hike/trail.rb
CHANGED
@@ -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.
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
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-
|
18
|
+
date: 2010-11-22 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|