Sha256: 20084f1183c16b9f998ec6d68d2f289813af177bd28befc6c14db62112f173bf

Contents?: true

Size: 1.75 KB

Versions: 15

Compression:

Stored size: 1.75 KB

Contents

# coding: utf-8

require 'cgi'

module  Fig; end
class   Fig::Command; end
module  Fig::Command::Action; end
module  Fig::Command::Action::Role; end

module Fig::Command::Action::Role::ListVariablesAsGraphviz
  def descriptor_requirement()
    return nil
  end

  def load_base_package?()
    return true
  end

  def register_base_package?()
    return nil # don't care
  end

  def apply_config?()
    return nil # don't care
  end

  private

  def node_content(package, config_name)
    style = ''
    color = ''
    if package == @execution_context.base_package
      if base_display_config_names.include?(config_name)
        style = ' style = "rounded, bold"'
      end
      if config_name == @execution_context.base_config
        color = ' color = blue'
      end
    end

    name = node_name package, config_name
    rows = variable_statement_rows package, config_name
    label = nil
    if rows.empty?
      label = %Q<"#{name}">
    else
      label = %Q[<<table border="0"><tr><td border="0" colspan="3"><b>#{name}</b></td></tr>#{rows}</table>>]
    end

    return %Q<"#{name}" [label = #{label}#{style}#{color}];>
  end

  def variable_statement_rows(package, config_name)
    string = ''

    package[config_name].walk_statements do
      |statement|

      if statement.is_environment_variable?
        string << format_variable_statement(statement)
      end
    end

    return string
  end

  def format_variable_statement(statement)
    string = '<tr><td align="right">'
    string << statement.statement_type
    string << '</td><td align="left">$'
    string << CGI.escape_html(statement.name)
    string << '</td><td align="left">'
    string << CGI.escape_html(statement.tokenized_value.to_escaped_string)
    string << '</td></tr>'

    return string
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fig-1.27.10 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.27.8 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.27.5 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.27.4 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.27.3 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.27.0 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.26.1.beta.1 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.26.0 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.25.1.beta.1 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.25.0 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.24.1.beta.3 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.24.1.beta.2 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.24.1.beta.1 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.24.0 lib/fig/command/action/role/list_variables_as_graphviz.rb
fig-1.23.1.beta.1 lib/fig/command/action/role/list_variables_as_graphviz.rb