cowl 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/bin/cowl +59 -17
- data/lib/cowl.rb +25 -0
- data/lib/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec29b6542eb34b987d246605d65bbb055569cf15
|
4
|
+
data.tar.gz: 526d928d71c5f86fbecd4f771933f42ea73a148d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ffda0a7455741198c8889ca278c7399711ae1412181b2c0f1e0f67a13b5eebd859d8c9bc79c7df3e617e457f7e72050eee51825c5015490cc4a7b3d125bc2d2
|
7
|
+
data.tar.gz: 198cc9de7b84a6e70940f562578170fd01b458a4faa8a7d86da045a706d8c40c9bb56139d27b9af55e31d9e95fd9a8f6abb809966181d2516086b039ca87ec9c
|
data/README.md
CHANGED
@@ -25,6 +25,9 @@ cowl is a shell wrapper around the traditional GNU [grep](http://www.gnu.org/sof
|
|
25
25
|
$ cowl examples/
|
26
26
|
examples/hello.bf:3:++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
|
27
27
|
|
28
|
+
$ cat examples/hello.bf | cowl
|
29
|
+
stdin:3:++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
|
30
|
+
|
28
31
|
$ wc -L examples/hello.bf
|
29
32
|
106 examples/hello.bf
|
30
33
|
|
@@ -33,6 +36,13 @@ $
|
|
33
36
|
|
34
37
|
$ cowl -i .bf examples/
|
35
38
|
$
|
39
|
+
|
40
|
+
$ cowl -h
|
41
|
+
Usage: cowl [options] [<files>|-]
|
42
|
+
-i, --ignore pattern Ignore file names matching Ruby regex pattern
|
43
|
+
-w, --max-width= Maximum column width, either an integer or "unlimited". Default: 80
|
44
|
+
-h, --help Print usage info
|
45
|
+
-v, --version Print version info
|
36
46
|
```
|
37
47
|
|
38
48
|
# REQUIREMENTS
|
data/bin/cowl
CHANGED
@@ -12,12 +12,12 @@ CONFIGURATION_FILENAME = '.cowlrc.yml'
|
|
12
12
|
def main
|
13
13
|
ignores = DEFAULT_IGNORES
|
14
14
|
|
15
|
-
filenames = ['
|
15
|
+
filenames = ['-']
|
16
16
|
|
17
17
|
configuration_flags = {}
|
18
18
|
|
19
19
|
option = OptionParser.new do |option|
|
20
|
-
option.banner = "Usage: cowl [options] [<files
|
20
|
+
option.banner = "Usage: cowl [options] [<files>|-]"
|
21
21
|
|
22
22
|
option.on('-i', '--ignore pattern', 'Ignore file names matching Ruby regex pattern') do |pattern|
|
23
23
|
ignores << pattern
|
@@ -42,20 +42,12 @@ def main
|
|
42
42
|
|
43
43
|
filenames = ARGV unless ARGV.empty?
|
44
44
|
|
45
|
-
|
45
|
+
if filenames.empty? || filenames == ['-'] then
|
46
|
+
configuration_dotfile = DEFAULT_CONFIGURATION
|
46
47
|
|
47
|
-
|
48
|
-
if File.directory? f
|
49
|
-
recursive_filenames = recursive_filenames.concat(recursive_list(f, ignores))
|
50
|
-
else
|
51
|
-
recursive_filenames << f
|
52
|
-
end
|
53
|
-
end
|
48
|
+
pwd = Dir.pwd
|
54
49
|
|
55
|
-
|
56
|
-
|
57
|
-
recursive_filenames.each do |f|
|
58
|
-
dir = File.expand_path("..", f)
|
50
|
+
dir = pwd
|
59
51
|
|
60
52
|
parent_of_home = File.expand_path("..", ENV["HOME"])
|
61
53
|
|
@@ -69,8 +61,8 @@ def main
|
|
69
61
|
dir = File.expand_path("..", dir)
|
70
62
|
end
|
71
63
|
|
72
|
-
if ignores.none? { |ignore|
|
73
|
-
dir =
|
64
|
+
if ignores.none? { |ignore| pwd =~ %r(#{ignore}) } then
|
65
|
+
dir = Dir.pwd
|
74
66
|
|
75
67
|
parent_of_home = File.expand_path("..", ENV["HOME"])
|
76
68
|
|
@@ -88,7 +80,57 @@ def main
|
|
88
80
|
# Command line flags override dotfile settings
|
89
81
|
configuration = configuration_dotfile.merge(configuration_flags)
|
90
82
|
|
91
|
-
|
83
|
+
check_stdin(configuration)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
recursive_filenames = []
|
87
|
+
|
88
|
+
filenames.each do |f|
|
89
|
+
if File.directory? f
|
90
|
+
recursive_filenames = recursive_filenames.concat(recursive_list(f, ignores))
|
91
|
+
else
|
92
|
+
recursive_filenames << f
|
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)
|
111
|
+
end
|
112
|
+
|
113
|
+
if ignores.none? { |ignore| f =~ %r(#{ignore}) } then
|
114
|
+
dir = File.expand_path("..", f)
|
115
|
+
|
116
|
+
parent_of_home = File.expand_path("..", ENV["HOME"])
|
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 = YAML.load_file(config_file)
|
123
|
+
break
|
124
|
+
else
|
125
|
+
dir = File.expand_path("..", dir)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Command line flags override dotfile settings
|
130
|
+
configuration = configuration_dotfile.merge(configuration_flags)
|
131
|
+
|
132
|
+
check(f, configuration)
|
133
|
+
end
|
92
134
|
end
|
93
135
|
end
|
94
136
|
end
|
data/lib/cowl.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'ptools'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
$stdout.sync = true
|
3
6
|
|
4
7
|
require 'version'
|
5
8
|
|
@@ -69,6 +72,28 @@ def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
|
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
75
|
+
def self.check_stdin(configuration = DEFAULT_CONFIGURATION)
|
76
|
+
max_width = configuration["max_width"]
|
77
|
+
|
78
|
+
contents = $stdin.read
|
79
|
+
|
80
|
+
t = Tempfile.new('aspelllint')
|
81
|
+
t.write(contents)
|
82
|
+
t.close
|
83
|
+
|
84
|
+
filename = t.path
|
85
|
+
|
86
|
+
if max_width != UNLIMITED
|
87
|
+
output = `grep -n \'^.\\{#{max_width.to_i + 1},\\}$\' \"#{filename}\"`
|
88
|
+
|
89
|
+
lines = output.split("\n")
|
90
|
+
|
91
|
+
widenings = lines.map { |line| Widening.parse('stdin', line) }
|
92
|
+
|
93
|
+
widenings.each { |m| puts m }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
72
97
|
def self.check(filename, configuration = DEFAULT_CONFIGURATION)
|
73
98
|
max_width = configuration["max_width"]
|
74
99
|
|
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.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Pennebaker
|
@@ -227,12 +227,12 @@ executables:
|
|
227
227
|
extensions: []
|
228
228
|
extra_rdoc_files: []
|
229
229
|
files:
|
230
|
-
- lib/cowl.rb
|
231
|
-
- lib/version.rb
|
232
230
|
- CONFIGURE.md
|
233
231
|
- LICENSE.md
|
234
232
|
- README.md
|
235
233
|
- bin/cowl
|
234
|
+
- lib/cowl.rb
|
235
|
+
- lib/version.rb
|
236
236
|
homepage: https://github.com/mcandre/cowl
|
237
237
|
licenses:
|
238
238
|
- FreeBSD
|
@@ -253,9 +253,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
requirements: []
|
255
255
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.
|
256
|
+
rubygems_version: 2.2.2
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: column width linter
|
260
260
|
test_files: []
|
261
|
-
has_rdoc:
|