ass_maintainer-info_bases 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92fb427c9909385868c7652e9f1f2a8b8f1ab123
4
- data.tar.gz: 9d40b97c157d16a587b46feb37aa44b3f815af8a
3
+ metadata.gz: 95dd835223f6fc962a45aeb6a6f7907e25d805c3
4
+ data.tar.gz: e3148beb76453ec283e9ee1bc58e33c695dc288a
5
5
  SHA512:
6
- metadata.gz: b6dcb20352852d448d51ec897f91e5b9138b5827f0252c7f3799475e646c2d001dcefac86ba03050ce37c7e027f69db9f92e9c26842704e50234f0ae6b9a0710
7
- data.tar.gz: 6757a6598d58a1560025d59ea8eba7d89bfc857a172dd97b746dd4bb4f77ea44a1d2f059de78673df2a4453256a26b93d86317f9a3151477fca70cf7b3c91c3a
6
+ metadata.gz: 2df93dd0f5e85f297d3c5af71d86134e47e71f1b3c69f1005d777d0e196fafccd971a55529d0cc6b9d4e7823bbfd74c4c5be329354252fe20a43de63e6543942
7
+ data.tar.gz: fda580e493c02e258278e2582098f076403935453e0fe2887e9d97e9dacdbc88782fb00de1ab751b3727471aaa03e85a2ffd573d953fbd4d751622b1b71e7f1c
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/ass_maintainer-info_bases.svg)](https://badge.fury.io/rb/ass_maintainer-info_bases)
1
2
  # AssMaintainer::InfoBases
2
3
 
3
4
  Gem provides [infobase](https://github.com/leoniv/ass_maintainer-info_base)
@@ -25,7 +26,9 @@ Or install it yourself as:
25
26
 
26
27
  ## Usage
27
28
 
28
- ### `TestInfoBase`
29
+ ### `class AssMaintainer::InfoBases::TestInfoBase`
30
+
31
+ Class for testing 1C:Enterprise application.
29
32
 
30
33
  ```ruby
31
34
  require 'ass_maintainer/info_bases/test_info_base'
@@ -46,6 +49,88 @@ Or install it yourself as:
46
49
 
47
50
  ```
48
51
 
52
+ ### `class AssMaintainer::InfoBases::TmpInfoBase`
53
+
54
+ Temporary infobase. Proper for cases when require make temporary
55
+ 1C application do anything and remove after.
56
+ Temporary infobase is file infobase always. It makes in temporary
57
+ directory.
58
+
59
+ #### Simple example.
60
+
61
+ Convers application xml source to `.cf` file
62
+
63
+ ```ruby
64
+ require 'ass_maintainer/info_bases/tmp_info_base'
65
+
66
+ PLATFORM_REQUIRE = '~> 8.3.10.0'
67
+
68
+ src = File.expand_path('../app.src', __FILE__)
69
+
70
+ # Do in the block with auto remove infobase
71
+ AssMaintainer::InfoBases::TmpInfoBase.make_rm src,
72
+ platform_require: PLATFORM_REQUIRE do |ib|
73
+ ib.db_cfg.dump('tmp/app.cf')
74
+ end
75
+
76
+ # Or remove infobase manually
77
+ tmp_ib = AssMaintainer::InfoBases::TmpInfoBase
78
+ .new(src, platform_require: PLATFORM_REQUIRE)
79
+ tmp_ib.make
80
+ tmp_ib.db_cfg.dump('tmp/app.cf')
81
+ tmp_ib.rm!
82
+
83
+ # Or do with AssMaintainer::InfoBases::TmpInfoBase::Api
84
+
85
+ include AssMaintainer::InfoBases::TmpInfoBase::Api
86
+
87
+ with_tmp_ib src, platform_require: PLATFORM_REQUIRE do |ib|
88
+ ib.db_cfg.dump('tmp/app.cf')
89
+ end
90
+
91
+ ```
92
+
93
+ #### More complex example.
94
+
95
+ Update application `.cf` file up to required version from update files `.cfu`
96
+
97
+ ```ruby
98
+ require 'ass_maintainer/info_bases/tmp_info_base'
99
+
100
+ class Updater < AssMaintainer::InfoBases::TmpInfoBase
101
+ def update_to(cfu_file, force = false)
102
+ designer do
103
+ _UpdateCfg cfu_file do
104
+ _Force if force
105
+ end
106
+ end.run.wait.result.verify!
107
+ end
108
+
109
+ def self.execute(from_cf, cfu_files, cf_file, force = false)
110
+ make_rm from_cf do |ib|
111
+ cfu_files.each do |cfu|
112
+ ib.update_to(cfu, force)
113
+ end
114
+ ib.cfg.dump(cfu_file)
115
+ end
116
+ end
117
+ end
118
+
119
+ from_cf = File.join(templates_root, 'vendor', 'app', '0', '1cv8.cf')
120
+ cf_file = 'tmp/app.v3.cf'
121
+
122
+ templates_root = 'path/to/1c/updates'
123
+ cfu_files = ['1','2','3'].map do |v|
124
+ File.join(templates_root, 'vendor', 'app', v, '1cv8.cfu')
125
+ end
126
+
127
+ Updater.configure do |conf|
128
+ conf.platform_require = '~> 8.3.10.0'
129
+ end
130
+
131
+ Updater.execute(from_cf, cfu_files, cf_file)
132
+ ```
133
+
49
134
  ## Development
50
135
 
51
136
  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.
@@ -1,7 +1,7 @@
1
1
  module AssMaintainer
2
2
  module InfoBases
3
3
  require 'ass_maintainer/info_base'
4
- # Class for for testing 1C:Enterprise application.
4
+ # Class for testing 1C:Enterprise application.
5
5
  # It like {https://github.com/leoniv/ass_maintainer-info_base
6
6
  # AssMaintainer::InfoBase} but {#initialize} accepts two additional
7
7
  # {OPTIONS}:
@@ -0,0 +1,137 @@
1
+ module AssMaintainer
2
+ module InfoBases
3
+ require 'ass_maintainer/info_bases/test_info_base'
4
+ require 'ass_maintainer/info_bases/support'
5
+ # Temporary infobase. Proper for cases when require make temporary
6
+ # 1C application do anything and remove after.
7
+ # Temporary infobase is file infobase always. It makes in temporary
8
+ # directory.
9
+ # @example Convert application xml source to +.cf+ file
10
+ # require 'ass_maintainer/info_bases/tmp_info_base'
11
+ #
12
+ # PLATFORM_REQUIRE = '~> 8.3.10.0'
13
+ #
14
+ # src = File.expand_path('../app.src', __FILE__)
15
+ #
16
+ # # Do in the block with auto remove infobase
17
+ # AssMaintainer::InfoBases::TmpInfoBase.make_rm src,
18
+ # platform_require: PLATFORM_REQUIRE do |ib|
19
+ # ib.db_cfg.dump('tmp/app.cf')
20
+ # end
21
+ #
22
+ # # Or remove infobase manually
23
+ # tmp_ib = AssMaintainer::InfoBases::TmpInfoBase
24
+ # .new(src, platform_require: PLATFORM_REQUIRE)
25
+ # tmp_ib.make
26
+ # tmp_ib.db_cfg.dump('tmp/app.cf')
27
+ # tmp_ib.rm!
28
+ #
29
+ # @example Update application +.cf+ file up to required version from update files +.cfu+
30
+ # require 'ass_maintainer/info_bases/tmp_info_base'
31
+ #
32
+ # class Updater < AssMaintainer::InfoBases::TmpInfoBase
33
+ # def update_to(cfu_file, force = false)
34
+ # designer do
35
+ # _UpdateCfg cfu_file do
36
+ # _Force if force
37
+ # end
38
+ # end.run.wait.result.verify!
39
+ # end
40
+ #
41
+ # def self.execute(from_cf, cfu_files, cf_file, force = false)
42
+ # make_rm from_cf do |ib|
43
+ # cfu_files.each do |cfu|
44
+ # ib.update_to(cfu, force)
45
+ # end
46
+ # ib.cfg.dump(cfu_file)
47
+ # end
48
+ # end
49
+ # end
50
+ #
51
+ # from_cf = File.join(templates_root, 'vendor', 'app', '0', '1cv8.cf')
52
+ # cf_file = 'tmp/app.v3.cf'
53
+ #
54
+ # templates_root = 'path/to/1c/updates'
55
+ # cfu_files = ['1','2','3'].map do |v|
56
+ # File.join(templates_root, 'vendor', 'app', v, '1cv8.cfu')
57
+ # end
58
+ #
59
+ # Updater.configure do |conf|
60
+ # conf.platform_require = '~> 8.3.10.0'
61
+ # end
62
+ #
63
+ # Updater.execute(from_cf, cfu_files, cf_file)
64
+ #
65
+ class TmpInfoBase < AssMaintainer::InfoBases::TestInfoBase
66
+ include Support::TmpPath
67
+ extend Support::TmpPath
68
+
69
+ # Mixin for convenience to use.
70
+ # @example Convert application xml source to +.cf+ file
71
+ # require 'ass_maintainer/info_bases/tmp_info_base'
72
+ #
73
+ # PLATFORM_REQUIRE = '~> 8.3.10.0'
74
+ #
75
+ # # Convert application xml source to .cf file
76
+ # src = File.expand_path('../app.src', __FILE__)
77
+ #
78
+ # include AssMaintainer::InfoBases::TmpInfoBase::Api
79
+ #
80
+ # with_tmp_ib src, platform_require: PLATFORM_REQUIRE do |ib|
81
+ # ib.db_cfg.dump('tmp/app.cf')
82
+ # end
83
+ module Api
84
+ # (see AssMaintainer::InfoBases::TestInfoBase.make_rm)
85
+ def with_tmp_ib(template = nil, **options, &block)
86
+ AssMaintainer::InfoBases::TmpInfoBase
87
+ .make_rm(template, **options, &block)
88
+ end
89
+ end
90
+
91
+ # Make new tmp infoabse and yield it in block
92
+ # after block executing remove tmp infobase
93
+ def self.make_rm(template = nil, **options, &block)
94
+ fail 'Block require' unless block_given?
95
+ ib = new(template, **options)
96
+ ib.make
97
+ begin
98
+ yield ib
99
+ ensure
100
+ ib.rm!
101
+ end
102
+ end
103
+
104
+ def initialize(template = nil, **opts)
105
+ opts_ = opts.dup
106
+ opts_ = opts_.merge! template: template if template
107
+ super *ArgsBuilder.new.args, **opts_
108
+ end
109
+
110
+ def rm!(*_)
111
+ super :yes
112
+ end
113
+
114
+ # @api private
115
+ class ArgsBuilder
116
+ include Support::TmpPath
117
+ include AssLauncher::Api
118
+ def args
119
+ [ib_name, ib_connstr, false]
120
+ end
121
+
122
+ def ib_connstr
123
+ @ib_connstr ||= cs_file(file: ib_path)
124
+ end
125
+
126
+ def ib_name
127
+ @ib_name ||= File.basename(tmp_path('ib')).gsub('-','_')
128
+ end
129
+
130
+ def ib_path
131
+ @ib_path ||= File.join(Dir.tmpdir, ib_name)
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+
@@ -1,5 +1,5 @@
1
1
  module AssMaintainer
2
2
  module InfoBases
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ass_maintainer-info_bases
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.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: 2018-01-09 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ass_maintainer-info_base
@@ -127,6 +127,7 @@ files:
127
127
  - lib/ass_maintainer/info_bases.rb
128
128
  - lib/ass_maintainer/info_bases/support.rb
129
129
  - lib/ass_maintainer/info_bases/test_info_base.rb
130
+ - lib/ass_maintainer/info_bases/tmp_info_base.rb
130
131
  - lib/ass_maintainer/info_bases/version.rb
131
132
  homepage: https://github.com/leoniv/ass_maintainer-info_bases
132
133
  licenses: []