texsc 0.1.0 → 0.2.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: e32f01e9713f452e0ed430e1b86a0336b60c124493f97c3e85534c9ccb82ecb4
4
- data.tar.gz: 969342bbe56d241096a82504328def1a22567779c1f6b97793da92c6c3b6691e
3
+ metadata.gz: 7afe2218441763abfb00eef1e6c2bfba99071e18dd70b63c5d6e9ed92a2109c1
4
+ data.tar.gz: 6f57f9a091a1dfeeb19c41cb6faceefb98ed3686726b2037a2d701c67677a655
5
5
  SHA512:
6
- metadata.gz: 7ea846d38263b985dd1f4e8fc701848e7fba88a661852d1e5aaeb265ca55967544e6ccc1994fadec7e4f5c8542d3743fb8d05c5df1feef795a1b639c124d85d0
7
- data.tar.gz: a0e9b64259720b8e39b321de67e99384865a7f2b7c0220e44b5d736b9beef1fe44aad56338177411d61799ad89359a701eda2f54d7550306955eb89ef024c481
6
+ metadata.gz: aa91ba8ea8c73543141b07bc77a70f303e4d3a1304ef374688283ddb2b7ed78e52e70d0c995cf6c1b840e0ea619af2898f9629f7c5032b2319a3eaf5a5608682
7
+ data.tar.gz: ca00529d0a63fb9fa78ccbc0f0e36bf2b8b50f3af8c398f9f4db2e42ef0b20a2bfe83b3016a2f3fbfd33d08b4de238b31cf0a71973ac9f7f15857ae685cd1f9c
@@ -4,29 +4,15 @@ AllCops:
4
4
  DisplayCopNames: true
5
5
  TargetRubyVersion: 2.3
6
6
 
7
- Style/ClassAndModuleChildren:
8
- Enabled: false
9
7
  Metrics/LineLength:
10
8
  Max: 100
11
9
  Layout/EndOfLine:
12
10
  EnforcedStyle: lf
13
- Metrics/CyclomaticComplexity:
14
- Max: 20
15
- Metrics/MethodLength:
16
- Enabled: false
17
- Layout/MultilineMethodCallIndentation:
18
- Enabled: false
19
- Metrics/ParameterLists:
20
- Max: 6
21
- Metrics/ClassLength:
22
- Max: 250
23
- Metrics/AbcSize:
11
+ Style/MultilineTernaryOperator:
24
12
  Enabled: false
25
13
  Metrics/BlockLength:
26
- Max: 100
27
- Metrics/PerceivedComplexity:
28
- Max: 20
29
- Style/MultilineTernaryOperator:
14
+ Max: 50
15
+ Layout/AlignParameters:
30
16
  Enabled: false
31
17
  Layout/EmptyLineAfterGuardClause:
32
18
  Enabled: false
@@ -1,6 +1,7 @@
1
1
  assets:
2
2
  rubygems.yml: yegor256/home#assets/rubygems.yml
3
3
  install: |
4
+ sudo apt install -y aspell
4
5
  pdd -f /dev/null
5
6
  sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
6
7
  release:
@@ -5,6 +5,10 @@ cache: bundler
5
5
  branches:
6
6
  only:
7
7
  - master
8
+ addons:
9
+ apt:
10
+ packages:
11
+ - aspell
8
12
  install:
9
13
  - gem install pdd -v 0.20.5
10
14
  - travis_retry bundle update
data/README.md CHANGED
@@ -8,18 +8,41 @@
8
8
  [![Build Status](https://travis-ci.org/yegor256/texsc.svg)](https://travis-ci.org/yegor256/texsc)
9
9
  [![PDD status](http://www.0pdd.com/svg?name=yegor256/texsc)](http://www.0pdd.com/p?name=yegor256/texsc)
10
10
  [![Gem Version](https://badge.fury.io/rb/texsc.svg)](http://badge.fury.io/rb/texsc)
11
- [![Maintainability](https://api.codeclimate.com/v1/badges/74c909f06d4afa0d8001/maintainability)](https://codeclimate.com/github/yegor256/texsc/maintainability)
11
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7593273bfae71f87ea8c/maintainability)](https://codeclimate.com/github/yegor256/texsc/maintainability)
12
12
 
13
13
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/takes/texsc/master/LICENSE.txt)
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
- Just run it like this for your LaTeX file:
17
+ This tool simplies the usage of [aspell](http://aspell.net/)
18
+ (you must have it installed)
19
+ for spell-checking of LaTeX files.
20
+
21
+ First, you install it:
22
+
23
+ ```bash
24
+ $ gem install texsc
25
+ ```
26
+
27
+ Then, you just run it like this for your LaTeX files:
18
28
 
19
29
  ```bash
20
30
  $ texsc article.tex
21
31
  ```
22
32
 
33
+ You may ignore certain tags or environments using `--ignore` option.
34
+
35
+ You may also use your own additional dictionary, via `--pws` option.
36
+ The file must contain one word per line:
37
+ they will be ignored during spell checking. Don't forget that
38
+ the first line of the file
39
+ [must contain](http://aspell.net/man-html/Format-of-the-Personal-and-Replacement-Dictionaries.html)
40
+ this:
41
+
42
+ ```
43
+ personal_ws-1.1 en 1 utf-8
44
+ ```
45
+
23
46
  ## How to contribute
24
47
 
25
48
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
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.1.0'
24
+ VERSION = '0.2.0'
25
25
 
26
26
  STDOUT.sync = true
27
27
 
@@ -38,6 +38,8 @@ begin
38
38
  Options are:"
39
39
  o.string '--pws', 'The location of aspell.en.pws file'
40
40
  o.array '--ignore', 'The name of the command or environment to ignore'
41
+ o.integer '--min-word-length',
42
+ 'The minimum length of the word to be checked', default: 3
41
43
  o.bool '--version', 'Print current version' do
42
44
  puts VERSION
43
45
  exit
@@ -60,6 +62,7 @@ Options are:"
60
62
  log.debug("The real path of PWS is: #{opts[:pws]}")
61
63
  end
62
64
  errors = 0
65
+ files = 0
63
66
  opts.arguments.each do |f|
64
67
  tex = File.read(f)
65
68
  opts[:ignore].each do |e|
@@ -68,29 +71,35 @@ Options are:"
68
71
  log.info("Checking #{f} (#{tex.length} chars)...")
69
72
  cmd = [
70
73
  'aspell',
71
- '--ignore=3',
74
+ "--ignore=#{opts['min-word-length']}",
72
75
  '--dont-tex-check-comments',
73
76
  '--lang=en',
74
77
  '--mode=tex',
75
78
  opts[:pws] ? "-p #{opts[:pws]}" : '',
76
- opts[:ignore].map { |e| "--add-tex-command '#{e} p'" }.join(' '),
79
+ opts[:ignore].map { |e| "--add-tex-command '#{e} pppppooooo'" }.join(' '),
77
80
  'pipe'
78
81
  ].join(' ')
79
82
  log.debug(cmd)
80
- Open3.popen3(cmd) do |stdin, stdout, _stderr, _thread|
83
+ Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
81
84
  stdin.print(tex)
82
85
  stdin.close
86
+ status = thread.value.to_i
87
+ unless status.zero?
88
+ log.error(stderr.read)
89
+ raise "Failed to run aspell, exit code is #{status}"
90
+ end
83
91
  stdout.read.split("\n").select { |t| t.start_with?('&') }.each do |t|
84
92
  log.info(t)
85
93
  errors += 1
86
94
  end
87
95
  end
96
+ files += 1
88
97
  end
89
98
  unless errors.zero?
90
- log.info("#{errors} spelling errors found")
99
+ log.info("#{errors} spelling errors found in #{files} file(s)")
91
100
  exit 1
92
101
  end
93
- log.info('No spelling errors found, the text is clean')
102
+ log.info("No spelling errors found in #{files} file(s), the text is clean")
94
103
  rescue StandardError => ex
95
104
  if opts[:verbose]
96
105
  puts Backtrace.new(ex).to_s
@@ -6,3 +6,82 @@ Feature: Command Line Processing
6
6
  Then Exit code is zero
7
7
  And Stdout contains "--help"
8
8
 
9
+ Scenario: Good LaTeX can be spell checked
10
+ Given I have a "article.tex" file with content:
11
+ """
12
+ \documentclass{article}
13
+ \begin{document}
14
+ How are you, my dear friend?
15
+ \end{document}
16
+ """
17
+ When I run bin/texsc with "article.tex"
18
+ Then Exit code is zero
19
+ And Stdout contains "No spelling errors found in 1 file(s)"
20
+
21
+ Scenario: Bad LaTeX can be spell checked
22
+ Given I have a "article.tex" file with content:
23
+ """
24
+ \documentclass{article}
25
+ \begin{document}
26
+ How are you, my dear friiend?
27
+ \end{document}
28
+ """
29
+ When I run bin/texsc with "article.tex"
30
+ Then Exit code is not zero
31
+ And Stdout contains "& friiend 33 21"
32
+
33
+ Scenario: Bad LaTeX with PWS can be spell checked
34
+ Given I have a "article.tex" file with content:
35
+ """
36
+ \documentclass{article}
37
+ \begin{document}
38
+ How are you, my dear friiend?
39
+ \end{document}
40
+ """
41
+ And I have a "aspell.en.pws" file with content:
42
+ """
43
+ personal_ws-1.1 en 1 utf-8
44
+ hello
45
+ friiend
46
+ """
47
+ When I run bin/texsc with "--pws aspell.en.pws article.tex"
48
+ Then Exit code is zero
49
+
50
+ Scenario: Bad LaTeX with broken PWS can be spell checked
51
+ Given I have a "article.tex" file with content:
52
+ """
53
+ \documentclass{article}
54
+ \begin{document}
55
+ How are you, my dear friiend?
56
+ \end{document}
57
+ """
58
+ And I have a "aspell.en.pws" file with content:
59
+ """
60
+ friiend
61
+ """
62
+ When I run bin/texsc with "--pws aspell.en.pws article.tex"
63
+ Then Exit code is not zero
64
+ And Stdout contains "is not in the proper format"
65
+
66
+ Scenario: Bad LaTeX with --ignore can be spell checked
67
+ Given I have a "article.tex" file with content:
68
+ """
69
+ \documentclass{article}
70
+ \begin{document}
71
+ How are you, my dear \nospell{friiend}?
72
+ \end{document}
73
+ """
74
+ When I run bin/texsc with "--ignore nospell article.tex"
75
+ Then Exit code is zero
76
+
77
+ Scenario: Bad LaTeX with too short words can be spell checked
78
+ Given I have a "article.tex" file with content:
79
+ """
80
+ \documentclass{article}
81
+ \begin{document}
82
+ How are you, my dear ZZZZ?
83
+ \end{document}
84
+ """
85
+ When I run bin/texsc with "--min-word-length=4 article.tex"
86
+ Then Exit code is zero
87
+
@@ -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.1.0'
35
+ s.version = '0.2.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.1.0
4
+ version: 0.2.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-07-01 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace