review-retrovert 0.1.0
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 +7 -0
- data/.editorconfig +13 -0
- data/.gitattributes +5 -0
- data/.github/FUNDING.yml +4 -0
- data/.github/workflows/release.yml +26 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/catalog.yml +49 -0
- data/exe/review-retrovert +5 -0
- data/lib/review/retrovert.rb +11 -0
- data/lib/review/retrovert/cli.rb +23 -0
- data/lib/review/retrovert/converter.rb +169 -0
- data/lib/review/retrovert/version.rb +5 -0
- data/lib/review/retrovert/yamlconfig.rb +130 -0
- data/review-retrovert.code-workspace +8 -0
- data/review-retrovert.gemspec +33 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 935ec51160017f46b8ceed226f0c1faa871f931b99b40bde3fb7d4a0b6967b65
|
4
|
+
data.tar.gz: 5c0aeca7c1228c2a04266b07d6386d54dd1fcb6f6672977d09a9d05002cca78a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1931ae7c86bd07cd1deb1f3ede33d35e4a661cdbdfaa4dea943e2bc962f2a02ee2705bca0506e593184708203db7c687b430c34b13eb34e2f64ac018d471eb8
|
7
|
+
data.tar.gz: 420dfc1580231b004a5de8059b495097486f051985b8fcc4130fd9acaea9c93d1682585ebcdbcadffe557c6d64cf7952bc4f8e5479d1046e62ec8dd2fe03b645
|
data/.editorconfig
ADDED
data/.gitattributes
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
on:
|
2
|
+
push:
|
3
|
+
tags:
|
4
|
+
- 'v*'
|
5
|
+
|
6
|
+
name: Publish
|
7
|
+
jobs:
|
8
|
+
publish:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- name: Set up Ruby 2.6
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
version: 2.6.x
|
16
|
+
- name: Publish to RubyGems
|
17
|
+
run: |
|
18
|
+
gem --version
|
19
|
+
mkdir -p $HOME/.gem
|
20
|
+
touch $HOME/.gem/credentials
|
21
|
+
chmod 0600 $HOME/.gem/credentials
|
22
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
23
|
+
gem build *.gemspec
|
24
|
+
gem push *.gem
|
25
|
+
env:
|
26
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
review-retrovert (0.1.0)
|
5
|
+
review (>= 3.2.0, < 4.0)
|
6
|
+
thor
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.3)
|
12
|
+
image_size (2.0.2)
|
13
|
+
rake (12.3.3)
|
14
|
+
review (3.2.0)
|
15
|
+
image_size
|
16
|
+
rouge
|
17
|
+
rubyzip
|
18
|
+
rouge (3.18.0)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.1)
|
24
|
+
rspec-support (~> 3.9.1)
|
25
|
+
rspec-expectations (3.9.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.2)
|
32
|
+
rubyzip (2.3.0)
|
33
|
+
thor (1.0.1)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
rake (~> 12.0)
|
40
|
+
review-retrovert!
|
41
|
+
rspec (~> 3.0)
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 srz_zumix
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Review::Retrovert
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'review-retrovert'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install review-retrovert
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
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).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/srz-zumix/review-retrovert.
|
32
|
+
|
33
|
+
|
34
|
+
## Develop
|
35
|
+
|
36
|
+
docker run -it --rm -v $(pwd)/../:/github vvakame/review:3.2 bash
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "review/retrovert"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/catalog.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PREDEF:
|
2
|
+
- c000-preface.re
|
3
|
+
|
4
|
+
CHAPS:
|
5
|
+
- 無料で使える CI サービス紹介:
|
6
|
+
- c001-free-ci.re
|
7
|
+
- c010-appveyor.re
|
8
|
+
- c010-azure-pipelines.re
|
9
|
+
- c010-bitrise.re
|
10
|
+
- c010-buddy-works.re
|
11
|
+
- c010-circleci.re
|
12
|
+
- c010-cirrus-ci.re
|
13
|
+
- c010-codefresh.re
|
14
|
+
- c010-codeship.re
|
15
|
+
- c010-drone.re
|
16
|
+
- c010-github-actions.re
|
17
|
+
- c010-semaphore.re
|
18
|
+
- c010-shippable.re
|
19
|
+
- c010-travis-ci.re
|
20
|
+
# - c010-wercker.re
|
21
|
+
- c090-free-others.re
|
22
|
+
- 無料で使える CI サービス比較:
|
23
|
+
- c101-vs-env.re
|
24
|
+
- c102-vs-specs.re
|
25
|
+
- c103-vs-yaml.re
|
26
|
+
- c104-vs-comment-command.re
|
27
|
+
- c105-vs-share.re
|
28
|
+
- c106-vs-security.re
|
29
|
+
- c130-vs-badge.re
|
30
|
+
|
31
|
+
APPENDIX:
|
32
|
+
- c200-appendix.re
|
33
|
+
|
34
|
+
POSTDEF:
|
35
|
+
|
36
|
+
##
|
37
|
+
## ■Tips
|
38
|
+
## 第I部、第II部、…のように「部」を使うには、「CHAPS:」を次のようにする。
|
39
|
+
##
|
40
|
+
## CHAPS:
|
41
|
+
## - 部タイトル:
|
42
|
+
## - chap01.re
|
43
|
+
## - chap02.re
|
44
|
+
## - 部タイトル:
|
45
|
+
## - chap03.re
|
46
|
+
## - chap04.re
|
47
|
+
##
|
48
|
+
## 「部タイトル」の最後に半角の「:」をつけることに注意。
|
49
|
+
##
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "review/retrovert/converter"
|
3
|
+
|
4
|
+
module ReVIEW
|
5
|
+
module Retrovert
|
6
|
+
class CLI < Thor
|
7
|
+
desc "convert {review_starter_configfile} {outdir}", "convert Re:VIEW Starter project to Re:VIEW project"
|
8
|
+
method_option "force", aliases: "f", desc: 'force output', type: :boolean
|
9
|
+
def convert(review_starter_configfile, outdir)
|
10
|
+
Converter.execute(review_starter_configfile, outdir, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "snake {CamelCaseString}", "convert {CamelCaseString} to {snake_case_string}"
|
14
|
+
def snake(str)
|
15
|
+
puts str
|
16
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
17
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
18
|
+
.tr("-", "_")
|
19
|
+
.downcase
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require "review"
|
2
|
+
require 'fileutils'
|
3
|
+
require "review/retrovert/yamlconfig"
|
4
|
+
|
5
|
+
module ReVIEW
|
6
|
+
module Retrovert
|
7
|
+
class Converter
|
8
|
+
attr_accessor :config, :basedir
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@basedir = nil
|
12
|
+
@outimagedir = nil
|
13
|
+
@logger = ReVIEW.logger
|
14
|
+
@configs = YamlConfig.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def error(msg)
|
18
|
+
@logger.error msg
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
def warn(msg)
|
23
|
+
@logger.warn msg
|
24
|
+
end
|
25
|
+
|
26
|
+
def info(msg)
|
27
|
+
@logger.info msg
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_config(outdir)
|
31
|
+
@configs.copy(outdir)
|
32
|
+
end
|
33
|
+
|
34
|
+
def copy_catalog(outdir)
|
35
|
+
yamlfile = @config['catalogfile']
|
36
|
+
FileUtils.copy(File.join(@basedir, yamlfile), File.join(outdir, File.basename(yamlfile)))
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy_contents(outdir)
|
40
|
+
contentdir = @config['contentdir']
|
41
|
+
path = File.join(@basedir, contentdir)
|
42
|
+
outpath = File.join(outdir, contentdir)
|
43
|
+
FileUtils.mkdir_p(outpath)
|
44
|
+
# FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outpath)
|
45
|
+
FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outdir)
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy_images(outdir)
|
49
|
+
imagedir = @config['imagedir']
|
50
|
+
srcpath = File.join(@basedir, imagedir)
|
51
|
+
outimagedir = File.basename(imagedir) # Re:VIEW not support sub-directory
|
52
|
+
outpath = File.join(outdir, outimagedir)
|
53
|
+
FileUtils.mkdir_p(outpath)
|
54
|
+
image_ext = @config['image_ext']
|
55
|
+
image_ext.each { |ext|
|
56
|
+
FileUtils.cp_r(Dir.glob(File.join(srcpath, "**/*.#{ext}")), outpath)
|
57
|
+
}
|
58
|
+
@configs.rewrite_yml('imagedir', outimagedir)
|
59
|
+
end
|
60
|
+
|
61
|
+
def update_config(outdir)
|
62
|
+
@configs.rewrite_yml('contentdir', '.')
|
63
|
+
@configs.rewrite_yml('hook_beforetexcompile', 'null')
|
64
|
+
@configs.rewrite_yml('texstyle', '["reviewmacro"]')
|
65
|
+
end
|
66
|
+
|
67
|
+
def replace_inline_command(content, command, sub)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def delete_inline_command(content, command)
|
72
|
+
# FIXME: 入れ子のフェンス記法({}|$)
|
73
|
+
content.gsub!(/@<#{command}>(?:(\$)|(?:({)|(\|)))((?:.*@<\w*>[\|${].*?[\|$}].*?|.*?)*)(?(1)(\$)|(?(2)(})|(\|)))/){"#{$4}"}
|
74
|
+
end
|
75
|
+
|
76
|
+
def copy_embedded_contents(outdir, content)
|
77
|
+
content.scan(/\#@mapfile\((.*?)\)/).each do |filepath|
|
78
|
+
srcpath = File.join(@basedir, filepath)
|
79
|
+
if File.exist?(srcpath)
|
80
|
+
outpath = File.join(File.absolute_path(outdir), filepath)
|
81
|
+
FileUtils.mkdir_p(File.dirname(outpath))
|
82
|
+
FileUtils.cp(srcpath, outpath)
|
83
|
+
update_content(outpath, outpath)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def update_content(outdir, contentfile)
|
89
|
+
info contentfile
|
90
|
+
content = File.read(contentfile)
|
91
|
+
content.gsub!(/(\/\/sideimage\[.*?\]\[.*?\])\[.*?\]/, '\1')
|
92
|
+
content.gsub!(/\/\/sideimage/, '//image')
|
93
|
+
content.gsub!(/@<href>{(.*?)#.*?}/, '@<href>{\1}')
|
94
|
+
while !content.gsub!(/(\/\/table.*)@<br>(.*?\/\/})/m, '\1\2').nil? do
|
95
|
+
end
|
96
|
+
delete_inline_command(content , 'xsmall')
|
97
|
+
delete_inline_command(content , 'weak')
|
98
|
+
File.write(contentfile, content)
|
99
|
+
copy_embedded_contents(outdir, content)
|
100
|
+
end
|
101
|
+
|
102
|
+
def update_content_files(outdir, contentdir, contentfiles)
|
103
|
+
files = contentfiles.is_a?(String) ? contentfiles.split(/\R/) : contentfiles
|
104
|
+
files.each do |content|
|
105
|
+
update_content(outdir, File.join(contentdir, content))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def update_contents(outdir)
|
110
|
+
yamlfile = @config['catalogfile']
|
111
|
+
abspath = File.absolute_path(outdir)
|
112
|
+
catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))
|
113
|
+
# contentdir = File.join(abspath, @config['contentdir'])
|
114
|
+
contentdir = abspath
|
115
|
+
info 'replace //sideimage to //image'
|
116
|
+
info 'replace starter inline command'
|
117
|
+
update_content_files(outdir, contentdir, catalog.predef())
|
118
|
+
update_content_files(outdir, contentdir, catalog.chaps())
|
119
|
+
update_content_files(outdir, contentdir, catalog.appendix())
|
120
|
+
update_content_files(outdir, contentdir, catalog.postdef())
|
121
|
+
end
|
122
|
+
|
123
|
+
def clean_initial_project(outdir)
|
124
|
+
FileUtils.rm(File.join(outdir, 'config.yml'))
|
125
|
+
FileUtils.rm(File.join(outdir, 'catalog.yml'))
|
126
|
+
FileUtils.rm_rf(File.join(outdir, 'images'))
|
127
|
+
FileUtils.rm(Dir.glob(File.join(outdir, '*.re')))
|
128
|
+
end
|
129
|
+
|
130
|
+
def load_config(yamlfile)
|
131
|
+
@configs.open(yamlfile)
|
132
|
+
@config = @configs.config
|
133
|
+
@basedir = @configs.basedir
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_initial_project(outdir, options)
|
137
|
+
FileUtils.rm_rf(outdir) if options['force']
|
138
|
+
ReVIEW::Init.execute(outdir)
|
139
|
+
clean_initial_project(outdir)
|
140
|
+
end
|
141
|
+
|
142
|
+
def execute(yamlfile, outdir, options)
|
143
|
+
load_config(yamlfile)
|
144
|
+
create_initial_project(outdir, options)
|
145
|
+
|
146
|
+
copy_config(outdir)
|
147
|
+
copy_catalog(outdir)
|
148
|
+
copy_contents(outdir)
|
149
|
+
copy_images(outdir)
|
150
|
+
update_config(outdir)
|
151
|
+
update_contents(outdir)
|
152
|
+
|
153
|
+
pwd = Dir.pwd
|
154
|
+
Dir.chdir(outdir)
|
155
|
+
updater = ReVIEW::Update.new
|
156
|
+
updater.force = true
|
157
|
+
# updater.backup = false
|
158
|
+
updater.execute()
|
159
|
+
Dir.chdir(pwd)
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.execute(yamlfile, outdir, options)
|
163
|
+
self.new.execute(yamlfile, outdir, options)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module ReVIEW
|
4
|
+
module Retrovert
|
5
|
+
class YamlConfig
|
6
|
+
attr_accessor :config, :config_files, :retrovert_configs, :basedir, :basename
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@config_files = []
|
10
|
+
@retrovert_configs = []
|
11
|
+
@config = ReVIEW::Configure.values
|
12
|
+
end
|
13
|
+
|
14
|
+
def error(msg)
|
15
|
+
ReVIEW.logger.error msg
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
def open(yamlfile)
|
20
|
+
error "#{yamlfile} not found." unless File.exist?(yamlfile)
|
21
|
+
|
22
|
+
begin
|
23
|
+
loader = ReVIEW::YAMLLoader.new
|
24
|
+
@config.deep_merge!(loader.load_file(yamlfile))
|
25
|
+
rescue => e
|
26
|
+
error "yaml error #{e.message}"
|
27
|
+
end
|
28
|
+
|
29
|
+
@basedir = File.absolute_path(File.dirname(yamlfile))
|
30
|
+
@basename = File.basename(yamlfile)
|
31
|
+
|
32
|
+
begin
|
33
|
+
@config.check_version(ReVIEW::VERSION)
|
34
|
+
rescue ReVIEW::ConfigError => e
|
35
|
+
warn e.message
|
36
|
+
end
|
37
|
+
|
38
|
+
# version 2 compatibility
|
39
|
+
unless @config['texdocumentclass']
|
40
|
+
if @config.check_version(2, exception: false)
|
41
|
+
@config['texdocumentclass'] = ['jsbook', 'uplatex,oneside']
|
42
|
+
else
|
43
|
+
@config['texdocumentclass'] = @config['_texdocumentclass']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
file_queue = [ @basename ]
|
48
|
+
loaded_files = {}
|
49
|
+
while file_queue.present?
|
50
|
+
current_file = file_queue.shift
|
51
|
+
yaml = load_yaml(File.expand_path(current_file, @basedir))
|
52
|
+
@config_files << current_file
|
53
|
+
|
54
|
+
if yaml.key?('inherit')
|
55
|
+
inherit_files = parse_inherit(yaml, yamlfile, loaded_files)
|
56
|
+
file_queue = inherit_files + file_queue
|
57
|
+
end
|
58
|
+
if yaml.key?('retrovert')
|
59
|
+
@retrovert_configs << current_file
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_inherit(yaml, yamlfile, loaded_files)
|
65
|
+
files = []
|
66
|
+
|
67
|
+
yaml['inherit'].reverse_each do |item|
|
68
|
+
inherit_file = File.expand_path(item, File.dirname(yamlfile))
|
69
|
+
|
70
|
+
# Check loop
|
71
|
+
if loaded_files[inherit_file]
|
72
|
+
error "Found circular YAML inheritance '#{inherit_file}' in #{yamlfile}."
|
73
|
+
end
|
74
|
+
|
75
|
+
loaded_files[inherit_file] = true
|
76
|
+
files << item
|
77
|
+
end
|
78
|
+
|
79
|
+
files
|
80
|
+
end
|
81
|
+
|
82
|
+
def copy(outdir)
|
83
|
+
@config_files.each { |current_file|
|
84
|
+
FileUtils.copy(File.expand_path(current_file, @basedir), File.join(outdir, current_file))
|
85
|
+
}
|
86
|
+
@basedir = outdir
|
87
|
+
rewrite_retrovert_yml()
|
88
|
+
end
|
89
|
+
|
90
|
+
def rewrite_yml_(yamlfile, key, val)
|
91
|
+
content = File.read(yamlfile)
|
92
|
+
content.gsub!(/^(\s*)#{key}:.*$/, '\1' + "#{key}: #{val}")
|
93
|
+
File.write(yamlfile, content)
|
94
|
+
end
|
95
|
+
|
96
|
+
def rewrite_yml(key, val)
|
97
|
+
config_files.each { |current_file|
|
98
|
+
rewrite_yml_(File.join(@basedir, current_file), key, val)
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def rewrite_retrovert_yml()
|
103
|
+
@retrovert_configs.each { |current_file|
|
104
|
+
yamlfile = File.expand_path(current_file, @basedir)
|
105
|
+
yaml = load_yaml(yamlfile)
|
106
|
+
retrovert = yaml['retrovert']
|
107
|
+
yaml.deep_merge!(retrovert)
|
108
|
+
yaml.delete('retrovert')
|
109
|
+
# YAML.dump(yaml, File.open(yamlfile, "w"))
|
110
|
+
content = Psych.dump(yaml)
|
111
|
+
content.gsub!('---','')
|
112
|
+
File.write(yamlfile, content)
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def load_yaml(filepath)
|
117
|
+
begin
|
118
|
+
yaml = YAML.load_file(filepath)
|
119
|
+
rescue => e
|
120
|
+
error "load error #{e.message}"
|
121
|
+
end
|
122
|
+
if yaml.class == FalseClass
|
123
|
+
raise "#{current_file} is malformed."
|
124
|
+
end
|
125
|
+
return yaml
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'lib/review/retrovert/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "review-retrovert"
|
5
|
+
spec.version = ReVIEW::Retrovert::VERSION
|
6
|
+
spec.authors = ["srz_zumix"]
|
7
|
+
spec.email = ["zumix.cpp@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Re:VIEW Starter to Re:VIEW}
|
10
|
+
spec.description = %q{Re:VIEW Starter to Re:VIEW}
|
11
|
+
spec.homepage = "https://github.com/srz-zumix/review-retrovert"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# spec.metadata["allowed_push_host"] = "http://mygemserver.com"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/srz-zumix/review-retrovert"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/srz-zumix/review-retrovert"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "thor"
|
31
|
+
spec.add_runtime_dependency "review", ['>= 3.2.0', '< 4.0']
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: review-retrovert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- srz_zumix
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
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: review
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '4.0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.2.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4.0'
|
47
|
+
description: Re:VIEW Starter to Re:VIEW
|
48
|
+
email:
|
49
|
+
- zumix.cpp@gmail.com
|
50
|
+
executables:
|
51
|
+
- review-retrovert
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- ".editorconfig"
|
56
|
+
- ".gitattributes"
|
57
|
+
- ".github/FUNDING.yml"
|
58
|
+
- ".github/workflows/release.yml"
|
59
|
+
- ".gitignore"
|
60
|
+
- ".rspec"
|
61
|
+
- ".travis.yml"
|
62
|
+
- CHANGELOG.md
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- catalog.yml
|
71
|
+
- exe/review-retrovert
|
72
|
+
- lib/review/retrovert.rb
|
73
|
+
- lib/review/retrovert/cli.rb
|
74
|
+
- lib/review/retrovert/converter.rb
|
75
|
+
- lib/review/retrovert/version.rb
|
76
|
+
- lib/review/retrovert/yamlconfig.rb
|
77
|
+
- review-retrovert.code-workspace
|
78
|
+
- review-retrovert.gemspec
|
79
|
+
homepage: https://github.com/srz-zumix/review-retrovert
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata:
|
83
|
+
homepage_uri: https://github.com/srz-zumix/review-retrovert
|
84
|
+
source_code_uri: https://github.com/srz-zumix/review-retrovert
|
85
|
+
changelog_uri: https://github.com/srz-zumix/review-retrovert
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.3.0
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.0.3
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Re:VIEW Starter to Re:VIEW
|
105
|
+
test_files: []
|