Class: AssLauncher::Enterprise::Cli::ArgumentsBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ass_launcher/enterprise/cli/arguments_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides DSL for build arguments for run 1C:Enterprise clients.

DSL dynamically generated based on CLI specifications CliSpec For each CLI parameter is assigned a DSL method called like a parameter but whitout parameter key such as TOP_LEVEL_PARAM_KEY or NESTED_LEVEL_PARAM_KEY. DSL methods may be prefixed _ char for escape uppercase name of method. DSL method _SomeParameter and someParameter equal and assigned for /SomParameter or -SomeParameter CLI parameter. DLS methods case insensitive. Top level builder have method IncludeConnectionString#connection_string for pass connection string and convert connection string into arguments array.

Examples:

client = AssLauncher::Enterprise.thick_clients('> 0').sort.last
# Builds arguments for check configuration:

# 1) Use #connection_string DLS method
args = AssLauncher::Enterprise::Cli::ArgumentsBuilder.build_args(
         client, :designer) do
  connection_string 'File="tmp/new.ib";Usr="user";Pwd="password";'
  checkConfig do            # top level CLI parameter '/CheckConfig'
     unreferenceProcedures  # nested parameter '-UnreferenceProcedures'
   end
end
args #=> ["/N", "user",\
# "/P", "password",
# "/F", "C:/cygwin/home/vlv/workspace/ass_launcher/tmp/new.ib",
# "/CheckConfig", "", "-UnreferenceProcedures", ""]

# 2) Without #connection_string DLS method
args = AssLauncher::Enterprise::Cli::ArgumentsBuilder.build_args(
          client, :designer) do
  _N 'user'
  _P 'password'
  _F 'tmp/new.ib'
  _CheckConfig do
    _UnreferenceProcedures
  end
end
args #=> ["/N", "user",
# "/P", "password",
# "/F", "C:/cygwin/home/vlv/workspace/ass_launcher/tmp/new.ib",
# "/CheckConfig", "", "-UnreferenceProcedures", ""]

Raises:

  • (BuildError)

    if could not find parameter

  • (BuildError)

    if argument already build

  • (ArgumentError)

    if invlid value passed in parameter

Defined Under Namespace

Modules: IncludeConnectionString Classes: BuildError

Constant Summary collapse

METHOD_TO_PARAM_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/^_/i
TOP_LEVEL_PARAM_KEY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'/'
NESTED_LEVEL_PARAM_KEY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'-'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli_spec, run_mode, parent_parameter = nil) ⇒ ArgumentsBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ArgumentsBuilder.

Parameters:



99
100
101
102
103
104
105
# File 'lib/ass_launcher/enterprise/cli/arguments_builder.rb', line 99

def initialize(cli_spec, run_mode, parent_parameter = nil)
  @builded_args = []
  @cli_spec = cli_spec
  @parent_parameter = parent_parameter
  @params_stack = []
  @run_mode = run_mode
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (BuildError)

    if could not find parameter

  • (BuildError)

    if argument already build

  • (ArgumentError)

    if invlid value passed in parameter



135
136
137
138
139
140
141
142
# File 'lib/ass_launcher/enterprise/cli/arguments_builder.rb', line 135

def method_missing(method, *args, &block)
  param = param_find(method)
  fail_no_parameter_error(method) unless param
  fail_if_parameter_exist(param)
  add_args(param.to_args(*param_argument_get(param, args)))
  self.builded_args += nested_builder(param).build_args(&block)\
    if block_given?
end

Class Method Details

.build_args(binary_wrapper, run_mode, &block) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns arguments for run 1C:Enterprise client.

Parameters:

Returns:

  • (Array)

    arguments for run 1C:Enterprise client



88
89
90
# File 'lib/ass_launcher/enterprise/cli/arguments_builder.rb', line 88

def self.build_args(binary_wrapper, run_mode, &block)
  new(binary_wrapper.cli_spec, run_mode).build_args(&block)
end

Instance Method Details

#build_args(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluate &block return array of arguments

Raises:

  • (ArgumentError)

    unless block given



119
120
121
122
123
124
125
# File 'lib/ass_launcher/enterprise/cli/arguments_builder.rb', line 119

def build_args(&block)
  fail ArgumentError, 'Block require' unless block_given?
  extend IncludeConnectionString\
    if (parent_parameter.nil? && run_mode != :webclient)
  instance_eval(&block)
  builded_args
end