texsc 0.3.0 → 0.4.2

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: 1f0e7863fdd9141c6d4d448b60e0feabc45b48bfa2652a93a6bce2cc39fd6087
4
- data.tar.gz: 80a989ea2b50f79af5860bb396cbd4a0a6d47aaa9a6bcd368296004c8972b29e
3
+ metadata.gz: e7f17174e45a527a1bbf5d038d2e36afa495654a8fd0144dd7b3d2877b75f8c3
4
+ data.tar.gz: 811be64333228d2d61a2ba50e1db531d78649017611a8e5e56d4cbaddee7d1c7
5
5
  SHA512:
6
- metadata.gz: dc4ee93d540b0fce8255a43bc4c7f1f744de57cd9e38b93f548af9fcc7857d6d8b25bdb3e2012e80a79b3c6c998ec752000a3473aa91919afec550882f0870b9
7
- data.tar.gz: 2d430663f77c0726fc498026dfbad83e94424f0d272f506ff0c2082c23dcebe0ab250d1e665df7e731b9cd2018b79fcf6b5cf04dd4bee2ba5442df345603bbb4
6
+ metadata.gz: afc5ea51b0e7d08da720c549b24dfd6df4547f040830de879e1fa94c084613b1f4549127a74a9f41db5c4f2835f63ec6c85508746f93f75c70229de088723af5
7
+ data.tar.gz: 516899e654760a261516f170f222d3e6d7ceeec2bf6c6f9963e1632222b62dbb70f24414c2f6b578e034aa9880310ac899bbad176fce0b3ee87fa229fdd136d9
@@ -11,7 +11,7 @@ Layout/EndOfLine:
11
11
  Style/MultilineTernaryOperator:
12
12
  Enabled: false
13
13
  Metrics/BlockLength:
14
- Max: 50
14
+ Max: 60
15
15
  Layout/AlignParameters:
16
16
  Enabled: false
17
17
  Layout/EmptyLineAfterGuardClause:
data/bin/texsc CHANGED
@@ -21,7 +21,7 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  # SOFTWARE.
23
23
 
24
- VERSION = '0.3.0'
24
+ VERSION = '0.4.2'
25
25
 
26
26
  STDOUT.sync = true
27
27
 
@@ -65,10 +65,22 @@ Options are:"
65
65
  files = 0
66
66
  opts.arguments.each do |f|
67
67
  tex = File.read(f)
68
- opts[:ignore].each do |e|
69
- tex = tex.gsub(/\\begin{#{e}}.+\\end{#{e}}/m, '')
68
+ ignores = opts[:ignore].map do |e|
69
+ c, o = e.split(':')
70
+ { cmd: c, opts: o || 'p' }
71
+ end
72
+ ignores.each do |i|
73
+ tex = tex.gsub(/\\begin{#{Regexp.escape(i[:cmd])}}.+\\end{#{Regexp.escape(i[:cmd])}}/m, '')
70
74
  end
71
75
  log.info("Checking #{f} (#{tex.length} chars)...")
76
+ log.debug(
77
+ tex.split("\n").each_with_index.map do |t, i|
78
+ if t.start_with?('---')
79
+ log.info("Line #{i + 1} starts with '---', this may lead to unexpected errors")
80
+ end
81
+ format('%<pos>4d: %<line>s', pos: i + 1, line: t)
82
+ end.join("\n")
83
+ )
72
84
  cmd = [
73
85
  'aspell',
74
86
  "--ignore=#{opts['min-word-length']}",
@@ -76,11 +88,7 @@ Options are:"
76
88
  '--lang=en',
77
89
  '--mode=tex',
78
90
  opts[:pws] ? "-p #{opts[:pws]}" : '',
79
- opts[:ignore].map do |e|
80
- cmd, opts = e.split(':')
81
- opts = 'p' if opts.nil?
82
- "--add-tex-command '#{cmd} #{opts}'"
83
- end.join(' '),
91
+ ignores.map { |i| "--add-tex-command '#{i[:cmd]} #{i[:opts]}'" }.join(' '),
84
92
  'pipe'
85
93
  ].join(' ')
86
94
  log.debug(cmd)
@@ -92,9 +100,18 @@ Options are:"
92
100
  log.error(stderr.read)
93
101
  raise "Failed to run aspell, exit code is #{status}"
94
102
  end
95
- stdout.read.split("\n").select { |t| t.start_with?('&') }.each do |t|
96
- log.info(t)
97
- errors += 1
103
+ out = stdout.read
104
+ if out.nil?
105
+ log.info('aspell produced no output, hm...')
106
+ else
107
+ lines = out.split("\n")
108
+ log.debug("aspell produced #{lines.length} lines of output")
109
+ lines.each_with_index do |t, i|
110
+ if t.start_with?('&')
111
+ log.info("[#{i}] #{t}")
112
+ errors += 1
113
+ end
114
+ end
98
115
  end
99
116
  end
100
117
  files += 1
@@ -26,7 +26,7 @@ Feature: Command Line Processing
26
26
  How are you, my dear friiend?
27
27
  \end{document}
28
28
  """
29
- When I run bin/texsc with "article.tex"
29
+ When I run bin/texsc with "--verbose article.tex"
30
30
  Then Exit code is not zero
31
31
  And Stdout contains "& friiend "
32
32
 
@@ -85,6 +85,28 @@ Feature: Command Line Processing
85
85
  When I run bin/texsc with "--ignore nospell:opp article.tex"
86
86
  Then Exit code is zero
87
87
 
88
+ Scenario: Bad LaTeX with complex --ignore can be spell checked
89
+ Given I have a "article.tex" file with content:
90
+ """
91
+ \documentclass{article}
92
+ \begin{document}
93
+ How are you, \begin{nospell}{test}friiend\end{nospell}?
94
+ \end{document}
95
+ """
96
+ When I run bin/texsc with "--ignore nospell:p article.tex"
97
+ Then Exit code is zero
98
+
99
+ Scenario: Bad LaTeX with complex --ignore can be spell checked
100
+ Given I have a "article.tex" file with content:
101
+ """
102
+ \documentclass{article}
103
+ \begin{document}
104
+ How are you, \begin{Nospell*}{test}friiend\end{Nospell*}?
105
+ \end{document}
106
+ """
107
+ When I run bin/texsc with "--ignore Nospell*:p article.tex"
108
+ Then Exit code is zero
109
+
88
110
  Scenario: Bad LaTeX with too short words can be spell checked
89
111
  Given I have a "article.tex" file with content:
90
112
  """
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.rubygems_version = '2.2'
33
33
  s.required_ruby_version = '>= 2.3'
34
34
  s.name = 'texsc'
35
- s.version = '0.3.0'
35
+ s.version = '0.4.2'
36
36
  s.license = 'MIT'
37
37
  s.summary = 'Spell Checker for LaTeX'
38
38
  s.description = 'Simple command-line spell checker for LaTeX documents'
@@ -46,8 +46,8 @@ Gem::Specification.new do |s|
46
46
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
47
47
  s.add_runtime_dependency 'backtrace', '~> 0.3'
48
48
  s.add_runtime_dependency 'loog', '~> 0.2'
49
- s.add_runtime_dependency 'slop', '~> 4.6'
50
- s.add_development_dependency 'codecov', '0.1.10'
49
+ s.add_runtime_dependency 'slop', '~> 4.8'
50
+ s.add_development_dependency 'codecov', '0.2.8'
51
51
  s.add_development_dependency 'cucumber', '~> 1.3.17'
52
52
  s.add_development_dependency 'rake', '12.0.0'
53
53
  s.add_development_dependency 'rubocop', '0.61.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.6'
47
+ version: '4.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.6'
54
+ version: '4.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.10
61
+ version: 0.2.8
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.10
68
+ version: 0.2.8
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber
71
71
  requirement: !ruby/object:Gem::Requirement