cowl 0.1

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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +23 -0
  3. data/bin/cowl +69 -0
  4. data/lib/cowl.rb +69 -0
  5. data/lib/version.rb +6 -0
  6. metadata +258 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1eeeaea54a13d739e017d255d4d621ac6230e521
4
+ data.tar.gz: 98202af27c71039c0757da39ebc94e21b30339e8
5
+ SHA512:
6
+ metadata.gz: 6e3461512a78c1c8d46044abe148276df37df975020a98e22a0b65836026535c951b266acf77417fcdcf0d4767a40c6cbe4b1e3878bbf234ad647ff562a8a026
7
+ data.tar.gz: c0c6ab889dd8c5205faecf30cb517da6c86a04cc674ead45390ade986328f0a288d5ee73c71dccb7db15ef63f9297a73455d3160411f179615e4078c37ef86da
data/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ # FreeBSD License
2
+
3
+ # Copyright 2014 Andrew Pennebaker. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation and/or
12
+ other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
15
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
17
+ SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/bin/cowl ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'find'
4
+ require 'optparse'
5
+
6
+ require 'rubygems'
7
+ require 'cowl'
8
+
9
+ def main
10
+ ignores = DEFAULT_IGNORES
11
+
12
+ filenames = ['.']
13
+
14
+ max_width = DEFAULT_MAX_WIDTH
15
+
16
+ option = OptionParser.new do |option|
17
+ option.banner = 'Usage: cowl [options] [<files>]'
18
+
19
+ option.on('-i', '--ignore pattern', 'Ignore file names matching Ruby regex pattern') do |pattern|
20
+ ignores << pattern
21
+ end
22
+
23
+ option.on('-w=', '--max-width', 'Maximum column width (default: 80 characters). Must be non-negative.') do |width|
24
+ max_width = width.to_i
25
+
26
+ if max_width <= 0 then
27
+ puts option
28
+ exit
29
+ end
30
+ end
31
+
32
+ option.on('-h', '--help', 'Print usage info') do
33
+ puts option
34
+ exit
35
+ end
36
+
37
+ option.on('-v', '--version', 'Print version info') do
38
+ puts "enlint #{Cowl::VERSION}"
39
+ exit
40
+ end
41
+ end
42
+
43
+ option.parse!
44
+
45
+ filenames = ARGV unless ARGV.empty?
46
+
47
+ recursive_filenames = []
48
+
49
+ filenames.each do |f|
50
+ if File.directory? f
51
+ recursive_filenames = recursive_filenames.concat(recursive_list(f, ignores))
52
+ else
53
+ recursive_filenames << f
54
+ end
55
+ end
56
+
57
+ recursive_filenames.each { |f| check(f, max_width) }
58
+ end
59
+
60
+ begin
61
+ main
62
+ # User may quit enlint before completion.
63
+ rescue Interrupt
64
+ nil
65
+ # enlint may be piped to another program (e.g. `less`),
66
+ # which is quit before enlint completes.
67
+ rescue Errno::EPIPE, Errno::EMFILE
68
+ nil
69
+ end
data/lib/cowl.rb ADDED
@@ -0,0 +1,69 @@
1
+ require 'rubygems'
2
+ require 'ptools'
3
+
4
+ require 'version'
5
+
6
+ DEFAULT_MAX_WIDTH = 80
7
+
8
+ DEFAULT_IGNORES = %w(
9
+ .hg/
10
+ .svn/
11
+ .git/
12
+ .git
13
+ .gitignore
14
+ node_modules/
15
+ .vagrant/
16
+ Gemfile.lock
17
+ .exe
18
+ .bin
19
+ .png
20
+ .jpg
21
+ .jpeg
22
+ .svg
23
+ .min.js
24
+ -min.js
25
+ )
26
+
27
+ #
28
+ # Parse, model, and print a line too wide for its own good
29
+ #
30
+ class Widening
31
+ attr_accessor :filename, :line_number, :line
32
+
33
+ def self.parse(filename, grep_line)
34
+ match = grep_line.match(/^(.+)\:(.+)$/)
35
+
36
+ line_number = match[1]
37
+ line = match[2]
38
+
39
+ Widening.new(filename, line_number, line)
40
+ end
41
+
42
+ def initialize(filename, line_number, line)
43
+ @filename = filename
44
+ @line_number = line_number
45
+ @line = line
46
+ end
47
+
48
+ def to_s
49
+ "#{filename}:#{line_number}:#{line}"
50
+ end
51
+ end
52
+
53
+ def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
54
+ Find.find(directory).reject do |f|
55
+ File.directory?(f) ||
56
+ ignores.any? { |ignore| f =~ /#{ignore}/ } ||
57
+ File.binary?(f)
58
+ end
59
+ end
60
+
61
+ def self.check(filename, width = DEFAULT_MAX_WIDTH)
62
+ output = `grep -n \'^.\\{#{width + 1},\\}$\' \"#{filename}\"`
63
+
64
+ lines = output.split("\n")
65
+
66
+ widenings = lines.map { |line| Widening.parse(filename, line) }
67
+
68
+ widenings.each { |m| puts m }
69
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,6 @@
1
+ #
2
+ # Cowl
3
+ #
4
+ module Cowl
5
+ VERSION = '0.1'
6
+ end
metadata ADDED
@@ -0,0 +1,258 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cowl
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Pennebaker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ptools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: reek
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: flay
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: flog
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '4.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: roodi
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: churn
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cane
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.6'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '2.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: excellent
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '2.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '2.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '0.24'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '0.24'
153
+ - !ruby/object:Gem::Dependency
154
+ name: tailor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: '1.4'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: '1.4'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '2.6'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: '2.6'
181
+ - !ruby/object:Gem::Dependency
182
+ name: guard-shell
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ~>
186
+ - !ruby/object:Gem::Version
187
+ version: '0.6'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ~>
193
+ - !ruby/object:Gem::Version
194
+ version: '0.6'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ~>
200
+ - !ruby/object:Gem::Version
201
+ version: '3.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ~>
207
+ - !ruby/object:Gem::Version
208
+ version: '3.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: cucumber
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ~>
214
+ - !ruby/object:Gem::Version
215
+ version: '1.3'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ~>
221
+ - !ruby/object:Gem::Version
222
+ version: '1.3'
223
+ description: See README.md for example usage
224
+ email: andrew.pennebaker@gmail.com
225
+ executables:
226
+ - cowl
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - LICENSE.md
231
+ - bin/cowl
232
+ - lib/cowl.rb
233
+ - lib/version.rb
234
+ homepage: https://github.com/mcandre/cowl
235
+ licenses:
236
+ - FreeBSD
237
+ metadata: {}
238
+ post_install_message:
239
+ rdoc_options: []
240
+ require_paths:
241
+ - lib
242
+ required_ruby_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - '>='
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - '>='
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ requirements: []
253
+ rubyforge_project:
254
+ rubygems_version: 2.2.2
255
+ signing_key:
256
+ specification_version: 4
257
+ summary: column width linter
258
+ test_files: []