servel 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 368f3a82244101749c5bd21dda7e82d229d093c4
4
- data.tar.gz: 66955c76c3cc09c6d38ea396da93ff3df65036b6
3
+ metadata.gz: 04bbc42b03ba43d1ec342e7f397178a97eeff3a9
4
+ data.tar.gz: 1a9a865af005bd23156c2a76053f4bbd6adbdbf1
5
5
  SHA512:
6
- metadata.gz: 5d278f493f55dcff11d89d97c958e01564bb8bda9a80b82d4b13fc055726a53c771179803b32dcc913c7eb9c3a750a9d7b5cad5059b4f97c0e7cb1d45b6ad5f8
7
- data.tar.gz: 8865989fd4ed41d1629753967e92bc4ef7a4b124aa456eaa129aa804c92a2900454d434ed6e28bd3d92135dc311c56f6a1700e2398c880e1415f82ebe9ffda15
6
+ metadata.gz: 4bdb0287d5b8c289e99b1e9c0ab940f4369fd63b7f3b55e350aebc6acbe3c838f18b81cd96262f9f23c2d7347f438743e12c8dc4227bd24adb185897e3eccade
7
+ data.tar.gz: ad5e295d7c21189dbe42934a97e424c03ef76a6280ab948ccf473864829038a9e9ef5c2da4cf1592682ad63ae003197bf42dbc3940aba4962416eb34cdac3a59
@@ -41,6 +41,8 @@ class Servel::EntryFactory
41
41
 
42
42
  def self.for(path)
43
43
  new(path).entry
44
+ rescue Errno::EACCES
45
+ nil
44
46
  end
45
47
 
46
48
  def initialize(path)
data/lib/servel/index.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Servel::Index
2
2
  extend Servel::Instrumentation
3
- LOCALS_CACHE = LruRedux::ThreadSafeCache.new(100)
3
+ RENDER_CACHE = LruRedux::ThreadSafeCache.new(100)
4
4
  SORT_METHODS = ["name", "mtime", "size", "type"]
5
5
  SORT_DIRECTIONS = ["asc", "desc"]
6
6
 
@@ -12,31 +12,15 @@ class Servel::Index
12
12
  end
13
13
 
14
14
  def render
15
- Servel::HamlContext.render('index.haml', locals)
15
+ RENDER_CACHE.getset(render_cache_key) { Servel::HamlContext.render('index.haml', locals) }
16
16
  end
17
17
 
18
- def sort_method
19
- param = @params["_servel_sort_method"]
20
- param = "name" unless SORT_METHODS.include?(param)
21
- param
22
- end
23
-
24
- def sort_direction
25
- param = @params["_servel_sort_direction"]
26
- param = "asc" unless SORT_DIRECTIONS.include?(param)
27
- param
28
- end
29
-
30
- def locals_cache_key
31
- @locals_cache_key ||= [@fs_path.to_s, @fs_path.mtime.to_i, sort_method, sort_direction].join("-")
18
+ def render_cache_key
19
+ @render_cache_key ||= [@fs_path.to_s, @fs_path.mtime.to_i, sort_method, sort_direction].join("-")
32
20
  end
33
21
 
34
22
  def locals
35
- LOCALS_CACHE.getset(locals_cache_key) { build_locals }
36
- end
37
-
38
- def build_locals
39
- entries = @fs_path.children.map { |path| Servel::EntryFactory.for(path) }
23
+ entries = @fs_path.children.map { |path| Servel::EntryFactory.for(path) }.compact
40
24
 
41
25
  {
42
26
  url_root: @url_root,
@@ -50,6 +34,18 @@ class Servel::Index
50
34
  }
51
35
  end
52
36
 
37
+ def sort_method
38
+ param = @params["_servel_sort_method"]
39
+ param = "name" unless SORT_METHODS.include?(param)
40
+ param
41
+ end
42
+
43
+ def sort_direction
44
+ param = @params["_servel_sort_direction"]
45
+ param = "asc" unless SORT_DIRECTIONS.include?(param)
46
+ param
47
+ end
48
+
53
49
  def directories(entries)
54
50
  list = apply_sort(entries.select { |entry| entry.directory? })
55
51
 
@@ -83,9 +79,5 @@ class Servel::Index
83
79
  entries
84
80
  end
85
81
 
86
- def sort_entries(entries)
87
- Naturalsorter::Sorter.sort_by_method(entries, :name, true)
88
- end
89
-
90
- instrument :locals, :directories, :files, :sort_entries
82
+ instrument :render, :locals, :directories, :files, :apply_sort
91
83
  end
@@ -1,3 +1,3 @@
1
1
  module Servel
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton "B-Train" Fletcher