Class: AssLauncher::Enterprise::WebClient
- Inherits:
-
Object
- Object
- AssLauncher::Enterprise::WebClient
- 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.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ disable_startup_messages: true }
- DEFAULT_VERSION =
'999'
- CLI_TO_WEB_PARAM_NAME =
%r{^/}
Instance Attribute Summary collapse
-
#uri ⇒ URI
Base uri location.
-
#version ⇒ Object
readonly
Version for 1C:Enterprise platform.
Class Method Summary collapse
-
.escape(string) ⇒ Object
Fuckin 1C is bad understand of CGI.escape.
-
.run_modes ⇒ Array<Symbol>
Defined run modes fo client.
Instance Method Summary collapse
- #cli_spec ⇒ Cli::CliSpec
- #initialize(uri = '', version = DEFAULT_VERSION) ⇒ WebClient constructor
-
#location(args = [], **options, &block) ⇒ Object
Build URI location for connect to web infobase.
-
#run_modes ⇒ Array<Symbol>
Defined run modes fo client.
Constructor Details
#initialize(uri = '', version = DEFAULT_VERSION) ⇒ WebClient
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
#uri ⇒ URI
Returns base uri location.
17 18 19 |
# File 'lib/ass_launcher/enterprise/web_client.rb', line 17 def uri @uri end |
#version ⇒ Object (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_modes ⇒ Array<Symbol>
Defined run modes fo client
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_spec ⇒ Cli::CliSpec
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.
109 110 111 112 113 114 115 |
# File 'lib/ass_launcher/enterprise/web_client.rb', line 109 def location(args = [], **, &block) = DEFAULT_OPTIONS.merge args += ['DisableStartupMessages', '']\ if [:disable_startup_messages] args += build_args(&block) if block_given? add_to_query uri.dup, args_to_query(args) end |
#run_modes ⇒ Array<Symbol>
Defined run modes fo client
60 61 62 |
# File 'lib/ass_launcher/enterprise/web_client.rb', line 60 def run_modes self.class.run_modes end |