Class: Playwright::CLI::Template
- Inherits:
-
Object
- Object
- Playwright::CLI::Template
- Includes:
- Utils::Display
- Defined in:
- lib/playwright/cli/template.rb
Constant Summary collapse
- InvalidTemplate =
Class.new(StandardError)
- SIMPLE_TYPE =
:simple
- SIMPLE_TEMPLATE =
'simple_script_template.erb'
- EXPANDED_TYPE =
:expanded
- EXPANDED_TEMPLATE =
'expanded_script_template.erb'
- SUBCOMMAND_TYPE =
:subcommand
- SUBCOMMAND_TEMPLATE =
'version_subcommand_template.erb'
- README_TYPE =
:readme
- README_TEMPLATE =
'script_readme_template.erb'
- SHELL_SCRIPT_TYPE =
:shell_script, SHELL_SCRIPT_TEMPLATE = 'launch_script_template.erb'
- TEMPLATE_MAP =
{ SIMPLE_TYPE => SIMPLE_TEMPLATE, EXPANDED_TYPE => EXPANDED_TEMPLATE, SUBCOMMAND_TYPE => SUBCOMMAND_TEMPLATE, README_TYPE => README_TEMPLATE, SHELL_SCRIPT_TYPE => SHELL_SCRIPT_TEMPLATE }
Instance Attribute Summary collapse
-
#out_file ⇒ Object
readonly
Returns the value of attribute out_file.
-
#script_name ⇒ Object
readonly
Returns the value of attribute script_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(name:, out_file:, type: SIMPLE_TYPE, klass_name: nil, values: {}) ⇒ Template
constructor
A new instance of Template.
- #klass_name ⇒ Object
- #render ⇒ Object
- #val ⇒ Object
Methods included from Utils::Display
Constructor Details
#initialize(name:, out_file:, type: SIMPLE_TYPE, klass_name: nil, values: {}) ⇒ Template
Returns a new instance of Template.
35 36 37 38 39 40 41 |
# File 'lib/playwright/cli/template.rb', line 35 def initialize(name:, out_file:, type: SIMPLE_TYPE, klass_name: nil, values: {}) @script_name = name @out_file = out_file @template_file = Playwright::CLI::TEMPLATES_PATH.join TEMPLATE_MAP[type] @klass_name = klass_name @values = values end |
Instance Attribute Details
#out_file ⇒ Object (readonly)
Returns the value of attribute out_file.
10 11 12 |
# File 'lib/playwright/cli/template.rb', line 10 def out_file @out_file end |
#script_name ⇒ Object (readonly)
Returns the value of attribute script_name.
10 11 12 |
# File 'lib/playwright/cli/template.rb', line 10 def script_name @script_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/playwright/cli/template.rb', line 10 def type @type end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
10 11 12 |
# File 'lib/playwright/cli/template.rb', line 10 def values @values end |
Instance Method Details
#klass_name ⇒ Object
43 44 45 |
# File 'lib/playwright/cli/template.rb', line 43 def klass_name @klass_name || @script_name.gsub('.rb', '').split(/[A-Z\-\_\/]/).map(&:capitalize).join end |
#render ⇒ Object
31 32 33 |
# File 'lib/playwright/cli/template.rb', line 31 def render(*args) new(*args).render end |
#val ⇒ Object
54 55 56 |
# File 'lib/playwright/cli/template.rb', line 54 def val values end |