gitlab-gollum-lib 4.2.7.6 → 4.2.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemspec.rb +1 -0
- data/lib/gollum-lib/sorters/wiki_sorter.rb +47 -0
- data/lib/gollum-lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ad328bee9b70bba0418001e4a5503610a1a26d8
|
4
|
+
data.tar.gz: dd9b959261b0ec13b647941b3dd5df90f087913c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd82f0009c1df043add484a9cdebdda584fde1bde3d5a548c5fc34e1a78ef7ad43fd3b3048878c07f477dce973d39c43b937e31541fcaaf0691d209e01f06298
|
7
|
+
data.tar.gz: 2b257ac9b7d4929cf64220131e7e35f73f3197a8cbb169b575e2e59fa58963807979ed5bd2b89906663cb10b8758662d2fd3eb74ac1fea7f762c142431568067
|
data/gemspec.rb
CHANGED
@@ -84,6 +84,7 @@ def specification(version, default_adapter, platform = nil)
|
|
84
84
|
lib/gollum-lib/filter/tags.rb
|
85
85
|
lib/gollum-lib/filter/toc.rb
|
86
86
|
lib/gollum-lib/filter/wsd.rb
|
87
|
+
lib/gollum-lib/sorters/wiki_sorter.rb
|
87
88
|
lib/gollum-lib/git_access.rb
|
88
89
|
lib/gollum-lib/gitcode.rb
|
89
90
|
lib/gollum-lib/helpers.rb
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Gollum
|
2
|
+
module Sorters
|
3
|
+
class WikiSorter
|
4
|
+
SORT_CREATED_AT = "created_at".freeze
|
5
|
+
|
6
|
+
attr_reader :sort, :direction_desc, :limit
|
7
|
+
|
8
|
+
def initialize(sort, direction_desc, limit)
|
9
|
+
@sort = sort
|
10
|
+
@direction_desc = direction_desc
|
11
|
+
@limit = limit
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(sha, access, blobs)
|
15
|
+
if sort == SORT_CREATED_AT
|
16
|
+
by_created_at(sha, access, blobs)
|
17
|
+
else
|
18
|
+
by_title(blobs)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def by_created_at(sha, access, blobs)
|
25
|
+
blobs_by_path = blobs.each_with_object({}) do |entry, hash|
|
26
|
+
hash[entry.path] = entry
|
27
|
+
end
|
28
|
+
|
29
|
+
filenames = access.files_sorted_by_created_at(sha)
|
30
|
+
iterator = direction_desc ? filenames.each : filenames.reverse_each
|
31
|
+
|
32
|
+
iterator.with_object([]) do |filename, blobs|
|
33
|
+
blob = blobs_by_path[filename]
|
34
|
+
next unless blob
|
35
|
+
blobs << blob
|
36
|
+
break blobs if limit && blobs.size == limit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def by_title(blobs)
|
41
|
+
blobs = blobs.reverse if direction_desc
|
42
|
+
blobs = blobs.take(limit) if limit
|
43
|
+
blobs
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/gollum-lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-gollum-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.7.
|
4
|
+
version: 4.2.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -416,6 +416,7 @@ files:
|
|
416
416
|
- lib/gollum-lib/page.rb
|
417
417
|
- lib/gollum-lib/pagination.rb
|
418
418
|
- lib/gollum-lib/sanitization.rb
|
419
|
+
- lib/gollum-lib/sorters/wiki_sorter.rb
|
419
420
|
- lib/gollum-lib/version.rb
|
420
421
|
- lib/gollum-lib/wiki.rb
|
421
422
|
- licenses/licenses.txt
|