ass_maintainer-info_bases 1.0.1
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 +5 -0
- data/Gemfile +6 -0
- data/README.md +57 -0
- data/Rakefile +10 -0
- data/ass_maintainer-info_bases.gemspec +31 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/lib/ass_maintainer/info_bases.rb +7 -0
- data/lib/ass_maintainer/info_bases/support.rb +17 -0
- data/lib/ass_maintainer/info_bases/test_info_base.rb +202 -0
- data/lib/ass_maintainer/info_bases/version.rb +5 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92fb427c9909385868c7652e9f1f2a8b8f1ab123
|
4
|
+
data.tar.gz: 9d40b97c157d16a587b46feb37aa44b3f815af8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6dcb20352852d448d51ec897f91e5b9138b5827f0252c7f3799475e646c2d001dcefac86ba03050ce37c7e027f69db9f92e9c26842704e50234f0ae6b9a0710
|
7
|
+
data.tar.gz: 6757a6598d58a1560025d59ea8eba7d89bfc857a172dd97b746dd4bb4f77ea44a1d2f059de78673df2a4453256a26b93d86317f9a3151477fca70cf7b3c91c3a
|
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,57 @@
|
|
1
|
+
# AssMaintainer::InfoBases
|
2
|
+
|
3
|
+
Gem provides [infobase](https://github.com/leoniv/ass_maintainer-info_base)
|
4
|
+
classes proper for various use casess.
|
5
|
+
|
6
|
+
What is _infobase_ see
|
7
|
+
[ass_maintainer-infobase](https://github.com/leoniv/ass_maintainer-info_base)
|
8
|
+
project.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'ass_maintainer-info_bases'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install ass_maintainer-info_bases
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### `TestInfoBase`
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'ass_maintainer/info_bases/test_info_base'
|
32
|
+
|
33
|
+
PLATFORM_REQUIRE = '~> 8.3.10.0'
|
34
|
+
|
35
|
+
# Build application from xml src
|
36
|
+
src = File.expand_path('../app.src')
|
37
|
+
fixt = proc do |ib|
|
38
|
+
# filling application data ...
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
ib = AssMaintainer::InfoBases::TestInfoBase
|
43
|
+
.new('test_app', 'File="tmp/test_app"', false,
|
44
|
+
template: src, fixtures: fixt, platform_require: PLATFORM_REQUIRE)
|
45
|
+
ib.rebuild!(:yes)
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/leoniv/ass_maintainer-info_bases.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ass_maintainer/info_bases/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ass_maintainer-info_bases"
|
8
|
+
spec.version = AssMaintainer::InfoBases::VERSION
|
9
|
+
spec.authors = ["Leonid Vlasov"]
|
10
|
+
spec.email = ["leoniv.vlasov@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Provides infobase classes proper for various use cases}
|
13
|
+
spec.description = %q{More about infobase see https://github.com/leoniv/ass_maintainer-info_base}
|
14
|
+
spec.homepage = "https://github.com/leoniv/ass_maintainer-info_bases"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "ass_maintainer-info_base", '~> 1.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
spec.add_development_dependency "simplecov"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "mocha"
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ass_maintainer/info_bases"
|
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
|
+
require "pry"
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module AssMaintainer
|
2
|
+
module InfoBases
|
3
|
+
module Support
|
4
|
+
module TmpPath
|
5
|
+
require 'tempfile'
|
6
|
+
# Generates temporary path's string
|
7
|
+
# @return [String]
|
8
|
+
def tmp_path(ext)
|
9
|
+
tf = Tempfile.new(ext)
|
10
|
+
tf.unlink
|
11
|
+
tf.to_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,202 @@
|
|
1
|
+
module AssMaintainer
|
2
|
+
module InfoBases
|
3
|
+
require 'ass_maintainer/info_base'
|
4
|
+
# Class for for testing 1C:Enterprise application.
|
5
|
+
# It like {https://github.com/leoniv/ass_maintainer-info_base
|
6
|
+
# AssMaintainer::InfoBase} but {#initialize} accepts two additional
|
7
|
+
# {OPTIONS}:
|
8
|
+
# - +:template+ - is template for infobase makes. Template can be +.cf+ or
|
9
|
+
# +.dt+ file path. Also +:template+ cat be path to application +xml+ files
|
10
|
+
# source or object which respons to +#src_root+ and returns path to +xml+
|
11
|
+
# files.
|
12
|
+
# - +:fixtures+ - is object for filling testing application data.
|
13
|
+
# It object must implemets +#call+ method accepts {TestInfoBase} argumet
|
14
|
+
# On default {TestInfoBase} suspects then application already exist and
|
15
|
+
# marks {TestInfoBase} as +read_only+. It means that, on default,
|
16
|
+
# +AssMaintainer::InfoBase::MethodDenied+ will be raised in
|
17
|
+
# {#load_template!} and {#load_fixtures!} if +:template+ or +:fixtures+
|
18
|
+
# options passed. It behavior is protection from destructive actions
|
19
|
+
# with exists application. If you need build new application from template
|
20
|
+
# or filling testing data, set +read_only == false+ explicitly!
|
21
|
+
class TestInfoBase < AssMaintainer::InfoBase
|
22
|
+
# see {#initialize}
|
23
|
+
OPTIONS = {
|
24
|
+
template: nil,
|
25
|
+
fixtures: nil,
|
26
|
+
}
|
27
|
+
|
28
|
+
OPTIONS.each_key do |key|
|
29
|
+
define_method key do
|
30
|
+
options[key]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ALL_OPTIONS = AssMaintainer::InfoBase::OPTIONS.merge OPTIONS
|
35
|
+
|
36
|
+
# @param name [String]
|
37
|
+
# @param connection_string [String AssLauncher::Support::ConnectionString]
|
38
|
+
# @param read_only [false true] flag for read_only infobase
|
39
|
+
# @option options [String #src_root] :template path to template like a
|
40
|
+
# +.cf+, +.dt+ file or dir of XML files. If respond to +#src_root+ then
|
41
|
+
# +#src_root+ must returns path to dir of XML files
|
42
|
+
# @option options [#call] :fixtures object for fill infobase data.
|
43
|
+
# Must implemets method #call accepts {TestInfoBase} argumet
|
44
|
+
# @note +options+ can includes other options defined for
|
45
|
+
# +AssMaintainer::InfoBase+
|
46
|
+
def initialize(name, connection_string, read_only = true, **options)
|
47
|
+
super name, connection_string, read_only
|
48
|
+
@options = validate_options(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def validate_options(options)
|
52
|
+
_opts = options.keys - ALL_OPTIONS.keys
|
53
|
+
fail ArgumentError, "Unknown options: #{_opts}" unless _opts.empty?
|
54
|
+
ALL_OPTIONS.merge(options)
|
55
|
+
end
|
56
|
+
private :validate_options
|
57
|
+
|
58
|
+
# True if +:fixtures+ passed and {#load_template!} successfully
|
59
|
+
# Nil unless +:template+
|
60
|
+
def template_loaded?
|
61
|
+
return unless template
|
62
|
+
@template_loaded || false
|
63
|
+
end
|
64
|
+
|
65
|
+
# True if +:template+ passed and {#load_fixtures!} successfully
|
66
|
+
# Nil unless +:fixtures+
|
67
|
+
def fixtures_loaded?
|
68
|
+
return unless fixtures
|
69
|
+
@fixtures_loaded || false
|
70
|
+
end
|
71
|
+
|
72
|
+
# True if infobase exists and template and fixtures loaded if
|
73
|
+
# +:template+, +:fixtures+ passed
|
74
|
+
def built?
|
75
|
+
exists? && true_if_nil(template_loaded?) &&\
|
76
|
+
true_if_nil(fixtures_loaded?)
|
77
|
+
end
|
78
|
+
|
79
|
+
def true_if_nil(true_false)
|
80
|
+
return true if true_false.nil?
|
81
|
+
true_false
|
82
|
+
end
|
83
|
+
private :true_if_nil
|
84
|
+
|
85
|
+
def make_infobase!
|
86
|
+
super
|
87
|
+
load_template!
|
88
|
+
load_fixtures!
|
89
|
+
self
|
90
|
+
end
|
91
|
+
private :make_infobase!
|
92
|
+
|
93
|
+
# Load +:template+ to application.
|
94
|
+
# @raise [AssMaintainer::InfoBase::MethodDenied] if +#read_only?+
|
95
|
+
# @return [self]
|
96
|
+
def load_template!
|
97
|
+
fail AssMaintainer::InfoBase::MethodDenied, :load_template! if\
|
98
|
+
read_only?
|
99
|
+
@template_loaded = false
|
100
|
+
load_template
|
101
|
+
@template_loaded = true
|
102
|
+
self
|
103
|
+
end
|
104
|
+
|
105
|
+
# Filling application data from +:fixtures+
|
106
|
+
# @raise [AssMaintainer::InfoBase::MethodDenied] if +#read_only?+
|
107
|
+
# @return [self]
|
108
|
+
def load_fixtures!
|
109
|
+
fail AssMaintainer::InfoBase::MethodDenied, :load_fixtures! if\
|
110
|
+
read_only?
|
111
|
+
@fixtures_loaded = false
|
112
|
+
fixtures.call(self) if fixtures
|
113
|
+
@fixtures_loaded = true
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
117
|
+
# Erase application data.
|
118
|
+
# @raise [AssMaintainer::InfoBase::MethodDenied] if +#read_only?+
|
119
|
+
# @return [self]
|
120
|
+
def erase_data!
|
121
|
+
fail AssMaintainer::InfoBase::MethodDenied, :erase_data! if read_only?
|
122
|
+
designer do
|
123
|
+
eraseData
|
124
|
+
end.run.wait.result.verify!
|
125
|
+
self
|
126
|
+
end
|
127
|
+
|
128
|
+
# Erase application data and filling application data from +:fixtures+
|
129
|
+
# @raise (see #erase_data!)
|
130
|
+
# @raise (see #load_fixtures!)
|
131
|
+
# @return [self]
|
132
|
+
def reload_fixtures!
|
133
|
+
erase_data!
|
134
|
+
load_fixtures!
|
135
|
+
self
|
136
|
+
end
|
137
|
+
|
138
|
+
# @api private
|
139
|
+
# @return [Symbol] :cf, :df or :src
|
140
|
+
def template_type
|
141
|
+
return :cf if template_cf?
|
142
|
+
return :dt if template_dt?
|
143
|
+
return :src if template_src?
|
144
|
+
template.to_s
|
145
|
+
end
|
146
|
+
|
147
|
+
# @api private
|
148
|
+
def file_template?(ext)
|
149
|
+
template.to_s =~ %r{\.#{ext}\z} && File.file?(template.to_s)
|
150
|
+
end
|
151
|
+
|
152
|
+
# @api private
|
153
|
+
def template_cf?
|
154
|
+
file_template? 'cf'
|
155
|
+
end
|
156
|
+
|
157
|
+
# @api private
|
158
|
+
def template_dt?
|
159
|
+
file_template? 'dt'
|
160
|
+
end
|
161
|
+
|
162
|
+
# @api private
|
163
|
+
def template_src?
|
164
|
+
File.file?(File.join(src_root, 'Configuration.xml')) if src_root
|
165
|
+
end
|
166
|
+
|
167
|
+
def src_root
|
168
|
+
return template if template.is_a? String
|
169
|
+
return template.src_root if template.respond_to?(:src_root)
|
170
|
+
end
|
171
|
+
private :src_root
|
172
|
+
|
173
|
+
# @api private
|
174
|
+
def load_template
|
175
|
+
return unless template
|
176
|
+
case template_type
|
177
|
+
when :cf then load_cf
|
178
|
+
when :dt then load_dt
|
179
|
+
when :src then load_src
|
180
|
+
else
|
181
|
+
fail "Invalid template: #{template}"
|
182
|
+
end
|
183
|
+
template_type
|
184
|
+
end
|
185
|
+
|
186
|
+
# @api private
|
187
|
+
def load_src
|
188
|
+
cfg.load_xml(src_root) && db_cfg.update
|
189
|
+
end
|
190
|
+
|
191
|
+
# @api private
|
192
|
+
def load_dt
|
193
|
+
restore!(template)
|
194
|
+
end
|
195
|
+
|
196
|
+
# @api private
|
197
|
+
def load_cf
|
198
|
+
cfg.load(template) && db_cfg.update
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ass_maintainer-info_bases
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leonid Vlasov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ass_maintainer-info_base
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.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.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
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: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
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: pry
|
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: mocha
|
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: More about infobase see https://github.com/leoniv/ass_maintainer-info_base
|
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_maintainer-info_bases.gemspec
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/ass_maintainer/info_bases.rb
|
128
|
+
- lib/ass_maintainer/info_bases/support.rb
|
129
|
+
- lib/ass_maintainer/info_bases/test_info_base.rb
|
130
|
+
- lib/ass_maintainer/info_bases/version.rb
|
131
|
+
homepage: https://github.com/leoniv/ass_maintainer-info_bases
|
132
|
+
licenses: []
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.6.13
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Provides infobase classes proper for various use cases
|
154
|
+
test_files: []
|