texsc 0.4.2 → 0.6.0

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: e7f17174e45a527a1bbf5d038d2e36afa495654a8fd0144dd7b3d2877b75f8c3
4
- data.tar.gz: 811be64333228d2d61a2ba50e1db531d78649017611a8e5e56d4cbaddee7d1c7
3
+ metadata.gz: 1a0b900b5f83d63e4125937fd67a0ee1f633278fe34a5a38393057fa4a604019
4
+ data.tar.gz: 2dc1b9b642e1789a7f4bdc0441c46f3bed2de18e4c59fefa93ae313ec19ed208
5
5
  SHA512:
6
- metadata.gz: afc5ea51b0e7d08da720c549b24dfd6df4547f040830de879e1fa94c084613b1f4549127a74a9f41db5c4f2835f63ec6c85508746f93f75c70229de088723af5
7
- data.tar.gz: 516899e654760a261516f170f222d3e6d7ceeec2bf6c6f9963e1632222b62dbb70f24414c2f6b578e034aa9880310ac899bbad176fce0b3ee87fa229fdd136d9
6
+ metadata.gz: b943bf18daae7bbb2d1af521a6fc2c4e2477347b4c661a90a4a0cc1f97264fa776afadecf0a68422846b48bec9abdbb241f39ddc8df362067b53077ed56a11e3
7
+ data.tar.gz: cc92c623781f8989dab859ebd07df50cd7c7757ca8f678ddc3be4c6da9065e1610fc8e29735d95a73fff715be3284e2065e897a3362b534ccc04f7c4618c529e
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.2'
24
+ VERSION = '0.6.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
 
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'
@@ -55,15 +66,17 @@ Options are:"
55
66
  rescue Slop::Error => ex
56
67
  raise ex.message
57
68
  end
58
- raise 'Try --help' if opts.arguments.empty?
69
+ candidates = opts.arguments
70
+ candidates += Dir['*.tex'] if candidates.empty?
59
71
  if opts[:pws]
60
72
  log.debug("PWS with an additional dictionary is here: #{opts[:pws]}")
61
73
  opts[:pws] = File.expand_path(opts[:pws])
62
74
  log.debug("The real path of PWS is: #{opts[:pws]}")
75
+ raise "The PWS file #{opts[:pws].inspect} is not found" unless File.exist?(opts[:pws])
63
76
  end
64
77
  errors = 0
65
78
  files = 0
66
- opts.arguments.each do |f|
79
+ candidates.each do |f|
67
80
  tex = File.read(f)
68
81
  ignores = opts[:ignore].map do |e|
69
82
  c, o = e.split(':')
@@ -83,12 +96,14 @@ Options are:"
83
96
  )
84
97
  cmd = [
85
98
  'aspell',
86
- "--ignore=#{opts['min-word-length']}",
99
+ Shellwords.escape("--ignore=#{opts['min-word-length']}"),
87
100
  '--dont-tex-check-comments',
88
101
  '--lang=en',
89
102
  '--mode=tex',
90
- opts[:pws] ? "-p #{opts[:pws]}" : '',
91
- ignores.map { |i| "--add-tex-command '#{i[:cmd]} #{i[:opts]}'" }.join(' '),
103
+ opts[:pws] ? "-p #{Shellwords.escape(opts[:pws])}" : '',
104
+ ignores.map do |i|
105
+ "--add-tex-command '#{Shellwords.escape(i[:cmd])} #{Shellwords.escape(i[:opts])}'"
106
+ end.join(' '),
92
107
  'pipe'
93
108
  ].join(' ')
94
109
  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.2'
35
+ s.version = '0.6.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.2
4
+ version: 0.6.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-18 00:00:00.000000000 Z
11
+ date: 2021-07-16 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