github-linguist 4.2.3 → 4.2.5

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.
@@ -34,10 +34,6 @@ module Linguist
34
34
  Dir.entries(ROOT).sort!.each do |category|
35
35
  next if category == '.' || category == '..'
36
36
 
37
- # Skip text and binary for now
38
- # Possibly reconsider this later
39
- next if category == 'Text' || category == 'Binary'
40
-
41
37
  dirname = File.join(ROOT, category)
42
38
  Dir.entries(dirname).each do |filename|
43
39
  next if filename == '.' || filename == '..'
@@ -18,23 +18,32 @@ module Linguist
18
18
  #
19
19
  # Returns a String or nil
20
20
  def self.interpreter(data)
21
- lines = data.lines
22
- return unless match = /^#! ?(.+)$/.match(lines.first)
21
+ shebang = data.lines.first
23
22
 
24
- tokens = match[1].split(' ')
25
- script = tokens.first.split('/').last
23
+ # First line must start with #!
24
+ return unless shebang && shebang.start_with?("#!")
26
25
 
26
+ # Get the parts of the shebang without the #!
27
+ tokens = shebang.sub(/^#!\s*/, '').strip.split(' ')
28
+
29
+ # There was nothing after the #!
30
+ return if tokens.empty?
31
+
32
+ # Get the name of the interpreter
33
+ script = File.basename(tokens.first)
34
+
35
+ # Get next argument if interpreter was /usr/bin/env
27
36
  script = tokens[1] if script == 'env'
28
37
 
29
- # If script has an invalid shebang, we might get here
38
+ # Interpreter was /usr/bin/env with no arguments
30
39
  return unless script
31
40
 
32
41
  # "python2.6" -> "python2"
33
- script.sub! $1, '' if script =~ /(\.\d+)$/
42
+ script.sub! /(\.\d+)$/, ''
34
43
 
35
44
  # Check for multiline shebang hacks that call `exec`
36
45
  if script == 'sh' &&
37
- lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
46
+ data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
38
47
  script = $1
39
48
  end
40
49
 
@@ -32,6 +32,7 @@
32
32
 
33
33
  # Erlang bundles
34
34
  - ^rebar$
35
+ - erlang.mk
35
36
 
36
37
  # Go dependencies
37
38
  - Godeps/_workspace/
@@ -1,3 +1,3 @@
1
1
  module Linguist
2
- VERSION = "4.2.3"
2
+ VERSION = "4.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-linguist
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charlock_holmes