Class: BadgeMarkup

Inherits:
Struct
  • Object
show all
Defined in:
app/services/badge_markup.rb

Constant Summary collapse

BASE_URL =
"http://inch-ci.org"
IMAGE_FORMATS =
[:svg, :png]
DEFAULT_IMAGE_FORMAT =
IMAGE_FORMATS.first
IMAGE_STYLES =
[nil, 'flat-square', 'shields']

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branchObject

Returns the value of attribute branch

Returns:

  • (Object)

    the current value of branch


1
2
3
# File 'app/services/badge_markup.rb', line 1

def branch
  @branch
end

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project


1
2
3
# File 'app/services/badge_markup.rb', line 1

def project
  @project
end

Instance Method Details

#each(format = DEFAULT_IMAGE_FORMAT, style = nil, &block) ⇒ Object


7
8
9
# File 'app/services/badge_markup.rb', line 7

def each(format = DEFAULT_IMAGE_FORMAT, style = nil, &block)
  format_map(format, style).each(&block)
end

#image_formatsObject


11
12
13
# File 'app/services/badge_markup.rb', line 11

def image_formats
  IMAGE_FORMATS
end

#image_path(format = DEFAULT_IMAGE_FORMAT, style = nil) ⇒ Object


15
16
17
18
19
# File 'app/services/badge_markup.rb', line 15

def image_path(format = DEFAULT_IMAGE_FORMAT, style = nil)
  base = "#{page_path}.#{format}?branch=#{branch.name}"
  base << "&style=#{style}" if style
  base
end

#image_url(format = DEFAULT_IMAGE_FORMAT, style = nil) ⇒ Object


21
22
23
# File 'app/services/badge_markup.rb', line 21

def image_url(format = DEFAULT_IMAGE_FORMAT, style = nil)
  "#{BASE_URL}#{image_path(format, style)}"
end

#stylesObject


25
26
27
# File 'app/services/badge_markup.rb', line 25

def styles
  IMAGE_STYLES
end