Module: InchCI::BadgeMethods

Included in:
Badge, BadgeRequest
Defined in:
lib/inch_ci/badge.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

IMAGE_FORMATS =
%w(png svg)
IMAGE_STYLES =
%w(default shields flat flat-square)
DEFAULT_IMAGE_FORMAT =
IMAGE_FORMATS.first
DEFAULT_IMAGE_STYLE =
IMAGE_STYLES.first

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


8
9
10
# File 'lib/inch_ci/badge.rb', line 8

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#filename(format = DEFAULT_IMAGE_FORMAT, style = DEFAULT_IMAGE_STYLE) ⇒ Object


12
13
14
15
16
17
# File 'lib/inch_ci/badge.rb', line 12

def filename(format = DEFAULT_IMAGE_FORMAT, style = DEFAULT_IMAGE_STYLE)
  unless IMAGE_STYLES.include?(style)
    style = DEFAULT_IMAGE_STYLE
  end
  File.join(*project_triple, "#{branch_name}.#{style}.#{format}")
end

#local_filename(format = DEFAULT_IMAGE_FORMAT, style = DEFAULT_IMAGE_STYLE) ⇒ Object


19
20
21
# File 'lib/inch_ci/badge.rb', line 19

def local_filename(format = DEFAULT_IMAGE_FORMAT, style = DEFAULT_IMAGE_STYLE)
  File.join(Rails.root, public_dir, filename(format, style))
end