Class: Jekyll::Stork

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/stork.rb

Constant Summary collapse

STEMMERS =
{
  'ar' => 'Arabic',
  'da' => 'Danish',
  'nl' => 'Dutch',
  'en' => 'English',
  'fi' => 'Finnish',
  'fr' => 'French',
  'de' => 'German',
  'el' => 'Greek',
  'hu' => 'Hungarian',
  'it' => 'Italian',
  'no' => 'Norwegian',
  'pt' => 'Portuguese',
  'ro' => 'Romanian',
  'ru' => 'Russian',
  'es' => 'Spanish',
  'sv' => 'Swedish',
  'ta' => 'Tamil',
  'tr' => 'Turkish'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Stork

Returns a new instance of Stork.

Parameters:

  • (Jekyll::Site)


32
33
34
# File 'lib/jekyll/stork.rb', line 32

def initialize(site)
  @site = site
end

Instance Attribute Details

#configString (readonly)

Returns:

  • (String)


84
85
86
# File 'lib/jekyll/stork.rb', line 84

def config
  @config
end

#siteObject (readonly)

Returns the value of attribute site.



8
9
10
# File 'lib/jekyll/stork.rb', line 8

def site
  @site
end

Instance Method Details

#destString

Returns:

  • (String)


79
80
81
# File 'lib/jekyll/stork.rb', line 79

def dest
  @dest ||= File.join(site.dest, file)
end

#fileString

Returns:

  • (String)


74
75
76
# File 'lib/jekyll/stork.rb', line 74

def file
  @file ||= 'index.st'
end

#filesHash

Returns:

  • (Hash)


63
64
65
66
67
68
69
70
71
# File 'lib/jekyll/stork.rb', line 63

def files
  @files ||= site.documents.concat(site.pages).map do |page|
    {
      'path' => page.destination(site.dest),
      'url' => page.url,
      'title' => page.data['title'] || ''
    }
  end
end

#index!Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jekyll/stork.rb', line 36

def index!
  Open3.popen2e('stork', '--build', config) do |_, stdout, thread|
    puts stdout.read

    if thread.value.success?
      site.static_files << Jekyll::StaticFile.new(site, site.source, '', file)
    end
  end
rescue Errno::ENOENT
  Jekyll.logger.warn "I couldn't find the `stork` program on your PATH, maybe you need to install it?"
end

#localeString

Returns the locale from the Site. Stork uses English as default language so we’re following that…

Returns:

  • (String)


52
53
54
# File 'lib/jekyll/stork.rb', line 52

def locale
  @locale ||= site.config['locale'] || site.config['lang'] || 'en'
end

#stemmerString

Returns:

  • (String)

See Also:



58
59
60
# File 'lib/jekyll/stork.rb', line 58

def stemmer
  @stemmer ||= STEMMERS[locale] || 'English'
end