sqlint 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/sqlint +31 -24
  4. data/lib/sqlint/version.rb +1 -1
  5. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a659c0622ca330e784dfecef69f5c0545f79836
4
- data.tar.gz: 14ad1e500274a2b00a98cb20ea3f58fe2eb2c5a4
3
+ metadata.gz: b14888e061953471546b3c17225b83b056b2d738
4
+ data.tar.gz: 3d760e0838c3a4ca4caa03e397d443c52b1cf131
5
5
  SHA512:
6
- metadata.gz: 52bfbfbfc45980d7398932b0098f152bd1e8ffa0a55e0acfa09480634553b58c0d63cbdd3490883b48ba4aa7202bee65252e0ff6cb7121e951d92183b3f8fb03
7
- data.tar.gz: 8f30c0e45b775eafd0e062e655d2d8bfba4fe2002049c7c6e7ced55da7581a8adf63cc58801eab91f7a97083299bb00e30b78ab32649574a808abc272cd1f501
6
+ metadata.gz: 19bcbb3e7c9532b315a3c55f6624f89eb9fd449b8bdd65b13b4bcf15ed1585d5ab1dfa88588814bf52bea190663519b9c1df9affb53f8e9d6ea70881e614bcde
7
+ data.tar.gz: e7640ef540312e72b0f1a68d3664ec29b0f7accd83d38e122bf79bcbb2a5af8966a0399e158a51c1d1499b1539f5736d8d45c139bd36366bdd442ac9ab9be20e
data/README.md CHANGED
@@ -35,7 +35,7 @@ Support for `sqlint` is provided for the following editors:
35
35
 
36
36
  - Emacs, via [Flycheck](https://github.com/flycheck/flycheck)
37
37
  - VIM, via [Syntastic](https://github.com/scrooloose/syntastic)
38
- - SublimeText, via the SublimeLinter package ([submission pending](https://github.com/SublimeLinter/SublimeLinter3/issues/297))
38
+ - SublimeText, via [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter3/)
39
39
 
40
40
  ### Authors
41
41
 
data/bin/sqlint CHANGED
@@ -5,14 +5,12 @@ require 'pg_query'
5
5
  require 'sqlint'
6
6
  require 'optparse'
7
7
 
8
- LIMIT = 1000
9
-
10
8
  options = { limit: 1000 }
11
9
  optparse = OptionParser.new do |opts|
12
- opts.banner = "Usage: #{File.basename($0)} [options] file.sql ..."
10
+ opts.banner = "Usage: #{File.basename($0)} [options] [file.sql ...]"
13
11
  opts.separator ""
14
12
  opts.separator "Options:"
15
- opts.on("--limit=N", Integer, "Limit checking to N errors") do |n|
13
+ opts.on("--limit=N", Integer, "Limit checking to N errors (default: #{options[:limit]})") do |n|
16
14
  options[:limit] = n
17
15
  end
18
16
  opts.on_tail("-h", "--help", "Print this help") do
@@ -25,10 +23,6 @@ optparse = OptionParser.new do |opts|
25
23
  end
26
24
  end
27
25
  optparse.parse!(ARGV)
28
- if ARGV.empty?
29
- puts optparse
30
- exit 1
31
- end
32
26
 
33
27
  ERROR_TYPES = {error: "ERROR", warning: "WARNING"}
34
28
 
@@ -40,25 +34,38 @@ class String
40
34
  end
41
35
  end
42
36
 
43
- saw_errors = false
44
- ARGV.each do |filename|
45
- File.open(filename, 'r') do |file|
46
- results = SQLint::Linter.new(filename, file).run.first(options[:limit])
47
- results.each do |lint|
48
- message_lines = lint.message.split("\n")
49
- puts [
50
- lint.filename,
51
- lint.line,
52
- lint.column,
53
- ERROR_TYPES[lint.type] + " " + message_lines.shift.sanitise
54
- ].join(":")
55
- message_lines.each do |line|
56
- puts " " + line.sanitise
57
- end
37
+ def display_lint(lint)
38
+ message_lines = lint.message.split("\n")
39
+ puts [
40
+ lint.filename,
41
+ lint.line,
42
+ lint.column,
43
+ ERROR_TYPES[lint.type] + " " + message_lines.shift.sanitise
44
+ ].join(":")
45
+ message_lines.each do |line|
46
+ puts " " + line.sanitise
47
+ end
48
+ end
58
49
 
59
- saw_errors ||= (lint.type == :error)
50
+ def each_input_file(&block)
51
+ if ARGV.empty?
52
+ yield [STDIN, "stdin"]
53
+ else
54
+ ARGV.each do |filename|
55
+ File.open(filename, 'r') do |file|
56
+ yield [file, filename]
57
+ end
60
58
  end
61
59
  end
62
60
  end
63
61
 
62
+ saw_errors = false
63
+ each_input_file do |file, filename|
64
+ results = SQLint::Linter.new(filename, file).run.first(options[:limit])
65
+ results.each do |lint|
66
+ display_lint(lint)
67
+ end
68
+ saw_errors ||= results.any? { |lint| lint.type == :error }
69
+ end
70
+
64
71
  exit 1 if saw_errors
@@ -1,3 +1,3 @@
1
1
  module SQLint
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlint
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
  - Steve Purcell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-17 00:00:00.000000000 Z
12
+ date: 2015-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg_query
@@ -67,8 +67,7 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.3'
70
- description: |2
71
- Simple SQL linter.
70
+ description: " Simple SQL linter.\n"
72
71
  email: steve@sanityinc.com
73
72
  executables:
74
73
  - sqlint