texsc 0.4.3 → 0.7.0

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: 287fe4226d8590443fd5fdc6e6f1484f958ebc59fa995b144dd3810e96eb7568
4
- data.tar.gz: 5a4cc39bd64baece9b719e30e181c7362ace4c6768562d117a8501aed0efc46f
3
+ metadata.gz: ef95432484b7b9ba335b54f67ba8a6353ac200f029a02656644b65a08199e9e4
4
+ data.tar.gz: e8f5f024fe483de15e1aad8818c07b145223914a4adfb3ecb8f3725a22335534
5
5
  SHA512:
6
- metadata.gz: 6ca3c9aa54f93f8cc592f89210889fb85c7d2078c461465d0fd0a20189a95852ab50524fbf267c443d7eca8ba4264c9d8fec1fcd19e9897928ee0b524c095430
7
- data.tar.gz: 23481f20b3e4be353df48a77ec4fab49f689465b9fc2f92b8ff3c2ca557136a6969bb65ae7ffc1c7129128aeb5464d93efb341b3bd85bcd41b8413c67a714d05
6
+ metadata.gz: 0dc98754b887f94d392eeab60b88bce43f6fe4c6ca73fc668b837d71824ace15d8952851022bdbaf37fbaf7b6e9e9e18d7bdd5e4e5cf8a6ca15e11ad07c7d563
7
+ data.tar.gz: 36489da384178533cff6b3b7e05d9bed796ff6d735bb3495ed1128a9ec524fad8865a7196f4612ab48b311ec9d947870a592b97cbc2667d6d6144885443a09fd
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.
@@ -55,6 +57,11 @@ this:
55
57
  personal_ws-1.1 en 1 utf-8
56
58
  ```
57
59
 
60
+ To make configuration easier, you can create `.texsc` file next to your
61
+ `.tex` file and place all your command line configuration options over there,
62
+ each one on its own line. You can also have a global configuration file
63
+ at `~/.texsc`, which will be read first.
64
+
58
65
  ## How to contribute
59
66
 
60
67
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
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,33 @@
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.3'
24
+ VERSION = '0.7.0'
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
 
34
+ def config(path)
35
+ args = []
36
+ f = File.expand_path(path)
37
+ if File.exist?(f)
38
+ body = File.read(f)
39
+ args += body.split(/\s+/).map(&:strip)
40
+ puts "Found #{args.length} lines in #{File.absolute_path(f)}"
41
+ end
42
+ args
43
+ end
44
+
33
45
  begin
34
46
  log = Loog::REGULAR
47
+ args = config('~/.texsc') + config('.texsc') + ARGV
48
+
35
49
  begin
36
- opts = Slop.parse(ARGV, strict: true, help: true) do |o|
50
+ opts = Slop.parse(args, strict: true, help: true) do |o|
37
51
  o.banner = "Usage (#{VERSION}): texsc [options] files
38
52
  Options are:"
39
53
  o.string '--pws', 'The location of aspell.en.pws file'
@@ -55,7 +69,8 @@ Options are:"
55
69
  rescue Slop::Error => ex
56
70
  raise ex.message
57
71
  end
58
- raise 'Try --help' if opts.arguments.empty?
72
+ candidates = opts.arguments
73
+ candidates += Dir['*.tex'] if candidates.empty?
59
74
  if opts[:pws]
60
75
  log.debug("PWS with an additional dictionary is here: #{opts[:pws]}")
61
76
  opts[:pws] = File.expand_path(opts[:pws])
@@ -64,7 +79,7 @@ Options are:"
64
79
  end
65
80
  errors = 0
66
81
  files = 0
67
- opts.arguments.each do |f|
82
+ candidates.each do |f|
68
83
  tex = File.read(f)
69
84
  ignores = opts[:ignore].map do |e|
70
85
  c, o = e.split(':')
@@ -84,12 +99,14 @@ Options are:"
84
99
  )
85
100
  cmd = [
86
101
  'aspell',
87
- "--ignore=#{opts['min-word-length']}",
102
+ Shellwords.escape("--ignore=#{opts['min-word-length']}"),
88
103
  '--dont-tex-check-comments',
89
104
  '--lang=en',
90
105
  '--mode=tex',
91
- opts[:pws] ? "-p #{opts[:pws]}" : '',
92
- ignores.map { |i| "--add-tex-command '#{i[:cmd]} #{i[:opts]}'" }.join(' '),
106
+ opts[:pws] ? "-p #{Shellwords.escape(opts[:pws])}" : '',
107
+ ignores.map do |i|
108
+ "--add-tex-command '#{Shellwords.escape(i[:cmd])} #{Shellwords.escape(i[:opts])}'"
109
+ end.join(' '),
93
110
  'pipe'
94
111
  ].join(' ')
95
112
  log.debug(cmd)
data/features/cli.feature CHANGED
@@ -14,7 +14,7 @@ Feature: Command Line Processing
14
14
  How are you, my dear friend?
15
15
  \end{document}
16
16
  """
17
- When I run bin/texsc with "article.tex"
17
+ When I run bin/texsc with ""
18
18
  Then Exit code is zero
19
19
  And Stdout contains "No spelling errors found in 1 file(s)"
20
20
 
@@ -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.3'
35
+ s.version = '0.7.0'
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'
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.3
4
+ version: 0.7.0
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-09-27 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.0.1
174
+ rubygems_version: 3.1.2
175
175
  signing_key:
176
176
  specification_version: 2
177
177
  summary: Spell Checker for LaTeX