Class: JekyllBadge::JekyllBadge

Inherits:
JekyllSupport::JekyllTag
  • Object
show all
Defined in:
lib/jekyll_badge.rb

Overview

This class implements the jekyll_badge functionality Assumes project is stored on GitHub

Constant Summary collapse

PLUGIN_NAME =
'jekyll_badge'.freeze
VERSION =
::JekyllBadge::VERSION

Instance Method Summary collapse

Instance Method Details

#render_implObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jekyll_badge.rb', line 21

def render_impl
  @align        = @helper.parameter_specified?('align') || 'right'
  @clear        = @helper.parameter_specified?('clear') ? 'clear' : nil
  @class        = @helper.parameter_specified?('class') || 'rounded shadow'
  # TODO: put this into _config.yml
  @git_url_base = @helper.parameter_specified?('git_url_base') || 'https://github.com/mslinn'
  @image        = @helper.parameter_specified?('image') || '/blog/images/git/github-mark'
  @name         = @helper.parameter_specified?('name')  || @page['name']
  @label        = @helper.parameter_specified?('label') || @name
  @style        = @helper.parameter_specified?('style') || ''
  @git_url      = @helper.parameter_specified?('git_url') || "#{@git_url_base}/#{@name}"

  unless %w[left center right].include? @align
    @helper.logger.warn { "Ignoring invalid align value ('#{@align}') on line #{@line_number} (plus front matter) of #{@page['name']}." }
    @align = 'right'
  end

  if @check_links
    check_url
  else
    generate_output
  end
end