ass_ole-snippets-shared 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.simplecov +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +10 -0
- data/ass_ole-snippets-shared.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/ass_ole/snippets/shared.rb +105 -0
- data/lib/ass_ole/snippets/shared/version.rb +7 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d74368593982bade07cdd79dbf4b9e7b49109b5
|
4
|
+
data.tar.gz: 1eb28f0eb79a4daa9fe629a4e4e0943610ccc434
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33e040b2db5bac4683deb08b937e43a579a02dbf799247c75ca7bbcccf928e88e1ff735ffffb5f506e12d6b08885d6a63f9a30ec5b10fd33494f13e08985158a
|
7
|
+
data.tar.gz: f5ca24df511adb432b4b053138e6a9fe00d9e2e8ab271c87aa179141ab0f3192e8daf911c5b619feb74871cd80215b47e1ec3e43bae3c8fdc58eaaa03f3a3fb3
|
data/.gitignore
ADDED
data/.simplecov
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SimpleCov.start if ENV['SIMPLECOV']
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# AssOle::Snippets::Shared
|
2
|
+
|
3
|
+
Shared ole snippets for [ass_ole](https://github.com/leoniv/ass_ole)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ass_ole-snippets-shared'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ass_ole-snippets-shared
|
20
|
+
|
21
|
+
## Testing
|
22
|
+
|
23
|
+
$ export SIMPLECOV=YES && rake test
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/leoniv/ass_ole-snippets-shared.
|
28
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ass_ole/snippets/shared/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ass_ole-snippets-shared"
|
8
|
+
spec.version = AssOle::Snippets::Shared::VERSION
|
9
|
+
spec.authors = ["Leonid Vlasov"]
|
10
|
+
spec.email = ["leoniv.vlasov@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Shared snippets for ass_ole gem}
|
13
|
+
spec.homepage = "https://github.com/leoniv/ass_ole-snippets-shared"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "ass_ole"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "ass_maintainer-info_base"
|
28
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ass_ole/snippets/shared"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
|
+
|
13
|
+
# require "irb"
|
14
|
+
# IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'ass_ole/snippets/shared/version'
|
2
|
+
require 'ass_ole'
|
3
|
+
|
4
|
+
module AssOle
|
5
|
+
module Snippets
|
6
|
+
module Shared
|
7
|
+
# Snippet for serialize and deserilize 1C objects to xml
|
8
|
+
# @note In external runtime it will be cause of a fail in {InfoBase#rm!}
|
9
|
+
# '... /1Cv8.1CD (Errno::EBUSY)' because external connection
|
10
|
+
# realy keep alive
|
11
|
+
module XMLSerializer
|
12
|
+
is_ole_snippet
|
13
|
+
|
14
|
+
# Serialize 1C oject to XML string
|
15
|
+
# @param obj [WIN32OLE] 1C object
|
16
|
+
# @return [String]
|
17
|
+
def to_xml(obj)
|
18
|
+
zxml = newObject 'XMLWriter'
|
19
|
+
zxml.SetString
|
20
|
+
xDTOSerializer.WriteXML zxml, obj
|
21
|
+
zxml.close
|
22
|
+
end
|
23
|
+
|
24
|
+
# Serialize 1C oject to XML file
|
25
|
+
# @param obj [WIN32OLE] 1C object
|
26
|
+
# @param xml_file [#path String] target file path
|
27
|
+
# @return +xml_file+
|
28
|
+
def to_xml_file(obj, xml_file)
|
29
|
+
zxml = newObject 'XMLWriter'
|
30
|
+
_path = xml_file.respond_to?(:path) ? xml_file.path : xml_file
|
31
|
+
zxml.openFile(real_win_path(_path))
|
32
|
+
xDTOSerializer.WriteXML zxml, obj
|
33
|
+
xml_file
|
34
|
+
ensure
|
35
|
+
zxml.close
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deserialize 1C object from XML srtring
|
39
|
+
# @param xml [String] xml string
|
40
|
+
# @return [WIN32OLE] 1C object
|
41
|
+
def from_xml(xml)
|
42
|
+
zxml = newObject 'XMLReader'
|
43
|
+
zxml.SetString xml
|
44
|
+
xDTOSerializer.ReadXml zxml
|
45
|
+
end
|
46
|
+
|
47
|
+
# Deserialize 1C object from XML file
|
48
|
+
# @param xml_file [#path String] path to xml file
|
49
|
+
# @return [WIN32OLE] 1C object
|
50
|
+
def from_xml_file(xml_file)
|
51
|
+
zxml = newObject 'XMLReader'
|
52
|
+
_path = xml_file.respond_to?(:path) ? xml_file.path : xml_file
|
53
|
+
zxml.openFile(real_win_path(_path))
|
54
|
+
obj = xDTOSerializer.ReadXml zxml
|
55
|
+
obj
|
56
|
+
ensure
|
57
|
+
zxml.close
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Snippet for worcking with 1C Query object
|
62
|
+
module Query
|
63
|
+
is_ole_snippet
|
64
|
+
|
65
|
+
# Returns 1C query object
|
66
|
+
# @return [WIN32OLE]
|
67
|
+
def query(text, temp_tables_manager = nil, **params)
|
68
|
+
q = newObject('Query', text)
|
69
|
+
q.TempTablesManager = temp_tables_manager || temp_tables_manager()
|
70
|
+
params.each do |k,v|
|
71
|
+
q.SetParameter(k.to_s,v)
|
72
|
+
end
|
73
|
+
q
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns 1C TempTablesManager
|
77
|
+
# @return [WIN32OLE]
|
78
|
+
def temp_tables_manager
|
79
|
+
newObject 'TempTablesManager'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Do in transaction wrapper
|
84
|
+
module Transaction
|
85
|
+
is_ole_snippet
|
86
|
+
|
87
|
+
# @fail [RuntimeError] if nested transaction
|
88
|
+
def do_in_transaction(&block)
|
89
|
+
fail ArgumentError, 'Block require' unless block_given?
|
90
|
+
fail 'Nested transaction is mindless in 1C runtime' if\
|
91
|
+
transactionActive
|
92
|
+
begin
|
93
|
+
beginTransAction
|
94
|
+
r = instance_eval(&block)
|
95
|
+
commitTransAction
|
96
|
+
r
|
97
|
+
rescue Exception => e
|
98
|
+
rollBackTransaction
|
99
|
+
fail e
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ass_ole-snippets-shared
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leonid Vlasov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ass_ole
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ass_maintainer-info_base
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- leoniv.vlasov@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .simplecov
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- ass_ole-snippets-shared.gemspec
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/ass_ole/snippets/shared.rb
|
128
|
+
- lib/ass_ole/snippets/shared/version.rb
|
129
|
+
homepage: https://github.com/leoniv/ass_ole-snippets-shared
|
130
|
+
licenses: []
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.0.14
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Shared snippets for ass_ole gem
|
152
|
+
test_files: []
|
153
|
+
has_rdoc:
|