filex 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '07842dde93309500dc3c9462ba33e530443a84376a4c6e5cf7edce3d5b9843a7'
4
- data.tar.gz: 73b1b04a6b0c0e42693e8ee11d523647b1aeaa57e31238f57ef3aecab64fc6b8
3
+ metadata.gz: 7c06f30e685dd60d4ac9dcdaec214e7a3577504adf9e3a01b49bd5441f3a09b1
4
+ data.tar.gz: 26ae4e902da3aca7127482db62cb0292f73c4fac41aadebda6f40fc1f2cfbd61
5
5
  SHA512:
6
- metadata.gz: da6c1f283a4578ef8e4bc7377fa5da990363db1c3c213783e98aa09f0564f7746999bf76750c4347f3ea10938d3b2414edadfe557c34ad0ab71b61e63e1fe87c
7
- data.tar.gz: 6526c843d4e043e4b996b73640323a0dcc0850b37370a6ad23ed50ed78037b0a10d586cd396cabc210d7e24fd7fa6a206372c77023d0de8d9795f4c41b18ec91
6
+ metadata.gz: 1260552fecb2730fbf4de170a295b1d9c018d107e7cd01f001bd6a48f8ed2fe1e130ab4d07f9601e103223ac0b1c188c3dc110c425f69f91cdafbaf65b31bc8a
7
+ data.tar.gz: 175eeaac4a0b02b57115f4621ee13f12b5af6a2fd79acefdef5f77b439ea013053d99ee13d6c2f1a6cb18594c7525b431dedca7f9a57e571829fb1543a9f6b47
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/filex.gemspec CHANGED
File without changes
data/lib/filex.rb CHANGED
@@ -128,7 +128,7 @@ module Filex
128
128
  end
129
129
 
130
130
  #
131
- # eRubyスクリプト文字列を、ハッシュを用いて置換した内容を1個の文字列に変換
131
+ # eRubyスクリプト文字列を、ハッシュを用いて置換した内容を、1個の文字列に変換
132
132
  #
133
133
  # @param eruby_str [String] eRubyスクリプト文字列
134
134
  # @param data [Hash] eRubyスクリプト置換用ハッシュ
@@ -216,7 +216,7 @@ module Filex
216
216
  # @param str [String] 分割対象文字列
217
217
  # @return [Array<String>] 第0要素 分割文字列の左側部分、第1要素 分割文字列の右側部分
218
218
  def self.hyphen_space(str)
219
- if (m = /^(\s*((\-\s+)+))(.+)$/.match(str))
219
+ if (m = /^(\s*((\-\s+)+))(.*)$/.match(str))
220
220
  left = m[1]
221
221
  right = m[4]
222
222
  end
@@ -233,30 +233,43 @@ module Filex
233
233
  def self.escape_single_quote_yaml_first(line, state)
234
234
  # lineに対して": "での分割を試みる
235
235
  left, right = colon_space(line)
236
- state[:mes].output_info("1|left=#{left}")
236
+ state[:mes].output_info("F1|left=#{left}|right=#{right}")
237
+ # 分割できなければ、lineに対して":"での分割を試みる
237
238
  left, right = colon(line) unless left
238
- state[:mes].output_info("2|left=#{left}")
239
+ state[:mes].output_info("F2|left=#{left}|right=#{right}")
239
240
 
241
+ # 右側部分に"-"が含まれていれば、"- "で区切れるか調べる
240
242
  if right&.index("-")
241
243
  left, right = hyphen_space(line)
242
- state[:mes].output_info("3|left=#{left}")
244
+ state[:mes].output_info("F3|left=#{left}")
243
245
  if left
244
246
  state[:need_quoto] = true
245
247
  state[:mes].output_info("NQ|1|need_quoto=#{state[:need_quoto]}")
246
248
  end
247
249
  end
248
250
 
251
+ # lineが":"が分割できなければ、lineに対して"- "での分割を試みる
249
252
  unless left
250
253
  left, right = hyphen_space(line)
254
+ state[:mes].output_info("F4|left=#{left}|right=#{right}")
255
+ if right&.index("-") == 0
256
+ state[:mes].output_info("F-X|index=0|right.size=#{right.size}")
257
+ if right.size == 1
258
+ left += right
259
+ right = nil
260
+ else
261
+ state[:need_quoto] = true
262
+ end
263
+ end
251
264
  end
252
265
 
266
+ state[:mes].output_info("FE|left=#{left}|right=#{right}")
253
267
  [left, right]
254
268
  end
255
269
 
256
270
  #
257
271
  # YAML形式の文字列に、シングルクォーテーションでのエスケープが必要かを調べる(第2段階)
258
272
  #
259
- # @param line [String] 対象文字列
260
273
  # @param right [String] 対象文字列の分割右側部分
261
274
  # @param state [Hash] 状態
262
275
  # @option state [Messagex] :mes Messagexクラスのインスタンス
@@ -285,18 +298,19 @@ module Filex
285
298
  # @param right [String] 対象文字列の分割右側部分
286
299
  # @return [Array<String>] 第0要素 分割された文字列の左側部分、第1要素 分割された文字列の右側部分
287
300
  def self.escape_single_quote_yaml_second(line, state, left, right)
288
- state[:mes].output_info("4|left=#{left}|right=#{right}")
289
-
290
301
  return [left, right] if right.nil? || right.strip.empty?
291
302
 
303
+ state[:mes].output_info("S1|left=#{left}|right=#{right}")
292
304
  state[:has_quoto] = true if right.index("'")
293
305
 
294
- return [left, right] if right.index(":").nil?
295
-
296
- return([left, right]) if /\d:/.match?(right)
306
+ if right.index(":")
307
+ state[:mes].output_info("S2|left=#{left}|right=#{right}")
297
308
 
309
+ return([left, right]) if /\d:/.match?(right)
310
+ state[:mes].output_info("S3|left=#{left}|right=#{right}")
311
+ end
298
312
  left2, right2 = colon_space(right)
299
- state[:mes].output_info("51|left2=#{left2}|right2=#{right2}")
313
+ state[:mes].output_info("S4|left2=#{left2}|right2=#{right2}")
300
314
 
301
315
  unless left2
302
316
  left2, right2 = check_colon_in_right(right, state)
@@ -305,8 +319,9 @@ module Filex
305
319
  if left2
306
320
  left += left2
307
321
  right = right2
308
- state[:mes].output_info("6|left=#{left}|right=#{right}")
322
+ state[:mes].output_info("S5|left=#{left}|right=#{right}")
309
323
  end
324
+ state[:mes].output_info("S6|left=#{left}|right=#{right}")
310
325
  [left, right]
311
326
  end
312
327
 
@@ -322,17 +337,20 @@ module Filex
322
337
  # @return [void]
323
338
  def self.escape_single_quote_yaml_third(line, state, left, right)
324
339
  return if right.nil? || right.strip.empty?
340
+ state[:mes].output_info("T1|left=#{left}|right=#{right}")
325
341
 
326
342
  return if state[:need_quoto]
343
+ state[:mes].output_info("T2|left=#{left}|right=#{right}")
327
344
 
328
345
  return unless right.index(":") && right.index("*")
346
+ state[:mes].output_info("T3|left=#{left}|right=#{right}")
329
347
 
330
- state[:mes].output_info("1 not need_quoto")
348
+ state[:mes].output_info("T4 not need_quoto")
331
349
  unless right.index("-")
332
350
  state[:need_quoto] = true
333
- state[:mes].output_info("NQ|2|need_quoto=#{state[:need_quoto]}")
351
+ state[:mes].output_info("NQ|T5|need_quoto=#{state[:need_quoto]}")
334
352
  end
335
- state[:mes].output_info("1A need_quoto=#{state[:need_quoto]}")
353
+ state[:mes].output_info("T6 need_quoto=#{state[:need_quoto]}")
336
354
  end
337
355
 
338
356
  #
data/lib/filex/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Filex
2
2
  # バージョン番号
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasuo kominami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-01 00:00:00.000000000 Z
11
+ date: 2019-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler