Class: AssLauncher::Enterprise::WebClient

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

Overview

Abstract 1C:Enterprise client. Provides #location method as URI generator for connection to 1C information base via web browser.

Examples:


# Get webclient usin connection string:
connection_string =\
AssLauncher::Support::ConnectionString.new(
  'ws="http://host:port/infobase"')
wc = AssLauncher::Enterprise::WebClient.new(cs.uri)

#or without connection_string
wc = AssLauncher::Enterprise::WebClient.new('http://host/path')
wc = AssLauncher::Enterprise::WebClient.new('http://host/path')

# Without ArgumentsBulder
wc.location(['O', 'low', 'C', 'passed string',
  'N', '1cuser',
  'P', '1cpassw',
  'Authoff', '']) #=> URI

# With ArgumentsBulder
wc.location do
  _O :Low
  _C 'passed string'
  _N '1cuser'
  _P '1cuser_password'
  wA :-
  oIDA :-
  authOff
  _L 'en'
  vL 'en'
  debuggerURL 'localhost'
  _UsePrivilegedMode
end  #=> URI

Constant Summary collapse

DEFAULT_OPTIONS =
{ disable_startup_messages: true }
DEFAULT_VERSION =
'999'
CLI_TO_WEB_PARAM_NAME =
%r{^/}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = '', version = DEFAULT_VERSION) ⇒ WebClient

Examples:


# Get webclient usin connection string:
connection_string =\
AssLauncher::Support::ConnectionString.new(
  'ws="http://host:port/infobase"')
wc = AssLauncher::Enterprise::WebClient.new(cs.uri)

#or without connection_string
wc = AssLauncher::Enterprise::WebClient.new('http://host/path')

Parameters:

  • uri (String URI) (defaults to: '')

    base infobase location

  • version (String) (defaults to: DEFAULT_VERSION)

    version 1C:Enterprise platform. The #cli_spec depends on the #version. Default supposed max possable version. DEFAULT_VERSION



39
40
41
42
# File 'lib/ass_launcher/enterprise/web_client.rb', line 39

def initialize(uri = '', version = DEFAULT_VERSION)
  @version = Gem::Version.new(version || DEFAULT_VERSION)
  @uri ||= URI(uri || '')
end

Instance Attribute Details

#uriURI

Returns base uri location.

Returns:

  • (URI)

    base uri location



17
18
19
# File 'lib/ass_launcher/enterprise/web_client.rb', line 17

def uri
  @uri
end

#versionObject (readonly)

Version for 1C:Enterprise platform



19
20
21
# File 'lib/ass_launcher/enterprise/web_client.rb', line 19

def version
  @version
end

Class Method Details

.escape(string) ⇒ Object

Fuckin 1C is bad understand of CGI.escape. From escaping exclude: =& and ‘ ’ replaced on ‘%20’



135
136
137
138
139
# File 'lib/ass_launcher/enterprise/web_client.rb', line 135

def self.escape(string)
  string.gsub(/([^ a-zA-Z0-9_.\-=&]+)/) do
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end.gsub(' ', '%20')
end

.run_modesArray<Symbol>

Defined run modes fo client

Returns:

  • (Array<Symbol>)


55
56
57
# File 'lib/ass_launcher/enterprise/web_client.rb', line 55

def self.run_modes
  Cli.defined_modes_for(self)
end

Instance Method Details

#cli_specCli::CliSpec

Returns:



49
50
51
# File 'lib/ass_launcher/enterprise/web_client.rb', line 49

def cli_spec
  @cli_spec ||= AssLauncher::Enterprise::Cli::CliSpec.for(self)
end

#location(args = [], **options, &block) ⇒ Object

Build URI location for connect to web infobase.

We can use Cli::ArgumentsBuilder for build connection string with validation parameters on defined in #cli_spec specifications.

Or we can pass parameters as args array directly.

Examples:

wc = AssLauncher::Enterprise::WebClient.new('http://host/path')

# Without ArgumentsBulder
wc.location(['O', 'low', 'C', 'passed string',
  'N', '1cuser',
  'P', '1cpassw',
  'Authoff', '']) #=> URI

# With ArgumentsBulder
wc.location do
  _O :Low
  _C 'passed string'
  _N '1cuser'
  _P '1cuser_password'
  wA :-
  oIDA :-
  authOff
  _L 'en'
  vL 'en'
  debuggerURL 'localhost'
  _UsePrivilegedMode
end  #=> URI

Parameters:

  • args (Arry) (defaults to: [])
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :disable_startup_messages (bool)

    adds or not ‘/DisableStartupMessages’ flag parameter into args



109
110
111
112
113
114
115
# File 'lib/ass_launcher/enterprise/web_client.rb', line 109

def location(args = [], **options, &block)
  options = DEFAULT_OPTIONS.merge options
  args += ['DisableStartupMessages', '']\
    if options[:disable_startup_messages]
  args += build_args(&block) if block_given?
  add_to_query uri.dup, args_to_query(args)
end

#run_modesArray<Symbol>

Defined run modes fo client

Returns:

  • (Array<Symbol>)


60
61
62
# File 'lib/ass_launcher/enterprise/web_client.rb', line 60

def run_modes
  self.class.run_modes
end