review-retrovert 0.2.1 → 0.3.3

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
  SHA256:
3
- metadata.gz: ebc50edd4b9d055120f8b3bf09037009c13e06fed8e12d4492290e790cf7b1b6
4
- data.tar.gz: 3dfd16af4857df3826974080cb01a9dae7e0d57860d09d85991f96fbf2efb41d
3
+ metadata.gz: 4018ff4ea97d4ea7a151e769c871e9d1f91d6c1ce2b18a500ae68a569987d1d0
4
+ data.tar.gz: 862bc4e9be33d25e15a2b1b3bfac1b3f231af1568e35d320ee5458740629ac50
5
5
  SHA512:
6
- metadata.gz: 424021ccdce323bf73bf19db45ddfa2519d3c4c49873560a19479f962ccab1608f64eb3aebba17faec5fb5fe17202ff7f00ec094364ec9bde6e85d84582f8015
7
- data.tar.gz: 15535316f97c3f6d20e60f7ea72d721f3b03eea0f4a321db5075605522877b8e426f771a002995283b1bc7eb296e5e023da16e989f8a8ef0dbcfbbe6834bbc1c
6
+ metadata.gz: 4423300d41d6ba1ad911c99145fa830c8c36a9dd4a54273dda177b27bca65ae8d86bb5300382f28b5bc05abe27ce8fb12c6313fb4967f2244d0583a4c32c1bed
7
+ data.tar.gz: 68d804e35464032a32bc6d4b0cd45f919128fecced2bf4e8692db0e0e9e62212e64c1e4539b943f076e32ea10baf5fdb631d146eb0afaaa465375f4a67b58886
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- review-retrovert (0.2.0)
4
+ review-retrovert (0.3.3)
5
5
  review (>= 3.2.0, < 4.0)
6
6
  thor
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  image_size
16
16
  rouge
17
17
  rubyzip
18
- rouge (3.20.0)
18
+ rouge (3.21.0)
19
19
  rspec (3.9.0)
20
20
  rspec-core (~> 3.9.0)
21
21
  rspec-expectations (~> 3.9.0)
@@ -7,6 +7,8 @@ module ReVIEW
7
7
  desc "convert {review_starter_configfile} {outdir}", "convert Re:VIEW Starter project to Re:VIEW project"
8
8
  method_option "force", aliases: "f", desc: 'Force output', type: :boolean
9
9
  method_option "strict", desc: 'Only process files registered in the catalog', type: :boolean
10
+ method_option "table-br-replace", desc: '@<br>{} in table replace string', type: :string, default: ''
11
+ method_option "table-empty-replace", desc: 'empty cell(.) in table replace string', type: :string, default: ' '
10
12
  def convert(review_starter_configfile, outdir)
11
13
  Converter.execute(review_starter_configfile, outdir, options)
12
14
  end
@@ -9,6 +9,7 @@ module ReVIEW
9
9
 
10
10
  def initialize
11
11
  @basedir = nil
12
+ @srccontentsdir = nil
12
13
  @outimagedir = nil
13
14
  @logger = ReVIEW.logger
14
15
  @configs = YamlConfig.new
@@ -37,10 +38,9 @@ module ReVIEW
37
38
  end
38
39
 
39
40
  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)
41
+ path = File.join(@basedir, @srccontentsdir)
42
+ # outpath = File.join(outdir, srccontentsdir)
43
+ # FileUtils.mkdir_p(outpath)
44
44
  # FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outpath)
45
45
  FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outdir)
46
46
  end
@@ -52,8 +52,13 @@ module ReVIEW
52
52
  outpath = File.join(outdir, outimagedir)
53
53
  FileUtils.mkdir_p(outpath)
54
54
  image_ext = @config['image_ext']
55
+ srcroot = Pathname.new(srcpath)
55
56
  image_ext.each { |ext|
56
- FileUtils.cp_r(Dir.glob(File.join(srcpath, "**/*.#{ext}")), outpath)
57
+ Dir.glob(File.join(srcpath, "**/*.#{ext}")).each { |srcimg|
58
+ outimg = File.join(outpath, Pathname.new(srcimg).relative_path_from(srcroot))
59
+ FileUtils.makedirs(File.dirname(outimg))
60
+ FileUtils.cp(srcimg, outimg)
61
+ }
57
62
  }
58
63
  @configs.rewrite_yml('imagedir', outimagedir)
59
64
  end
@@ -90,8 +95,13 @@ module ReVIEW
90
95
  content = File.read(contentfile)
91
96
  content.gsub!(/(\/\/sideimage\[.*?\]\[.*?\])\[.*?\]/, '\1')
92
97
  content.gsub!(/\/\/sideimage/, '//image')
98
+ content.gsub!(/@<href>{(.*?)#.*?,(.*?)}/, '@<href>{\1,\2}')
93
99
  content.gsub!(/@<href>{(.*?)#.*?}/, '@<href>{\1}')
94
- while !content.gsub!(/(\/\/table.*)@<br>(.*?\/\/})/m, '\1\2').nil? do
100
+ # table 内の @ コマンドは不安定らしい
101
+ while !content.gsub!(/(\/\/table.*)@<br>{}(.*?\/\/})/m, "\\1#{@table_br_replace}\\2").nil? do
102
+ end
103
+ # 空セルが2行になることがあるらしい
104
+ while !content.gsub!(/(\/\/table.*\s)\.(\s.*?\/\/})/m, "\\1#{@table_empty_replace}\\2").nil? do
95
105
  end
96
106
  delete_inline_command(content , 'xsmall')
97
107
  delete_inline_command(content , 'weak')
@@ -104,7 +114,8 @@ module ReVIEW
104
114
  files.each do |content|
105
115
  contentpath = File.join(contentdir, content)
106
116
  unless File.exist?(contentpath)
107
- srcpath = File.join(@basedir, content)
117
+ srcpath = File.join(File.join(@basedir, @srccontentsdir), content)
118
+ # info srcpath
108
119
  if File.exist?(srcpath)
109
120
  FileUtils.cp(srcpath, contentdir)
110
121
  end
@@ -116,7 +127,6 @@ module ReVIEW
116
127
  def update_contents(outdir, options)
117
128
  yamlfile = @config['catalogfile']
118
129
  abspath = File.absolute_path(outdir)
119
- # contentdir = File.join(abspath, @config['contentdir'])
120
130
  contentdir = abspath
121
131
  info 'replace //sideimage to //image'
122
132
  info 'replace starter inline command'
@@ -127,8 +137,9 @@ module ReVIEW
127
137
  update_content_files(outdir, contentdir, catalog.appendix())
128
138
  update_content_files(outdir, contentdir, catalog.postdef())
129
139
  else
130
- copy_contents(outdir)
131
- update_content_files(outdir, contentdir, Dir.glob(File.join(abspath, '*.re')))
140
+ # copy_contents(outdir)
141
+ contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
142
+ update_content_files(outdir, contentdir, contentsfiles)
132
143
  end
133
144
  end
134
145
 
@@ -143,6 +154,7 @@ module ReVIEW
143
154
  @configs.open(yamlfile)
144
155
  @config = @configs.config
145
156
  @basedir = @configs.basedir
157
+ @srccontentsdir = @config['contentdir']
146
158
  end
147
159
 
148
160
  def create_initial_project(outdir, options)
@@ -152,6 +164,8 @@ module ReVIEW
152
164
  end
153
165
 
154
166
  def execute(yamlfile, outdir, options)
167
+ @table_br_replace = options['table-br-replace']
168
+ @table_empty_replace = options['table-empty-replace']
155
169
  load_config(yamlfile)
156
170
  create_initial_project(outdir, options)
157
171
 
@@ -1,5 +1,5 @@
1
1
  module ReVIEW
2
2
  module Retrovert
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: review-retrovert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - srz_zumix
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-28 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor