Module: Debci::HTMLHelpers
- Includes:
- ActiveSupport::NumberHelper, ERB::Util
- Included in:
- Admin, App, Frontend, SelfService, Status
- Defined in:
- lib/debci/html_helpers.rb
Constant Summary collapse
- ICONS =
{ pass: 'thumbs-up', neutral: 'minus-circle', fail: 'thumbs-down', fail_passed_never: ['thumbs-down', 'ban'], fail_passed_current: ['thumbs-down', 'bolt'], fail_passed_old: ['thumbs-down', 'arrow-down'], tmpfail_pass: 'thumbs-up', tmpfail_fail: 'thumbs-down', tmpfail: 'question-circle', no_test_data: 'question', }.freeze
Instance Method Summary collapse
- #expand_pin_packages(test) ⇒ Object
-
#expand_url(url, suite) ⇒ Object
expand { SUITE } macro in URLs.
- #file_link(size, link_pattern) ⇒ Object
- #history_url(job) ⇒ Object
- #icon(status) ⇒ Object
- #package_url(package) ⇒ Object
- #title_test_trigger_pin(test) ⇒ Object
Instance Method Details
#expand_pin_packages(test) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/debci/html_helpers.rb', line 51 def (test) return [] unless test.pinned? test.pin_packages.map do |pin| *packages, suite = pin Array(packages).map do |pkglist| String(pkglist).split(/\s*,\s*/).map do |pkg| "#{pkg} from #{suite}" end end end.flatten end |
#expand_url(url, suite) ⇒ Object
expand { SUITE } macro in URLs
73 74 75 |
# File 'lib/debci/html_helpers.rb', line 73 def (url, suite) url&.gsub('{SUITE}', suite) end |
#file_link(size, link_pattern) ⇒ Object
30 31 32 33 |
# File 'lib/debci/html_helpers.rb', line 30 def file_link(size, link_pattern) return unless size link_pattern % number_to_human_size(size) end |
#history_url(job) ⇒ Object
64 65 66 |
# File 'lib/debci/html_helpers.rb', line 64 def history_url(job) "/packages/#{job.package.prefix}/#{job.package.name}/#{job.suite}/#{job.arch}/" end |
#icon(status) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/debci/html_helpers.rb', line 23 def icon(status) status ||= :no_test_data Array(ICONS[status.to_sym]).map do |i| "<i class='#{status} fa fa-#{i}'></i>" end.join(' ') end |
#package_url(package) ⇒ Object
68 69 70 |
# File 'lib/debci/html_helpers.rb', line 68 def package_url(package) "/packages/#{package.prefix}/#{package.name}/" end |
#title_test_trigger_pin(test) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/debci/html_helpers.rb', line 35 def title_test_trigger_pin(test) title = '' unless test.trigger.blank? title << "Trigger:\n" title << h(test.trigger) end if test.pinned? title << "\n\n" unless test.trigger.blank? title << "Pinned packages:\n" (test).each do |pin| title << pin << "\n" end end title end |