korekto 1.2.210314 → 1.5.210331

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: '0286890774dd2081acbbf5df67402cc2897f873f3d2b778cdd6b493ddef80558'
4
- data.tar.gz: 1f1741821e6d783c496553f22a1649a98d665ddf685e90fdedd032c83f4e3613
3
+ metadata.gz: 636a9add2c269f979a980cd798f6aae0bc4b624c1b32f979aea02c0b4534c34a
4
+ data.tar.gz: 72cb33eb156931b0c6e5b5be64093ec9ede966032b36d7933980bed888d9fe94
5
5
  SHA512:
6
- metadata.gz: ba94530c442c879ff65ddc1876f3a8dc8210c7fb6084581b508640efd2f7b62024c977d11280f0ab0e0206925f0301f10eaf587148fbf1157ed28ad239cee171
7
- data.tar.gz: 6ef15ca196921ab9b1fd63f1bc948bdb33040444a31c01095ad0138f142c0388ab425c24f94edd1274779e0137afc21e15ab0e6b2e1b849c6316d852de27fd2a
6
+ metadata.gz: 426b6d679b487fd95ae073c63a9ad19d25e17081b1e44c691756ec3d53d5257215985977dec1e44263c1348880069b360a6caab0c04d0c9162c9daa97a2afc19
7
+ data.tar.gz: 530aa7d72c18360b330f39caaaa17d7f1bad6f68f144584a6683fbb44031203fe70652f74967135298fde45e99899ffb63f0310e9c93371de8972bc303fd1928
data/bin/korekto CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'help_parser'
3
3
 
4
- OPTIONS = HelpParser['1.2.210314', <<HELP]
4
+ OPTIONS = HelpParser['1.5.210331', <<HELP]
5
5
  Usage:
6
- korekto [:options+]
6
+ korekto [:options]
7
7
  Options:
8
8
  -h --help
9
9
  -v --version
10
+ --edits \tShow only needed edits
10
11
  --install \tInstalls the korekto neovim ruby plugin
11
12
  --readme \tOpen korekto github page
12
13
  # Example usage:
data/lib/korekto.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Korekto
2
- VERSION = '1.2.210314'
2
+ VERSION = '1.5.210331'
3
3
  class Error < Exception; end
4
4
  require 'korekto/symbols'
5
5
  require 'korekto/syntax'
data/lib/korekto/main.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Korekto
2
2
  class Main
3
- MD_STATEMENT_CODE_TITLE = %r{^(?<statement>.*)\s#(?<code>[A-Z](\d+(/[\w,.]+)?)?)( (?<title>\S.*?\S))?$}
3
+ MD_STATEMENT_CODE_TITLE = %r{^(?<statement>.*)\s#(?<code>[A-Z](\d+(\.\w+)?(/[\w,.]+)?)?)( (?<title>\S.*?\S))?$}
4
4
  MD_FILENAME = %r{^< (?<filename>[/\w\-.]+)$}
5
5
  MD_KLASS_METHOD_DEFINITION = /^(?<klass>::[A-Z]\w+)#(?<method>\w+)(?<definition>[^=]*=.+)$/ # patch
6
6
  MD_RULE = /^[?] (?<rule>\S.*)$/
@@ -15,8 +15,9 @@ class Main
15
15
 
16
16
  def initialize(filename='-', statements: Statements.new, imports: [])
17
17
  @filename,@statements,@imports = filename,statements,imports
18
- @imports.push @filename
18
+ @imports.push @filename.freeze
19
19
  @line,@active = nil,false
20
+ @section = File.basename(@filename,'.*')
20
21
  @m_fence_korekto = /^```korekto$/
21
22
  end
22
23
 
@@ -65,6 +66,8 @@ class Main
65
66
  @statements.symbols.set_scanner value
66
67
  when 'fence'
67
68
  @m_fence_korekto = Regexp.new "^```#{value}$"
69
+ when 'section'
70
+ @section = value
68
71
  when 'save'
69
72
  BACKUPS[value] = Marshal.dump(@statements)
70
73
  when 'restore'
@@ -109,13 +112,13 @@ class Main
109
112
  next unless active?
110
113
  next if preprocess?
111
114
  if md = MD_STATEMENT_CODE_TITLE.match(@line)
112
- statement_number += 1
113
115
  code,title = @statements.add(md[:statement].strip,
114
116
  md[:code],
115
117
  md[:title],
116
- @filename,
117
- statement_number)
118
- puts "#{@filename}:#{line_number}:#{code}:#{title}"
118
+ @section){ statement_number += 1 }
119
+ if not OPTIONS.edits? or (@filename=='-' and not (md[:code]==code and md[:title]==title))
120
+ puts "#{@filename}:#{line_number}:#{code}:#{title}"
121
+ end
119
122
  else
120
123
  raise Error, 'unrecognized korekto line'
121
124
  end
@@ -1,10 +1,10 @@
1
1
  module Korekto
2
2
  class Statement
3
- attr_reader :code,:title,:regexp,:filename,:statement_number
4
- def initialize(statement,code,title,filename,statement_number,context)
5
- @statement,@code,@title,@statement_number,@context = statement,code,title,statement_number,context
6
- @filename = File.basename(filename,'.*')
7
- @statement.freeze; @filename.freeze; @statement_number.freeze
3
+ attr_reader :code,:title,:regexp,:section,:statement_number
4
+ def initialize(statement,code,title,section,statement_number,context)
5
+ @statement,@code,@title,@section,@statement_number,@context =
6
+ statement,code,title,section,statement_number,context
7
+ @statement.freeze; @section.freeze; @statement_number.freeze
8
8
  syntax_check unless @statement[0]=='/' and @statement[-1]=='/' and ['A','L','M','E','I'].include?(@code[0])
9
9
  @regexp = nil
10
10
  set_acceptance_code
@@ -73,6 +73,7 @@ class Statement
73
73
 
74
74
  def set_statement(support=nil, title=nil)
75
75
  @code = "#{@code[0]}#{@statement_number}"
76
+ @code += '.' + @section unless @section=='-'
76
77
  @code += "/#{support}" if support
77
78
  @title = title.split(':',2).first if title
78
79
  end
@@ -81,7 +82,6 @@ class Statement
81
82
  support = []
82
83
  s.each do |s|
83
84
  c = s.code.split('/',2)[0]
84
- c = s.filename+'.'+c unless s.filename=='-'
85
85
  support.push(c)
86
86
  end
87
87
  return support.join(',')
@@ -11,7 +11,7 @@ class Statements
11
11
  def type(c) = @statements.select{_1.type==c}
12
12
  def length = @statements.length
13
13
 
14
- def add(statement,code,title,filename,statement_number)
14
+ def add(statement,code,title,filename)
15
15
  c = code[0]; w = c=='W'
16
16
  if restatement = @statements.detect{(w or _1.type==c) and _1.to_s==statement}
17
17
  case restatement.type
@@ -24,6 +24,7 @@ class Statements
24
24
  title ||= restatement.title
25
25
  return code, title
26
26
  end
27
+ statement_number = yield
27
28
  statement = Statement.new(statement,code,title,filename,statement_number,self)
28
29
  @statements.push statement
29
30
  case statement.type
@@ -1,6 +1,6 @@
1
1
  Neovim.plugin do |plug|
2
2
  plug.command(:Korekto) do |nvim|
3
- validations = nvim.command_output('w !korekto').strip.split("\n").map(&:strip)
3
+ validations = nvim.command_output('w !korekto --edits').strip.split("\n").map(&:strip)
4
4
  msg = 'OK'
5
5
  unless validations.empty?
6
6
  buf = nvim.get_current_buf
@@ -1,12 +1,21 @@
1
+ syntax match Unsup /#[A-Z]\d\+\(\.\w\+\)\?/ contained containedin=Type
2
+ syntax match Sup /#[A-Z]\d\+\(\.\w\+\)\?\/\S\+/ contained containedin=Type
3
+ syntax match Title / [^:]\+/ contained containedin=Type
4
+ syntax match Undef /:[^#]\+$/ contained containedin=Type
5
+ syntax match Type /\s#[A-Z][^#]\+/ contains=Unsup,Sup,Title,Undef
1
6
  syntax match Comment /^\s*#.\+$/
2
- syntax match Pass /\s#[A-Z][^#]*$/
3
- syntax match Syntax /^[?] \w.\+$/
7
+ syntax match Syntax /^[?] \S.\+$/
4
8
  syntax match Patch /^::[A-Z]\w\+#\w\+[^=]\+=.\+$/
5
9
  syntax match Import /^< [\/A-Za-z\_\-\.]\+$/
10
+ syntax match Setting /^! \S.*$/
11
+ highlight Unsup ctermfg=brown
12
+ highlight Sup ctermfg=darkgreen
13
+ highlight Title ctermfg=darkblue
14
+ highlight Undef ctermfg=red
6
15
  highlight Comment ctermfg=darkblue
7
- highlight Pass ctermfg=darkgreen
8
- highlight Syntax ctermfg=darkmagenta
16
+ highlight Import ctermfg=brown
9
17
  highlight Patch ctermfg=darkgrey
10
- highlight Import ctermfg=darkyellow
18
+ highlight Syntax ctermfg=darkgrey
19
+ highlight Setting ctermfg=darkmagenta
11
20
  setlocal tabstop=23
12
21
  map <F7> :Korekto<CR>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: korekto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.210314
4
+ version: 1.5.210331
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-14 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: help_parser