Module: Tungsten::DeploymentsHelper
- Defined in:
- app/helpers/tungsten/deployments_helper.rb
Instance Method Summary collapse
- #deployment_data(name = nil) ⇒ Object
- #deployment_graphic ⇒ Object
- #deployment_icon(name, options = {}) ⇒ Object
- #deployment_svg(name, options = {}) ⇒ Object
- #deployment_text(text, options = {}) ⇒ Object
Instance Method Details
#deployment_data(name = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/tungsten/deployments_helper.rb', line 3 def deployment_data(name = nil) deployments = Cyborg.config_data['deployments']['deployments'] if name.nil? deployments else deployment = deployments.find { |d| d[:name] =~ /#{name}/i || d[:slug] == name } if deployment.nil? && !Rails.env.production? raise %Q{No deployment type "#{name}" exists.} end deployment end end |
#deployment_graphic ⇒ Object
21 22 23 |
# File 'app/helpers/tungsten/deployments_helper.rb', line 21 def deployment_graphic @deployment_icon ||= Esvg.find_symbol('deployment') end |
#deployment_icon(name, options = {}) ⇒ Object
54 55 56 57 58 |
# File 'app/helpers/tungsten/deployments_helper.rb', line 54 def deployment_icon(name, ={}) [:stroke_width] ||= 8 [:text] ||= { "font-weight" => 600, "font-size" => "76px" } deployment_svg name, end |
#deployment_svg(name, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/tungsten/deployments_helper.rb', line 39 def deployment_svg(name, ={}) data = deployment_data(name) ([:use] ||= {}) [:use][:stroke] ||= .delete(:stroke) || "currentColor" [:use][:stroke_width] ||= .delete(:stroke_width) || 4 [:use][:class] = "deployment-icon-hex #{[:use][:class]}".strip [:color] ||= "#fff" [:fill] ||= "none" # options[:fill] ||= "url(##{data[:name].downcase}-gradient-bg)" [:content] ||= deployment_text(data[:short_name], .delete(:text) || {}) deployment_graphic.use().html_safe end |
#deployment_text(text, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/tungsten/deployments_helper.rb', line 25 def deployment_text(text, ={}) = { x: deployment_graphic.width.to_f / 2, y: deployment_graphic.height.to_f / 2, fill: "currentColor", "font-weight" => 700, "font-size" => "57px", "text-anchor" => "middle", "dominant-baseline" =>"central", "alignment-baseline" => "central" }.merge() content_tag(:text, text, ).html_safe end |