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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3d050f02e3eebffdd28a3b55d0c9fd2b08eef05
4
- data.tar.gz: 01a9193c484d491e60f7343f12d9ac1b40a2019f
3
+ metadata.gz: 3ad328bee9b70bba0418001e4a5503610a1a26d8
4
+ data.tar.gz: dd9b959261b0ec13b647941b3dd5df90f087913c
5
5
  SHA512:
6
- metadata.gz: cfd51af7b6c3e1b98a14728e65dfcabd1ffc2c11a97753d71071700906aa7e32e64437ada8fd12f3c789f2a0e1a6c0f9daf0275e1a2a6ce9ae343e60bbf6c66a
7
- data.tar.gz: 81652b1fbf2ab4a508db406b5d78a420f8e4f62441f60a3040c540e37c3bca51e0a70d33606ff2418b217dddaeb40cce85d745f479e93eef9c94226b4ae37e73
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
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module Lib
3
- VERSION = '4.2.7.6'
3
+ VERSION = '4.2.7.7'
4
4
  end
5
5
  end
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.6
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