jekyll-locales 0.1.9 → 0.1.10

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
  SHA256:
3
- metadata.gz: e7e6fdd0bef170f9bc080d6ed57e256e3d1ace2c0faa9c33fad9073490dd0703
4
- data.tar.gz: 4637537e057a944190caaff98070168a24a30cd866da6bd1596d072f42429724
3
+ metadata.gz: 6b8cd80411bc24509a21502d5972966dd9cb990ec1716aacc19724855e8c957b
4
+ data.tar.gz: 557fdfd91a846aa99f180076b186ddf21fad118cc0b01de438e66e0a7303c2bd
5
5
  SHA512:
6
- metadata.gz: '0768e9186dae694e308d7e4b9471543a32de53bd1f3bb45668901241245b75b4ffb38c9134133fec6884effa2b6c164ff109f1682471856e525dc37dd271c63b'
7
- data.tar.gz: 367a38099307c74170cd19a88e95a70a6823c73c03a77dbb3bddad1fd8a24442b9dd2ade786670d002c4f63efe58a2d5d6b3b286da1a16f007ce81d687ae4870
6
+ metadata.gz: 2d3826a63a1f0d581e4c9a0e516680fe012f99c88d6ad62a761e61140a3a25f1c71ca9ea08853155c7a817d3919f32715c0b20dd9d87c1383e052984c55832a5
7
+ data.tar.gz: 5471c147d18a8bd76445857b4251902c454d09f123e4e64e177fd7df02c0d4b1789b465c465e590ca8f590f9539af9fc35602623579137d8b8acabb161cb2b5f
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency 'bundler', '~> 2.0'
37
37
  spec.add_development_dependency 'minitest', '~> 5.0'
38
- spec.add_development_dependency 'rake', '~> 10.0'
38
+ spec.add_development_dependency 'rake', '~> 12.0'
39
39
  spec.add_development_dependency 'rubocop', '~> 0.74'
40
40
  end
@@ -4,3 +4,4 @@ require 'jekyll/site'
4
4
  require 'jekyll/locales/site'
5
5
  require 'jekyll/locales/site_drop'
6
6
  require 'jekyll/locales/hooks/page_post_init'
7
+ require 'jekyll/locales/hooks/cleanup'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # We keep a global variable with the site in it because we can't access
4
+ # it from the cleanup hook.
5
+ $site = nil
6
+
7
+ # Only run on the default locale since it's going to be in the root
8
+ # destination
9
+ Jekyll::Hooks.register :site, :post_render do |site|
10
+ next unless site.locales?
11
+ next unless site.default_locale?
12
+
13
+ $site = site
14
+ end
15
+
16
+ # Keep files in other locales since they're not generated by the default
17
+ # locale.
18
+ Jekyll::Hooks.register :clean, :on_obsolete do |obsolete|
19
+ next if $site.nil?
20
+
21
+ $site.locales.each do |locale|
22
+ next if locale == $site.locale
23
+
24
+ obsolete.delete_if do |x|
25
+ x.sub($site.dest + '/', '').start_with? locale
26
+ end
27
+ end
28
+ end
@@ -43,6 +43,23 @@ module Jekyll
43
43
  copy_redirector if redirect?
44
44
  end
45
45
 
46
+ def locales?
47
+ locales.length > 1
48
+ end
49
+
50
+ # Get locales from configuration
51
+ def locales
52
+ @locales ||= config.fetch('locales', [])
53
+ end
54
+
55
+ def default_locale
56
+ @default_locale ||= locales.first
57
+ end
58
+
59
+ def default_locale?
60
+ default_locale == locale
61
+ end
62
+
46
63
  private
47
64
 
48
65
  # Redefine #render_docs so it doesn't render the locale collections
@@ -60,10 +77,6 @@ module Jekyll
60
77
  end
61
78
  end
62
79
 
63
- def locales?
64
- locales.size > 1
65
- end
66
-
67
80
  def locale_config
68
81
  # XXX: Retrocompatibility
69
82
  config['locale'] = config['lang'] = locale
@@ -80,19 +93,6 @@ module Jekyll
80
93
  config['baseurl'] = locale_baseurl
81
94
  end
82
95
 
83
- # Get locales from configuration
84
- def locales
85
- @locales ||= config.fetch('locales', [])
86
- end
87
-
88
- def default_locale
89
- @default_locale ||= locales.first
90
- end
91
-
92
- def default_locale?
93
- default_locale == locale
94
- end
95
-
96
96
  # Read the other locales as collections but don't render them, only
97
97
  # make them available to templates.
98
98
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Locales
5
- VERSION = '0.1.9'
5
+ VERSION = '0.1.10'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-locales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,6 @@ files:
80
80
  - ".travis.yml"
81
81
  - CHANGELOG.md
82
82
  - Gemfile
83
- - Gemfile.lock
84
83
  - LICENSE
85
84
  - README.md
86
85
  - Rakefile
@@ -90,6 +89,7 @@ files:
90
89
  - jekyll-locales.gemspec
91
90
  - lib/jekyll-locales.rb
92
91
  - lib/jekyll/locales.rb
92
+ - lib/jekyll/locales/hooks/cleanup.rb
93
93
  - lib/jekyll/locales/hooks/page_post_init.rb
94
94
  - lib/jekyll/locales/site.rb
95
95
  - lib/jekyll/locales/site_drop.rb
@@ -1,38 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- jekyll-locales (0.1.9)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.0)
10
- jaro_winkler (1.5.3)
11
- minitest (5.11.3)
12
- parallel (1.17.0)
13
- parser (2.6.4.1)
14
- ast (~> 2.4.0)
15
- rainbow (3.0.0)
16
- rake (10.5.0)
17
- rubocop (0.74.0)
18
- jaro_winkler (~> 1.5.1)
19
- parallel (~> 1.10)
20
- parser (>= 2.6)
21
- rainbow (>= 2.2.2, < 4.0)
22
- ruby-progressbar (~> 1.7)
23
- unicode-display_width (>= 1.4.0, < 1.7)
24
- ruby-progressbar (1.10.1)
25
- unicode-display_width (1.6.0)
26
-
27
- PLATFORMS
28
- ruby
29
-
30
- DEPENDENCIES
31
- bundler (~> 2.0)
32
- jekyll-locales!
33
- minitest (~> 5.0)
34
- rake (~> 10.0)
35
- rubocop (~> 0.74)
36
-
37
- BUNDLED WITH
38
- 2.1.4