ass_ole-snippets-shared 0.3.1 → 0.3.2

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: 15ad4297c56ecc803b82f6d11790ac0811678b69
4
- data.tar.gz: 6ac5e824f42a44761fc0020eafce4a3d76462099
3
+ metadata.gz: 5ef8af3522c444ae9dc38adca2ac74a46f6c88a6
4
+ data.tar.gz: 63163372c91ab83d973249f3f0a152ad70084c4d
5
5
  SHA512:
6
- metadata.gz: b65c3b61ff9c4bdf149e595ff51bfeaf505fc52954c99ebcff4373e498581e57d1096dedc67de8b42391238e260f780fdd351fbbd4b36af767bb77d4582a8abd
7
- data.tar.gz: fa74480b38d453141112f1c8f962143165a197d38473badfa980a12f04a6884bee68b8f978906b870ea596e5c4f9f9cc834cb89ff827916c2b508ac1d4866bda
6
+ metadata.gz: 9b17ae1e23d8cd2dce0af0e1d384e9c9a81a19440547ba99cf47e1371cc6ff9fdc6fb5b581f498a379fe8bf2ec0ae1092327fc2dff85c177f04ed5afdbc828e4
7
+ data.tar.gz: b8ea8240651d0bcd64c463c58490581589bf6ea97d6cfe0d1f1b46e2cfcc4448c08f4ed733091b46913882c7b98eb83e1d19e11c76c35b1188e394ceca9e54fc
@@ -15,7 +15,7 @@ module AssOle
15
15
  # vt_wrapper.add f1: 0, f2: 1, f3: 2
16
16
  # end # => WIN32OLE
17
17
  #
18
- # # Make new ValueTable and insert into 3 rows
18
+ # # Make new ValueTable without typing of columns and insert into 3 rows
19
19
  # value_table :f1, :f2, :f3 do |vt_wrapper|
20
20
  # 3.times do |r|
21
21
  # vt_wrapper.add do |row|
@@ -25,6 +25,17 @@ module AssOle
25
25
  # end
26
26
  # end
27
27
  # end # => WIN32OLE
28
+ #
29
+ # # Make new ValueTable with typing of columns and insert into 3 rows
30
+ # value_table f1:%w{String Boolean}, f2:[String, Date], f3:'String,Date' do |vt_wrapper|
31
+ # 3.times do |r|
32
+ # vt_wrapper.add do |row|
33
+ # row.f1 = r
34
+ # row.f2 = 10 + r
35
+ # row.f3 = 20 + r
36
+ # end
37
+ # end
38
+ # end # => WIN32OLE
28
39
  module ValueTable
29
40
  # Warapper for add rows into +ValueTable+
30
41
  # @api private
@@ -55,14 +66,42 @@ module AssOle
55
66
  end
56
67
  end
57
68
 
69
+ module Columns
70
+ def self.make(vtable, columns, columns_with_types, ole_connector)
71
+ to_columns_with_types(columns).merge(columns_with_types)
72
+ .each do |col, types|
73
+ type_desc_ = type_desc(types, ole_connector)
74
+ vtable.Columns.Add(col.to_s, type_desc_) if type_desc_
75
+ vtable.Columns.Add(col.to_s) unless type_desc_
76
+ end
77
+ vtable.Columns
78
+ end
79
+
80
+ def self.type_desc(types, ole_connector)
81
+ return unless types
82
+ types_ = types.clone
83
+ types_ = types_.split(',') if types.is_a? String
84
+ ole_connector.newObject('TypeDescription', types_.join(','))
85
+ end
86
+
87
+ def self.to_columns_with_types(columns)
88
+ r = {}
89
+ columns.each do |col|
90
+ r[col.to_sym] = nil
91
+ end
92
+ r
93
+ end
94
+ end
95
+
58
96
  # @param columns [Array] +ValueTable+ columns
97
+ # @param columns_with_types [Hash] +ValueTable+ columns with column
98
+ # type names [Array] like %w{TypeName OtheTypeName}
99
+ # or [String] like 'TypeName, OtheTypeName'
59
100
  # @yield [Wrapper]
60
101
  # @return [WIN32OLE] 1C +ValueTable+ object
61
- def value_table(*columns, &block)
102
+ def value_table(*columns, **columns_with_types, &block)
62
103
  r = newObject('ValueTable')
63
- columns.each do |coll|
64
- r.Columns.Add(coll.to_s)
65
- end
104
+ Columns.make(r, columns, columns_with_types, ole_connector)
66
105
  r = Wrapper.new(r)
67
106
  yield r if block_given?
68
107
  r.ole
@@ -2,7 +2,7 @@ module AssOle
2
2
  module Snippets
3
3
  #
4
4
  module Shared
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
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.3.1
4
+ version: 0.3.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: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ass_ole