ass_ole-snippets-shared 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1e87ed71d806e2d6a1a079359937696701793d
|
4
|
+
data.tar.gz: e7599f9ad981c463c51d5be524ec1847866f958d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71fa1b31d75d856293dbc648aff58d7f590ed2e7f9405cd9bb5660b2dc7fe549ab03518d9d1617fb5af9cd3bcb1a282710dd42fcc7b21067a3dd0be617a47c1e
|
7
|
+
data.tar.gz: 7bdfc89cbc2a543d67c657efc83f515ab27394f3d52b54401f2e3fca878bf5542ab98030c53dafe50a8956a77a3e67e41cea91989c9aa863fee5dc28a396010d
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module AssOle
|
2
|
+
module Snippets
|
3
|
+
module Shared
|
4
|
+
# Snippet for puck/unpack
|
5
|
+
# data to/from 1C BinaryData
|
6
|
+
module BinaryData
|
7
|
+
require 'tempfile'
|
8
|
+
is_ole_snippet
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
class TempFile
|
12
|
+
include AssOle::Snippets::IsSnippet::WinPath
|
13
|
+
|
14
|
+
attr_reader :data
|
15
|
+
def initialize(data)
|
16
|
+
@data = data
|
17
|
+
end
|
18
|
+
|
19
|
+
def win_path
|
20
|
+
real_win_path path
|
21
|
+
end
|
22
|
+
|
23
|
+
def write
|
24
|
+
temp_file.write(data)
|
25
|
+
temp_file.close
|
26
|
+
end
|
27
|
+
|
28
|
+
def read
|
29
|
+
temp_file.open
|
30
|
+
temp_file.read
|
31
|
+
end
|
32
|
+
|
33
|
+
def temp_file
|
34
|
+
@temp_file ||= Tempfile.new('ass_ole_bin_data')
|
35
|
+
end
|
36
|
+
|
37
|
+
def exist?
|
38
|
+
return false unless path
|
39
|
+
File.exist? path
|
40
|
+
end
|
41
|
+
|
42
|
+
def rm!
|
43
|
+
temp_file.unlink if exist?
|
44
|
+
end
|
45
|
+
|
46
|
+
def path
|
47
|
+
temp_file.path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Packing data to 1C BinaryData
|
52
|
+
# @param data data for packing
|
53
|
+
# @return [WIN32OLE]
|
54
|
+
def binary_data(data)
|
55
|
+
temp_file = TempFile.new(data)
|
56
|
+
temp_file.write
|
57
|
+
result = newObject('BinaryData', temp_file.win_path)
|
58
|
+
result
|
59
|
+
ensure
|
60
|
+
temp_file.rm!
|
61
|
+
end
|
62
|
+
|
63
|
+
# Unpacking data form 1C BinaryData
|
64
|
+
# @param ole_bin_data [WIN32OLE] 1C BinaryData
|
65
|
+
def binary_data_get(ole_bin_data)
|
66
|
+
temp_file = TempFile.new(nil)
|
67
|
+
temp_file.temp_file.close
|
68
|
+
ole_bin_data.Write(temp_file.win_path)
|
69
|
+
temp_file.read
|
70
|
+
ensure
|
71
|
+
temp_file.rm!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Vlasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ass_ole
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mocha
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description:
|
112
126
|
email:
|
113
127
|
- leoniv.vlasov@gmail.com
|
@@ -126,6 +140,7 @@ files:
|
|
126
140
|
- bin/setup
|
127
141
|
- lib/ass_ole/snippets/shared.rb
|
128
142
|
- lib/ass_ole/snippets/shared/array.rb
|
143
|
+
- lib/ass_ole/snippets/shared/binary_data.rb
|
129
144
|
- lib/ass_ole/snippets/shared/mapped.rb
|
130
145
|
- lib/ass_ole/snippets/shared/version.rb
|
131
146
|
homepage: https://github.com/leoniv/ass_ole-snippets-shared
|
@@ -152,4 +167,3 @@ signing_key:
|
|
152
167
|
specification_version: 4
|
153
168
|
summary: Shared snippets for ass_ole gem
|
154
169
|
test_files: []
|
155
|
-
has_rdoc:
|