pronto-textlint 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 18cade83bff004ddd37ab25237b2638b07b14e60
4
- data.tar.gz: 682aadd62a6a251a66e9b166b1166c591a201cf2
3
+ metadata.gz: d0df249cc1483e57cea5601c53cc31a67a434f6c
4
+ data.tar.gz: 570e5a8ec29c90e085d1ac0e61beef405bd8963e
5
5
  SHA512:
6
- metadata.gz: 9a787866231d0122b46752482135b88605acf19ce65e9cb280ad7dbd9b689ab6a28449e4edd875a575c886d5973ebe2fcea8a5ea0c99a3b196f3956b6696a7f5
7
- data.tar.gz: b331996fe70f4b1a5266ce801720d0d9d335037f4ea016474723cdb9c9f60588011fa8db1ab5212edcf27ef827a2108aa4fb7035c62f4192b22f32971c63b56a
6
+ metadata.gz: 9fa7340eb92ffdb281c6b2ee09431ba6115db5cf95c79c8ea78a39594397ce0c462d74416a70d30b5f9397a59804f109d6fe69755f4ae0a1e5d48054f2030c38
7
+ data.tar.gz: a84ad5243ba11dcea764ce45cffebbaea9debbd1c50ade71af69c1e595392655c9c3b04995ae760ac5520839a56dd3c8e3325db758f604dc2646247257ddd1e4
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.3.1
4
4
  before_install: gem install bundler -v 1.11.2
@@ -1,65 +1,2 @@
1
- require 'pronto'
2
-
3
- require 'open3'
4
- require 'shellwords'
5
-
6
- module Pronto
7
- class Textlint < Runner
8
- def run
9
- return [] unless @patches
10
-
11
- @patches.select(&method(:valid_patch?))
12
- .flat_map(&method(:inspect))
13
- .compact
14
- end
15
-
16
- private
17
-
18
- def textlint_path
19
- ENV['PRONTO_TEXTLINT_PATH'] || 'textlint'
20
- end
21
-
22
- def config_path
23
- ENV['PRONTO_TEXTLINT_CONFIG_PATH'] || '.textlintrc'
24
- end
25
-
26
- def valid_patch?(patch)
27
- patch.additions > 0
28
- end
29
-
30
- def inspect(patch)
31
- output = run_textlint(patch)
32
- offences = clean_up_textlint_output(output)
33
-
34
- offences.flat_map do |offence|
35
- patch.added_lines
36
- .select { |line| line.new_lineno == offence['line'] }
37
- .map { |line| new_message(offence, line) }
38
- end
39
- end
40
-
41
- def run_textlint(patch)
42
- Dir.chdir(patch.repo.path) do
43
- path = patch.new_file_full_path.to_s
44
- command = "#{textlint_path.shellescape} -f json -c #{config_path} #{path.shellescape}"
45
- stdout, stderr, = Open3.capture3(command)
46
- puts "WARN: pronto-textlint: #{stderr}" if stderr && !stderr.empty?
47
-
48
- return [] if stdout.nil?
49
- JSON.parse(stdout)
50
- end
51
- end
52
-
53
- def new_message(offence, line)
54
- Message.new(offence['path'], line, :warning, offence['message'], nil, self.class)
55
- end
56
-
57
- def clean_up_textlint_output(output)
58
- output.flat_map do |offence|
59
- offence['messages'].map do |message|
60
- message.merge('path' => offence['filePath'])
61
- end
62
- end
63
- end
64
- end
65
- end
1
+ require_relative 'textlint/version'
2
+ require_relative 'textlint/runner'
@@ -0,0 +1,67 @@
1
+ require 'pronto'
2
+
3
+ require 'open3'
4
+ require 'shellwords'
5
+
6
+ module Pronto
7
+ module Textlint
8
+ class Runner < Pronto::Runner
9
+ def run
10
+ return [] unless @patches
11
+
12
+ @patches.select(&method(:valid_patch?))
13
+ .flat_map(&method(:inspect))
14
+ .compact
15
+ end
16
+
17
+ private
18
+
19
+ def textlint_path
20
+ ENV['PRONTO_TEXTLINT_PATH'] || 'textlint'
21
+ end
22
+
23
+ def config_path
24
+ ENV['PRONTO_TEXTLINT_CONFIG_PATH'] || '.textlintrc'
25
+ end
26
+
27
+ def valid_patch?(patch)
28
+ patch.additions > 0
29
+ end
30
+
31
+ def inspect(patch)
32
+ output = run_textlint(patch)
33
+ offences = clean_up_textlint_output(output)
34
+
35
+ offences.flat_map do |offence|
36
+ patch.added_lines
37
+ .select { |line| line.new_lineno == offence['line'] }
38
+ .map { |line| new_message(offence, line) }
39
+ end
40
+ end
41
+
42
+ def run_textlint(patch)
43
+ Dir.chdir(patch.repo.path) do
44
+ path = patch.new_file_full_path.to_s
45
+ command = "#{textlint_path.shellescape} -f json -c #{config_path} #{path.shellescape}"
46
+ stdout, stderr, = Open3.capture3(command)
47
+ puts "WARN: pronto-textlint: #{stderr}" if stderr && !stderr.empty?
48
+
49
+ return [] if stdout.nil?
50
+ JSON.parse(stdout)
51
+ end
52
+ end
53
+
54
+ def new_message(offence, line)
55
+ Message.new(offence['path'], line, :warning, offence['message'], nil, self.class)
56
+ end
57
+
58
+ def clean_up_textlint_output(output)
59
+ output.flat_map do |offence|
60
+ offence['messages'].map do |message|
61
+ message.merge('path' => offence['filePath'])
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,7 +1,5 @@
1
- require 'pronto'
2
-
3
1
  module Pronto
4
- class Textlint < Runner
5
- VERSION = '0.1.1'
2
+ module Textlint
3
+ VERSION = '0.1.2'
6
4
  end
7
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-textlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiichi KONDO
@@ -142,6 +142,7 @@ files:
142
142
  - bin/console
143
143
  - bin/setup
144
144
  - lib/pronto/textlint.rb
145
+ - lib/pronto/textlint/runner.rb
145
146
  - lib/pronto/textlint/version.rb
146
147
  - pronto-textlint.gemspec
147
148
  homepage: https://github.com/seikichi/pronto-luacheck