hike 1.2.2 → 1.2.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 (4) hide show
  1. data/lib/hike/index.rb +11 -9
  2. data/lib/hike/trail.rb +11 -6
  3. metadata +13 -9
  4. checksums.yaml +0 -7
@@ -76,10 +76,14 @@ module Hike
76
76
  # `~` swap files. Returns an empty `Array` if the directory does
77
77
  # not exist.
78
78
  def entries(path)
79
- key = path.to_s
80
- @entries[key] ||= Pathname.new(path).entries.reject { |entry| entry.to_s =~ /^\.|~$|^\#.*\#$/ }.sort
81
- rescue Errno::ENOENT
82
- @entries[key] = []
79
+ @entries[path.to_s] ||= begin
80
+ pathname = Pathname.new(path)
81
+ if pathname.directory?
82
+ pathname.entries.reject { |entry| entry.to_s =~ /^\.|~$|^\#.*\#$/ }.sort
83
+ else
84
+ []
85
+ end
86
+ end
83
87
  end
84
88
 
85
89
  # A cached version of `File.stat`. Returns nil if the file does
@@ -88,12 +92,10 @@ module Hike
88
92
  key = path.to_s
89
93
  if @stats.key?(key)
90
94
  @stats[key]
95
+ elsif File.exist?(path)
96
+ @stats[key] = File.stat(path)
91
97
  else
92
- begin
93
- @stats[key] = File.stat(path)
94
- rescue Errno::ENOENT
95
- @stats[key] = nil
96
- end
98
+ @stats[key] = nil
97
99
  end
98
100
  end
99
101
 
@@ -157,18 +157,23 @@ module Hike
157
157
  # recommend to use this method for general purposes. It exists for
158
158
  # parity with `Index#entries`.
159
159
  def entries(path)
160
- Pathname.new(path).entries.reject { |entry| entry.to_s =~ /^\.|~$|^\#.*\#$/ }.sort
161
- rescue Errno::ENOENT
162
- []
160
+ pathname = Pathname.new(path)
161
+ if pathname.directory?
162
+ pathname.entries.reject { |entry| entry.to_s =~ /^\.|~$|^\#.*\#$/ }.sort
163
+ else
164
+ []
165
+ end
163
166
  end
164
167
 
165
168
  # `Trail#stat` is equivalent to `File#stat`. It is not
166
169
  # recommend to use this method for general purposes. It exists for
167
170
  # parity with `Index#stat`.
168
171
  def stat(path)
169
- File.stat(path.to_s)
170
- rescue Errno::ENOENT
171
- nil
172
+ if File.exist?(path)
173
+ File.stat(path.to_s)
174
+ else
175
+ nil
176
+ end
172
177
  end
173
178
 
174
179
  private
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hike
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Sam Stephenson
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-09 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  description: A Ruby library for finding files in a set of paths.
@@ -42,25 +45,26 @@ files:
42
45
  homepage: http://github.com/sstephenson/hike
43
46
  licenses:
44
47
  - MIT
45
- metadata: {}
46
48
  post_install_message:
47
49
  rdoc_options: []
48
50
  require_paths:
49
51
  - lib
50
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
51
54
  requirements:
52
- - - '>='
55
+ - - ! '>='
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0'
55
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
56
60
  requirements:
57
- - - '>='
61
+ - - ! '>='
58
62
  - !ruby/object:Gem::Version
59
63
  version: '0'
60
64
  requirements: []
61
65
  rubyforge_project:
62
- rubygems_version: 2.0.0
66
+ rubygems_version: 1.8.23
63
67
  signing_key:
64
- specification_version: 4
68
+ specification_version: 3
65
69
  summary: Find files in a set of paths
66
70
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 01de26f4036e2ee500951abeab83b4ae19a6434d
4
- data.tar.gz: 2ba70fc875f4d5043c4d07043ce5dae4503cca0f
5
- SHA512:
6
- metadata.gz: 21fc21254d387204b69182230f5f039442bac40769479a91497127c90ee3a0e1c9d23617da68facb9332ef70206a9b4f142b26f4ba829e11cb448e65dfe1c5d7
7
- data.tar.gz: 898b5bbe2f9326b5a80d7d47b7c8278324ae20a3a5bd16bd945bdc46671de7122a0f9c8a7b486e1a1e8f26fbad2d76f006469a0967665e310057ec51488c97c0