github-linguist 4.2.7 → 4.3.0

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.
@@ -0,0 +1,30 @@
1
+ module Linguist
2
+ module Strategy
3
+ class Modeline
4
+ EmacsModeline = /-\*-\s*(?:mode:)?\s*(\w+);?\s*-\*-/
5
+ VimModeline = /\/\*\s*vim:\s*set\s*(?:ft|filetype)=(\w+):\s*\*\//
6
+
7
+ # Public: Detects language based on Vim and Emacs modelines
8
+ #
9
+ # blob - An object that quacks like a blob.
10
+ #
11
+ # Examples
12
+ #
13
+ # Modeline.call(FileBlob.new("path/to/file"))
14
+ #
15
+ # Returns an Array with one Language if the blob has a Vim or Emacs modeline
16
+ # that matches a Language name or alias. Returns an empty array if no match.
17
+ def self.call(blob, _ = nil)
18
+ Array(Language.find_by_alias(modeline(blob.data)))
19
+ end
20
+
21
+ # Public: Get the modeline from the first n-lines of the file
22
+ #
23
+ # Returns a String or nil
24
+ def self.modeline(data)
25
+ match = data.match(EmacsModeline) || data.match(VimModeline)
26
+ match[1] if match
27
+ end
28
+ end
29
+ end
30
+ end
@@ -33,7 +33,8 @@ module Linguist
33
33
  ['<!--', '-->'], # XML
34
34
  ['{-', '-}'], # Haskell
35
35
  ['(*', '*)'], # Coq
36
- ['"""', '"""'] # Python
36
+ ['"""', '"""'], # Python
37
+ ["'''", "'''"] # Python
37
38
  ]
38
39
 
39
40
  START_SINGLE_LINE_COMMENT = Regexp.compile(SINGLE_LINE_COMMENTS.map { |c|
@@ -1,3 +1,3 @@
1
1
  module Linguist
2
- VERSION = "4.2.7"
2
+ VERSION = "4.3.0"
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.7
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charlock_holmes
@@ -163,6 +163,7 @@ files:
163
163
  - lib/linguist/samples.rb
164
164
  - lib/linguist/shebang.rb
165
165
  - lib/linguist/strategy/filename.rb
166
+ - lib/linguist/strategy/modeline.rb
166
167
  - lib/linguist/tokenizer.rb
167
168
  - lib/linguist/vendor.yml
168
169
  - lib/linguist/version.rb