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: 7c22baf0aaf834bd40ba22c2d1bf43d2e3bd26fc
4
- data.tar.gz: 36ae2cd0d3825293282920d2f515444d5156c19c
3
+ metadata.gz: 4e1e87ed71d806e2d6a1a079359937696701793d
4
+ data.tar.gz: e7599f9ad981c463c51d5be524ec1847866f958d
5
5
  SHA512:
6
- metadata.gz: 38ecd808d23559f84f0619978d09f69f6c152d8fdaf6309a8946b366fa0fb6ce2a37d8203a44f58f28938e041c43285fa31cb964da16961294ca43ca9e7daa2e
7
- data.tar.gz: 5734f5774ec482f63c239c31921b22fad6ec1e0216ccbd48a0b8915288aa787447d0f547e2fbab4b6b2f46165f8087afe78ad7ff8d04f8029f0ae2daf5ed6c45
6
+ metadata.gz: 71fa1b31d75d856293dbc648aff58d7f590ed2e7f9405cd9bb5660b2dc7fe549ab03518d9d1617fb5af9cd3bcb1a282710dd42fcc7b21067a3dd0be617a47c1e
7
+ data.tar.gz: 7bdfc89cbc2a543d67c657efc83f515ab27394f3d52b54401f2e3fca878bf5542ab98030c53dafe50a8956a77a3e67e41cea91989c9aa863fee5dc28a396010d
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "pry"
26
26
  spec.add_development_dependency "simplecov"
27
27
  spec.add_development_dependency "ass_maintainer-info_base"
28
+ spec.add_development_dependency "mocha"
28
29
  end
@@ -108,6 +108,7 @@ module AssOle
108
108
 
109
109
  require 'ass_ole/snippets/shared/mapped'
110
110
  require 'ass_ole/snippets/shared/array'
111
+ require 'ass_ole/snippets/shared/binary_data'
111
112
  end
112
113
  end
113
114
  end
@@ -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
@@ -2,7 +2,7 @@ module AssOle
2
2
  module Snippets
3
3
  #
4
4
  module Shared
5
- VERSION = '0.1.2'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
8
8
  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.2
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: 2016-12-05 00:00:00.000000000 Z
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: