Class: RubyUIConverter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ui_converter/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_namespace: "Views", base_class: "Phlex::HTML", phlex_version: 2, indent: " ", output_root: nil, verbose: false, dry_run: false, force: false, ruby_ui: true, literal: false, root: nil) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_ui_converter/configuration.rb', line 9

def initialize(base_namespace: "Views", base_class: "Phlex::HTML",
               phlex_version: 2, indent: "  ", output_root: nil,
               verbose: false, dry_run: false, force: false, ruby_ui: true,
               literal: false, root: nil)
  @base_namespace = base_namespace
  @base_class = base_class
  @phlex_version = phlex_version
  @indent = indent
  @output_root = output_root
  @verbose = verbose
  @dry_run = dry_run
  @force = force
  @ruby_ui = ruby_ui
  @literal = literal
  @root = root
  @component_map = ComponentMap.new
  enable_rubyui_rules! if ruby_ui
end

Instance Attribute Details

#base_classObject

Returns the value of attribute base_class.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def base_class
  @base_class
end

#base_namespaceObject

Returns the value of attribute base_namespace.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def base_namespace
  @base_namespace
end

#component_mapObject

Returns the value of attribute component_map.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def component_map
  @component_map
end

#dry_runObject

Returns the value of attribute dry_run.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def dry_run
  @dry_run
end

#forceObject

Returns the value of attribute force.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def force
  @force
end

#indentObject

Returns the value of attribute indent.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def indent
  @indent
end

#literalObject

Returns the value of attribute literal.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def literal
  @literal
end

#output_rootObject

Returns the value of attribute output_root.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def output_root
  @output_root
end

#phlex_versionObject

Returns the value of attribute phlex_version.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def phlex_version
  @phlex_version
end

#rootObject

Returns the value of attribute root.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def root
  @root
end

#ruby_uiObject

Returns the value of attribute ruby_ui.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def ruby_ui
  @ruby_ui
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/ruby_ui_converter/configuration.rb', line 5

def verbose
  @verbose
end

Instance Method Details

#enable_rubyui_rules!Object



48
49
50
51
# File 'lib/ruby_ui_converter/configuration.rb', line 48

def enable_rubyui_rules!
  ComponentMap.rubyui_rules(@component_map)
  self
end

#literal?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ruby_ui_converter/configuration.rb', line 44

def literal?
  !!@literal
end

#raw_call(expr) ⇒ Object

Emit a raw (unescaped) output call for the given Ruby expression. Phlex 2 dropped ‘unsafe_raw` in favor of `raw(safe(…))`; Phlex 1 used `unsafe_raw(…)`.



36
37
38
# File 'lib/ruby_ui_converter/configuration.rb', line 36

def raw_call(expr)
  phlex_version.to_i >= 2 ? "raw(safe(#{expr}))" : "unsafe_raw(#{expr})"
end

#ruby_ui?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/ruby_ui_converter/configuration.rb', line 40

def ruby_ui?
  !!@ruby_ui
end

#template_methodObject

Phlex 2 uses ‘view_template`; Phlex 1 used `template`.



29
30
31
# File 'lib/ruby_ui_converter/configuration.rb', line 29

def template_method
  phlex_version.to_i >= 2 ? "view_template" : "template"
end