cowl 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONFIGURE.md +1 -1
- data/README.md +27 -25
- data/bin/cowl +22 -95
- data/lib/cowl.rb +61 -41
- data/lib/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c8fcb9be685e11e164c6fafa86fe354eba6714
|
4
|
+
data.tar.gz: 6c8b6e63914a308fc77da6423f9b1e2a38f4e5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2663c5811b77a77bb346337ec43e48974b9073dc18a997f9261fe6c7629f71b1676989a1f73a2be3c52dcccd10db08359a7441a92bf2cedc1dbbd66e2b19635
|
7
|
+
data.tar.gz: b84ce5aa9cff6f05194c397c36498b087913dc98b63005694031135a0ab3189ac851ca292fba3b14a5a034cb9ee259c7fdb779c5bb31c906d911c87bf3b2faff
|
data/CONFIGURE.md
CHANGED
@@ -15,7 +15,7 @@ Run `cowl -h` or `cowl --help` for a full list, or refer to the source code for
|
|
15
15
|
```
|
16
16
|
$ cowl -h
|
17
17
|
Usage: cowl [options] [<files>]
|
18
|
-
-i, --ignore pattern Ignore file
|
18
|
+
-i, --ignore pattern Ignore file patterns (fnmatch)
|
19
19
|
-w, --max-width= Maximum column width, either an integer or "unlimited". Default: 80
|
20
20
|
-h, --help Print usage info
|
21
21
|
-v, --version Print version info
|
data/README.md
CHANGED
@@ -1,25 +1,8 @@
|
|
1
1
|
# cowl - column width linter
|
2
2
|
|
3
|
-
|
3
|
+
`cowl` helps you keep your source code / text in a terminal-friendly 80-column width.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
# RUBYGEMS
|
8
|
-
|
9
|
-
https://rubygems.org/gems/cowl
|
10
|
-
|
11
|
-
# ABOUT
|
12
|
-
|
13
|
-
Cowl is a command line program for identifying text lines that are considered too long, wider than the conventional column width `80` or so.
|
14
|
-
|
15
|
-
cowl is a shell wrapper around the traditional GNU [grep](http://www.gnu.org/software/grep/) backend, presenting a frontend similar to modern linters like [Reek](https://github.com/troessner/reek/wiki) and [JSHint](http://jshint.com/).
|
16
|
-
|
17
|
-
* Recursive file search by default
|
18
|
-
* Optional ignore patterns
|
19
|
-
* Configuration via per-project and per-user [dotfiles](https://github.com/mcandre/cowl/blob/master/CONFIGURE.md#dotfiles)
|
20
|
-
* Install via a standard programming language package manager
|
21
|
-
|
22
|
-
# EXAMPLE
|
5
|
+
# EXAMPLES
|
23
6
|
|
24
7
|
```
|
25
8
|
$ cowl examples/
|
@@ -28,26 +11,45 @@ examples/hello.bf:3:++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++
|
|
28
11
|
$ cat examples/hello.bf | cowl
|
29
12
|
stdin:3:++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
|
30
13
|
|
31
|
-
$ wc -
|
32
|
-
|
14
|
+
$ wc -c examples/hello.bf
|
15
|
+
158 examples/hello.bf
|
33
16
|
|
34
|
-
$ cowl -w
|
17
|
+
$ cowl -w 160 examples/hello.bf
|
35
18
|
$
|
36
19
|
|
37
|
-
$ cowl -i
|
20
|
+
$ cowl -i '*.bf' examples/
|
38
21
|
$
|
39
22
|
|
40
23
|
$ cowl -h
|
41
24
|
Usage: cowl [options] [<files>|-]
|
42
|
-
-i, --ignore pattern Ignore file
|
25
|
+
-i, --ignore pattern Ignore file patterns (fnmatch)
|
43
26
|
-w, --max-width= Maximum column width, either an integer or "unlimited". Default: 80
|
44
27
|
-h, --help Print usage info
|
45
28
|
-v, --version Print version info
|
46
29
|
```
|
47
30
|
|
31
|
+
# HOMEPAGE
|
32
|
+
|
33
|
+
https://github.com/mcandre/cowl
|
34
|
+
|
35
|
+
# RUBYGEMS
|
36
|
+
|
37
|
+
https://rubygems.org/gems/cowl
|
38
|
+
|
39
|
+
# ABOUT
|
40
|
+
|
41
|
+
Cowl is a command line program for identifying text lines that are considered too long, wider than the conventional column width `80` or so.
|
42
|
+
|
43
|
+
cowl is a shell wrapper around the traditional GNU [grep](http://www.gnu.org/software/grep/) backend, presenting a frontend similar to modern linters like [Reek](https://github.com/troessner/reek/wiki) and [JSHint](http://jshint.com/).
|
44
|
+
|
45
|
+
* Recursive file scanning, like `jshint .`
|
46
|
+
* Optional ignore patterns, like `.gitignore`
|
47
|
+
* Configuration via per-project and per-user [dotfiles](https://github.com/mcandre/cowl/blob/master/CONFIGURE.md#dotfiles)
|
48
|
+
* Install via a standard programming language package manager
|
49
|
+
|
48
50
|
# REQUIREMENTS
|
49
51
|
|
50
|
-
* [Ruby](https://www.ruby-lang.org/) 2+
|
52
|
+
* [Ruby](https://www.ruby-lang.org/) 2.0+
|
51
53
|
* [grep](http://www.gnu.org/software/grep/) (often built-in, or provided by [git](http://git-scm.com/))
|
52
54
|
|
53
55
|
E.g., Windows users can `chocolatey install git`.
|
data/bin/cowl
CHANGED
@@ -3,28 +3,24 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'find'
|
5
5
|
require 'optparse'
|
6
|
+
require 'dotsmack'
|
6
7
|
require 'yaml'
|
7
8
|
require 'cowl'
|
8
9
|
|
9
|
-
IGNORE_FILENAME = '.cowlignore'
|
10
|
-
CONFIGURATION_FILENAME = '.cowlrc.yml'
|
11
|
-
|
12
10
|
def main
|
13
11
|
ignores = DEFAULT_IGNORES
|
14
12
|
|
15
|
-
filenames = ['-']
|
16
|
-
|
17
13
|
configuration_flags = {}
|
18
14
|
|
19
15
|
option = OptionParser.new do |option|
|
20
16
|
option.banner = "Usage: cowl [options] [<files>|-]"
|
21
17
|
|
22
|
-
option.on('-i', '--ignore pattern', 'Ignore file
|
18
|
+
option.on('-i', '--ignore pattern', 'Ignore file patterns (fnmatch)') do |pattern|
|
23
19
|
ignores << pattern
|
24
20
|
end
|
25
21
|
|
26
22
|
option.on('-w=', '--max-width', "Maximum column width, either an integer or \"unlimited\". Default: 80") do |max_width|
|
27
|
-
configuration_flags[
|
23
|
+
configuration_flags['max_width'] = max_width
|
28
24
|
end
|
29
25
|
|
30
26
|
option.on('-h', '--help', 'Print usage info') do
|
@@ -40,100 +36,31 @@ def main
|
|
40
36
|
|
41
37
|
option.parse!
|
42
38
|
|
43
|
-
filenames =
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
pwd = Dir.pwd
|
49
|
-
|
50
|
-
dir = pwd
|
51
|
-
|
52
|
-
parent_of_home = File.expand_path("..", ENV["HOME"])
|
53
|
-
|
54
|
-
while dir != parent_of_home
|
55
|
-
ignore_file = dir + File::SEPARATOR + IGNORE_FILENAME
|
56
|
-
|
57
|
-
if File.exist?(ignore_file) then
|
58
|
-
ignores.concat(open(ignore_file).read.split("\n"))
|
59
|
-
end
|
60
|
-
|
61
|
-
dir = File.expand_path("..", dir)
|
39
|
+
filenames =
|
40
|
+
if ARGV == []
|
41
|
+
['-']
|
42
|
+
else
|
43
|
+
ARGV
|
62
44
|
end
|
63
45
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
while dir != parent_of_home
|
70
|
-
config_file = dir + File::SEPARATOR + CONFIGURATION_FILENAME
|
71
|
-
|
72
|
-
if File.exist?(config_file) then
|
73
|
-
configuration_dotfile = DEFAULT_CONFIGURATION.merge(YAML.load_file(config_file))
|
74
|
-
break
|
75
|
-
else
|
76
|
-
dir = File.expand_path("..", dir)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Command line flags override dotfile settings
|
81
|
-
configuration = configuration_dotfile.merge(configuration_flags)
|
82
|
-
|
83
|
-
check_stdin(configuration)
|
84
|
-
end
|
85
|
-
else
|
86
|
-
recursive_filenames = []
|
46
|
+
dotsmack = Dotsmack::Smacker.new(
|
47
|
+
dotignore = '.cowlignore',
|
48
|
+
additional_ignores = ignores,
|
49
|
+
dotconfig = '.cowlrc.yml'
|
50
|
+
)
|
87
51
|
|
88
|
-
|
89
|
-
|
90
|
-
|
52
|
+
dotsmack.enumerate(filenames).each do |filename, config|
|
53
|
+
config =
|
54
|
+
if config.nil?
|
55
|
+
configuration_flags
|
91
56
|
else
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
configuration_dotfile = DEFAULT_CONFIGURATION
|
97
|
-
|
98
|
-
recursive_filenames.each do |f|
|
99
|
-
dir = File.expand_path("..", f)
|
100
|
-
|
101
|
-
parent_of_home = File.expand_path("..", ENV["HOME"])
|
102
|
-
|
103
|
-
while dir != parent_of_home
|
104
|
-
ignore_file = dir + File::SEPARATOR + IGNORE_FILENAME
|
105
|
-
|
106
|
-
if File.exist?(ignore_file) then
|
107
|
-
ignores.concat(open(ignore_file).read.split("\n"))
|
108
|
-
end
|
109
|
-
|
110
|
-
dir = File.expand_path("..", dir)
|
57
|
+
YAML.load(config).merge(configuration_flags)
|
111
58
|
end
|
112
59
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
while dir != parent_of_home
|
119
|
-
config_file = dir + File::SEPARATOR + CONFIGURATION_FILENAME
|
120
|
-
|
121
|
-
if File.exist?(config_file) then
|
122
|
-
configuration_dotfile = DEFAULT_CONFIGURATION.merge(YAML.load_file(config_file))
|
123
|
-
break
|
124
|
-
else
|
125
|
-
dir = File.expand_path("..", dir)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# Hack to Reset configuration when changing directories
|
130
|
-
configuration_dotfile = DEFAULT_CONFIGURATION unless File.exist?(dir + File::SEPARATOR + CONFIGURATION_FILENAME)
|
131
|
-
|
132
|
-
# Command line flags override dotfile settings
|
133
|
-
configuration = configuration_dotfile.merge(configuration_flags)
|
134
|
-
|
135
|
-
check(f, configuration)
|
136
|
-
end
|
60
|
+
if filename == '-'
|
61
|
+
check_stdin(config)
|
62
|
+
else
|
63
|
+
check(filename, config)
|
137
64
|
end
|
138
65
|
end
|
139
66
|
end
|
data/lib/cowl.rb
CHANGED
@@ -1,33 +1,52 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'ptools'
|
3
2
|
require 'tempfile'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
require 'version'
|
4
|
+
require_relative 'version'
|
8
5
|
|
9
6
|
DEFAULT_IGNORES = %w(
|
10
|
-
tmp
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
tmp
|
8
|
+
.hg
|
9
|
+
.svn
|
10
|
+
.git
|
11
|
+
.gitignore
|
12
|
+
node_modules
|
13
|
+
bower_components
|
14
|
+
target
|
15
|
+
dist
|
16
|
+
.vagrant
|
19
17
|
Gemfile.lock
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
*.exe
|
19
|
+
*.bin
|
20
|
+
*.apk
|
21
|
+
*.ap_
|
22
|
+
res
|
23
|
+
*.dmg
|
24
|
+
*.pkg
|
25
|
+
*.app
|
26
|
+
*.xcodeproj
|
27
|
+
*.lproj
|
28
|
+
*.xcassets
|
29
|
+
*.pmdoc
|
30
|
+
*.dSYM
|
31
|
+
*.class
|
32
|
+
*.zip
|
33
|
+
*.jar
|
34
|
+
*.war
|
35
|
+
*.xpi
|
36
|
+
*.jad
|
37
|
+
*.cmo
|
38
|
+
*.cmi
|
39
|
+
*.png
|
40
|
+
*.gif
|
41
|
+
*.jpg
|
42
|
+
*.jpeg
|
43
|
+
*.tiff
|
44
|
+
*.ico
|
45
|
+
*.svg
|
46
|
+
*.dot
|
47
|
+
*.wav
|
48
|
+
*.mp3
|
49
|
+
*[.-]min.*
|
31
50
|
)
|
32
51
|
|
33
52
|
DEFAULT_MAX_WIDTH = 80
|
@@ -35,7 +54,7 @@ DEFAULT_MAX_WIDTH = 80
|
|
35
54
|
UNLIMITED = 'unlimited'
|
36
55
|
|
37
56
|
DEFAULT_CONFIGURATION = {
|
38
|
-
|
57
|
+
'max_width' => DEFAULT_MAX_WIDTH
|
39
58
|
}
|
40
59
|
|
41
60
|
#
|
@@ -64,25 +83,19 @@ class Widening
|
|
64
83
|
end
|
65
84
|
end
|
66
85
|
|
67
|
-
def self.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
File.binary?(f)
|
74
|
-
rescue Errno::ENOENT
|
75
|
-
true
|
86
|
+
def self.check_stdin(configuration = nil)
|
87
|
+
configuration =
|
88
|
+
if configuration.nil?
|
89
|
+
DEFAULT_CONFIGURATION
|
90
|
+
else
|
91
|
+
configuration
|
76
92
|
end
|
77
|
-
end
|
78
|
-
end
|
79
93
|
|
80
|
-
|
81
|
-
max_width = configuration["max_width"]
|
94
|
+
max_width = configuration['max_width']
|
82
95
|
|
83
96
|
contents = $stdin.read
|
84
97
|
|
85
|
-
t = Tempfile.new('
|
98
|
+
t = Tempfile.new('cowl')
|
86
99
|
t.write(contents)
|
87
100
|
t.close
|
88
101
|
|
@@ -99,8 +112,15 @@ def self.check_stdin(configuration = DEFAULT_CONFIGURATION)
|
|
99
112
|
end
|
100
113
|
end
|
101
114
|
|
102
|
-
def self.check(filename, configuration =
|
103
|
-
|
115
|
+
def self.check(filename, configuration = nil)
|
116
|
+
configuration =
|
117
|
+
if configuration.nil?
|
118
|
+
DEFAULT_CONFIGURATION
|
119
|
+
else
|
120
|
+
configuration
|
121
|
+
end
|
122
|
+
|
123
|
+
max_width = configuration['max_width']
|
104
124
|
|
105
125
|
if max_width != UNLIMITED
|
106
126
|
output = `grep -n \'^.\\{#{max_width.to_i + 1},\\}$\' \"#{filename}\"`
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cowl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Pennebaker
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotsmack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,7 +259,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
259
|
requirements:
|
246
260
|
- - '>='
|
247
261
|
- !ruby/object:Gem::Version
|
248
|
-
version: '0'
|
262
|
+
version: '2.0'
|
249
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
264
|
requirements:
|
251
265
|
- - '>='
|
@@ -253,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
267
|
version: '0'
|
254
268
|
requirements: []
|
255
269
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.4.6
|
257
271
|
signing_key:
|
258
272
|
specification_version: 4
|
259
273
|
summary: column width linter
|