mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b56a243e7 | ||
|
|
5d08605aef | ||
|
|
bf705cbaf2 | ||
|
|
fe827896e0 | ||
|
|
64e7df7596 | ||
|
|
b3ff84872b | ||
|
|
5d176a781c | ||
|
|
e0c97f97ba | ||
|
|
83f358976e | ||
|
|
9ee6153891 | ||
|
|
825e640061 | ||
|
|
e5ae213839 | ||
|
|
74e034c689 | ||
|
|
a55a60a161 | ||
|
|
9e3cc01715 | ||
|
|
0f204767a9 | ||
|
|
11e3251efd | ||
|
|
1f1416a5f7 | ||
|
|
b3786f3825 | ||
|
|
09c2eee91e | ||
|
|
dc78b14902 | ||
|
|
500ce0959a | ||
|
|
aa0c9e3572 | ||
|
|
e6de75d48a | ||
|
|
a5ad0a34f8 | ||
|
|
6e609cc4e3 | ||
|
|
27727a927f | ||
|
|
5ff580df0a | ||
|
|
b34acac722 | ||
|
|
37840856ed | ||
|
|
acfad4371f | ||
|
|
c462c2bd31 | ||
|
|
213cf322f5 | ||
|
|
2c2b37bec3 | ||
|
|
c777f2d388 | ||
|
|
eca10056a8 | ||
|
|
5a646384f6 | ||
|
|
8917f1a91a |
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -646,7 +646,7 @@
|
|||||||
url = https://github.com/SRI-CSL/SMT.tmbundle.git
|
url = https://github.com/SRI-CSL/SMT.tmbundle.git
|
||||||
[submodule "vendor/grammars/language-crystal"]
|
[submodule "vendor/grammars/language-crystal"]
|
||||||
path = vendor/grammars/language-crystal
|
path = vendor/grammars/language-crystal
|
||||||
url = https://github.com/k2b6s9j/language-crystal
|
url = https://github.com/atom-crystal/language-crystal
|
||||||
[submodule "vendor/grammars/language-xbase"]
|
[submodule "vendor/grammars/language-xbase"]
|
||||||
path = vendor/grammars/language-xbase
|
path = vendor/grammars/language-xbase
|
||||||
url = https://github.com/hernad/atom-language-harbour
|
url = https://github.com/hernad/atom-language-harbour
|
||||||
@@ -680,3 +680,6 @@
|
|||||||
[submodule "vendor/grammars/Stata.tmbundle"]
|
[submodule "vendor/grammars/Stata.tmbundle"]
|
||||||
path = vendor/grammars/Stata.tmbundle
|
path = vendor/grammars/Stata.tmbundle
|
||||||
url = https://github.com/pschumm/Stata.tmbundle
|
url = https://github.com/pschumm/Stata.tmbundle
|
||||||
|
[submodule "vendor/grammars/FreeMarker.tmbundle"]
|
||||||
|
path = vendor/grammars/FreeMarker.tmbundle
|
||||||
|
url = https://github.com/freemarker/FreeMarker.tmbundle
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ We try only to add new extensions once they have some usage on GitHub. In most c
|
|||||||
|
|
||||||
To add support for a new extension:
|
To add support for a new extension:
|
||||||
|
|
||||||
0. Add your extension to the language entry in [`languages.yml`][languages].
|
0. Add your extension to the language entry in [`languages.yml`][languages], keeping the extensions in alphabetical order.
|
||||||
0. Add at least one sample for your extension to the [samples directory][samples] in the correct subdirectory.
|
0. Add at least one sample for your extension to the [samples directory][samples] in the correct subdirectory.
|
||||||
0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage.
|
0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage.
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ The Language stats bar displays languages percentages for the files in the repos
|
|||||||
|
|
||||||
0. Click on the name of the language in the stats bar to see a list of the files that are identified as that language.
|
0. Click on the name of the language in the stats bar to see a list of the files that are identified as that language.
|
||||||
0. If you see files that you didn't write, consider moving the files into one of the [paths for vendored code](/lib/linguist/vendor.yml), or use the [manual overrides](#overrides) feature to ignore them.
|
0. If you see files that you didn't write, consider moving the files into one of the [paths for vendored code](/lib/linguist/vendor.yml), or use the [manual overrides](#overrides) feature to ignore them.
|
||||||
0. If the files are being misclassified, search for [open issues][issues] to see if anyone else has already reported the issue. Any information you an add, especially links to public repositories, is helpful.
|
0. If the files are being misclassified, search for [open issues][issues] to see if anyone else has already reported the issue. Any information you can add, especially links to public repositories, is helpful.
|
||||||
0. If there are no reported issues of this misclassification, [open an issue][new-issue] and include a link to the repository or a sample of the code that is being misclassified.
|
0. If there are no reported issues of this misclassification, [open an issue][new-issue] and include a link to the repository or a sample of the code that is being misclassified.
|
||||||
|
|
||||||
## Overrides
|
## Overrides
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ vendor/grammars/Docker.tmbundle:
|
|||||||
- source.dockerfile
|
- source.dockerfile
|
||||||
vendor/grammars/Elm.tmLanguage:
|
vendor/grammars/Elm.tmLanguage:
|
||||||
- source.elm
|
- source.elm
|
||||||
|
vendor/grammars/FreeMarker.tmbundle:
|
||||||
|
- text.html.ftl
|
||||||
vendor/grammars/G-Code/:
|
vendor/grammars/G-Code/:
|
||||||
- source.LS
|
- source.LS
|
||||||
- source.MCPOST
|
- source.MCPOST
|
||||||
|
|||||||
73
lib/linguist/blob.rb
Normal file
73
lib/linguist/blob.rb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
require 'linguist/blob_helper'
|
||||||
|
|
||||||
|
module Linguist
|
||||||
|
# A Blob is a wrapper around the content of a file to make it quack
|
||||||
|
# like a Grit::Blob. It provides the basic interface: `name`,
|
||||||
|
# `data`, `path` and `size`.
|
||||||
|
class Blob
|
||||||
|
include BlobHelper
|
||||||
|
|
||||||
|
# Public: Initialize a new Blob.
|
||||||
|
#
|
||||||
|
# path - A path String (does not necessarily exists on the file system).
|
||||||
|
# content - Content of the file.
|
||||||
|
#
|
||||||
|
# Returns a FileBlob.
|
||||||
|
def initialize(path, content)
|
||||||
|
@path = path
|
||||||
|
@content = content
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Filename
|
||||||
|
#
|
||||||
|
# Examples
|
||||||
|
#
|
||||||
|
# Blob.new("/path/to/linguist/lib/linguist.rb", "").path
|
||||||
|
# # => "/path/to/linguist/lib/linguist.rb"
|
||||||
|
#
|
||||||
|
# Returns a String
|
||||||
|
attr_reader :path
|
||||||
|
|
||||||
|
# Public: File name
|
||||||
|
#
|
||||||
|
# Returns a String
|
||||||
|
def name
|
||||||
|
File.basename(@path)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: File contents.
|
||||||
|
#
|
||||||
|
# Returns a String.
|
||||||
|
def data
|
||||||
|
@content
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Get byte size
|
||||||
|
#
|
||||||
|
# Returns an Integer.
|
||||||
|
def size
|
||||||
|
@content.bytesize
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Get file extension.
|
||||||
|
#
|
||||||
|
# Returns a String.
|
||||||
|
def extension
|
||||||
|
extensions.last || ""
|
||||||
|
end
|
||||||
|
|
||||||
|
# Public: Return an array of the file extensions
|
||||||
|
#
|
||||||
|
# >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions
|
||||||
|
# => [".html.erb", ".erb"]
|
||||||
|
#
|
||||||
|
# Returns an Array
|
||||||
|
def extensions
|
||||||
|
basename, *segments = name.downcase.split(".")
|
||||||
|
|
||||||
|
segments.map.with_index do |segment, index|
|
||||||
|
"." + segments[index..-1].join(".")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
require 'linguist/blob_helper'
|
require 'linguist/blob_helper'
|
||||||
|
require 'linguist/blob'
|
||||||
|
|
||||||
module Linguist
|
module Linguist
|
||||||
# A FileBlob is a wrapper around a File object to make it quack
|
# A FileBlob is a wrapper around a File object to make it quack
|
||||||
# like a Grit::Blob. It provides the basic interface: `name`,
|
# like a Grit::Blob. It provides the basic interface: `name`,
|
||||||
# `data`, `path` and `size`.
|
# `data`, `path` and `size`.
|
||||||
class FileBlob
|
class FileBlob < Blob
|
||||||
include BlobHelper
|
include BlobHelper
|
||||||
|
|
||||||
# Public: Initialize a new FileBlob from a path
|
# Public: Initialize a new FileBlob from a path
|
||||||
@@ -18,20 +19,6 @@ module Linguist
|
|||||||
@path = base_path ? path.sub("#{base_path}/", '') : path
|
@path = base_path ? path.sub("#{base_path}/", '') : path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Filename
|
|
||||||
#
|
|
||||||
# Examples
|
|
||||||
#
|
|
||||||
# FileBlob.new("/path/to/linguist/lib/linguist.rb").path
|
|
||||||
# # => "/path/to/linguist/lib/linguist.rb"
|
|
||||||
#
|
|
||||||
# FileBlob.new("/path/to/linguist/lib/linguist.rb",
|
|
||||||
# "/path/to/linguist").path
|
|
||||||
# # => "lib/linguist.rb"
|
|
||||||
#
|
|
||||||
# Returns a String
|
|
||||||
attr_reader :path
|
|
||||||
|
|
||||||
# Public: Read file permissions
|
# Public: Read file permissions
|
||||||
#
|
#
|
||||||
# Returns a String like '100644'
|
# Returns a String like '100644'
|
||||||
@@ -39,13 +26,6 @@ module Linguist
|
|||||||
File.stat(@fullpath).mode.to_s(8)
|
File.stat(@fullpath).mode.to_s(8)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: File name
|
|
||||||
#
|
|
||||||
# Returns a String
|
|
||||||
def name
|
|
||||||
File.basename(@fullpath)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Public: Read file contents.
|
# Public: Read file contents.
|
||||||
#
|
#
|
||||||
# Returns a String.
|
# Returns a String.
|
||||||
@@ -59,26 +39,5 @@ module Linguist
|
|||||||
def size
|
def size
|
||||||
File.size(@fullpath)
|
File.size(@fullpath)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Get file extension.
|
|
||||||
#
|
|
||||||
# Returns a String.
|
|
||||||
def extension
|
|
||||||
extensions.last || ""
|
|
||||||
end
|
|
||||||
|
|
||||||
# Public: Return an array of the file extensions
|
|
||||||
#
|
|
||||||
# >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions
|
|
||||||
# => [".html.erb", ".erb"]
|
|
||||||
#
|
|
||||||
# Returns an Array
|
|
||||||
def extensions
|
|
||||||
basename, *segments = name.downcase.split(".")
|
|
||||||
|
|
||||||
segments.map.with_index do |segment, index|
|
|
||||||
"." + segments[index..-1].join(".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ module Linguist
|
|||||||
generated_jni_header? ||
|
generated_jni_header? ||
|
||||||
vcr_cassette? ||
|
vcr_cassette? ||
|
||||||
generated_module? ||
|
generated_module? ||
|
||||||
generated_unity3d_meta?
|
generated_unity3d_meta? ||
|
||||||
|
generated_racc?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Internal: Is the blob an Xcode file?
|
# Internal: Is the blob an Xcode file?
|
||||||
@@ -359,5 +360,18 @@ module Linguist
|
|||||||
return false unless lines.count > 1
|
return false unless lines.count > 1
|
||||||
return lines[0].include?("fileFormatVersion: ")
|
return lines[0].include?("fileFormatVersion: ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Internal: Is this a Racc-generated file?
|
||||||
|
#
|
||||||
|
# A Racc-generated file contains:
|
||||||
|
# # This file is automatically generated by Racc x.y.z
|
||||||
|
# on the third line.
|
||||||
|
#
|
||||||
|
# Return true or false
|
||||||
|
def generated_racc?
|
||||||
|
return false unless extname == '.rb'
|
||||||
|
return false unless lines.count > 2
|
||||||
|
return lines[2].start_with?("# This file is automatically generated by Racc")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1029,6 +1029,16 @@ Forth:
|
|||||||
- .fs
|
- .fs
|
||||||
ace_mode: forth
|
ace_mode: forth
|
||||||
|
|
||||||
|
FreeMarker:
|
||||||
|
type: programming
|
||||||
|
color: "#0050b2"
|
||||||
|
aliases:
|
||||||
|
- ftl
|
||||||
|
extensions:
|
||||||
|
- .ftl
|
||||||
|
tm_scope: text.html.ftl
|
||||||
|
ace_mode: ftl
|
||||||
|
|
||||||
Frege:
|
Frege:
|
||||||
type: programming
|
type: programming
|
||||||
color: "#00cafe"
|
color: "#00cafe"
|
||||||
@@ -1323,6 +1333,16 @@ HTML+Django:
|
|||||||
- htmldjango
|
- htmldjango
|
||||||
ace_mode: django
|
ace_mode: django
|
||||||
|
|
||||||
|
HTML+EEX:
|
||||||
|
type: markup
|
||||||
|
tm_scope: text.html.elixir
|
||||||
|
group: HTML
|
||||||
|
aliases:
|
||||||
|
- eex
|
||||||
|
extensions:
|
||||||
|
- .eex
|
||||||
|
ace_mode: text
|
||||||
|
|
||||||
HTML+ERB:
|
HTML+ERB:
|
||||||
type: markup
|
type: markup
|
||||||
tm_scope: text.html.erb
|
tm_scope: text.html.erb
|
||||||
@@ -1332,7 +1352,7 @@ HTML+ERB:
|
|||||||
extensions:
|
extensions:
|
||||||
- .erb
|
- .erb
|
||||||
- .erb.deface
|
- .erb.deface
|
||||||
ace_mode: html_ruby
|
ace_mode: text
|
||||||
|
|
||||||
HTML+PHP:
|
HTML+PHP:
|
||||||
type: markup
|
type: markup
|
||||||
@@ -1681,6 +1701,7 @@ KiCad:
|
|||||||
type: programming
|
type: programming
|
||||||
extensions:
|
extensions:
|
||||||
- .sch
|
- .sch
|
||||||
|
- .brd
|
||||||
- .kicad_pcb
|
- .kicad_pcb
|
||||||
tm_scope: none
|
tm_scope: none
|
||||||
ace_mode: text
|
ace_mode: text
|
||||||
@@ -2063,6 +2084,14 @@ Mercury:
|
|||||||
tm_scope: source.mercury
|
tm_scope: source.mercury
|
||||||
ace_mode: prolog
|
ace_mode: prolog
|
||||||
|
|
||||||
|
Metal:
|
||||||
|
type: programming
|
||||||
|
color: "#8f14e9"
|
||||||
|
extensions:
|
||||||
|
- .metal
|
||||||
|
tm_scope: source.c++
|
||||||
|
ace_mode: c_cpp
|
||||||
|
|
||||||
MiniD: # Legacy
|
MiniD: # Legacy
|
||||||
type: programming
|
type: programming
|
||||||
searchable: false
|
searchable: false
|
||||||
@@ -2441,6 +2470,7 @@ PHP:
|
|||||||
- .php3
|
- .php3
|
||||||
- .php4
|
- .php4
|
||||||
- .php5
|
- .php5
|
||||||
|
- .phps
|
||||||
- .phpt
|
- .phpt
|
||||||
filenames:
|
filenames:
|
||||||
- Phakefile
|
- Phakefile
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Linguist
|
module Linguist
|
||||||
VERSION = "4.6.4"
|
VERSION = "4.7.0"
|
||||||
end
|
end
|
||||||
|
|||||||
31
samples/FreeMarker/example.ftl
Normal file
31
samples/FreeMarker/example.ftl
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<#import "layout.ftl" as layout>
|
||||||
|
|
||||||
|
<#assign results = [
|
||||||
|
{
|
||||||
|
"title": "Example Result",
|
||||||
|
"description": "Lorem ipsum dolor sit amet, pede id pellentesque, sollicitudin turpis sed in sed sed, libero dictum."
|
||||||
|
}
|
||||||
|
] />
|
||||||
|
|
||||||
|
<@layout.page title="FreeMarker Example">
|
||||||
|
<#if results?size == 0>
|
||||||
|
There were no results.
|
||||||
|
<#else>
|
||||||
|
<ul>
|
||||||
|
<#list results as result>
|
||||||
|
<li>
|
||||||
|
<strong>${result.title}</strong>
|
||||||
|
<p>${result.description}</p>
|
||||||
|
</li>
|
||||||
|
</#list>
|
||||||
|
</ul>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#-- This is a FreeMarker comment -->
|
||||||
|
<@currentTime />
|
||||||
|
</@layout.page>
|
||||||
|
|
||||||
|
|
||||||
|
<#macro currentTime>
|
||||||
|
${.now?string.full}
|
||||||
|
</#macro>
|
||||||
32
samples/FreeMarker/layout.ftl
Normal file
32
samples/FreeMarker/layout.ftl
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<#ftl strip_text=true />
|
||||||
|
|
||||||
|
<#macro page title>
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="${.lang}">
|
||||||
|
<head>
|
||||||
|
<title>${title}</title>
|
||||||
|
<@metaTags />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<#nested />
|
||||||
|
<@footer />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
|
||||||
|
<#---
|
||||||
|
Default meta tags
|
||||||
|
-->
|
||||||
|
<#macro metaTags>
|
||||||
|
<#compress>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta name="format-detection" content="telephone=no">
|
||||||
|
</#compress>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro footer>
|
||||||
|
<p>This page is using FreeMarker v${.version}</p>
|
||||||
|
</#macro>
|
||||||
26
samples/HTML+EEX/index.html.eex
Normal file
26
samples/HTML+EEX/index.html.eex
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<h1>Listing Books</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Summary</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<%= for book <- @books do %>
|
||||||
|
<tr>
|
||||||
|
<%# comment %>
|
||||||
|
<td><%= book.title %></td>
|
||||||
|
<td><%= book.content %></td>
|
||||||
|
<td><%= link "Show", to: book_path(@conn, :show, book) %></td>
|
||||||
|
<td><%= link "Edit", to: book_path(@conn, :edit, book) %></td>
|
||||||
|
<td><%= link "Delete", to: book_path(@conn, :delete, book), method: :delete, data: [confirm: "Are you sure?"] %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%= link "New book", to: book_path(@conn, :new) %>
|
||||||
14069
samples/KiCad/tc14badge.brd
Normal file
14069
samples/KiCad/tc14badge.brd
Normal file
File diff suppressed because it is too large
Load Diff
99
samples/Metal/ITMVisualisationEngine.metal
Normal file
99
samples/Metal/ITMVisualisationEngine.metal
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
// Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM
|
||||||
|
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
#include "../../DeviceAgnostic/ITMSceneReconstructionEngine.h"
|
||||||
|
#include "../../DeviceAgnostic/ITMVisualisationEngine.h"
|
||||||
|
#include "ITMVisualisationEngine_Metal.h"
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
kernel void genericRaycastVH_device(DEVICEPTR(Vector4f) *pointsRay [[ buffer(0) ]],
|
||||||
|
const CONSTPTR(ITMVoxel) *voxelData [[ buffer(1) ]],
|
||||||
|
const CONSTPTR(typename ITMVoxelIndex::IndexData) *voxelIndex [[ buffer(2) ]],
|
||||||
|
const CONSTPTR(Vector2f) *minmaxdata [[ buffer(3) ]],
|
||||||
|
const CONSTPTR(CreateICPMaps_Params) *params [[ buffer(4) ]],
|
||||||
|
uint2 threadIdx [[ thread_position_in_threadgroup ]],
|
||||||
|
uint2 blockIdx [[ threadgroup_position_in_grid ]],
|
||||||
|
uint2 blockDim [[ threads_per_threadgroup ]])
|
||||||
|
{
|
||||||
|
int x = threadIdx.x + blockIdx.x * blockDim.x, y = threadIdx.y + blockIdx.y * blockDim.y;
|
||||||
|
|
||||||
|
if (x >= params->imgSize.x || y >= params->imgSize.y) return;
|
||||||
|
|
||||||
|
int locId = x + y * params->imgSize.x;
|
||||||
|
int locId2 = (int)floor((float)x / minmaximg_subsample) + (int)floor((float)y / minmaximg_subsample) * params->imgSize.x;
|
||||||
|
|
||||||
|
castRay<ITMVoxel, ITMVoxelIndex>(pointsRay[locId], x, y, voxelData, voxelIndex, params->invM, params->invProjParams,
|
||||||
|
params->voxelSizes.y, params->lightSource.w, minmaxdata[locId2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void genericRaycastVGMissingPoints_device(DEVICEPTR(Vector4f) *forwardProjection [[ buffer(0) ]],
|
||||||
|
const CONSTPTR(int) *fwdProjMissingPoints [[ buffer(1) ]],
|
||||||
|
const CONSTPTR(ITMVoxel) *voxelData [[ buffer(2) ]],
|
||||||
|
const CONSTPTR(typename ITMVoxelIndex::IndexData) *voxelIndex [[ buffer(3) ]],
|
||||||
|
const CONSTPTR(Vector2f) *minmaxdata [[ buffer(4) ]],
|
||||||
|
const CONSTPTR(CreateICPMaps_Params) *params [[ buffer(5) ]],
|
||||||
|
uint2 threadIdx [[ thread_position_in_threadgroup ]],
|
||||||
|
uint2 blockIdx [[ threadgroup_position_in_grid ]],
|
||||||
|
uint2 blockDim [[ threads_per_threadgroup ]])
|
||||||
|
{
|
||||||
|
int pointId = threadIdx.x + blockIdx.x * blockDim.x;
|
||||||
|
|
||||||
|
if (pointId >= params->imgSize.z) return;
|
||||||
|
|
||||||
|
int locId = fwdProjMissingPoints[pointId];
|
||||||
|
int y = locId / params->imgSize.x, x = locId - y * params->imgSize.x;
|
||||||
|
int locId2 = (int)floor((float)x / minmaximg_subsample) + (int)floor((float)y / minmaximg_subsample) * params->imgSize.x;
|
||||||
|
|
||||||
|
castRay<ITMVoxel, ITMVoxelIndex>(forwardProjection[locId], x, y, voxelData, voxelIndex, params->invM, params->invProjParams,
|
||||||
|
params->voxelSizes.y, params->lightSource.w, minmaxdata[locId2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void renderICP_device(const CONSTPTR(Vector4f) *pointsRay [[ buffer(0) ]],
|
||||||
|
DEVICEPTR(Vector4f) *pointsMap [[ buffer(1) ]],
|
||||||
|
DEVICEPTR(Vector4f) *normalsMap [[ buffer(2) ]],
|
||||||
|
DEVICEPTR(Vector4u) *outRendering [[ buffer(3) ]],
|
||||||
|
const CONSTPTR(CreateICPMaps_Params) *params [[ buffer(4) ]],
|
||||||
|
uint2 threadIdx [[ thread_position_in_threadgroup ]],
|
||||||
|
uint2 blockIdx [[ threadgroup_position_in_grid ]],
|
||||||
|
uint2 blockDim [[ threads_per_threadgroup ]])
|
||||||
|
{
|
||||||
|
int x = threadIdx.x + blockIdx.x * blockDim.x, y = threadIdx.y + blockIdx.y * blockDim.y;
|
||||||
|
|
||||||
|
if (x >= params->imgSize.x || y >= params->imgSize.y) return;
|
||||||
|
|
||||||
|
processPixelICP<false>(outRendering, pointsMap, normalsMap, pointsRay, params->imgSize.xy, x, y, params->voxelSizes.x, TO_VECTOR3(params->lightSource));
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void renderForward_device(DEVICEPTR(Vector4u) *outRendering [[ buffer(0) ]],
|
||||||
|
const CONSTPTR(Vector4f) *pointsRay [[ buffer(1) ]],
|
||||||
|
const CONSTPTR(CreateICPMaps_Params) *params [[ buffer(2) ]],
|
||||||
|
uint2 threadIdx [[ thread_position_in_threadgroup ]],
|
||||||
|
uint2 blockIdx [[ threadgroup_position_in_grid ]],
|
||||||
|
uint2 blockDim [[ threads_per_threadgroup ]])
|
||||||
|
{
|
||||||
|
int x = threadIdx.x + blockIdx.x * blockDim.x, y = threadIdx.y + blockIdx.y * blockDim.y;
|
||||||
|
|
||||||
|
if (x >= params->imgSize.x || y >= params->imgSize.y) return;
|
||||||
|
|
||||||
|
processPixelForwardRender<false>(outRendering, pointsRay, params->imgSize.xy, x, y, params->voxelSizes.x, TO_VECTOR3(params->lightSource));
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void forwardProject_device(DEVICEPTR(Vector4f) *forwardProjection [[ buffer(0) ]],
|
||||||
|
const CONSTPTR(Vector4f) *pointsRay [[ buffer(1) ]],
|
||||||
|
const CONSTPTR(CreateICPMaps_Params) *params [[ buffer(2) ]],
|
||||||
|
uint2 threadIdx [[ thread_position_in_threadgroup ]],
|
||||||
|
uint2 blockIdx [[ threadgroup_position_in_grid ]],
|
||||||
|
uint2 blockDim [[ threads_per_threadgroup ]])
|
||||||
|
{
|
||||||
|
int x = (threadIdx.x + blockIdx.x * blockDim.x), y = (threadIdx.y + blockIdx.y * blockDim.y);
|
||||||
|
|
||||||
|
if (x >= params->imgSize.x || y >= params->imgSize.y) return;
|
||||||
|
|
||||||
|
int locId = x + y * params->imgSize.x;
|
||||||
|
Vector4f pixel = pointsRay[locId];
|
||||||
|
|
||||||
|
int locId_new = forwardProjectPixel(pixel * params->voxelSizes.x, params->M, params->projParams, params->imgSize.xy);
|
||||||
|
if (locId_new >= 0) forwardProjection[locId_new] = pixel;
|
||||||
|
}
|
||||||
31
samples/PHP/mail.phps
Normal file
31
samples/PHP/mail.phps
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This example shows sending a message using PHP's mail() function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../PHPMailerAutoload.php';
|
||||||
|
|
||||||
|
//Create a new PHPMailer instance
|
||||||
|
$mail = new PHPMailer;
|
||||||
|
//Set who the message is to be sent from
|
||||||
|
$mail->setFrom('from@example.com', 'First Last');
|
||||||
|
//Set an alternative reply-to address
|
||||||
|
$mail->addReplyTo('replyto@example.com', 'First Last');
|
||||||
|
//Set who the message is to be sent to
|
||||||
|
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||||
|
//Set the subject line
|
||||||
|
$mail->Subject = 'PHPMailer mail() test';
|
||||||
|
//Read an HTML message body from an external file, convert referenced images to embedded,
|
||||||
|
//convert HTML into a basic plain-text alternative body
|
||||||
|
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
|
||||||
|
//Replace the plain text body with one created manually
|
||||||
|
$mail->AltBody = 'This is a plain-text message body';
|
||||||
|
//Attach an image file
|
||||||
|
$mail->addAttachment('images/phpmailer_mini.png');
|
||||||
|
|
||||||
|
//send the message, check for errors
|
||||||
|
if (!$mail->send()) {
|
||||||
|
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||||
|
} else {
|
||||||
|
echo "Message sent!";
|
||||||
|
}
|
||||||
267
samples/Ruby/racc.rb
Normal file
267
samples/Ruby/racc.rb
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
#
|
||||||
|
# DO NOT MODIFY!!!!
|
||||||
|
# This file is automatically generated by Racc 1.4.7
|
||||||
|
# from Racc grammer file "".
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'racc/parser.rb'
|
||||||
|
module RJSON
|
||||||
|
class Parser < Racc::Parser
|
||||||
|
|
||||||
|
|
||||||
|
require 'rjson/handler'
|
||||||
|
|
||||||
|
attr_reader :handler
|
||||||
|
|
||||||
|
def initialize tokenizer, handler = Handler.new
|
||||||
|
@tokenizer = tokenizer
|
||||||
|
@handler = handler
|
||||||
|
super()
|
||||||
|
end
|
||||||
|
|
||||||
|
def next_token
|
||||||
|
@tokenizer.next_token
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse
|
||||||
|
do_parse
|
||||||
|
handler
|
||||||
|
end
|
||||||
|
##### State transition tables begin ###
|
||||||
|
|
||||||
|
racc_action_table = [
|
||||||
|
9, 33, 9, 11, 13, 16, 19, 22, 9, 7,
|
||||||
|
23, 1, 9, 11, 13, 16, 19, 29, 30, 7,
|
||||||
|
21, 1, 9, 11, 13, 16, 19, 31, nil, 7,
|
||||||
|
21, 1, 23, 7, nil, 1 ]
|
||||||
|
|
||||||
|
racc_action_check = [
|
||||||
|
6, 27, 33, 33, 33, 33, 33, 3, 31, 33,
|
||||||
|
6, 33, 29, 29, 29, 29, 29, 12, 22, 29,
|
||||||
|
12, 29, 2, 2, 2, 2, 2, 25, nil, 2,
|
||||||
|
2, 2, 25, 0, nil, 0 ]
|
||||||
|
|
||||||
|
racc_action_pointer = [
|
||||||
|
24, nil, 20, 7, nil, nil, -2, nil, nil, nil,
|
||||||
|
nil, nil, 10, nil, nil, nil, nil, nil, nil, nil,
|
||||||
|
nil, nil, 18, nil, nil, 20, nil, -7, nil, 10,
|
||||||
|
nil, 6, nil, 0, nil, nil, nil ]
|
||||||
|
|
||||||
|
racc_action_default = [
|
||||||
|
-27, -12, -21, -27, -1, -2, -27, -10, -15, -26,
|
||||||
|
-8, -22, -27, -23, -17, -16, -24, -20, -18, -25,
|
||||||
|
-19, -11, -27, -13, -3, -27, -6, -27, -9, -21,
|
||||||
|
37, -27, -4, -21, -14, -5, -7 ]
|
||||||
|
|
||||||
|
racc_goto_table = [
|
||||||
|
8, 26, 24, 27, 10, 3, 25, 5, 4, 12,
|
||||||
|
nil, nil, nil, nil, 28, nil, nil, nil, nil, nil,
|
||||||
|
nil, 32, nil, nil, nil, nil, 35, 34, 27, nil,
|
||||||
|
nil, 36 ]
|
||||||
|
|
||||||
|
racc_goto_check = [
|
||||||
|
9, 7, 5, 8, 11, 1, 6, 3, 2, 12,
|
||||||
|
nil, nil, nil, nil, 11, nil, nil, nil, nil, nil,
|
||||||
|
nil, 5, nil, nil, nil, nil, 7, 9, 8, nil,
|
||||||
|
nil, 9 ]
|
||||||
|
|
||||||
|
racc_goto_pointer = [
|
||||||
|
nil, 5, 8, 7, nil, -4, 0, -5, -3, -2,
|
||||||
|
nil, 2, 7, nil, nil ]
|
||||||
|
|
||||||
|
racc_goto_default = [
|
||||||
|
nil, nil, 14, 18, 6, nil, nil, nil, 20, nil,
|
||||||
|
2, nil, nil, 15, 17 ]
|
||||||
|
|
||||||
|
racc_reduce_table = [
|
||||||
|
0, 0, :racc_error,
|
||||||
|
1, 14, :_reduce_none,
|
||||||
|
1, 14, :_reduce_none,
|
||||||
|
2, 15, :_reduce_none,
|
||||||
|
3, 15, :_reduce_none,
|
||||||
|
3, 19, :_reduce_none,
|
||||||
|
1, 19, :_reduce_none,
|
||||||
|
3, 20, :_reduce_none,
|
||||||
|
2, 16, :_reduce_none,
|
||||||
|
3, 16, :_reduce_none,
|
||||||
|
1, 23, :_reduce_10,
|
||||||
|
1, 24, :_reduce_11,
|
||||||
|
1, 17, :_reduce_12,
|
||||||
|
1, 18, :_reduce_13,
|
||||||
|
3, 25, :_reduce_none,
|
||||||
|
1, 25, :_reduce_none,
|
||||||
|
1, 22, :_reduce_none,
|
||||||
|
1, 22, :_reduce_none,
|
||||||
|
1, 22, :_reduce_none,
|
||||||
|
1, 26, :_reduce_none,
|
||||||
|
1, 26, :_reduce_20,
|
||||||
|
0, 27, :_reduce_none,
|
||||||
|
1, 27, :_reduce_22,
|
||||||
|
1, 27, :_reduce_23,
|
||||||
|
1, 27, :_reduce_24,
|
||||||
|
1, 27, :_reduce_25,
|
||||||
|
1, 21, :_reduce_26 ]
|
||||||
|
|
||||||
|
racc_reduce_n = 27
|
||||||
|
|
||||||
|
racc_shift_n = 37
|
||||||
|
|
||||||
|
racc_token_table = {
|
||||||
|
false => 0,
|
||||||
|
:error => 1,
|
||||||
|
:STRING => 2,
|
||||||
|
:NUMBER => 3,
|
||||||
|
:TRUE => 4,
|
||||||
|
:FALSE => 5,
|
||||||
|
:NULL => 6,
|
||||||
|
"," => 7,
|
||||||
|
":" => 8,
|
||||||
|
"[" => 9,
|
||||||
|
"]" => 10,
|
||||||
|
"{" => 11,
|
||||||
|
"}" => 12 }
|
||||||
|
|
||||||
|
racc_nt_base = 13
|
||||||
|
|
||||||
|
racc_use_result_var = true
|
||||||
|
|
||||||
|
Racc_arg = [
|
||||||
|
racc_action_table,
|
||||||
|
racc_action_check,
|
||||||
|
racc_action_default,
|
||||||
|
racc_action_pointer,
|
||||||
|
racc_goto_table,
|
||||||
|
racc_goto_check,
|
||||||
|
racc_goto_default,
|
||||||
|
racc_goto_pointer,
|
||||||
|
racc_nt_base,
|
||||||
|
racc_reduce_table,
|
||||||
|
racc_token_table,
|
||||||
|
racc_shift_n,
|
||||||
|
racc_reduce_n,
|
||||||
|
racc_use_result_var ]
|
||||||
|
|
||||||
|
Racc_token_to_s_table = [
|
||||||
|
"$end",
|
||||||
|
"error",
|
||||||
|
"STRING",
|
||||||
|
"NUMBER",
|
||||||
|
"TRUE",
|
||||||
|
"FALSE",
|
||||||
|
"NULL",
|
||||||
|
"\",\"",
|
||||||
|
"\":\"",
|
||||||
|
"\"[\"",
|
||||||
|
"\"]\"",
|
||||||
|
"\"{\"",
|
||||||
|
"\"}\"",
|
||||||
|
"$start",
|
||||||
|
"document",
|
||||||
|
"object",
|
||||||
|
"array",
|
||||||
|
"start_object",
|
||||||
|
"end_object",
|
||||||
|
"pairs",
|
||||||
|
"pair",
|
||||||
|
"string",
|
||||||
|
"value",
|
||||||
|
"start_array",
|
||||||
|
"end_array",
|
||||||
|
"values",
|
||||||
|
"scalar",
|
||||||
|
"literal" ]
|
||||||
|
|
||||||
|
Racc_debug_parser = false
|
||||||
|
|
||||||
|
##### State transition tables end #####
|
||||||
|
|
||||||
|
# reduce 0 omitted
|
||||||
|
|
||||||
|
# reduce 1 omitted
|
||||||
|
|
||||||
|
# reduce 2 omitted
|
||||||
|
|
||||||
|
# reduce 3 omitted
|
||||||
|
|
||||||
|
# reduce 4 omitted
|
||||||
|
|
||||||
|
# reduce 5 omitted
|
||||||
|
|
||||||
|
# reduce 6 omitted
|
||||||
|
|
||||||
|
# reduce 7 omitted
|
||||||
|
|
||||||
|
# reduce 8 omitted
|
||||||
|
|
||||||
|
# reduce 9 omitted
|
||||||
|
|
||||||
|
def _reduce_10(val, _values, result)
|
||||||
|
@handler.start_array
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_11(val, _values, result)
|
||||||
|
@handler.end_array
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_12(val, _values, result)
|
||||||
|
@handler.start_object
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_13(val, _values, result)
|
||||||
|
@handler.end_object
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
# reduce 14 omitted
|
||||||
|
|
||||||
|
# reduce 15 omitted
|
||||||
|
|
||||||
|
# reduce 16 omitted
|
||||||
|
|
||||||
|
# reduce 17 omitted
|
||||||
|
|
||||||
|
# reduce 18 omitted
|
||||||
|
|
||||||
|
# reduce 19 omitted
|
||||||
|
|
||||||
|
def _reduce_20(val, _values, result)
|
||||||
|
@handler.scalar val[0]
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
# reduce 21 omitted
|
||||||
|
|
||||||
|
def _reduce_22(val, _values, result)
|
||||||
|
n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_23(val, _values, result)
|
||||||
|
result = true
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_24(val, _values, result)
|
||||||
|
result = false
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_25(val, _values, result)
|
||||||
|
result = nil
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_26(val, _values, result)
|
||||||
|
@handler.scalar val[0].gsub(/^"|"$/, '')
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def _reduce_none(val, _values, result)
|
||||||
|
val[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
end # class Parser
|
||||||
|
end # module RJSON
|
||||||
@@ -3,6 +3,7 @@ require "minitest/autorun"
|
|||||||
require "mocha/setup"
|
require "mocha/setup"
|
||||||
require "linguist"
|
require "linguist"
|
||||||
require 'color-proximity'
|
require 'color-proximity'
|
||||||
|
require "linguist/blob"
|
||||||
require 'licensee'
|
require 'licensee'
|
||||||
|
|
||||||
def fixtures_path
|
def fixtures_path
|
||||||
@@ -10,8 +11,14 @@ def fixtures_path
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fixture_blob(name)
|
def fixture_blob(name)
|
||||||
name = File.join(fixtures_path, name) unless name =~ /^\//
|
filepath = (name =~ /^\//)? name : File.join(fixtures_path, name)
|
||||||
Linguist::FileBlob.new(name, fixtures_path)
|
Linguist::FileBlob.new(filepath, fixtures_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fixture_blob_memory(name)
|
||||||
|
filepath = (name =~ /^\//)? name : File.join(fixtures_path, name)
|
||||||
|
content = File.read(filepath)
|
||||||
|
Linguist::Blob.new(name, content)
|
||||||
end
|
end
|
||||||
|
|
||||||
def samples_path
|
def samples_path
|
||||||
@@ -19,6 +26,12 @@ def samples_path
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sample_blob(name)
|
def sample_blob(name)
|
||||||
name = File.join(samples_path, name) unless name =~ /^\//
|
filepath = (name =~ /^\//)? name : File.join(samples_path, name)
|
||||||
Linguist::FileBlob.new(name, samples_path)
|
Linguist::FileBlob.new(filepath, samples_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sample_blob_memory(name)
|
||||||
|
filepath = (name =~ /^\//)? name : File.join(samples_path, name)
|
||||||
|
content = File.read(filepath)
|
||||||
|
Linguist::Blob.new(name, content)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,50 +15,47 @@ class TestBlob < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def script_blob(name)
|
def script_blob(name)
|
||||||
blob = sample_blob(name)
|
blob = sample_blob_memory(name)
|
||||||
blob.instance_variable_set(:@name, 'script')
|
blob.instance_variable_set(:@name, 'script')
|
||||||
blob
|
blob
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_name
|
def test_name
|
||||||
assert_equal "foo.rb", sample_blob("foo.rb").name
|
assert_equal "foo.rb", sample_blob_memory("Ruby/foo.rb").name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mime_type
|
def test_mime_type
|
||||||
assert_equal "application/postscript", fixture_blob("Binary/octocat.ai").mime_type
|
assert_equal "application/postscript", fixture_blob_memory("Binary/octocat.ai").mime_type
|
||||||
assert_equal "application/x-ruby", sample_blob("Ruby/grit.rb").mime_type
|
assert_equal "application/x-ruby", sample_blob_memory("Ruby/grit.rb").mime_type
|
||||||
assert_equal "application/x-sh", sample_blob("Shell/script.sh").mime_type
|
assert_equal "application/x-sh", sample_blob_memory("Shell/script.sh").mime_type
|
||||||
assert_equal "application/xml", sample_blob("XML/bar.xml").mime_type
|
assert_equal "text/plain", fixture_blob_memory("Data/README").mime_type
|
||||||
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").mime_type
|
|
||||||
assert_equal "text/plain", fixture_blob("Data/README").mime_type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_content_type
|
def test_content_type
|
||||||
assert_equal "application/pdf", fixture_blob("Binary/foo.pdf").content_type
|
assert_equal "application/pdf", fixture_blob_memory("Binary/foo.pdf").content_type
|
||||||
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").content_type
|
assert_equal "image/png", fixture_blob_memory("Binary/foo.png").content_type
|
||||||
assert_equal "image/png", fixture_blob("Binary/foo.png").content_type
|
assert_equal "text/plain; charset=iso-8859-2", fixture_blob_memory("Data/README").content_type
|
||||||
assert_equal "text/plain; charset=iso-8859-2", fixture_blob("Data/README").content_type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_disposition
|
def test_disposition
|
||||||
assert_equal "attachment; filename=foo+bar.jar", fixture_blob("Binary/foo bar.jar").disposition
|
assert_equal "attachment; filename=foo+bar.jar", fixture_blob_memory("Binary/foo bar.jar").disposition
|
||||||
assert_equal "attachment; filename=foo.bin", fixture_blob("Binary/foo.bin").disposition
|
assert_equal "attachment; filename=foo.bin", fixture_blob_memory("Binary/foo.bin").disposition
|
||||||
assert_equal "attachment; filename=linguist.gem", fixture_blob("Binary/linguist.gem").disposition
|
assert_equal "attachment; filename=linguist.gem", fixture_blob_memory("Binary/linguist.gem").disposition
|
||||||
assert_equal "attachment; filename=octocat.ai", fixture_blob("Binary/octocat.ai").disposition
|
assert_equal "attachment; filename=octocat.ai", fixture_blob_memory("Binary/octocat.ai").disposition
|
||||||
assert_equal "inline", fixture_blob("Data/README").disposition
|
assert_equal "inline", fixture_blob_memory("Data/README").disposition
|
||||||
assert_equal "inline", sample_blob("Text/foo.txt").disposition
|
assert_equal "inline", sample_blob_memory("Text/foo.txt").disposition
|
||||||
assert_equal "inline", sample_blob("Ruby/grit.rb").disposition
|
assert_equal "inline", sample_blob_memory("Ruby/grit.rb").disposition
|
||||||
assert_equal "inline", fixture_blob("Binary/octocat.png").disposition
|
assert_equal "inline", fixture_blob_memory("Binary/octocat.png").disposition
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_data
|
def test_data
|
||||||
assert_equal "module Foo\nend\n", sample_blob("Ruby/foo.rb").data
|
assert_equal "module Foo\nend\n", sample_blob_memory("Ruby/foo.rb").data
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lines
|
def test_lines
|
||||||
assert_equal ["module Foo", "end", ""], sample_blob("Ruby/foo.rb").lines
|
assert_equal ["module Foo", "end", ""], sample_blob_memory("Ruby/foo.rb").lines
|
||||||
assert_equal ["line 1", "line 2", ""], sample_blob("Text/mac.txt").lines
|
assert_equal ["line 1", "line 2", ""], sample_blob_memory("Text/mac.txt").lines
|
||||||
assert_equal 475, sample_blob("Emacs Lisp/ess-julia.el").lines.length
|
assert_equal 475, sample_blob_memory("Emacs Lisp/ess-julia.el").lines.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lines_maintains_original_encoding
|
def test_lines_maintains_original_encoding
|
||||||
@@ -66,534 +63,173 @@ class TestBlob < Minitest::Test
|
|||||||
# earlier versions of the gem made implicit guarantees that the encoding of
|
# earlier versions of the gem made implicit guarantees that the encoding of
|
||||||
# each `line` is in the same encoding as the file was originally read (in
|
# each `line` is in the same encoding as the file was originally read (in
|
||||||
# practice, UTF-8 or ASCII-8BIT)
|
# practice, UTF-8 or ASCII-8BIT)
|
||||||
assert_equal Encoding.default_external, fixture_blob("Data/utf16le").lines.first.encoding
|
assert_equal Encoding.default_external, fixture_blob_memory("Data/utf16le").lines.first.encoding
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_size
|
def test_size
|
||||||
assert_equal 15, sample_blob("Ruby/foo.rb").size
|
assert_equal 15, sample_blob_memory("Ruby/foo.rb").size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_loc
|
def test_loc
|
||||||
assert_equal 3, sample_blob("Ruby/foo.rb").loc
|
assert_equal 3, sample_blob_memory("Ruby/foo.rb").loc
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sloc
|
def test_sloc
|
||||||
assert_equal 2, sample_blob("Ruby/foo.rb").sloc
|
assert_equal 2, sample_blob_memory("Ruby/foo.rb").sloc
|
||||||
assert_equal 3, fixture_blob("Data/utf16le-windows").sloc
|
assert_equal 3, fixture_blob_memory("Data/utf16le-windows").sloc
|
||||||
assert_equal 1, fixture_blob("Data/iso8859-8-i").sloc
|
assert_equal 1, fixture_blob_memory("Data/iso8859-8-i").sloc
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encoding
|
def test_encoding
|
||||||
assert_equal "ISO-8859-2", fixture_blob("Data/README").encoding
|
assert_equal "ISO-8859-2", fixture_blob_memory("Data/README").encoding
|
||||||
assert_equal "ISO-8859-2", fixture_blob("Data/README").ruby_encoding
|
assert_equal "ISO-8859-2", fixture_blob_memory("Data/README").ruby_encoding
|
||||||
assert_equal "UTF-8", sample_blob("Text/foo.txt").encoding
|
assert_equal "UTF-8", sample_blob_memory("Text/foo.txt").encoding
|
||||||
assert_equal "UTF-8", sample_blob("Text/foo.txt").ruby_encoding
|
assert_equal "UTF-8", sample_blob_memory("Text/foo.txt").ruby_encoding
|
||||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").encoding
|
assert_equal "UTF-16LE", fixture_blob_memory("Data/utf16le").encoding
|
||||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").ruby_encoding
|
assert_equal "UTF-16LE", fixture_blob_memory("Data/utf16le").ruby_encoding
|
||||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").encoding
|
assert_equal "UTF-16LE", fixture_blob_memory("Data/utf16le-windows").encoding
|
||||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").ruby_encoding
|
assert_equal "UTF-16LE", fixture_blob_memory("Data/utf16le-windows").ruby_encoding
|
||||||
assert_equal "ISO-2022-KR", sample_blob("Text/ISO-2022-KR.txt").encoding
|
assert_equal "ISO-2022-KR", sample_blob_memory("Text/ISO-2022-KR.txt").encoding
|
||||||
assert_equal "binary", sample_blob("Text/ISO-2022-KR.txt").ruby_encoding
|
assert_equal "binary", sample_blob_memory("Text/ISO-2022-KR.txt").ruby_encoding
|
||||||
assert_nil fixture_blob("Binary/dog.o").encoding
|
assert_nil fixture_blob_memory("Binary/dog.o").encoding
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_binary
|
def test_binary
|
||||||
# Large blobs aren't loaded
|
assert fixture_blob_memory("Binary/git.deb").binary?
|
||||||
large_blob = sample_blob("git.exe")
|
assert fixture_blob_memory("Binary/hello.pbc").binary?
|
||||||
large_blob.instance_eval do
|
assert fixture_blob_memory("Binary/linguist.gem").binary?
|
||||||
def data; end
|
assert fixture_blob_memory("Binary/octocat.ai").binary?
|
||||||
end
|
assert fixture_blob_memory("Binary/octocat.png").binary?
|
||||||
assert large_blob.binary?
|
assert fixture_blob_memory("Binary/zip").binary?
|
||||||
|
assert !fixture_blob_memory("Data/README").binary?
|
||||||
assert fixture_blob("Binary/git.deb").binary?
|
assert !sample_blob_memory("Ruby/foo.rb").binary?
|
||||||
assert fixture_blob("Binary/git.exe").binary?
|
assert !sample_blob_memory("Perl/script.pl").binary?
|
||||||
assert fixture_blob("Binary/hello.pbc").binary?
|
|
||||||
assert fixture_blob("Binary/linguist.gem").binary?
|
|
||||||
assert fixture_blob("Binary/octocat.ai").binary?
|
|
||||||
assert fixture_blob("Binary/octocat.png").binary?
|
|
||||||
assert fixture_blob("Binary/zip").binary?
|
|
||||||
assert !fixture_blob("Data/README").binary?
|
|
||||||
assert !sample_blob("Ruby/foo.rb").binary?
|
|
||||||
assert !sample_blob("Perl/script.pl").binary?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_all_binary
|
def test_all_binary
|
||||||
Samples.each do |sample|
|
Samples.each do |sample|
|
||||||
blob = sample_blob(sample[:path])
|
blob = sample_blob_memory(sample[:path])
|
||||||
assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file"
|
assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_text
|
def test_text
|
||||||
assert fixture_blob("Data/README").text?
|
assert fixture_blob_memory("Data/README").text?
|
||||||
assert fixture_blob("Data/md").text?
|
assert fixture_blob_memory("Data/md").text?
|
||||||
assert sample_blob("Shell/script.sh").text?
|
assert sample_blob_memory("Shell/script.sh").text?
|
||||||
assert fixture_blob("Data/txt").text?
|
assert fixture_blob_memory("Data/txt").text?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_image
|
def test_image
|
||||||
assert fixture_blob("Binary/octocat.gif").image?
|
assert fixture_blob_memory("Binary/octocat.png").image?
|
||||||
assert fixture_blob("Binary/octocat.jpeg").image?
|
assert !fixture_blob_memory("Binary/octocat.ai").image?
|
||||||
assert fixture_blob("Binary/octocat.jpg").image?
|
assert !fixture_blob_memory("Binary/octocat.psd").image?
|
||||||
assert fixture_blob("Binary/octocat.png").image?
|
|
||||||
assert !fixture_blob("Binary/octocat.ai").image?
|
|
||||||
assert !fixture_blob("Binary/octocat.psd").image?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_solid
|
def test_solid
|
||||||
assert fixture_blob("Binary/cube.stl").solid?
|
assert fixture_blob_memory("Binary/cube.stl").solid?
|
||||||
assert fixture_blob("Data/cube.stl").solid?
|
assert fixture_blob_memory("Data/cube.stl").solid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_csv
|
def test_csv
|
||||||
assert fixture_blob("Data/cars.csv").csv?
|
assert fixture_blob_memory("Data/cars.csv").csv?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pdf
|
def test_pdf
|
||||||
assert fixture_blob("Binary/foo.pdf").pdf?
|
assert fixture_blob_memory("Binary/foo.pdf").pdf?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_viewable
|
def test_viewable
|
||||||
assert fixture_blob("Data/README").viewable?
|
assert fixture_blob_memory("Data/README").viewable?
|
||||||
assert sample_blob("Ruby/foo.rb").viewable?
|
assert sample_blob_memory("Ruby/foo.rb").viewable?
|
||||||
assert sample_blob("Perl/script.pl").viewable?
|
assert sample_blob_memory("Perl/script.pl").viewable?
|
||||||
assert !fixture_blob("Binary/linguist.gem").viewable?
|
assert !fixture_blob_memory("Binary/linguist.gem").viewable?
|
||||||
assert !fixture_blob("Binary/octocat.ai").viewable?
|
assert !fixture_blob_memory("Binary/octocat.ai").viewable?
|
||||||
assert !fixture_blob("Binary/octocat.png").viewable?
|
assert !fixture_blob_memory("Binary/octocat.png").viewable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generated
|
def test_generated
|
||||||
assert !fixture_blob("Data/README").generated?
|
assert !fixture_blob_memory("Data/README").generated?
|
||||||
|
|
||||||
# Xcode project files
|
|
||||||
assert !sample_blob("XML/MainMenu.xib").generated?
|
|
||||||
assert fixture_blob("Binary/MainMenu.nib").generated?
|
|
||||||
assert !sample_blob("XML/project.pbxproj").generated?
|
|
||||||
|
|
||||||
# Gemfile.lock is NOT generated
|
|
||||||
assert !sample_blob("Gemfile.lock").generated?
|
|
||||||
|
|
||||||
# Generated .NET Docfiles
|
# Generated .NET Docfiles
|
||||||
assert sample_blob("XML/net_docfile.xml").generated?
|
assert sample_blob_memory("XML/net_docfile.xml").generated?
|
||||||
|
|
||||||
# Long line
|
# Long line
|
||||||
assert !sample_blob("JavaScript/uglify.js").generated?
|
assert !sample_blob_memory("JavaScript/uglify.js").generated?
|
||||||
|
|
||||||
# Inlined JS, but mostly code
|
# Inlined JS, but mostly code
|
||||||
assert !sample_blob("JavaScript/json2_backbone.js").generated?
|
assert !sample_blob_memory("JavaScript/json2_backbone.js").generated?
|
||||||
|
|
||||||
# Minified JS
|
# Minified JS
|
||||||
assert !sample_blob("JavaScript/jquery-1.6.1.js").generated?
|
assert !sample_blob_memory("JavaScript/jquery-1.6.1.js").generated?
|
||||||
assert sample_blob("JavaScript/jquery-1.6.1.min.js").generated?
|
assert sample_blob_memory("JavaScript/jquery-1.6.1.min.js").generated?
|
||||||
assert sample_blob("JavaScript/jquery-1.4.2.min.js").generated?
|
assert sample_blob_memory("JavaScript/jquery-1.4.2.min.js").generated?
|
||||||
|
|
||||||
# CoffeeScript-generated JS
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
# TypeScript-generated JS
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
# Composer generated composer.lock file
|
# Composer generated composer.lock file
|
||||||
assert sample_blob("JSON/composer.lock").generated?
|
assert sample_blob_memory("JSON/composer.lock").generated?
|
||||||
|
|
||||||
# PEG.js-generated parsers
|
# PEG.js-generated parsers
|
||||||
assert sample_blob("JavaScript/parser.js").generated?
|
assert sample_blob_memory("JavaScript/parser.js").generated?
|
||||||
|
|
||||||
# Generated PostScript
|
# Generated PostScript
|
||||||
assert !sample_blob("PostScript/sierpinski.ps").generated?
|
assert !sample_blob_memory("PostScript/sierpinski.ps").generated?
|
||||||
|
|
||||||
# These examples are too basic to tell
|
# These examples are too basic to tell
|
||||||
assert !sample_blob("JavaScript/hello.js").generated?
|
assert !sample_blob_memory("JavaScript/hello.js").generated?
|
||||||
|
|
||||||
assert sample_blob("JavaScript/intro-old.js").generated?
|
assert sample_blob_memory("JavaScript/intro-old.js").generated?
|
||||||
assert sample_blob("JavaScript/classes-old.js").generated?
|
assert sample_blob_memory("JavaScript/classes-old.js").generated?
|
||||||
|
|
||||||
assert sample_blob("JavaScript/intro.js").generated?
|
assert sample_blob_memory("JavaScript/intro.js").generated?
|
||||||
assert sample_blob("JavaScript/classes.js").generated?
|
assert sample_blob_memory("JavaScript/classes.js").generated?
|
||||||
|
|
||||||
# Protocol Buffer generated code
|
# Protocol Buffer generated code
|
||||||
assert sample_blob("C++/protocol-buffer.pb.h").generated?
|
assert sample_blob_memory("C++/protocol-buffer.pb.h").generated?
|
||||||
assert sample_blob("C++/protocol-buffer.pb.cc").generated?
|
assert sample_blob_memory("C++/protocol-buffer.pb.cc").generated?
|
||||||
assert sample_blob("Java/ProtocolBuffer.java").generated?
|
assert sample_blob_memory("Java/ProtocolBuffer.java").generated?
|
||||||
assert sample_blob("Python/protocol_buffer_pb2.py").generated?
|
assert sample_blob_memory("Python/protocol_buffer_pb2.py").generated?
|
||||||
assert sample_blob("Go/api.pb.go").generated?
|
assert sample_blob_memory("Go/api.pb.go").generated?
|
||||||
assert sample_blob("Go/embedded.go").generated?
|
assert sample_blob_memory("Go/embedded.go").generated?
|
||||||
|
|
||||||
# Apache Thrift generated code
|
# Apache Thrift generated code
|
||||||
assert sample_blob("Python/gen-py-linguist-thrift.py").generated?
|
assert sample_blob_memory("Python/gen-py-linguist-thrift.py").generated?
|
||||||
assert sample_blob("Go/gen-go-linguist-thrift.go").generated?
|
assert sample_blob_memory("Go/gen-go-linguist-thrift.go").generated?
|
||||||
assert sample_blob("Java/gen-java-linguist-thrift.java").generated?
|
assert sample_blob_memory("Java/gen-java-linguist-thrift.java").generated?
|
||||||
assert sample_blob("JavaScript/gen-js-linguist-thrift.js").generated?
|
assert sample_blob_memory("JavaScript/gen-js-linguist-thrift.js").generated?
|
||||||
assert sample_blob("Ruby/gen-rb-linguist-thrift.rb").generated?
|
assert sample_blob_memory("Ruby/gen-rb-linguist-thrift.rb").generated?
|
||||||
assert sample_blob("Objective-C/gen-cocoa-linguist-thrift.m").generated?
|
assert sample_blob_memory("Objective-C/gen-cocoa-linguist-thrift.m").generated?
|
||||||
|
|
||||||
# Generated JNI
|
# Generated JNI
|
||||||
assert sample_blob("C/jni_layer.h").generated?
|
assert sample_blob_memory("C/jni_layer.h").generated?
|
||||||
|
|
||||||
# Minified CSS
|
# Minified CSS
|
||||||
assert !sample_blob("CSS/bootstrap.css").generated?
|
assert !sample_blob_memory("CSS/bootstrap.css").generated?
|
||||||
assert sample_blob("CSS/bootstrap.min.css").generated?
|
assert sample_blob_memory("CSS/bootstrap.min.css").generated?
|
||||||
|
|
||||||
# Generated VCR
|
# Generated VCR
|
||||||
assert sample_blob("YAML/vcr_cassette.yml").generated?
|
assert sample_blob_memory("YAML/vcr_cassette.yml").generated?
|
||||||
|
|
||||||
# Generated by Zephir
|
# Generated by Zephir
|
||||||
assert sample_blob("Zephir/filenames/exception.zep.c").generated?
|
assert !sample_blob_memory("Zephir/Router.zep").generated?
|
||||||
assert sample_blob("Zephir/filenames/exception.zep.h").generated?
|
|
||||||
assert sample_blob("Zephir/filenames/exception.zep.php").generated?
|
|
||||||
assert !sample_blob("Zephir/Router.zep").generated?
|
|
||||||
|
|
||||||
assert sample_blob("node_modules/grunt/lib/grunt.js").generated?
|
|
||||||
|
|
||||||
# Godep saved dependencies
|
|
||||||
assert sample_blob("Godeps/Godeps.json").generated?
|
|
||||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
|
||||||
|
|
||||||
# Cython-generated C/C++
|
# Cython-generated C/C++
|
||||||
assert sample_blob("C/sgd_fast.c").generated?
|
assert sample_blob_memory("C/sgd_fast.c").generated?
|
||||||
assert sample_blob("C++/wrapper_inner.cpp").generated?
|
assert sample_blob_memory("C++/wrapper_inner.cpp").generated?
|
||||||
|
|
||||||
# Unity3D-generated metadata
|
# Unity3D-generated metadata
|
||||||
assert sample_blob("Unity3D Asset/Tiles.meta").generated?
|
assert sample_blob_memory("Unity3D Asset/Tiles.meta").generated?
|
||||||
|
|
||||||
|
# Racc-generated Ruby
|
||||||
|
assert sample_blob_memory("Ruby/racc.rb").generated?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_vendored
|
def test_vendored
|
||||||
assert !fixture_blob("Data/README").vendored?
|
assert !fixture_blob_memory("Data/README").vendored?
|
||||||
assert !sample_blob("ext/extconf.rb").vendored?
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
assert sample_blob("dependencies/windows/headers/GL/glext.h").vendored?
|
|
||||||
|
|
||||||
# Node dependencies
|
|
||||||
assert sample_blob("node_modules/coffee-script/lib/coffee-script.js").vendored?
|
|
||||||
|
|
||||||
# Bower Components
|
|
||||||
assert sample_blob("bower_components/custom/custom.js").vendored?
|
|
||||||
assert sample_blob("app/bower_components/custom/custom.js").vendored?
|
|
||||||
assert sample_blob("vendor/assets/bower_components/custom/custom.js").vendored?
|
|
||||||
|
|
||||||
# Go dependencies
|
|
||||||
assert !sample_blob("Godeps/Godeps.json").vendored?
|
|
||||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored?
|
|
||||||
|
|
||||||
# Rails vendor/
|
|
||||||
assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
|
||||||
|
|
||||||
# Vendor/
|
|
||||||
assert sample_blob("Vendor/my_great_file.h").vendored?
|
|
||||||
|
|
||||||
# 'thirdparty' directory
|
|
||||||
assert sample_blob("thirdparty/lib/main.c").vendored?
|
|
||||||
|
|
||||||
# 'extern(al)' directory
|
|
||||||
assert sample_blob("extern/util/__init__.py").vendored?
|
|
||||||
assert sample_blob("external/jquery.min.js").vendored?
|
|
||||||
|
|
||||||
# C deps
|
|
||||||
assert sample_blob("deps/http_parser/http_parser.c").vendored?
|
|
||||||
assert sample_blob("deps/v8/src/v8.h").vendored?
|
|
||||||
|
|
||||||
assert sample_blob("tools/something/else.c").vendored?
|
|
||||||
|
|
||||||
# Chart.js
|
|
||||||
assert sample_blob("some/vendored/path/Chart.js").vendored?
|
|
||||||
assert !sample_blob("some/vendored/path/chart.js").vendored?
|
|
||||||
|
|
||||||
# Codemirror deps
|
|
||||||
assert sample_blob("codemirror/mode/blah.js").vendored?
|
|
||||||
assert sample_blob("codemirror/5.0/mode/blah.js").vendored?
|
|
||||||
|
|
||||||
# Debian packaging
|
|
||||||
assert sample_blob("debian/cron.d").vendored?
|
|
||||||
|
|
||||||
# Erlang
|
|
||||||
assert sample_blob("rebar").vendored?
|
|
||||||
|
|
||||||
# git config files
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("some/path/.gitattributes"), :vendored?
|
|
||||||
assert_predicate fixture_blob(".gitignore"), :vendored?
|
|
||||||
assert_predicate fixture_blob("special/path/.gitmodules"), :vendored?
|
|
||||||
|
|
||||||
# Minified JavaScript and CSS
|
|
||||||
assert sample_blob("foo.min.js").vendored?
|
|
||||||
assert sample_blob("foo.min.css").vendored?
|
|
||||||
assert sample_blob("foo-min.js").vendored?
|
|
||||||
assert sample_blob("foo-min.css").vendored?
|
|
||||||
assert !sample_blob("foomin.css").vendored?
|
|
||||||
assert !sample_blob("foo.min.txt").vendored?
|
|
||||||
|
|
||||||
#.osx
|
|
||||||
assert sample_blob(".osx").vendored?
|
|
||||||
|
|
||||||
# Prototype
|
|
||||||
assert !sample_blob("public/javascripts/application.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/prototype.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/effects.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/controls.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/dragdrop.js").vendored?
|
|
||||||
|
|
||||||
# jQuery
|
|
||||||
assert sample_blob("jquery.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery.min.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.7.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.7.min.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.5.2.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.6.1.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.6.1.min.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.10.1.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/jquery-1.10.1.min.js").vendored?
|
|
||||||
assert !sample_blob("public/javascripts/jquery.github.menu.js").vendored?
|
|
||||||
|
|
||||||
# jQuery UI
|
|
||||||
assert sample_blob("themes/ui-lightness/jquery-ui.css").vendored?
|
|
||||||
assert sample_blob("themes/ui-lightness/jquery-ui-1.8.22.custom.css").vendored?
|
|
||||||
assert sample_blob("themes/ui-lightness/jquery.ui.accordion.css").vendored?
|
|
||||||
assert sample_blob("ui/i18n/jquery.ui.datepicker-ar.js").vendored?
|
|
||||||
assert sample_blob("ui/i18n/jquery-ui-i18n.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery.effects.blind.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery-ui-1.8.22.custom.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery-ui-1.8.22.custom.min.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery-ui-1.8.22.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery-ui-1.8.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery-ui.min.js").vendored?
|
|
||||||
assert sample_blob("ui/jquery.ui.accordion.js").vendored?
|
|
||||||
assert sample_blob("ui/minified/jquery.effects.blind.min.js").vendored?
|
|
||||||
assert sample_blob("ui/minified/jquery.ui.accordion.min.js").vendored?
|
|
||||||
|
|
||||||
# jQuery Gantt
|
|
||||||
assert sample_blob("web-app/jquery-gantt/js/jquery.fn.gantt.js").vendored?
|
|
||||||
|
|
||||||
# jQuery fancyBox
|
|
||||||
assert sample_blob("web-app/fancybox/jquery.fancybox.js").vendored?
|
|
||||||
|
|
||||||
# Fuel UX
|
|
||||||
assert sample_blob("web-app/fuelux/js/fuelux.js").vendored?
|
|
||||||
|
|
||||||
# jQuery File Upload
|
|
||||||
assert sample_blob("fileupload-9.0.0/jquery.fileupload-process.js").vendored?
|
|
||||||
|
|
||||||
# Slick
|
|
||||||
assert sample_blob("web-app/slickgrid/controls/slick.columnpicker.js").vendored?
|
|
||||||
|
|
||||||
# Leaflet plugins
|
|
||||||
assert sample_blob("leaflet-plugins/Leaflet.Coordinates-0.5.0.src.js").vendored?
|
|
||||||
assert sample_blob("leaflet-plugins/leaflet.draw-src.js").vendored?
|
|
||||||
assert sample_blob("leaflet-plugins/leaflet.spin.js").vendored?
|
|
||||||
|
|
||||||
# MooTools
|
|
||||||
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat-yc.js").vendored?
|
|
||||||
|
|
||||||
# Dojo
|
|
||||||
assert sample_blob("public/javascripts/dojo.js").vendored?
|
|
||||||
|
|
||||||
# MochiKit
|
|
||||||
assert sample_blob("public/javascripts/MochiKit.js").vendored?
|
|
||||||
|
|
||||||
# YUI
|
|
||||||
assert sample_blob("public/javascripts/yahoo-dom-event.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/yahoo-min.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/yuiloader-dom-event.js").vendored?
|
|
||||||
|
|
||||||
# WYS editors
|
|
||||||
assert sample_blob("public/javascripts/ckeditor.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/tiny_mce.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/tiny_mce_popup.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/tiny_mce_src.js").vendored?
|
|
||||||
|
|
||||||
# AngularJS
|
|
||||||
assert sample_blob("public/javascripts/angular.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/angular.min.js").vendored?
|
|
||||||
|
|
||||||
# D3.js
|
|
||||||
assert sample_blob("public/javascripts/d3.v3.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/d3.v3.min.js").vendored?
|
|
||||||
|
|
||||||
# Modernizr
|
|
||||||
assert sample_blob("public/javascripts/modernizr-2.7.1.js").vendored?
|
|
||||||
assert sample_blob("public/javascripts/modernizr.custom.01009.js").vendored?
|
|
||||||
|
|
||||||
# Fabric
|
|
||||||
assert sample_blob("fabfile.py").vendored?
|
|
||||||
|
|
||||||
# WAF
|
|
||||||
assert sample_blob("waf").vendored?
|
|
||||||
|
|
||||||
# Visual Studio IntelliSense
|
|
||||||
assert sample_blob("Scripts/jquery-1.7-vsdoc.js").vendored?
|
|
||||||
|
|
||||||
# Microsoft Ajax
|
|
||||||
assert sample_blob("Scripts/MicrosoftAjax.debug.js").vendored?
|
|
||||||
assert sample_blob("Scripts/MicrosoftAjax.js").vendored?
|
|
||||||
assert sample_blob("Scripts/MicrosoftMvcAjax.debug.js").vendored?
|
|
||||||
assert sample_blob("Scripts/MicrosoftMvcAjax.js").vendored?
|
|
||||||
assert sample_blob("Scripts/MicrosoftMvcValidation.debug.js").vendored?
|
|
||||||
assert sample_blob("Scripts/MicrosoftMvcValidation.js").vendored?
|
|
||||||
|
|
||||||
# jQuery validation plugin (MS bundles this with asp.net mvc)
|
|
||||||
assert sample_blob("Scripts/jquery.validate.js").vendored?
|
|
||||||
assert sample_blob("Scripts/jquery.validate.min.js").vendored?
|
|
||||||
assert sample_blob("Scripts/jquery.validate.unobtrusive.js").vendored?
|
|
||||||
assert sample_blob("Scripts/jquery.validate.unobtrusive.min.js").vendored?
|
|
||||||
assert sample_blob("Scripts/jquery.unobtrusive-ajax.js").vendored?
|
|
||||||
assert sample_blob("Scripts/jquery.unobtrusive-ajax.min.js").vendored?
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
assert sample_blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
|
|
||||||
|
|
||||||
# Font Awesome
|
|
||||||
assert sample_blob("some/asset/path/font-awesome.min.css").vendored?
|
|
||||||
assert sample_blob("some/asset/path/font-awesome.css").vendored?
|
|
||||||
|
|
||||||
# Normalize
|
|
||||||
assert sample_blob("some/asset/path/normalize.css").vendored?
|
|
||||||
|
|
||||||
# Carthage
|
|
||||||
assert sample_blob('Carthage/blah').vendored?
|
|
||||||
|
|
||||||
# Cocoapods
|
|
||||||
assert sample_blob('Pods/blah').vendored?
|
|
||||||
|
|
||||||
# Html5shiv
|
|
||||||
assert sample_blob("Scripts/html5shiv.js").vendored?
|
|
||||||
assert sample_blob("Scripts/html5shiv.min.js").vendored?
|
|
||||||
|
|
||||||
# Test fixtures
|
|
||||||
assert sample_blob("test/fixtures/random.rkt").vendored?
|
|
||||||
assert sample_blob("Test/fixtures/random.rkt").vendored?
|
|
||||||
assert sample_blob("tests/fixtures/random.rkt").vendored?
|
|
||||||
|
|
||||||
# Cordova/PhoneGap
|
|
||||||
assert sample_blob("cordova.js").vendored?
|
|
||||||
assert sample_blob("cordova.min.js").vendored?
|
|
||||||
assert sample_blob("cordova-2.1.0.js").vendored?
|
|
||||||
assert sample_blob("cordova-2.1.0.min.js").vendored?
|
|
||||||
|
|
||||||
# Foundation js
|
|
||||||
assert sample_blob("foundation.js").vendored?
|
|
||||||
assert sample_blob("foundation.min.js").vendored?
|
|
||||||
assert sample_blob("foundation.abide.js").vendored?
|
|
||||||
|
|
||||||
# Vagrant
|
|
||||||
assert sample_blob("Vagrantfile").vendored?
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
assert sample_blob("gradlew").vendored?
|
|
||||||
assert sample_blob("gradlew.bat").vendored?
|
|
||||||
assert sample_blob("gradle/wrapper/gradle-wrapper.properties").vendored?
|
|
||||||
assert sample_blob("subproject/gradlew").vendored?
|
|
||||||
assert sample_blob("subproject/gradlew.bat").vendored?
|
|
||||||
assert sample_blob("subproject/gradle/wrapper/gradle-wrapper.properties").vendored?
|
|
||||||
|
|
||||||
# Octicons
|
|
||||||
assert sample_blob("octicons.css").vendored?
|
|
||||||
assert sample_blob("public/octicons.min.css").vendored?
|
|
||||||
assert sample_blob("public/octicons/sprockets-octicons.scss").vendored?
|
|
||||||
|
|
||||||
# Typesafe Activator
|
|
||||||
assert sample_blob("activator").vendored?
|
|
||||||
assert sample_blob("activator.bat").vendored?
|
|
||||||
assert sample_blob("subproject/activator").vendored?
|
|
||||||
assert sample_blob("subproject/activator.bat").vendored?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob(".google_apis/bar.jar"), :vendored?
|
|
||||||
assert_predicate fixture_blob("foo/.google_apis/bar.jar"), :vendored?
|
|
||||||
|
|
||||||
# Sphinx docs
|
|
||||||
assert sample_blob("docs/_build/asset.doc").vendored?
|
|
||||||
assert sample_blob("docs/theme/file.css").vendored?
|
|
||||||
|
|
||||||
# Vagrant
|
|
||||||
assert sample_blob("puphpet/file.pp").vendored?
|
|
||||||
|
|
||||||
# Fabric.io
|
|
||||||
assert sample_blob("Fabric.framework/Fabric.h").vendored?
|
|
||||||
|
|
||||||
# Crashlytics
|
|
||||||
assert sample_blob("Crashlytics.framework/Crashlytics.h").vendored?
|
|
||||||
|
|
||||||
# Xcode
|
|
||||||
assert sample_blob("myapp/My Template.xctemplate/___FILEBASENAME___.h").vendored?
|
|
||||||
assert sample_blob("myapp/My Images.xcassets/some/stuff.imageset/Contents.json").vendored?
|
|
||||||
assert !sample_blob("myapp/MyData.json").vendored?
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_documentation
|
|
||||||
assert_predicate fixture_blob("doc/foo.html"), :documentation?
|
|
||||||
assert_predicate fixture_blob("docs/foo.html"), :documentation?
|
|
||||||
refute_predicate fixture_blob("project/doc/foo.html"), :documentation?
|
|
||||||
refute_predicate fixture_blob("project/docs/foo.html"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("Documentation/foo.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("documentation/foo.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("project/Documentation/foo.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("project/documentation/foo.md"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("javadoc/foo.html"), :documentation?
|
|
||||||
assert_predicate fixture_blob("project/javadoc/foo.html"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("man/foo.html"), :documentation?
|
|
||||||
refute_predicate fixture_blob("project/man/foo.html"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("README"), :documentation?
|
|
||||||
assert_predicate fixture_blob("README.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("README.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("Readme"), :documentation?
|
|
||||||
assert_predicate fixture_blob("readme"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/README"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("CHANGE"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGE.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGE.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/CHANGE"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("CHANGELOG"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGELOG.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGELOG.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/CHANGELOG"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("CHANGES"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGES.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CHANGES.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/CHANGES"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("CONTRIBUTING"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CONTRIBUTING.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("CONTRIBUTING.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/CONTRIBUTING"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("examples/some-file.pl"), :documentation?
|
|
||||||
assert_predicate fixture_blob("Examples/some-example-file.rb"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("LICENSE"), :documentation?
|
|
||||||
assert_predicate fixture_blob("LICENCE.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("License.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("LICENSE.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/LICENSE"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("COPYING"), :documentation?
|
|
||||||
assert_predicate fixture_blob("COPYING.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("COPYING.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/COPYING"), :documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("INSTALL"), :documentation?
|
|
||||||
assert_predicate fixture_blob("INSTALL.md"), :documentation?
|
|
||||||
assert_predicate fixture_blob("INSTALL.txt"), :documentation?
|
|
||||||
assert_predicate fixture_blob("foo/INSTALL"), :documentation?
|
|
||||||
|
|
||||||
refute_predicate fixture_blob("foo.md"), :documentation?
|
|
||||||
|
|
||||||
# Samples
|
|
||||||
assert sample_blob("Samples/Ruby/foo.rb").documentation?
|
|
||||||
|
|
||||||
assert_predicate fixture_blob("INSTALL.txt"), :documentation?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_language
|
def test_language
|
||||||
Samples.each do |sample|
|
Samples.each do |sample|
|
||||||
blob = sample_blob(sample[:path])
|
blob = sample_blob_memory(sample[:path])
|
||||||
assert blob.language, "No language for #{sample[:path]}"
|
assert blob.language, "No language for #{sample[:path]}"
|
||||||
assert_equal sample[:language], blob.language.name, blob.name
|
assert_equal sample[:language], blob.language.name, blob.name
|
||||||
end
|
end
|
||||||
@@ -612,7 +248,7 @@ class TestBlob < Minitest::Test
|
|||||||
filepath = File.join(dirname, filename)
|
filepath = File.join(dirname, filename)
|
||||||
next unless File.file?(filepath)
|
next unless File.file?(filepath)
|
||||||
|
|
||||||
blob = fixture_blob(filepath)
|
blob = fixture_blob_memory(filepath)
|
||||||
if language == 'Data'
|
if language == 'Data'
|
||||||
assert blob.language.nil?, "A language was found for #{filepath}"
|
assert blob.language.nil?, "A language was found for #{filepath}"
|
||||||
elsif language == 'Generated'
|
elsif language == 'Generated'
|
||||||
@@ -626,7 +262,7 @@ class TestBlob < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_minified_files_not_safe_to_highlight
|
def test_minified_files_not_safe_to_highlight
|
||||||
assert !sample_blob("JavaScript/jquery-1.6.1.min.js").safe_to_colorize?
|
assert !sample_blob_memory("JavaScript/jquery-1.6.1.min.js").safe_to_colorize?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_empty
|
def test_empty
|
||||||
@@ -639,27 +275,19 @@ class TestBlob < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_include_in_language_stats
|
def test_include_in_language_stats
|
||||||
vendored = sample_blob("bower_components/custom/custom.js")
|
generated = sample_blob_memory("CSS/bootstrap.min.css")
|
||||||
assert_predicate vendored, :vendored?
|
|
||||||
refute_predicate vendored, :include_in_language_stats?
|
|
||||||
|
|
||||||
documentation = fixture_blob("README")
|
|
||||||
assert_predicate documentation, :documentation?
|
|
||||||
refute_predicate documentation, :include_in_language_stats?
|
|
||||||
|
|
||||||
generated = sample_blob("CSS/bootstrap.min.css")
|
|
||||||
assert_predicate generated, :generated?
|
assert_predicate generated, :generated?
|
||||||
refute_predicate generated, :include_in_language_stats?
|
refute_predicate generated, :include_in_language_stats?
|
||||||
|
|
||||||
data = sample_blob("Ant Build System/filenames/ant.xml")
|
data = sample_blob_memory("Ant Build System/filenames/ant.xml")
|
||||||
assert_equal :data, data.language.type
|
assert_equal :data, data.language.type
|
||||||
refute_predicate data, :include_in_language_stats?
|
refute_predicate data, :include_in_language_stats?
|
||||||
|
|
||||||
prose = sample_blob("Markdown/tender.md")
|
prose = sample_blob_memory("Markdown/tender.md")
|
||||||
assert_equal :prose, prose.language.type
|
assert_equal :prose, prose.language.type
|
||||||
refute_predicate prose, :include_in_language_stats?
|
refute_predicate prose, :include_in_language_stats?
|
||||||
|
|
||||||
included = sample_blob("HTML/pages.html")
|
included = sample_blob_memory("HTML/pages.html")
|
||||||
assert_predicate included, :include_in_language_stats?
|
assert_predicate included, :include_in_language_stats?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,669 @@
|
|||||||
require_relative "./helper"
|
require_relative "./helper"
|
||||||
|
|
||||||
class TestFileBlob < Minitest::Test
|
class TestBlob < Minitest::Test
|
||||||
|
include Linguist
|
||||||
|
|
||||||
|
def setup
|
||||||
|
# git blobs are normally loaded as ASCII-8BIT since they may contain data
|
||||||
|
# with arbitrary encoding not known ahead of time
|
||||||
|
@original_external = Encoding.default_external
|
||||||
|
Encoding.default_external = Encoding.find("ASCII-8BIT")
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
Encoding.default_external = @original_external
|
||||||
|
end
|
||||||
|
|
||||||
|
def script_blob(name)
|
||||||
|
blob = sample_blob(name)
|
||||||
|
blob.instance_variable_set(:@name, 'script')
|
||||||
|
blob
|
||||||
|
end
|
||||||
|
|
||||||
def test_extensions
|
def test_extensions
|
||||||
assert_equal [".gitignore"], Linguist::FileBlob.new(".gitignore").extensions
|
assert_equal [".gitignore"], Linguist::FileBlob.new(".gitignore").extensions
|
||||||
assert_equal [".xml"], Linguist::FileBlob.new("build.xml").extensions
|
assert_equal [".xml"], Linguist::FileBlob.new("build.xml").extensions
|
||||||
assert_equal [".html.erb", ".erb"], Linguist::FileBlob.new("dotted.dir/index.html.erb").extensions
|
assert_equal [".html.erb", ".erb"], Linguist::FileBlob.new("dotted.dir/index.html.erb").extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_name
|
||||||
|
assert_equal "foo.rb", sample_blob("foo.rb").name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_mime_type
|
||||||
|
assert_equal "application/postscript", fixture_blob("Binary/octocat.ai").mime_type
|
||||||
|
assert_equal "application/x-ruby", sample_blob("Ruby/grit.rb").mime_type
|
||||||
|
assert_equal "application/x-sh", sample_blob("Shell/script.sh").mime_type
|
||||||
|
assert_equal "application/xml", sample_blob("XML/bar.xml").mime_type
|
||||||
|
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").mime_type
|
||||||
|
assert_equal "text/plain", fixture_blob("Data/README").mime_type
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_content_type
|
||||||
|
assert_equal "application/pdf", fixture_blob("Binary/foo.pdf").content_type
|
||||||
|
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").content_type
|
||||||
|
assert_equal "image/png", fixture_blob("Binary/foo.png").content_type
|
||||||
|
assert_equal "text/plain; charset=iso-8859-2", fixture_blob("Data/README").content_type
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_disposition
|
||||||
|
assert_equal "attachment; filename=foo+bar.jar", fixture_blob("Binary/foo bar.jar").disposition
|
||||||
|
assert_equal "attachment; filename=foo.bin", fixture_blob("Binary/foo.bin").disposition
|
||||||
|
assert_equal "attachment; filename=linguist.gem", fixture_blob("Binary/linguist.gem").disposition
|
||||||
|
assert_equal "attachment; filename=octocat.ai", fixture_blob("Binary/octocat.ai").disposition
|
||||||
|
assert_equal "inline", fixture_blob("Data/README").disposition
|
||||||
|
assert_equal "inline", sample_blob("Text/foo.txt").disposition
|
||||||
|
assert_equal "inline", sample_blob("Ruby/grit.rb").disposition
|
||||||
|
assert_equal "inline", fixture_blob("Binary/octocat.png").disposition
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_data
|
||||||
|
assert_equal "module Foo\nend\n", sample_blob("Ruby/foo.rb").data
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_lines
|
||||||
|
assert_equal ["module Foo", "end", ""], sample_blob("Ruby/foo.rb").lines
|
||||||
|
assert_equal ["line 1", "line 2", ""], sample_blob("Text/mac.txt").lines
|
||||||
|
assert_equal 475, sample_blob("Emacs Lisp/ess-julia.el").lines.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_lines_maintains_original_encoding
|
||||||
|
# Even if the file's encoding is detected as something like UTF-16LE,
|
||||||
|
# earlier versions of the gem made implicit guarantees that the encoding of
|
||||||
|
# each `line` is in the same encoding as the file was originally read (in
|
||||||
|
# practice, UTF-8 or ASCII-8BIT)
|
||||||
|
assert_equal Encoding.default_external, fixture_blob("Data/utf16le").lines.first.encoding
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_size
|
||||||
|
assert_equal 15, sample_blob("Ruby/foo.rb").size
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_loc
|
||||||
|
assert_equal 3, sample_blob("Ruby/foo.rb").loc
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_sloc
|
||||||
|
assert_equal 2, sample_blob("Ruby/foo.rb").sloc
|
||||||
|
assert_equal 3, fixture_blob("Data/utf16le-windows").sloc
|
||||||
|
assert_equal 1, fixture_blob("Data/iso8859-8-i").sloc
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_encoding
|
||||||
|
assert_equal "ISO-8859-2", fixture_blob("Data/README").encoding
|
||||||
|
assert_equal "ISO-8859-2", fixture_blob("Data/README").ruby_encoding
|
||||||
|
assert_equal "UTF-8", sample_blob("Text/foo.txt").encoding
|
||||||
|
assert_equal "UTF-8", sample_blob("Text/foo.txt").ruby_encoding
|
||||||
|
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").encoding
|
||||||
|
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").ruby_encoding
|
||||||
|
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").encoding
|
||||||
|
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").ruby_encoding
|
||||||
|
assert_equal "ISO-2022-KR", sample_blob("Text/ISO-2022-KR.txt").encoding
|
||||||
|
assert_equal "binary", sample_blob("Text/ISO-2022-KR.txt").ruby_encoding
|
||||||
|
assert_nil fixture_blob("Binary/dog.o").encoding
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_binary
|
||||||
|
# Large blobs aren't loaded
|
||||||
|
large_blob = sample_blob("git.exe")
|
||||||
|
large_blob.instance_eval do
|
||||||
|
def data; end
|
||||||
|
end
|
||||||
|
assert large_blob.binary?
|
||||||
|
|
||||||
|
assert fixture_blob("Binary/git.deb").binary?
|
||||||
|
assert fixture_blob("Binary/git.exe").binary?
|
||||||
|
assert fixture_blob("Binary/hello.pbc").binary?
|
||||||
|
assert fixture_blob("Binary/linguist.gem").binary?
|
||||||
|
assert fixture_blob("Binary/octocat.ai").binary?
|
||||||
|
assert fixture_blob("Binary/octocat.png").binary?
|
||||||
|
assert fixture_blob("Binary/zip").binary?
|
||||||
|
assert !fixture_blob("Data/README").binary?
|
||||||
|
assert !sample_blob("Ruby/foo.rb").binary?
|
||||||
|
assert !sample_blob("Perl/script.pl").binary?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_all_binary
|
||||||
|
Samples.each do |sample|
|
||||||
|
blob = sample_blob(sample[:path])
|
||||||
|
assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_text
|
||||||
|
assert fixture_blob("Data/README").text?
|
||||||
|
assert fixture_blob("Data/md").text?
|
||||||
|
assert sample_blob("Shell/script.sh").text?
|
||||||
|
assert fixture_blob("Data/txt").text?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_image
|
||||||
|
assert fixture_blob("Binary/octocat.gif").image?
|
||||||
|
assert fixture_blob("Binary/octocat.jpeg").image?
|
||||||
|
assert fixture_blob("Binary/octocat.jpg").image?
|
||||||
|
assert fixture_blob("Binary/octocat.png").image?
|
||||||
|
assert !fixture_blob("Binary/octocat.ai").image?
|
||||||
|
assert !fixture_blob("Binary/octocat.psd").image?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_solid
|
||||||
|
assert fixture_blob("Binary/cube.stl").solid?
|
||||||
|
assert fixture_blob("Data/cube.stl").solid?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_csv
|
||||||
|
assert fixture_blob("Data/cars.csv").csv?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pdf
|
||||||
|
assert fixture_blob("Binary/foo.pdf").pdf?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_viewable
|
||||||
|
assert fixture_blob("Data/README").viewable?
|
||||||
|
assert sample_blob("Ruby/foo.rb").viewable?
|
||||||
|
assert sample_blob("Perl/script.pl").viewable?
|
||||||
|
assert !fixture_blob("Binary/linguist.gem").viewable?
|
||||||
|
assert !fixture_blob("Binary/octocat.ai").viewable?
|
||||||
|
assert !fixture_blob("Binary/octocat.png").viewable?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generated
|
||||||
|
assert !fixture_blob("Data/README").generated?
|
||||||
|
|
||||||
|
# Xcode project files
|
||||||
|
assert !sample_blob("XML/MainMenu.xib").generated?
|
||||||
|
assert fixture_blob("Binary/MainMenu.nib").generated?
|
||||||
|
assert !sample_blob("XML/project.pbxproj").generated?
|
||||||
|
|
||||||
|
# Gemfile.lock is NOT generated
|
||||||
|
assert !sample_blob("Gemfile.lock").generated?
|
||||||
|
|
||||||
|
# Generated .NET Docfiles
|
||||||
|
assert sample_blob("XML/net_docfile.xml").generated?
|
||||||
|
|
||||||
|
# Long line
|
||||||
|
assert !sample_blob("JavaScript/uglify.js").generated?
|
||||||
|
|
||||||
|
# Inlined JS, but mostly code
|
||||||
|
assert !sample_blob("JavaScript/json2_backbone.js").generated?
|
||||||
|
|
||||||
|
# Minified JS
|
||||||
|
assert !sample_blob("JavaScript/jquery-1.6.1.js").generated?
|
||||||
|
assert sample_blob("JavaScript/jquery-1.6.1.min.js").generated?
|
||||||
|
assert sample_blob("JavaScript/jquery-1.4.2.min.js").generated?
|
||||||
|
|
||||||
|
# CoffeeScript-generated JS
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# TypeScript-generated JS
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# Composer generated composer.lock file
|
||||||
|
assert sample_blob("JSON/composer.lock").generated?
|
||||||
|
|
||||||
|
# PEG.js-generated parsers
|
||||||
|
assert sample_blob("JavaScript/parser.js").generated?
|
||||||
|
|
||||||
|
# Generated PostScript
|
||||||
|
assert !sample_blob("PostScript/sierpinski.ps").generated?
|
||||||
|
|
||||||
|
# These examples are too basic to tell
|
||||||
|
assert !sample_blob("JavaScript/hello.js").generated?
|
||||||
|
|
||||||
|
assert sample_blob("JavaScript/intro-old.js").generated?
|
||||||
|
assert sample_blob("JavaScript/classes-old.js").generated?
|
||||||
|
|
||||||
|
assert sample_blob("JavaScript/intro.js").generated?
|
||||||
|
assert sample_blob("JavaScript/classes.js").generated?
|
||||||
|
|
||||||
|
# Protocol Buffer generated code
|
||||||
|
assert sample_blob("C++/protocol-buffer.pb.h").generated?
|
||||||
|
assert sample_blob("C++/protocol-buffer.pb.cc").generated?
|
||||||
|
assert sample_blob("Java/ProtocolBuffer.java").generated?
|
||||||
|
assert sample_blob("Python/protocol_buffer_pb2.py").generated?
|
||||||
|
assert sample_blob("Go/api.pb.go").generated?
|
||||||
|
assert sample_blob("Go/embedded.go").generated?
|
||||||
|
|
||||||
|
# Apache Thrift generated code
|
||||||
|
assert sample_blob("Python/gen-py-linguist-thrift.py").generated?
|
||||||
|
assert sample_blob("Go/gen-go-linguist-thrift.go").generated?
|
||||||
|
assert sample_blob("Java/gen-java-linguist-thrift.java").generated?
|
||||||
|
assert sample_blob("JavaScript/gen-js-linguist-thrift.js").generated?
|
||||||
|
assert sample_blob("Ruby/gen-rb-linguist-thrift.rb").generated?
|
||||||
|
assert sample_blob("Objective-C/gen-cocoa-linguist-thrift.m").generated?
|
||||||
|
|
||||||
|
# Generated JNI
|
||||||
|
assert sample_blob("C/jni_layer.h").generated?
|
||||||
|
|
||||||
|
# Minified CSS
|
||||||
|
assert !sample_blob("CSS/bootstrap.css").generated?
|
||||||
|
assert sample_blob("CSS/bootstrap.min.css").generated?
|
||||||
|
|
||||||
|
# Generated VCR
|
||||||
|
assert sample_blob("YAML/vcr_cassette.yml").generated?
|
||||||
|
|
||||||
|
# Generated by Zephir
|
||||||
|
assert sample_blob("Zephir/filenames/exception.zep.c").generated?
|
||||||
|
assert sample_blob("Zephir/filenames/exception.zep.h").generated?
|
||||||
|
assert sample_blob("Zephir/filenames/exception.zep.php").generated?
|
||||||
|
assert !sample_blob("Zephir/Router.zep").generated?
|
||||||
|
|
||||||
|
assert sample_blob("node_modules/grunt/lib/grunt.js").generated?
|
||||||
|
|
||||||
|
# Godep saved dependencies
|
||||||
|
assert sample_blob("Godeps/Godeps.json").generated?
|
||||||
|
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
||||||
|
|
||||||
|
# Cython-generated C/C++
|
||||||
|
assert sample_blob("C/sgd_fast.c").generated?
|
||||||
|
assert sample_blob("C++/wrapper_inner.cpp").generated?
|
||||||
|
|
||||||
|
# Unity3D-generated metadata
|
||||||
|
assert sample_blob("Unity3D Asset/Tiles.meta").generated?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_vendored
|
||||||
|
assert !fixture_blob("Data/README").vendored?
|
||||||
|
assert !sample_blob("ext/extconf.rb").vendored?
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
assert sample_blob("dependencies/windows/headers/GL/glext.h").vendored?
|
||||||
|
|
||||||
|
# Node dependencies
|
||||||
|
assert sample_blob("node_modules/coffee-script/lib/coffee-script.js").vendored?
|
||||||
|
|
||||||
|
# Bower Components
|
||||||
|
assert sample_blob("bower_components/custom/custom.js").vendored?
|
||||||
|
assert sample_blob("app/bower_components/custom/custom.js").vendored?
|
||||||
|
assert sample_blob("vendor/assets/bower_components/custom/custom.js").vendored?
|
||||||
|
|
||||||
|
# Go dependencies
|
||||||
|
assert !sample_blob("Godeps/Godeps.json").vendored?
|
||||||
|
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored?
|
||||||
|
|
||||||
|
# Rails vendor/
|
||||||
|
assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
||||||
|
|
||||||
|
# Vendor/
|
||||||
|
assert sample_blob("Vendor/my_great_file.h").vendored?
|
||||||
|
|
||||||
|
# 'thirdparty' directory
|
||||||
|
assert sample_blob("thirdparty/lib/main.c").vendored?
|
||||||
|
|
||||||
|
# 'extern(al)' directory
|
||||||
|
assert sample_blob("extern/util/__init__.py").vendored?
|
||||||
|
assert sample_blob("external/jquery.min.js").vendored?
|
||||||
|
|
||||||
|
# C deps
|
||||||
|
assert sample_blob("deps/http_parser/http_parser.c").vendored?
|
||||||
|
assert sample_blob("deps/v8/src/v8.h").vendored?
|
||||||
|
|
||||||
|
assert sample_blob("tools/something/else.c").vendored?
|
||||||
|
|
||||||
|
# Chart.js
|
||||||
|
assert sample_blob("some/vendored/path/Chart.js").vendored?
|
||||||
|
assert !sample_blob("some/vendored/path/chart.js").vendored?
|
||||||
|
|
||||||
|
# Codemirror deps
|
||||||
|
assert sample_blob("codemirror/mode/blah.js").vendored?
|
||||||
|
assert sample_blob("codemirror/5.0/mode/blah.js").vendored?
|
||||||
|
|
||||||
|
# Debian packaging
|
||||||
|
assert sample_blob("debian/cron.d").vendored?
|
||||||
|
|
||||||
|
# Erlang
|
||||||
|
assert sample_blob("rebar").vendored?
|
||||||
|
|
||||||
|
# git config files
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("some/path/.gitattributes"), :vendored?
|
||||||
|
assert_predicate fixture_blob(".gitignore"), :vendored?
|
||||||
|
assert_predicate fixture_blob("special/path/.gitmodules"), :vendored?
|
||||||
|
|
||||||
|
# Minified JavaScript and CSS
|
||||||
|
assert sample_blob("foo.min.js").vendored?
|
||||||
|
assert sample_blob("foo.min.css").vendored?
|
||||||
|
assert sample_blob("foo-min.js").vendored?
|
||||||
|
assert sample_blob("foo-min.css").vendored?
|
||||||
|
assert !sample_blob("foomin.css").vendored?
|
||||||
|
assert !sample_blob("foo.min.txt").vendored?
|
||||||
|
|
||||||
|
#.osx
|
||||||
|
assert sample_blob(".osx").vendored?
|
||||||
|
|
||||||
|
# Prototype
|
||||||
|
assert !sample_blob("public/javascripts/application.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/prototype.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/effects.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/controls.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/dragdrop.js").vendored?
|
||||||
|
|
||||||
|
# jQuery
|
||||||
|
assert sample_blob("jquery.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery.min.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.7.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.7.min.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.5.2.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.6.1.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.6.1.min.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.10.1.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/jquery-1.10.1.min.js").vendored?
|
||||||
|
assert !sample_blob("public/javascripts/jquery.github.menu.js").vendored?
|
||||||
|
|
||||||
|
# jQuery UI
|
||||||
|
assert sample_blob("themes/ui-lightness/jquery-ui.css").vendored?
|
||||||
|
assert sample_blob("themes/ui-lightness/jquery-ui-1.8.22.custom.css").vendored?
|
||||||
|
assert sample_blob("themes/ui-lightness/jquery.ui.accordion.css").vendored?
|
||||||
|
assert sample_blob("ui/i18n/jquery.ui.datepicker-ar.js").vendored?
|
||||||
|
assert sample_blob("ui/i18n/jquery-ui-i18n.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery.effects.blind.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery-ui-1.8.22.custom.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery-ui-1.8.22.custom.min.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery-ui-1.8.22.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery-ui-1.8.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery-ui.min.js").vendored?
|
||||||
|
assert sample_blob("ui/jquery.ui.accordion.js").vendored?
|
||||||
|
assert sample_blob("ui/minified/jquery.effects.blind.min.js").vendored?
|
||||||
|
assert sample_blob("ui/minified/jquery.ui.accordion.min.js").vendored?
|
||||||
|
|
||||||
|
# jQuery Gantt
|
||||||
|
assert sample_blob("web-app/jquery-gantt/js/jquery.fn.gantt.js").vendored?
|
||||||
|
|
||||||
|
# jQuery fancyBox
|
||||||
|
assert sample_blob("web-app/fancybox/jquery.fancybox.js").vendored?
|
||||||
|
|
||||||
|
# Fuel UX
|
||||||
|
assert sample_blob("web-app/fuelux/js/fuelux.js").vendored?
|
||||||
|
|
||||||
|
# jQuery File Upload
|
||||||
|
assert sample_blob("fileupload-9.0.0/jquery.fileupload-process.js").vendored?
|
||||||
|
|
||||||
|
# Slick
|
||||||
|
assert sample_blob("web-app/slickgrid/controls/slick.columnpicker.js").vendored?
|
||||||
|
|
||||||
|
# Leaflet plugins
|
||||||
|
assert sample_blob("leaflet-plugins/Leaflet.Coordinates-0.5.0.src.js").vendored?
|
||||||
|
assert sample_blob("leaflet-plugins/leaflet.draw-src.js").vendored?
|
||||||
|
assert sample_blob("leaflet-plugins/leaflet.spin.js").vendored?
|
||||||
|
|
||||||
|
# MooTools
|
||||||
|
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat-yc.js").vendored?
|
||||||
|
|
||||||
|
# Dojo
|
||||||
|
assert sample_blob("public/javascripts/dojo.js").vendored?
|
||||||
|
|
||||||
|
# MochiKit
|
||||||
|
assert sample_blob("public/javascripts/MochiKit.js").vendored?
|
||||||
|
|
||||||
|
# YUI
|
||||||
|
assert sample_blob("public/javascripts/yahoo-dom-event.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/yahoo-min.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/yuiloader-dom-event.js").vendored?
|
||||||
|
|
||||||
|
# WYS editors
|
||||||
|
assert sample_blob("public/javascripts/ckeditor.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/tiny_mce.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/tiny_mce_popup.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/tiny_mce_src.js").vendored?
|
||||||
|
|
||||||
|
# AngularJS
|
||||||
|
assert sample_blob("public/javascripts/angular.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/angular.min.js").vendored?
|
||||||
|
|
||||||
|
# D3.js
|
||||||
|
assert sample_blob("public/javascripts/d3.v3.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/d3.v3.min.js").vendored?
|
||||||
|
|
||||||
|
# Modernizr
|
||||||
|
assert sample_blob("public/javascripts/modernizr-2.7.1.js").vendored?
|
||||||
|
assert sample_blob("public/javascripts/modernizr.custom.01009.js").vendored?
|
||||||
|
|
||||||
|
# Fabric
|
||||||
|
assert sample_blob("fabfile.py").vendored?
|
||||||
|
|
||||||
|
# WAF
|
||||||
|
assert sample_blob("waf").vendored?
|
||||||
|
|
||||||
|
# Visual Studio IntelliSense
|
||||||
|
assert sample_blob("Scripts/jquery-1.7-vsdoc.js").vendored?
|
||||||
|
|
||||||
|
# Microsoft Ajax
|
||||||
|
assert sample_blob("Scripts/MicrosoftAjax.debug.js").vendored?
|
||||||
|
assert sample_blob("Scripts/MicrosoftAjax.js").vendored?
|
||||||
|
assert sample_blob("Scripts/MicrosoftMvcAjax.debug.js").vendored?
|
||||||
|
assert sample_blob("Scripts/MicrosoftMvcAjax.js").vendored?
|
||||||
|
assert sample_blob("Scripts/MicrosoftMvcValidation.debug.js").vendored?
|
||||||
|
assert sample_blob("Scripts/MicrosoftMvcValidation.js").vendored?
|
||||||
|
|
||||||
|
# jQuery validation plugin (MS bundles this with asp.net mvc)
|
||||||
|
assert sample_blob("Scripts/jquery.validate.js").vendored?
|
||||||
|
assert sample_blob("Scripts/jquery.validate.min.js").vendored?
|
||||||
|
assert sample_blob("Scripts/jquery.validate.unobtrusive.js").vendored?
|
||||||
|
assert sample_blob("Scripts/jquery.validate.unobtrusive.min.js").vendored?
|
||||||
|
assert sample_blob("Scripts/jquery.unobtrusive-ajax.js").vendored?
|
||||||
|
assert sample_blob("Scripts/jquery.unobtrusive-ajax.min.js").vendored?
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
assert sample_blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
|
||||||
|
|
||||||
|
# Font Awesome
|
||||||
|
assert sample_blob("some/asset/path/font-awesome.min.css").vendored?
|
||||||
|
assert sample_blob("some/asset/path/font-awesome.css").vendored?
|
||||||
|
|
||||||
|
# Normalize
|
||||||
|
assert sample_blob("some/asset/path/normalize.css").vendored?
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
assert sample_blob('Carthage/blah').vendored?
|
||||||
|
|
||||||
|
# Cocoapods
|
||||||
|
assert sample_blob('Pods/blah').vendored?
|
||||||
|
|
||||||
|
# Html5shiv
|
||||||
|
assert sample_blob("Scripts/html5shiv.js").vendored?
|
||||||
|
assert sample_blob("Scripts/html5shiv.min.js").vendored?
|
||||||
|
|
||||||
|
# Test fixtures
|
||||||
|
assert sample_blob("test/fixtures/random.rkt").vendored?
|
||||||
|
assert sample_blob("Test/fixtures/random.rkt").vendored?
|
||||||
|
assert sample_blob("tests/fixtures/random.rkt").vendored?
|
||||||
|
|
||||||
|
# Cordova/PhoneGap
|
||||||
|
assert sample_blob("cordova.js").vendored?
|
||||||
|
assert sample_blob("cordova.min.js").vendored?
|
||||||
|
assert sample_blob("cordova-2.1.0.js").vendored?
|
||||||
|
assert sample_blob("cordova-2.1.0.min.js").vendored?
|
||||||
|
|
||||||
|
# Foundation js
|
||||||
|
assert sample_blob("foundation.js").vendored?
|
||||||
|
assert sample_blob("foundation.min.js").vendored?
|
||||||
|
assert sample_blob("foundation.abide.js").vendored?
|
||||||
|
|
||||||
|
# Vagrant
|
||||||
|
assert sample_blob("Vagrantfile").vendored?
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
assert sample_blob("gradlew").vendored?
|
||||||
|
assert sample_blob("gradlew.bat").vendored?
|
||||||
|
assert sample_blob("gradle/wrapper/gradle-wrapper.properties").vendored?
|
||||||
|
assert sample_blob("subproject/gradlew").vendored?
|
||||||
|
assert sample_blob("subproject/gradlew.bat").vendored?
|
||||||
|
assert sample_blob("subproject/gradle/wrapper/gradle-wrapper.properties").vendored?
|
||||||
|
|
||||||
|
# Octicons
|
||||||
|
assert sample_blob("octicons.css").vendored?
|
||||||
|
assert sample_blob("public/octicons.min.css").vendored?
|
||||||
|
assert sample_blob("public/octicons/sprockets-octicons.scss").vendored?
|
||||||
|
|
||||||
|
# Typesafe Activator
|
||||||
|
assert sample_blob("activator").vendored?
|
||||||
|
assert sample_blob("activator.bat").vendored?
|
||||||
|
assert sample_blob("subproject/activator").vendored?
|
||||||
|
assert sample_blob("subproject/activator.bat").vendored?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob(".google_apis/bar.jar"), :vendored?
|
||||||
|
assert_predicate fixture_blob("foo/.google_apis/bar.jar"), :vendored?
|
||||||
|
|
||||||
|
# Sphinx docs
|
||||||
|
assert sample_blob("docs/_build/asset.doc").vendored?
|
||||||
|
assert sample_blob("docs/theme/file.css").vendored?
|
||||||
|
|
||||||
|
# Vagrant
|
||||||
|
assert sample_blob("puphpet/file.pp").vendored?
|
||||||
|
|
||||||
|
# Fabric.io
|
||||||
|
assert sample_blob("Fabric.framework/Fabric.h").vendored?
|
||||||
|
|
||||||
|
# Crashlytics
|
||||||
|
assert sample_blob("Crashlytics.framework/Crashlytics.h").vendored?
|
||||||
|
assert sample_blob("myapp/My Template.xctemplate/___FILEBASENAME___.h").vendored?
|
||||||
|
assert sample_blob("myapp/My Images.xcassets/some/stuff.imageset/Contents.json").vendored?
|
||||||
|
assert !sample_blob("myapp/MyData.json").vendored?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_documentation
|
||||||
|
assert_predicate fixture_blob("doc/foo.html"), :documentation?
|
||||||
|
assert_predicate fixture_blob("docs/foo.html"), :documentation?
|
||||||
|
refute_predicate fixture_blob("project/doc/foo.html"), :documentation?
|
||||||
|
refute_predicate fixture_blob("project/docs/foo.html"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("Documentation/foo.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("documentation/foo.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("project/Documentation/foo.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("project/documentation/foo.md"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("javadoc/foo.html"), :documentation?
|
||||||
|
assert_predicate fixture_blob("project/javadoc/foo.html"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("man/foo.html"), :documentation?
|
||||||
|
refute_predicate fixture_blob("project/man/foo.html"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("README"), :documentation?
|
||||||
|
assert_predicate fixture_blob("README.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("README.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("Readme"), :documentation?
|
||||||
|
assert_predicate fixture_blob("readme"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/README"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("CHANGE"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGE.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGE.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/CHANGE"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("CHANGELOG"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGELOG.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGELOG.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/CHANGELOG"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("CHANGES"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGES.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CHANGES.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/CHANGES"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("CONTRIBUTING"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CONTRIBUTING.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("CONTRIBUTING.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/CONTRIBUTING"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("examples/some-file.pl"), :documentation?
|
||||||
|
assert_predicate fixture_blob("Examples/some-example-file.rb"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("LICENSE"), :documentation?
|
||||||
|
assert_predicate fixture_blob("LICENCE.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("License.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("LICENSE.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/LICENSE"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("COPYING"), :documentation?
|
||||||
|
assert_predicate fixture_blob("COPYING.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("COPYING.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/COPYING"), :documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("INSTALL"), :documentation?
|
||||||
|
assert_predicate fixture_blob("INSTALL.md"), :documentation?
|
||||||
|
assert_predicate fixture_blob("INSTALL.txt"), :documentation?
|
||||||
|
assert_predicate fixture_blob("foo/INSTALL"), :documentation?
|
||||||
|
|
||||||
|
refute_predicate fixture_blob("foo.md"), :documentation?
|
||||||
|
|
||||||
|
# Samples
|
||||||
|
assert sample_blob("Samples/Ruby/foo.rb").documentation?
|
||||||
|
|
||||||
|
assert_predicate fixture_blob("INSTALL.txt"), :documentation?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_language
|
||||||
|
Samples.each do |sample|
|
||||||
|
blob = sample_blob(sample[:path])
|
||||||
|
assert blob.language, "No language for #{sample[:path]}"
|
||||||
|
assert_equal sample[:language], blob.language.name, blob.name
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test language detection for files which shouldn't be used as samples
|
||||||
|
root = File.expand_path('../fixtures', __FILE__)
|
||||||
|
Dir.entries(root).each do |language|
|
||||||
|
next if language == '.' || language == '..' || language == 'Binary' ||
|
||||||
|
File.basename(language) == 'ace_modes.json'
|
||||||
|
|
||||||
|
# Each directory contains test files of a language
|
||||||
|
dirname = File.join(root, language)
|
||||||
|
Dir.entries(dirname).each do |filename|
|
||||||
|
# By default blob search the file in the samples;
|
||||||
|
# thus, we need to give it the absolute path
|
||||||
|
filepath = File.join(dirname, filename)
|
||||||
|
next unless File.file?(filepath)
|
||||||
|
|
||||||
|
blob = fixture_blob(filepath)
|
||||||
|
if language == 'Data'
|
||||||
|
assert blob.language.nil?, "A language was found for #{filepath}"
|
||||||
|
elsif language == 'Generated'
|
||||||
|
assert blob.generated?, "#{filepath} is not a generated file"
|
||||||
|
else
|
||||||
|
assert blob.language, "No language for #{filepath}"
|
||||||
|
assert_equal language, blob.language.name, blob.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_minified_files_not_safe_to_highlight
|
||||||
|
assert !sample_blob("JavaScript/jquery-1.6.1.min.js").safe_to_colorize?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_empty
|
||||||
|
blob = Struct.new(:data) { include Linguist::BlobHelper }
|
||||||
|
|
||||||
|
assert blob.new("").empty?
|
||||||
|
assert blob.new(nil).empty?
|
||||||
|
refute blob.new(" ").empty?
|
||||||
|
refute blob.new("nope").empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_include_in_language_stats
|
||||||
|
vendored = sample_blob("bower_components/custom/custom.js")
|
||||||
|
assert_predicate vendored, :vendored?
|
||||||
|
refute_predicate vendored, :include_in_language_stats?
|
||||||
|
|
||||||
|
documentation = fixture_blob("README")
|
||||||
|
assert_predicate documentation, :documentation?
|
||||||
|
refute_predicate documentation, :include_in_language_stats?
|
||||||
|
|
||||||
|
generated = sample_blob("CSS/bootstrap.min.css")
|
||||||
|
assert_predicate generated, :generated?
|
||||||
|
refute_predicate generated, :include_in_language_stats?
|
||||||
|
|
||||||
|
data = sample_blob("Ant Build System/filenames/ant.xml")
|
||||||
|
assert_equal :data, data.language.type
|
||||||
|
refute_predicate data, :include_in_language_stats?
|
||||||
|
|
||||||
|
prose = sample_blob("Markdown/tender.md")
|
||||||
|
assert_equal :prose, prose.language.type
|
||||||
|
refute_predicate prose, :include_in_language_stats?
|
||||||
|
|
||||||
|
included = sample_blob("HTML/pages.html")
|
||||||
|
assert_predicate included, :include_in_language_stats?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
1
vendor/grammars/FreeMarker.tmbundle
vendored
Submodule
1
vendor/grammars/FreeMarker.tmbundle
vendored
Submodule
Submodule vendor/grammars/FreeMarker.tmbundle added at 6b7b880c53
2
vendor/grammars/InnoSetup
vendored
2
vendor/grammars/InnoSetup
vendored
Submodule vendor/grammars/InnoSetup updated: 9a8fca6c05...a7f79fd1a5
2
vendor/grammars/NimLime
vendored
2
vendor/grammars/NimLime
vendored
Submodule vendor/grammars/NimLime updated: 50d7344f9b...5111833868
2
vendor/grammars/Stylus
vendored
2
vendor/grammars/Stylus
vendored
Submodule vendor/grammars/Stylus updated: 8b1c77d054...9766d8d936
2
vendor/grammars/abap.tmbundle
vendored
2
vendor/grammars/abap.tmbundle
vendored
Submodule vendor/grammars/abap.tmbundle updated: e8619c9692...8ab33a8978
2
vendor/grammars/atom-fsharp
vendored
2
vendor/grammars/atom-fsharp
vendored
Submodule vendor/grammars/atom-fsharp updated: 053f5dc3ab...7051d65d63
2
vendor/grammars/dart-sublime-bundle
vendored
2
vendor/grammars/dart-sublime-bundle
vendored
Submodule vendor/grammars/dart-sublime-bundle updated: 2e5295ab32...d891fb36c9
2
vendor/grammars/factor
vendored
2
vendor/grammars/factor
vendored
Submodule vendor/grammars/factor updated: 0f387e750d...9b5cb445ee
2
vendor/grammars/haxe-sublime-bundle
vendored
2
vendor/grammars/haxe-sublime-bundle
vendored
Submodule vendor/grammars/haxe-sublime-bundle updated: c3b96f1c75...94cc8eea31
2
vendor/grammars/language-babel
vendored
2
vendor/grammars/language-babel
vendored
Submodule vendor/grammars/language-babel updated: b49eb32388...44ff68da9e
2
vendor/grammars/language-clojure
vendored
2
vendor/grammars/language-clojure
vendored
Submodule vendor/grammars/language-clojure updated: 6dfdabde51...3173abe995
2
vendor/grammars/language-csharp
vendored
2
vendor/grammars/language-csharp
vendored
Submodule vendor/grammars/language-csharp updated: 4c4dbea323...f635e67ede
2
vendor/grammars/language-hy
vendored
2
vendor/grammars/language-hy
vendored
Submodule vendor/grammars/language-hy updated: f9750744ae...93d267de4c
2
vendor/grammars/language-javascript
vendored
2
vendor/grammars/language-javascript
vendored
Submodule vendor/grammars/language-javascript updated: f7e166b65d...9d69b86e30
2
vendor/grammars/language-python
vendored
2
vendor/grammars/language-python
vendored
Submodule vendor/grammars/language-python updated: 44e1d18366...6d7b52b882
2
vendor/grammars/language-shellscript
vendored
2
vendor/grammars/language-shellscript
vendored
Submodule vendor/grammars/language-shellscript updated: d034fecce8...0bbc7eee5a
2
vendor/grammars/latex.tmbundle
vendored
2
vendor/grammars/latex.tmbundle
vendored
Submodule vendor/grammars/latex.tmbundle updated: 6358337b62...d40245e130
2
vendor/grammars/nesC.tmbundle
vendored
2
vendor/grammars/nesC.tmbundle
vendored
Submodule vendor/grammars/nesC.tmbundle updated: d0d322ceaf...f58def8c55
2
vendor/grammars/php.tmbundle
vendored
2
vendor/grammars/php.tmbundle
vendored
Submodule vendor/grammars/php.tmbundle updated: baad875878...2ecaa60d92
2
vendor/grammars/sublime-rust
vendored
2
vendor/grammars/sublime-rust
vendored
Submodule vendor/grammars/sublime-rust updated: 4fcfd98b22...06a278ccfa
2
vendor/grammars/sublime-typescript
vendored
2
vendor/grammars/sublime-typescript
vendored
Submodule vendor/grammars/sublime-typescript updated: 066599f6af...a4c4b9fc79
Reference in New Issue
Block a user