Top Level Namespace
Defined Under Namespace
Modules: Cowl
Classes: Widening
Constant Summary
collapse
- DEFAULT_IGNORES =
%w(
tmp
.hg
.svn
.git
.gitignore
node_modules
bower_components
target
dist
.vagrant
Gemfile.lock
*.exe
*.bin
*.apk
*.ap_
res
*.dmg
*.pkg
*.app
*.xcodeproj
*.lproj
*.xcassets
*.pmdoc
*.dSYM
*.class
*.zip
*.jar
*.war
*.xpi
*.jad
*.cmo
*.cmi
*.png
*.gif
*.jpg
*.jpeg
*.tiff
*.ico
*.svg
*.dot
*.wav
*.mp3
*[.-]min.*
)
- DEFAULT_MAX_WIDTH =
80
- UNLIMITED =
'unlimited'
- DEFAULT_CONFIGURATION =
{
'max_width' => DEFAULT_MAX_WIDTH
}
Class Method Summary
collapse
Class Method Details
.check(filename, configuration = nil) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/cowl.rb', line 115
def self.check(filename, configuration = nil)
configuration =
if configuration.nil?
DEFAULT_CONFIGURATION
else
configuration
end
max_width = configuration['max_width']
if max_width != UNLIMITED
output = `grep -n \'^.\\{#{max_width.to_i + 1},\\}$\' \"#{filename}\"`
lines = output.split("\n").reject { |line| line =~ /^Binary file/ }
widenings = lines.map { |line| Widening.parse(filename, line) }
widenings.each { |m| puts m }
end
end
|
.check_stdin(configuration = nil) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/cowl.rb', line 86
def self.check_stdin(configuration = nil)
configuration =
if configuration.nil?
DEFAULT_CONFIGURATION
else
configuration
end
max_width = configuration['max_width']
contents = $stdin.read
t = Tempfile.new('cowl')
t.write(contents)
t.close
filename = t.path
if max_width != UNLIMITED
output = `grep -n \'^.\\{#{max_width.to_i + 1},\\}$\' \"#{filename}\"`
lines = output.split("\n").reject { |line| line =~ /^Binary file/ }
widenings = lines.map { |line| Widening.parse('stdin', line) }
widenings.each { |m| puts m }
end
end
|