Skip to content

Commit

Permalink
Merge branch 'master' into 972
Browse files Browse the repository at this point in the history
Conflicts:
	lib/linguist/vendor.yml
  • Loading branch information
arfon committed May 3, 2014
2 parents 869cf8b + 8b87878 commit f103306
Show file tree
Hide file tree
Showing 185 changed files with 63,876 additions and 717 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Gemfile.lock
.bundle/
vendor/
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ before_install:
- sudo apt-get install libicu-dev -y
- gem update --system 2.1.11
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- ree
- 2.1.1
notifications:
disabled: true
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
source 'https://rubygems.org'
gemspec

if RUBY_VERSION < "1.9.3"
# escape_utils 1.0.0 requires 1.9.3 and above
gem "escape_utils", "0.3.2"
end
6 changes: 4 additions & 2 deletions github-linguist.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require File.expand_path('../lib/linguist/version', __FILE__)

Gem::Specification.new do |s|
s.name = 'github-linguist'
s.version = '2.10.11'
s.version = Linguist::VERSION
s.summary = "GitHub Language detection"
s.description = 'We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.'

Expand All @@ -12,7 +14,7 @@ Gem::Specification.new do |s|
s.executables << 'linguist'

s.add_dependency 'charlock_holmes', '~> 0.6.6'
s.add_dependency 'escape_utils', '>= 0.3.1'
s.add_dependency 'escape_utils', '~> 1.0.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.5.4'

Expand Down
1 change: 1 addition & 0 deletions lib/linguist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
require 'linguist/language'
require 'linguist/repository'
require 'linguist/samples'
require 'linguist/version'
13 changes: 12 additions & 1 deletion lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def generated?
generated_protocol_buffer? ||
generated_jni_header? ||
composer_lock? ||
node_modules?
node_modules? ||
vcr_cassette?
end

# Internal: Is the blob an XCode project file?
Expand Down Expand Up @@ -235,5 +236,15 @@ def node_modules?
def composer_lock?
!!name.match(/composer.lock/)
end

# Is the blob a VCR Cassette file?
#
# Returns true or false
def vcr_cassette?
return false unless extname == '.yml'
return false unless lines.count > 2
# VCR Cassettes have "recorded_with: VCR" in the second last line.
return lines[-2].include?("recorded_with: VCR")
end
end
end
10 changes: 10 additions & 0 deletions lib/linguist/heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def self.find_by_heuristics(data, languages)
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
disambiguate_cl(data, languages)
end
if languages.all? { |l| ["Rebol", "R"].include?(l) }
disambiguate_r(data, languages)
end
end
end

Expand Down Expand Up @@ -73,6 +76,13 @@ def self.disambiguate_cl(data, languages)
matches
end

def self.disambiguate_r(data, languages)
matches = []
matches << Language["Rebol"] if /\bRebol\b/i.match(data)
matches << Language["R"] if data.include?("<-")
matches
end

def self.active?
!!ACTIVE
end
Expand Down
7 changes: 6 additions & 1 deletion lib/linguist/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ def initialize(attributes = {})
#
# Returns the extensions Array
attr_reader :filenames

# Public: Return all possible extensions for language
def all_extensions
(extensions + [primary_extension]).uniq
end

# Public: Get URL escaped name.
#
Expand Down Expand Up @@ -485,7 +490,7 @@ def searchable?
#
# Returns html String
def colorize(text, options = {})
lexer.highlight(text, options = {})
lexer.highlight(text, options)
end

# Public: Return name as String representation
Expand Down
Loading

0 comments on commit f103306

Please sign in to comment.