ass_ole-snippets-shared 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c22baf0aaf834bd40ba22c2d1bf43d2e3bd26fc
|
4
|
+
data.tar.gz: 36ae2cd0d3825293282920d2f515444d5156c19c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ecd808d23559f84f0619978d09f69f6c152d8fdaf6309a8946b366fa0fb6ce2a37d8203a44f58f28938e041c43285fa31cb964da16961294ca43ca9e7daa2e
|
7
|
+
data.tar.gz: 5734f5774ec482f63c239c31921b22fad6ec1e0216ccbd48a0b8915288aa787447d0f547e2fbab4b6b2f46165f8087afe78ad7ff8d04f8029f0ae2daf5ed6c45
|
@@ -3,9 +3,10 @@ require 'ass_ole'
|
|
3
3
|
|
4
4
|
module AssOle
|
5
5
|
module Snippets
|
6
|
+
# Shared Ole snippets
|
6
7
|
module Shared
|
7
8
|
# Snippet for serialize and deserilize 1C objects to xml
|
8
|
-
# @note In external runtime it will be cause of a fail in
|
9
|
+
# @note In external runtime it will be cause of a fail in +InfoBase#rm!+
|
9
10
|
# '... /1Cv8.1CD (Errno::EBUSY)' because external connection
|
10
11
|
# realy keep alive
|
11
12
|
module XMLSerializer
|
@@ -27,8 +28,8 @@ module AssOle
|
|
27
28
|
# @return +xml_file+
|
28
29
|
def to_xml_file(obj, xml_file)
|
29
30
|
zxml = newObject 'XMLWriter'
|
30
|
-
|
31
|
-
zxml.openFile(real_win_path(
|
31
|
+
path_ = xml_file.respond_to?(:path) ? xml_file.path : xml_file
|
32
|
+
zxml.openFile(real_win_path(path_))
|
32
33
|
xDTOSerializer.WriteXML zxml, obj
|
33
34
|
xml_file
|
34
35
|
ensure
|
@@ -49,8 +50,8 @@ module AssOle
|
|
49
50
|
# @return [WIN32OLE] 1C object
|
50
51
|
def from_xml_file(xml_file)
|
51
52
|
zxml = newObject 'XMLReader'
|
52
|
-
|
53
|
-
zxml.openFile(real_win_path(
|
53
|
+
path_ = xml_file.respond_to?(:path) ? xml_file.path : xml_file
|
54
|
+
zxml.openFile(real_win_path(path_))
|
54
55
|
obj = xDTOSerializer.ReadXml zxml
|
55
56
|
obj
|
56
57
|
ensure
|
@@ -64,11 +65,11 @@ module AssOle
|
|
64
65
|
|
65
66
|
# Returns 1C query object
|
66
67
|
# @return [WIN32OLE]
|
67
|
-
def query(text,
|
68
|
+
def query(text, temp_tables_manager_ = nil, **params)
|
68
69
|
q = newObject('Query', text)
|
69
|
-
q.TempTablesManager =
|
70
|
-
params.each do |k,v|
|
71
|
-
q.SetParameter(k.to_s,v)
|
70
|
+
q.TempTablesManager = temp_tables_manager_ || temp_tables_manager
|
71
|
+
params.each do |k, v|
|
72
|
+
q.SetParameter(k.to_s, v)
|
72
73
|
end
|
73
74
|
q
|
74
75
|
end
|
@@ -84,7 +85,9 @@ module AssOle
|
|
84
85
|
module Transaction
|
85
86
|
is_ole_snippet
|
86
87
|
|
87
|
-
#
|
88
|
+
# rubocop:disable Metrics/MethodLength
|
89
|
+
|
90
|
+
# @raise [RuntimeError] if nested transaction
|
88
91
|
def do_in_transaction(&block)
|
89
92
|
fail ArgumentError, 'Block require' unless block_given?
|
90
93
|
fail 'Nested transaction is mindless in 1C runtime' if\
|
@@ -94,12 +97,17 @@ module AssOle
|
|
94
97
|
r = instance_eval(&block)
|
95
98
|
commitTransAction
|
96
99
|
r
|
97
|
-
rescue
|
100
|
+
rescue StandardError => e
|
98
101
|
rollBackTransaction
|
99
|
-
|
102
|
+
raise e
|
100
103
|
end
|
101
104
|
end
|
105
|
+
|
106
|
+
# rubocop:enable Metrics/MethodLength
|
102
107
|
end
|
108
|
+
|
109
|
+
require 'ass_ole/snippets/shared/mapped'
|
110
|
+
require 'ass_ole/snippets/shared/array'
|
103
111
|
end
|
104
112
|
end
|
105
113
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module AssOle
|
2
|
+
module Snippets
|
3
|
+
#
|
4
|
+
module Shared
|
5
|
+
# Snippet for worcking with 1C Array object
|
6
|
+
module Array
|
7
|
+
is_ole_snippet
|
8
|
+
|
9
|
+
# Returns new 1C Array
|
10
|
+
# @return [WIN32OLE]
|
11
|
+
def array(*args)
|
12
|
+
args_ = (args.size == 1) && (args[0].is_a? ::Array) ? args[0] : args
|
13
|
+
args_.each_with_object(newObject('Array')) do |val, obj|
|
14
|
+
obj.add val
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module AssOle
|
2
|
+
module Snippets
|
3
|
+
#
|
4
|
+
module Shared
|
5
|
+
# @api private
|
6
|
+
def self.mapped_mixin(module_)
|
7
|
+
module_.instance_eval do
|
8
|
+
define_method :_hash_to_object do |hash_, object_|
|
9
|
+
hash_.each_with_object(object_) do |k_v, obj|
|
10
|
+
obj.Insert((k_v[0].is_a?(Symbol) ? k_v[0].to_s : k_v[0]), k_v[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
private :_hash_to_object
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Snippet for worcking with 1C Map obect
|
18
|
+
module Map
|
19
|
+
Shared.mapped_mixin self
|
20
|
+
# Returns new Map builded from hash
|
21
|
+
# @note If +key.is_a? Symbol+ key will be converts to +String+
|
22
|
+
# @return [WIN32OLE]
|
23
|
+
def map(hash_ = nil, **hash__)
|
24
|
+
hash_ = hash__ if hash_.nil?
|
25
|
+
_hash_to_object(hash_, newObject('Map'))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Snippet for worcking with 1C Structure obect
|
30
|
+
module Structure
|
31
|
+
Shared.mapped_mixin self
|
32
|
+
# Returns new Structure builded from hash
|
33
|
+
# @note (see Map#map)
|
34
|
+
# @return [WIN32OLE]
|
35
|
+
def structure(hash_ = nil, **hash__)
|
36
|
+
hash_ = hash__ if hash_.nil?
|
37
|
+
_hash_to_object(hash_, newObject('Structure'))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ass_ole-snippets-shared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Vlasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ass_ole
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- bin/console
|
126
126
|
- bin/setup
|
127
127
|
- lib/ass_ole/snippets/shared.rb
|
128
|
+
- lib/ass_ole/snippets/shared/array.rb
|
129
|
+
- lib/ass_ole/snippets/shared/mapped.rb
|
128
130
|
- lib/ass_ole/snippets/shared/version.rb
|
129
131
|
homepage: https://github.com/leoniv/ass_ole-snippets-shared
|
130
132
|
licenses: []
|