enlint 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/enlint.rb +27 -5
  3. data/lib/version.rb +1 -1
  4. metadata +19 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81dcac354178551b172cc03f7baab170db48007e
4
- data.tar.gz: 6dc00dcf8c1d354599066f8d4bcd2e1047e929a1
3
+ metadata.gz: 2e1edaeaa418532489fb5c29243d713688c717e0
4
+ data.tar.gz: 88144e5d6feae44c1cc8357d67cb88efdbf98e43
5
5
  SHA512:
6
- metadata.gz: ec8f8479a28d55276911c1223ae612349dae2a0487313cf5b9782b622c8cf43e18b9e48e5aa283a65020ab9841493c981b96e766482ad023e6f0f183329d04cc
7
- data.tar.gz: 675ca015f2fe1eb712d8fabc58059a5a212c75d32e14c9d46729322a242d791be471cdc898bacf444a13b80e229491bd7cc5cd890fd7fff8e442146ffc5c76a5
6
+ metadata.gz: 2071abe5fc051fc7f7b8bd0183f7cf8b9a5203820b2a556a52aee4e7c4d0beebe5c8562d6c62af505707de0e31f2a9ec3802cb4c739a0782387c1a39e167d5d2
7
+ data.tar.gz: b2cbc3611556a4a39cc056ef88fb67a65af5a6b6b0c33feee2835fe0f454ae00998ccd85764a8f3dfa767cfbea31db2c64ec0c4e41b6d2d82b66dfc4d57cea74
data/lib/enlint.rb CHANGED
@@ -18,7 +18,6 @@ DEFAULT_IGNORES = %w(
18
18
  .png
19
19
  .jpg
20
20
  .jpeg
21
- .svg
22
21
  .min.js
23
22
  -min.js
24
23
  )
@@ -35,6 +34,29 @@ DEFAULT_RULES = [
35
34
  # Warning for files that do not exist
36
35
  NO_SUCH_FILE = 'no such file'
37
36
 
37
+ MAC_OS_X = RUBY_PLATFORM =~ /darwin/
38
+
39
+ MIME_FLAG =
40
+ if MAC_OS_X then
41
+ '--mime-encoding'
42
+ else
43
+ '-i'
44
+ end
45
+
46
+ PARSER =
47
+ if MAC_OS_X then
48
+ /^(.+)\:\s+(.+)$/
49
+ else
50
+ /^.+\:\s+(.+);\s+charset=(.+)$/
51
+ end
52
+
53
+ DNE =
54
+ if MAC_OS_X then
55
+ /^.+: cannot open `.+' (No such file or directory)$/
56
+ else
57
+ /ERROR\:/
58
+ end
59
+
38
60
  #
39
61
  # Parse, model, and print an encoding.
40
62
  # Distinct from Ruby's built-in Encoding class.
@@ -43,12 +65,12 @@ class AnEncoding
43
65
  attr_accessor :filename, :empty, :encoding
44
66
 
45
67
  def self.parse(filename, file_line)
46
- if file_line =~ /ERROR\:/ then
68
+ if file_line =~ DNE then
47
69
  AnEncoding.new(filename, false, NO_SUCH_FILE)
48
70
  else
49
- match = file_line.match(/^.+\:\s+(.+);\s+charset=(.+)$/)
71
+ match = file_line.match(PARSER)
50
72
 
51
- empty = match[1] == 'inode/x-empty'
73
+ empty = match[1] == 'inode/x-empty' || match[2] == 'binary'
52
74
  encoding = match[2]
53
75
 
54
76
  AnEncoding.new(filename, empty, encoding)
@@ -101,7 +123,7 @@ def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
101
123
  end
102
124
 
103
125
  def self.check(filename, rules = DEFAULT_RULES)
104
- line = `file -i "#{filename}" 2>&1`
126
+ line = `file #{MIME_FLAG} "#{filename}" 2>&1`
105
127
 
106
128
  encoding = AnEncoding.parse(filename, line)
107
129
 
data/lib/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # EnLint
3
3
  #
4
4
  module EnLint
5
- VERSION = '0.2'
5
+ VERSION = '0.3'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enlint
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Pennebaker
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ~>
221
221
  - !ruby/object:Gem::Version
222
222
  version: '1.3'
223
+ - !ruby/object:Gem::Dependency
224
+ name: cowl
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: '0.2'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ~>
235
+ - !ruby/object:Gem::Version
236
+ version: '0.2'
223
237
  description: See README.md for example usage
224
238
  email: andrew.pennebaker@gmail.com
225
239
  executables:
@@ -227,10 +241,10 @@ executables:
227
241
  extensions: []
228
242
  extra_rdoc_files: []
229
243
  files:
230
- - LICENSE.md
231
- - bin/enlint
232
244
  - lib/enlint.rb
233
245
  - lib/version.rb
246
+ - LICENSE.md
247
+ - bin/enlint
234
248
  homepage: https://github.com/mcandre/enlint
235
249
  licenses:
236
250
  - FreeBSD
@@ -251,8 +265,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
265
  version: '0'
252
266
  requirements: []
253
267
  rubyforge_project:
254
- rubygems_version: 2.2.2
268
+ rubygems_version: 2.1.10
255
269
  signing_key:
256
270
  specification_version: 4
257
271
  summary: encoding linter
258
272
  test_files: []
273
+ has_rdoc: