texsc 0.3.2 → 0.5.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: 1338246224d9ddf219b8b4193767dcb6ddc43314ce84e8e1c6379a08176010f2
4
- data.tar.gz: 740893c232d33535750f17734ae05e160628a40c4994765db96fad1e1186f468
3
+ metadata.gz: '08fb045de44fe6a3e9d660fd9231b172a26b7905d98241e39d3086d0d2c4f7d9'
4
+ data.tar.gz: e2c60a9cb1f3daecd4cf69478c81d427f75cc0629767d2193a6691e7ab83c216
5
5
  SHA512:
6
- metadata.gz: 308b393c03295b853346781afd52bd68052619240715a00aeb12baca4347bbd646ba1d48c58f774faf0a55f59058149544e604e85b3e29459a8304381e4b5e1e
7
- data.tar.gz: d2b2056be3591b0b6c68e7eaa9e96765d8c31ee55dd4ca01591a02168a800d6a59d389d7be6dfa1b7381b73bc9cb423baaddbad9aada087e11dce545f32361c9
6
+ metadata.gz: bcee7468fdd0ea4671873b1269e8095a9af24e325daeee1493f4d71c0495816686094b6ce32c1eae9bbd114da7c220165d28e86da907957d13439fca2c2dcd4a
7
+ data.tar.gz: 9d89d67e6d611e7f83e42df8b40058990052396cea5453bfd37d3e0e027de36fb82c942bb4b2ee2a173c5c89ed2fa67624252723728e3212d6186a59d01b6087
@@ -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/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/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.2'
24
+ VERSION = '0.5.0'
25
25
 
26
26
  STDOUT.sync = true
27
27
 
@@ -32,8 +32,18 @@ require 'slop'
32
32
 
33
33
  begin
34
34
  log = Loog::REGULAR
35
+ args = []
36
+ if File.exist?('.texsc')
37
+ cfg = File.new('.texsc')
38
+ body = File.read(cfg)
39
+ extra = body.split(/\s+/).map(&:strip)
40
+ args += extra
41
+ puts "Found #{body.split(/\n/).length} lines in #{File.absolute_path(cfg)}"
42
+ end
43
+ args += ARGV
44
+
35
45
  begin
36
- opts = Slop.parse(ARGV, strict: true, help: true) do |o|
46
+ opts = Slop.parse(args, strict: true, help: true) do |o|
37
47
  o.banner = "Usage (#{VERSION}): texsc [options] files
38
48
  Options are:"
39
49
  o.string '--pws', 'The location of aspell.en.pws file'
@@ -60,6 +70,7 @@ Options are:"
60
70
  log.debug("PWS with an additional dictionary is here: #{opts[:pws]}")
61
71
  opts[:pws] = File.expand_path(opts[:pws])
62
72
  log.debug("The real path of PWS is: #{opts[:pws]}")
73
+ raise "The PWS file #{opts[:pws].inspect} is not found" unless File.exist?(opts[:pws])
63
74
  end
64
75
  errors = 0
65
76
  files = 0
@@ -73,6 +84,14 @@ Options are:"
73
84
  tex = tex.gsub(/\\begin{#{Regexp.escape(i[:cmd])}}.+\\end{#{Regexp.escape(i[:cmd])}}/m, '')
74
85
  end
75
86
  log.info("Checking #{f} (#{tex.length} chars)...")
87
+ log.debug(
88
+ tex.split("\n").each_with_index.map do |t, i|
89
+ if t.start_with?('---')
90
+ log.info("Line #{i + 1} starts with '---', this may lead to unexpected errors")
91
+ end
92
+ format('%<pos>4d: %<line>s', pos: i + 1, line: t)
93
+ end.join("\n")
94
+ )
76
95
  cmd = [
77
96
  'aspell',
78
97
  "--ignore=#{opts['min-word-length']}",
@@ -93,10 +112,16 @@ Options are:"
93
112
  raise "Failed to run aspell, exit code is #{status}"
94
113
  end
95
114
  out = stdout.read
96
- unless out.nil?
97
- out.split("\n").select { |t| t.start_with?('&') }.each do |t|
98
- log.info(t)
99
- errors += 1
115
+ if out.nil?
116
+ log.info('aspell produced no output, hm...')
117
+ else
118
+ lines = out.split("\n")
119
+ log.debug("aspell produced #{lines.length} lines of output")
120
+ lines.each_with_index do |t, i|
121
+ if t.start_with?('&')
122
+ log.info("[#{i}] #{t}")
123
+ errors += 1
124
+ end
100
125
  end
101
126
  end
102
127
  end
@@ -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
 
@@ -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.2'
35
+ s.version = '0.5.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'
@@ -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.2
4
+ version: 0.5.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-08-07 00:00:00.000000000 Z
11
+ date: 2020-10-14 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