Class: Jekyll::Site
- Inherits:
-
Object
- Object
- Jekyll::Site
- Defined in:
- lib/polyglot.rb
Overview
Alteration to Jekyll Site class provides aliased methods to direct site.write to output into seperate language folders
Instance Attribute Summary collapse
-
#active_lang ⇒ Object
Returns the value of attribute active_lang.
-
#default_lang ⇒ Object
readonly
Returns the value of attribute default_lang.
-
#exclude_from_localization ⇒ Object
readonly
Returns the value of attribute exclude_from_localization.
-
#file_langs ⇒ Object
Returns the value of attribute file_langs.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
Instance Method Summary collapse
- #prepare ⇒ Object
- #process ⇒ Object
- #process_active_language ⇒ Object
- #process_language(lang) ⇒ Object
- #process_orig ⇒ Object
- #site_payload ⇒ Object
- #site_payload_orig ⇒ Object
Instance Attribute Details
#active_lang ⇒ Object
Returns the value of attribute active_lang.
13 14 15 |
# File 'lib/polyglot.rb', line 13 def active_lang @active_lang end |
#default_lang ⇒ Object (readonly)
Returns the value of attribute default_lang.
12 13 14 |
# File 'lib/polyglot.rb', line 12 def default_lang @default_lang end |
#exclude_from_localization ⇒ Object (readonly)
Returns the value of attribute exclude_from_localization.
12 13 14 |
# File 'lib/polyglot.rb', line 12 def exclude_from_localization @exclude_from_localization end |
#file_langs ⇒ Object
Returns the value of attribute file_langs.
13 14 15 |
# File 'lib/polyglot.rb', line 13 def file_langs @file_langs end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
12 13 14 |
# File 'lib/polyglot.rb', line 12 def languages @languages end |
Instance Method Details
#prepare ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/polyglot.rb', line 15 def prepare @file_langs = {} @default_lang = config['default_lang'] || 'en' @languages = config['languages'] || ['en'] @parallel_localization = config['parallel_localization'] || true (@keep_files << @languages - [@default_lang]).flatten! @exclude_from_localization = config['exclude_from_localization'] || [] @active_lang = @default_lang end |
#process ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/polyglot.rb', line 26 def process prepare if @parallel_localization pids = {} languages.each do |lang| pids[lang] = fork do process_language lang end end Signal.trap('INT') do languages.each do |lang| puts "Killing #{pids[lang]} : #{lang}" kill('INT', pids[lang]) end end languages.each do |lang| waitpid pids[lang] detach pids[lang] end else languages.each do |lang| process_language lang end end end |
#process_active_language ⇒ Object
68 69 70 71 72 |
# File 'lib/polyglot.rb', line 68 def process_active_language @dest = @dest + '/' + @active_lang @exclude += config['exclude_from_localization'] process_orig end |
#process_language(lang) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/polyglot.rb', line 61 def process_language(lang) @active_lang = lang config['active_lang'] = @active_lang return process_orig if @active_lang == @default_lang process_active_language end |
#process_orig ⇒ Object
25 |
# File 'lib/polyglot.rb', line 25 alias_method :process_orig, :process |
#site_payload ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/polyglot.rb', line 53 def site_payload payload = site_payload_orig payload['site']['default_lang'] = default_lang payload['site']['languages'] = languages payload['site']['active_lang'] = active_lang payload end |
#site_payload_orig ⇒ Object
52 |
# File 'lib/polyglot.rb', line 52 alias_method :site_payload_orig, :site_payload |