texsc 0.4.0 → 0.5.1

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: 66cf2c3cd1fdf24062daf97f76e2a1d2a9bbc7496d4de4b110863fa9a05e34f7
4
- data.tar.gz: 9482805d7979f80530858c721bcccb1cc80f9b01a59edf3c79e320a22979a90a
3
+ metadata.gz: 5c17175ccf4ff188118c169998a047fcffff963bba7bb6c0091e8009ab649765
4
+ data.tar.gz: 676f6c7eb559122c01aa94850f26341486ca3d69c171a23a8b79a987179919e4
5
5
  SHA512:
6
- metadata.gz: 37f58dc30b1ccadd1edf187b5264d2f95d078c9502ab946711728c88f08bde644dd78a8285b25cec7f793ea5103cf5c8657e5b312fb04000068e1ed429bb19a6
7
- data.tar.gz: 7477be10ec95d87d4a39429fedb65fa132227afa3b14c5238a5e470eaf7e64f9248473cb92d9e3306c5d8f75ad0cb22cb88c2ef0b12075b09dd003d85941e94a
6
+ metadata.gz: 4c63654aeaf9750b6b4084d112b0ccfd5c3460f679e8361027e2955d0c10a48c714bd8e3d177249fc5d14119697d5cea4544d551e3d5208d9589bfacf89841f2
7
+ data.tar.gz: b0714b11c3c1dcb4eff8463314c5bf195f373c034dba9600aa1a5c732cc30fcd1b3911970157d5c843d0d5cc67543502629f036c8d4b7861b18444b0fd036aae
data/.rubocop.yml CHANGED
@@ -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/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Yegor Bugayenko
1
+ # Copyright (c) 2020-2021 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2020 Yegor Bugayenko
3
+ # Copyright (c) 2020-2021 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/README.md CHANGED
@@ -14,6 +14,8 @@
14
14
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/texsc.svg)](https://codecov.io/github/yegor256/texsc?branch=master)
15
15
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/texsc)](https://hitsofcode.com/view/github/yegor256/texsc)
16
16
 
17
+ Read this blog post: [_Spell Check Your LaTeX Writings Using GNU Aspell_](https://www.yegor256.com/2020/10/06/latex-spell-checking.html)
18
+
17
19
  This tool simplies the usage of [GNU aspell](http://aspell.net/)
18
20
  (you must have it installed)
19
21
  for spell-checking of LaTeX files.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2020 Yegor Bugayenko
3
+ # Copyright (c) 2020-2021 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/bin/texsc CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (c) 2020 Yegor Bugayenko
4
+ # Copyright (c) 2020-2021 Yegor Bugayenko
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the 'Software'), to deal
@@ -21,19 +21,30 @@
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.4.0'
24
+ VERSION = '0.5.1'
25
25
 
26
26
  STDOUT.sync = true
27
27
 
28
28
  require 'backtrace'
29
29
  require 'loog'
30
30
  require 'open3'
31
+ require 'shellwords'
31
32
  require 'slop'
32
33
 
33
34
  begin
34
35
  log = Loog::REGULAR
36
+ args = []
37
+ if File.exist?('.texsc')
38
+ cfg = File.new('.texsc')
39
+ body = File.read(cfg)
40
+ extra = body.split(/\s+/).map(&:strip)
41
+ args += extra
42
+ puts "Found #{body.split(/\n/).length} lines in #{File.absolute_path(cfg)}"
43
+ end
44
+ args += ARGV
45
+
35
46
  begin
36
- opts = Slop.parse(ARGV, strict: true, help: true) do |o|
47
+ opts = Slop.parse(args, strict: true, help: true) do |o|
37
48
  o.banner = "Usage (#{VERSION}): texsc [options] files
38
49
  Options are:"
39
50
  o.string '--pws', 'The location of aspell.en.pws file'
@@ -60,6 +71,7 @@ Options are:"
60
71
  log.debug("PWS with an additional dictionary is here: #{opts[:pws]}")
61
72
  opts[:pws] = File.expand_path(opts[:pws])
62
73
  log.debug("The real path of PWS is: #{opts[:pws]}")
74
+ raise "The PWS file #{opts[:pws].inspect} is not found" unless File.exist?(opts[:pws])
63
75
  end
64
76
  errors = 0
65
77
  files = 0
@@ -74,18 +86,23 @@ Options are:"
74
86
  end
75
87
  log.info("Checking #{f} (#{tex.length} chars)...")
76
88
  log.debug(
77
- tex.split("\n")
78
- .each_with_index.map { |t, i| format('%<pos>4d: %<line>s', pos: i + 1, line: t) }
79
- .join("\n")
89
+ tex.split("\n").each_with_index.map do |t, i|
90
+ if t.start_with?('---')
91
+ log.info("Line #{i + 1} starts with '---', this may lead to unexpected errors")
92
+ end
93
+ format('%<pos>4d: %<line>s', pos: i + 1, line: t)
94
+ end.join("\n")
80
95
  )
81
96
  cmd = [
82
97
  'aspell',
83
- "--ignore=#{opts['min-word-length']}",
98
+ Shellwords.escape("--ignore=#{opts['min-word-length']}"),
84
99
  '--dont-tex-check-comments',
85
100
  '--lang=en',
86
101
  '--mode=tex',
87
- opts[:pws] ? "-p #{opts[:pws]}" : '',
88
- ignores.map { |i| "--add-tex-command '#{i[:cmd]} #{i[:opts]}'" }.join(' '),
102
+ opts[:pws] ? "-p #{Shellwords.escape(opts[:pws])}" : '',
103
+ ignores.map do |i|
104
+ "--add-tex-command '#{Shellwords.escape(i[:cmd])} #{Shellwords.escape(i[:opts])}'"
105
+ end.join(' '),
89
106
  'pipe'
90
107
  ].join(' ')
91
108
  log.debug(cmd)
@@ -102,7 +119,7 @@ Options are:"
102
119
  log.info('aspell produced no output, hm...')
103
120
  else
104
121
  lines = out.split("\n")
105
- log.info("aspell produced #{lines.length} lines of output")
122
+ log.debug("aspell produced #{lines.length} lines of output")
106
123
  lines.each_with_index do |t, i|
107
124
  if t.start_with?('&')
108
125
  log.info("[#{i}] #{t}")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2020 Yegor Bugayenko
3
+ # Copyright (c) 2020-2021 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2020 Yegor Bugayenko
3
+ # Copyright (c) 2020-2021 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/texsc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2020 Yegor Bugayenko
3
+ # Copyright (c) 2020-2021 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -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.4.0'
35
+ s.version = '0.5.1'
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,7 +46,7 @@ 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'
49
+ s.add_runtime_dependency 'slop', '~> 4.8'
50
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'
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.4.0
4
+ version: 0.5.1
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-30 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -44,14 +44,14 @@ 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