xmp2assert 8 → 9

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: 14c558b16e211cc2198f003c708b87acebe83406
4
- data.tar.gz: ed3a7c00a1d6b5bda7e734b00d0cd43ba1954acb
3
+ metadata.gz: 5ae8c02650ca81c693170d40a67874a8622a3601
4
+ data.tar.gz: 4a9dbbc7a6138af3430254152e545e605a742177
5
5
  SHA512:
6
- metadata.gz: ff38753c94e6c2b553efca12c639c77d91c4872cb5d539f26bb862e92dba881288e469c7fd67063a055b884b0f94863aed614befe7693aa61b74728c12bdaefe
7
- data.tar.gz: ce410e98585873f3064f901d6803a86b69f1af44aa0053017b429f7ef8d01e2ef713ab883142d5a06f2fbbe49604fdfe3b39451dd42667b0fbd0e61afdbe8af3
6
+ metadata.gz: 9bf2ea17492c7442179e9c6fb2ea43e0975a99e506d7c4bee1dfacf934a224da6e785fa391355d1ebe88f66d6a576406512ad77c9e2b29bbe9a3de1b70f30cf4
7
+ data.tar.gz: 1ecb3f324149b5cccc53ceb0a8bc5e404c6a76b8b4863f9736430523779c2d1ce6db425a7e2975b80cef5ccd6920626aeb095dfcaa8118bf5d4fc04d6c43ca5f
data/.rubocop.yml CHANGED
@@ -78,6 +78,9 @@ Style/ClassAndModuleChildren:
78
78
  Style/ClassVars:
79
79
  Enabled: false
80
80
 
81
+ Style/ConstantName:
82
+ Enabled: false
83
+
81
84
  Style/ElseAlignment:
82
85
  Enabled: false
83
86
 
@@ -129,9 +132,15 @@ Style/MultilineIfThen:
129
132
  Style/MultilineMethodCallIndentation:
130
133
  Enabled: false
131
134
 
135
+ Style/MutableConstant:
136
+ Enabled: false
137
+
132
138
  Style/Not:
133
139
  Enabled: false
134
140
 
141
+ Style/NumericLiterals:
142
+ Enabled: false
143
+
135
144
  Style/ParallelAssignment:
136
145
  Enabled: false
137
146
 
@@ -29,6 +29,7 @@ require 'test/unit/assertion-failed-error'
29
29
  require_relative 'namespace'
30
30
  require_relative 'quasifile'
31
31
  require_relative 'xmp2rexp'
32
+ require_relative 'converter'
32
33
  require_relative 'renderer'
33
34
  require_relative 'spawn'
34
35
 
@@ -46,7 +47,6 @@ module XMP2Assert::Assertions
46
47
  #
47
48
  # @param script [Quasifile] a ruby script.
48
49
  # @param message [String] extra failure message.
49
- # @param rubyopts [Array<String>] extra opts to pass to ruby process.
50
50
  # @param stdin_data [String] extra stdin to pass to ruby process.
51
51
  # @param opts [Hash] extra opts to pass to Kernel.spawn.
52
52
  def assert_xmp script, message = nil, stdin_data: '', **opts
@@ -339,9 +339,16 @@ class XMP2Assert::Converter
339
339
  xmp = tok
340
340
  end
341
341
  when :comment then
342
+ re = /^#\s*/
342
343
  if xmp then
343
- xmp.to_s.concat tok.to_s.sub(/^#/, '')
344
- tok.yylval = "#\n"
344
+ space = re.match(tok.to_s).to_s.length
345
+ if xmp.__COLUMN__ + 5 <= tok.__COLUMN__ + space # 5 is `# => `
346
+ xmp.to_s.concat tok.to_s.sub(re, ' ')
347
+ tok.yylval = "#\n"
348
+ else
349
+ # dedent
350
+ xmp = nil
351
+ end
345
352
  else
346
353
  xmp = nil
347
354
  end
@@ -63,7 +63,7 @@ class XMP2Assert::Parser < Ripper
63
63
 
64
64
  def on_comment c
65
65
  case c
66
- when /^# ([~=!>]>) / then
66
+ when /^# ([~=!>]>)(?: |$)/ then
67
67
  yylex = $1.intern
68
68
  yylval = $'
69
69
  else
@@ -24,4 +24,4 @@
24
24
  # SOFTWARE.
25
25
  ;
26
26
 
27
- XMP2Assert::VERSION = 8
27
+ XMP2Assert::VERSION = 9
@@ -48,7 +48,7 @@ module XMP2Assert::XMP2Rexp
48
48
  # :NOTE: we are editing regular expressions using regular expressions. In
49
49
  # order to hack this method you must be a seasoned regular expression
50
50
  # craftsperson who can count backslashes at ease.
51
- src = Regexp.escape xmp.chomp
51
+ src = Regexp.escape xmp.strip
52
52
  src.gsub!(/([^\\])(\\n|\\ )+/, '\\1\s+')
53
53
  src.gsub!(/(#<[\w:]+?:)0x[0-9a-f]+/, '\\10x[0-9a-f]+')
54
54
  src.gsub!(/\\\.rb:\d+/, '\\.rb:\d+')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmp2assert
3
3
  version: !ruby/object:Gem::Version
4
- version: '8'
4
+ version: '9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urabe, Shyouhei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler