From 96e8a5d2cc65c312e570d3fbf751083273fef4b9 Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Tue, 30 Jul 2013 13:30:39 -0700 Subject: [PATCH] Start detecting CSS --- lib/linguist/language.rb | 7 +++ lib/linguist/repository.rb | 4 +- lib/linguist/samples.json | 117 ++++++++++++++++++++++++++----------- test/test_blob.rb | 8 +-- 4 files changed, 95 insertions(+), 41 deletions(-) diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index aa550890..0d34f4f9 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -21,6 +21,13 @@ module Linguist # Valid Languages types TYPES = [:data, :markup, :programming] + # Names of non-programming languages that we will still detect + # + # Returns an array + def self.detectable_markup + ["CSS", "Less", "Sass"] + end + # Internal: Create a new Language object # # attributes - A hash of attributes diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 5c1ffdaf..4b34be0a 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -73,8 +73,8 @@ module Linguist # Skip vendored or generated blobs next if blob.vendored? || blob.generated? || blob.language.nil? - # Only include programming languages - if blob.language.type == :programming + # Only include programming languages and acceptable markup languages + if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) @sizes[blob.language.group] += blob.size end end diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index c7da5dfc..74759f0b 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -366,6 +366,7 @@ ".zprofile", ".zshenv", ".zshrc", + "Dockerfile", "PKGBUILD", "bash_logout", "bash_profile", @@ -387,8 +388,8 @@ ".gemrc" ] }, - "tokens_total": 363334, - "languages_total": 432, + "tokens_total": 363536, + "languages_total": 433, "tokens": { "ABAP": { "*/**": 1, @@ -35824,24 +35825,24 @@ "Shell": { "SHEBANG#!bash": 8, "typeset": 5, - "-": 364, - "i": 1, + "-": 391, + "i": 2, "n": 22, "bottles": 6, "no": 16, "while": 3, - "[": 84, - "]": 84, + "[": 85, + "]": 85, "do": 8, - "echo": 69, + "echo": 71, "case": 9, "{": 63, "}": 61, "in": 25, ")": 154, "%": 5, - "s": 13, - ";": 135, + "s": 14, + ";": 138, "esac": 7, "done": 8, "exit": 10, @@ -35853,12 +35854,12 @@ "export": 25, "SCREENDIR": 2, "fi": 34, - "PATH": 12, - "/usr/local/bin": 4, - "/usr/local/sbin": 4, + "PATH": 14, + "/usr/local/bin": 6, + "/usr/local/sbin": 6, "/usr/xpg4/bin": 4, - "/usr/sbin": 4, - "/usr/bin": 6, + "/usr/sbin": 6, + "/usr/bin": 8, "/usr/sfw/bin": 4, "/usr/ccs/bin": 4, "/usr/openwin/bin": 4, @@ -35880,8 +35881,8 @@ "actually": 2, "DISPLAY": 2, "r": 17, - "&&": 56, - ".": 4, + "&&": 65, + ".": 5, "function": 6, "ls": 6, "command": 5, @@ -35891,7 +35892,7 @@ "long": 2, "format...": 2, "ll": 2, - "|": 16, + "|": 17, "less": 2, "XF": 2, "pipe": 2, @@ -35905,7 +35906,7 @@ "extglob": 2, "progcomp": 2, "complete": 82, - "f": 65, + "f": 68, "X": 54, "bunzip2": 2, "bzcat": 2, @@ -35981,7 +35982,7 @@ "opera": 2, "w3m": 2, "galeon": 2, - "curl": 6, + "curl": 8, "dillo": 2, "elinks": 2, "links": 2, @@ -36006,7 +36007,7 @@ "disown": 2, "other": 2, "job": 3, - "v": 9, + "v": 11, "readonly": 4, "unset": 10, "and": 5, @@ -36017,7 +36018,7 @@ "helptopic": 2, "help": 5, "helptopics": 2, - "a": 11, + "a": 12, "unalias": 4, "aliases": 2, "binding": 2, @@ -36037,7 +36038,7 @@ "on": 4, "d": 9, "pushd": 2, - "cd": 6, + "cd": 11, "rmdir": 2, "Make": 2, "directory": 5, @@ -36056,7 +36057,7 @@ "as": 2, "bash...": 2, "quit": 2, - "q": 6, + "q": 8, "even": 3, "shorter": 2, "D": 2, @@ -36083,7 +36084,7 @@ "path": 13, "/opt/local/bin": 2, "/opt/local/sbin": 2, - "/bin": 2, + "/bin": 4, "prompt": 2, "history": 18, "endif": 2, @@ -36144,9 +36145,64 @@ "fpath": 6, "HOME/.zsh/func": 2, "U": 2, + "docker": 1, + "version": 12, + "from": 1, + "ubuntu": 1, + "maintainer": 1, + "Solomon": 1, + "Hykes": 1, + "": 1, + "run": 13, + "apt": 6, + "get": 6, + "install": 8, + "y": 5, + "git": 16, + "https": 2, + "//go.googlecode.com/files/go1.1.1.linux": 1, + "amd64.tar.gz": 1, + "tar": 1, + "C": 1, + "/usr/local": 1, + "xz": 1, + "env": 4, + "/usr/local/go/bin": 2, + "/sbin": 2, + "GOPATH": 1, + "/go": 1, + "CGO_ENABLED": 1, + "/tmp": 1, + "t.go": 1, + "go": 2, + "test": 1, + "PKG": 12, + "github.com/kr/pty": 1, + "REV": 6, + "c699": 1, + "clone": 5, + "http": 3, + "//": 3, + "/go/src/": 6, + "checkout": 3, + "github.com/gorilla/context/": 1, + "d61e5": 1, + "github.com/gorilla/mux/": 1, + "b36453141c": 1, + "iptables": 1, + "/etc/apt/sources.list": 1, + "update": 2, + "lxc": 1, + "aufs": 1, + "tools": 1, + "add": 1, + "/go/src/github.com/dotcloud/docker": 1, + "/go/src/github.com/dotcloud/docker/docker": 1, + "ldflags": 1, + "/go/bin": 1, + "cmd": 1, "pkgname": 1, "stud": 4, - "git": 9, "pkgver": 1, "pkgrel": 1, "pkgdesc": 1, @@ -36162,7 +36218,6 @@ "provides": 1, "conflicts": 1, "_gitroot": 1, - "https": 1, "//github.com/bumptech/stud.git": 1, "_gitname": 1, "build": 2, @@ -36170,14 +36225,12 @@ "pull": 3, "origin": 1, "else": 10, - "clone": 2, "rm": 2, "rf": 1, "package": 1, "PREFIX": 1, "/usr": 1, "DESTDIR": 1, - "install": 2, "Dm755": 1, "init.stud": 1, "mkdir": 2, @@ -36246,7 +36299,6 @@ "rbenv": 2, "versions": 1, "bare": 1, - "version": 11, "&": 5, "prefix": 1, "/dev/null": 6, @@ -36428,7 +36480,6 @@ "build.properties": 1, "an": 1, "property": 1, - "update": 1, "disk.": 1, "That": 1, "scalacOptions": 3, @@ -39431,7 +39482,7 @@ "Scheme": 3478, "Scilab": 69, "SCSS": 39, - "Shell": 3542, + "Shell": 3744, "Slash": 187, "Standard ML": 243, "SuperCollider": 268, @@ -39533,7 +39584,7 @@ "Scheme": 1, "Scilab": 3, "SCSS": 1, - "Shell": 36, + "Shell": 37, "Slash": 1, "Standard ML": 2, "SuperCollider": 2, @@ -39555,5 +39606,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "23dbdcbc5407d2cd14bbb5926d29774c" + "md5": "748cee37cde5be6ab7d9349db78010df" } \ No newline at end of file diff --git a/test/test_blob.rb b/test/test_blob.rb index a64be883..b57e08fb 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -233,7 +233,7 @@ class TestBlob < Test::Unit::TestCase assert blob("public/javascripts/jquery-1.6.1.js").vendored? assert blob("public/javascripts/jquery-1.6.1.min.js").vendored? assert !blob("public/javascripts/jquery.github.menu.js").vendored? - + # jQuery UI assert blob("themes/ui-lightness/jquery-ui.css").vendored? assert blob("themes/ui-lightness/jquery-ui-1.8.22.custom.css").vendored? @@ -249,7 +249,7 @@ class TestBlob < Test::Unit::TestCase assert blob("ui/jquery.ui.accordion.js").vendored? assert blob("ui/minified/jquery.effects.blind.min.js").vendored? assert blob("ui/minified/jquery.ui.accordion.min.js").vendored? - + # MooTools assert blob("public/javascripts/mootools-core-1.3.2-full-compat.js").vendored? @@ -266,10 +266,6 @@ class TestBlob < Test::Unit::TestCase assert blob("public/javascripts/yahoo-min.js").vendored? assert blob("public/javascripts/yuiloader-dom-event.js").vendored? - # LESS - assert blob("public/javascripts/less-1.1.0.js").vendored? - assert blob("public/javascripts/less-1.1.0.min.js").vendored? - # WYS editors assert blob("public/javascripts/ckeditor.js").vendored? assert blob("public/javascripts/tiny_mce.js").vendored?