Merge branch 'master' into 1320-local

Conflicts:
	lib/linguist/samples.json
This commit is contained in:
Arfon Smith
2014-07-02 13:27:34 -05:00
21 changed files with 67737 additions and 66755 deletions

View File

@@ -1,4 +1,6 @@
before_install:
- git fetch origin master:master
- git fetch origin v2.0.0:v2.0.0
- sudo apt-get install libicu-dev -y
- gem update --system 2.1.11
rvm:

View File

@@ -152,4 +152,4 @@ If you are the current maintainer of this gem:
0. Test behavior locally, branch deploy, whatever needs to happen
0. Merge github/linguist PR
0. Tag and push: `git tag vx.xx.xx; git push --tags`
0. Push to rubygems.org -- `gem push github-linguist-2.10.12.gem`
0. Push to rubygems.org -- `gem push github-linguist-3.0.0.gem`

View File

@@ -5,6 +5,7 @@
require 'linguist/file_blob'
require 'linguist/repository'
require 'rugged'
path = ARGV[0] || Dir.pwd
@@ -18,7 +19,8 @@ ARGV.shift
breakdown = true if ARGV[0] == "--breakdown"
if File.directory?(path)
repo = Linguist::Repository.from_directory(path)
rugged = Rugged::Repository.new(path)
repo = Linguist::Repository.new(rugged, rugged.head.target_id)
repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
percentage = ((size / repo.size.to_f) * 100)
percentage = sprintf '%.2f' % percentage

View File

@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.add_dependency 'escape_utils', '~> 1.0.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.6.0'
s.add_dependency 'rugged', '~> 0.21.0'
s.add_development_dependency 'json'
s.add_development_dependency 'mocha'

View File

@@ -313,15 +313,7 @@ module Linguist
#
# Returns a Language or nil if none is detected
def language
return @language if defined? @language
if defined?(@data) && @data.is_a?(String)
data = @data
else
data = lambda { (binary_mime_type? || binary?) ? "" : self.data }
end
@language = Language.detect(name.to_s, data, mode)
@language ||= Language.detect(self)
end
# Internal: Get the lexer of the blob.

View File

@@ -92,18 +92,17 @@ module Linguist
# Public: Detects the Language of the blob.
#
# name - String filename
# data - String blob data. A block also maybe passed in for lazy
# loading. This behavior is deprecated and you should always
# pass in a String.
# mode - Optional String mode (defaults to nil)
# blob - an object that implements the Linguist `Blob` interface;
# see Linguist::LazyBlob and Linguist::FileBlob for examples
#
# Returns Language or nil.
def self.detect(name, data, mode = nil)
def self.detect(blob)
name = blob.name.to_s
# A bit of an elegant hack. If the file is executable but extensionless,
# append a "magic" extension so it can be classified with other
# languages that have shebang scripts.
if File.extname(name).empty? && mode && (mode.to_i(8) & 05) == 05
if File.extname(name).empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05
name += ".script!"
end
@@ -114,7 +113,7 @@ module Linguist
# extension at all, in the case of extensionless scripts), we need to continue
# our detection work
if possible_languages.length > 1
data = data.call() if data.respond_to?(:call)
data = blob.data
possible_language_names = possible_languages.map(&:name)
# Don't bother with emptiness

View File

@@ -89,7 +89,7 @@ Agda:
Alloy:
type: programming # 'modeling' would be more appropiate
lexer: Text only
lexer: Alloy
color: "#cc5c24"
extensions:
- .als
@@ -222,6 +222,8 @@ BlitzBasic:
- .decls
BlitzMax:
type: programming
color: "#cd6400"
extensions:
- .bmx
@@ -735,12 +737,14 @@ GLSL:
- .glsl
- .fp
- .frag
- .frg
- .fshader
- .geom
- .glslv
- .gshader
- .shader
- .vert
- .vrx
- .vshader
Genshi:
@@ -798,6 +802,12 @@ Gosu:
extensions:
- .gs
Grace:
type: programming
lexer: Text only
extensions:
- .grace
Grammatical Framework:
type: programming
lexer: Haskell
@@ -1397,7 +1407,6 @@ Nimrod:
Nit:
type: programming
#lexer: Nit
lexer: Text only
color: "#0d8921"
extensions:
@@ -1544,6 +1553,8 @@ PHP:
- .phpt
filenames:
- Phakefile
interpreters:
- php
Pan:
type: programming

37
lib/linguist/lazy_blob.rb Normal file
View File

@@ -0,0 +1,37 @@
require 'linguist/blob_helper'
require 'rugged'
module Linguist
class LazyBlob
include BlobHelper
MAX_SIZE = 128 * 1024
attr_reader :repository
attr_reader :oid
attr_reader :name
attr_reader :mode
def initialize(repo, oid, name, mode = nil)
@repository = repo
@oid = oid
@name = name
@mode = mode
end
def data
load_blob!
@data
end
def size
load_blob!
@size
end
protected
def load_blob!
@data, @size = Rugged::Blob.to_buffer(repository, oid, MAX_SIZE) if @data.nil?
end
end
end

View File

@@ -1,4 +1,5 @@
require 'linguist/file_blob'
require 'linguist/lazy_blob'
require 'rugged'
module Linguist
# A Repository is an abstraction of a Grit::Repo or a basic file
@@ -7,100 +8,146 @@ module Linguist
# Its primary purpose is for gathering language statistics across
# the entire project.
class Repository
# Public: Initialize a new Repository from a File directory
#
# base_path - A path String
#
# Returns a Repository
def self.from_directory(base_path)
new Dir["#{base_path}/**/*"].
select { |f| File.file?(f) }.
map { |path| FileBlob.new(path, base_path) }
attr_reader :repository
# Public: Create a new Repository based on the stats of
# an existing one
def self.incremental(repo, commit_oid, old_commit_oid, old_stats)
repo = self.new(repo, commit_oid)
repo.load_existing_stats(old_commit_oid, old_stats)
repo
end
# Public: Initialize a new Repository
# Public: Initialize a new Repository to be analyzed for language
# data
#
# enum - Enumerator that responds to `each` and
# yields Blob objects
# repo - a Rugged::Repository object
# commit_oid - the sha1 of the commit that will be analyzed;
# this is usually the master branch
#
# Returns a Repository
def initialize(enum)
@enum = enum
@computed_stats = false
@language = @size = nil
@sizes = Hash.new { 0 }
@file_breakdown = Hash.new { |h,k| h[k] = Array.new }
def initialize(repo, commit_oid)
@repository = repo
@commit_oid = commit_oid
raise TypeError, 'commit_oid must be a commit SHA1' unless commit_oid.is_a?(String)
end
# Public: Load the results of a previous analysis on this repository
# to speed up the new scan.
#
# The new analysis will be performed incrementally as to only take
# into account the file changes since the last time the repository
# was scanned
#
# old_commit_oid - the sha1 of the commit that was previously analyzed
# old_stats - the result of the previous analysis, obtained by calling
# Repository#cache on the old repository
#
# Returns nothing
def load_existing_stats(old_commit_oid, old_stats)
@old_commit_oid = old_commit_oid
@old_stats = old_stats
nil
end
# Public: Returns a breakdown of language stats.
#
# Examples
#
# # => { Language['Ruby'] => 46319,
# Language['JavaScript'] => 258 }
# # => { 'Ruby' => 46319,
# 'JavaScript' => 258 }
#
# Returns a Hash of Language keys and Integer size values.
# Returns a Hash of language names and Integer size values.
def languages
compute_stats
@sizes
@sizes ||= begin
sizes = Hash.new { 0 }
cache.each do |_, (language, size)|
sizes[language] += size
end
sizes
end
end
# Public: Get primary Language of repository.
#
# Returns a Language
# Returns a language name
def language
compute_stats
@language
@language ||= begin
primary = languages.max_by { |(_, size)| size }
primary && primary[0]
end
end
# Public: Get the total size of the repository.
#
# Returns a byte size Integer
def size
compute_stats
@size
@size ||= languages.inject(0) { |s,(_,v)| s + v }
end
# Public: Return the language breakdown of this repository by file
#
# Returns a map of language names => [filenames...]
def breakdown_by_file
compute_stats
@file_breakdown
@file_breakdown ||= begin
breakdown = Hash.new { |h,k| h[k] = Array.new }
cache.each do |filename, (language, _)|
breakdown[language] << filename
end
breakdown
end
end
# Internal: Compute language breakdown for each blob in the Repository.
# Public: Return the cached results of the analysis
#
# Returns nothing
def compute_stats
return if @computed_stats
# This is a per-file breakdown that can be passed to other instances
# of Linguist::Repository to perform incremental scans
#
# Returns a map of filename => [language, size]
def cache
@cache ||= begin
if @old_commit_oid == @commit_oid
@old_stats
else
compute_stats(@old_commit_oid, @commit_oid, @old_stats)
end
end
end
@enum.each do |blob|
# Skip files that are likely binary
next if blob.likely_binary?
protected
def compute_stats(old_commit_oid, commit_oid, cache = nil)
file_map = cache ? cache.dup : {}
old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree
new_tree = Rugged::Commit.lookup(repository, commit_oid).tree
# Skip vendored or generated blobs
next if blob.vendored? || blob.generated? || blob.language.nil?
diff = Rugged::Tree.diff(repository, old_tree, new_tree)
# Only include programming languages and acceptable markup languages
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
diff.each_delta do |delta|
old = delta.old_file[:path]
new = delta.new_file[:path]
# Build up the per-file breakdown stats
@file_breakdown[blob.language.group.name] << blob.name
file_map.delete(old)
next if delta.binary
@sizes[blob.language.group] += blob.size
if [:added, :modified].include? delta.status
# Skip submodules
mode = delta.new_file[:mode]
next if (mode & 040000) != 0
blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8))
# Skip vendored or generated blobs
next if blob.vendored? || blob.generated? || blob.language.nil?
# Only include programming languages and acceptable markup languages
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
file_map[new] = [blob.language.group.name, blob.size]
end
end
end
# Compute total size
@size = @sizes.inject(0) { |s,(_,v)| s + v }
# Get primary language
if primary = @sizes.max_by { |(_, size)| size }
@language = primary[0]
end
@computed_stats = true
nil
file_map
end
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,7 @@ module Linguist
#
# Returns nothing.
def self.each(&block)
Dir.entries(ROOT).each do |category|
Dir.entries(ROOT).sort!.each do |category|
next if category == '.' || category == '..'
# Skip text and binary for now

View File

@@ -43,6 +43,7 @@
# Vendored dependencies
- thirdparty/
- vendors?/
- extern(al)?/
# Debian packaging
- ^debian/

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "2.12.0"
VERSION = "3.0.0"
end

View File

@@ -0,0 +1,25 @@
SuperStrict
Framework Brl.StandardIO
Type TMyType
Field property:int
Function A:int(param:int)
'do nothing
End Function
Method B:int(param:int)
'do nothing
End Method
End Type
Global my:TMyType = new TMyType
?Win32
my.A()
my.B()
?Linux
my.B()
my.A()
?

View File

@@ -0,0 +1,6 @@
varying vec4 v_color;
void main()
{
gl_FragColor = v_color;
}

12
samples/GLSL/myvertex.vrx Normal file
View File

@@ -0,0 +1,12 @@
uniform mat4 u_MVPMatrix;
attribute vec4 a_position;
attribute vec4 a_color;
varying vec4 v_color;
void main()
{
v_color = a_color;
gl_Position = u_MVPMatrix * pos;
}

View File

@@ -0,0 +1,6 @@
method ack (m : Number, n : Number) -> Number {
print "ack {m} {n}"
if (m < = 0) then {n + 1}
elseif {n <= 0} then {ack((m -1), 1)}
else {ack(m -1, ack(m, n-1))}
}

View File

@@ -0,0 +1,554 @@
import "gtk" as gtk
import "io" as io
import "mgcollections" as collections
import "button_factory" as button_factory
import "dialog_factory" as dialog_factory
import "syntax_highlighter" as highlighter
import "auto_completer" as aComp
//TODO
// Autocomplete typing
// FileChooser
// Themes
// Details for the Top Level Window
def window = gtk.window(gtk.GTK_WINDOW_TOPLEVEL)
window.title := "Grace"
window.set_default_size(700, 700)
// -------------
// Placeholder for the console window that can be popped out
// of the main window
var popped := gtk.window(gtk.GTK_WINDOW_TOPLEVEL)
// Initialise the Boxes
def mBox = gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2)
def buttonBox = gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 2)
var consoleButtons := gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 3)
var consoleBox := gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2)
var editorBox := gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2)
var splitPane := gtk.paned(gtk.GTK_ORIENTATION_VERTICAL, 2)
def menuBox = gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 4)
// -------------
// Initialise the buttons
def runButton = button_factory.make("run")
var clearButton := button_factory.make("clear")
var outButton := button_factory.make("out")
var errorButton := button_factory.make("error")
var popButton := button_factory.make("pop")
def newButton = button_factory.make("new")
def openButton = button_factory.make("open")
def saveButton = button_factory.make("save")
def saveAsButton = button_factory.make("saveAs")
def closeButton = button_factory.make("close")
// -------------
// Details for the default text editor and scrolled window
var tEdit := gtk.text_view
tEdit.set_size_request(700, 400)
var scrolled_main := gtk.scrolled_window
scrolled_main.set_size_request(700, 400)
scrolled_main.add(tEdit)
// -------------
// Widget that allows multiple files to be edited (tabs)
var notebook := gtk.notebook
notebook.scrollable := true
// -------------
// Maps for holding the text_views and scrolled_windows
var editor_map := collections.map.new
editor_map.put(0, tEdit)
var scrolled_map := collections.map.new
scrolled_map.put(0, scrolled_main)
// -------------
// Class that manages the syntax highlighting (This needs to be passed around otherwise
// the text_tag table gets confused, ie there can only be one)
def lighter = highlighter.Syntax_Highlighter.new(notebook, editor_map)
tEdit.buffer.on "changed" do {
lighter.highlightLine
}
// Class that manages any auto completion that is required
def completer = aComp.Auto_Completer.new(window, notebook, editor_map)
// Utility methods
// -------------
method deleteCompileFiles(page_num : Number) {
def cur_scrolled = scrolled_map.get(page_num)
var filename := notebook.get_tab_label_text(cur_scrolled)
filename := filename.substringFrom(0)to(filename.size - 7) //Removes .grace extension
io.system("rm -f files/" ++ filename)
io.system("rm -f files/" ++ filename ++ ".c")
io.system("rm -f files/" ++ filename ++ ".gcn")
io.system("rm -f files/" ++ filename ++ ".gct")
}
// -------------
var currentConsole := "output" // Which console is being shown
var out := false
var outText := ""
var errorText := ""
// Give actions to the buttons
// -------------
runButton.on "clicked" do {
clearConsoles()
// Get the details for the current page selected
def cur_page_num = notebook.current_page
def cur_page = editor_map.get(cur_page_num)
def cur_scrolled = scrolled_map.get(cur_page_num)
def cur_page_label = notebook.get_tab_label_text(cur_scrolled)
// Initialise text iterators
def sIter = gtk.text_iter
def eIter = gtk.text_iter
// Set one at the beggining and one at the end of the text
cur_page.buffer.get_iter_at_offset(sIter, 0)
cur_page.buffer.get_iter_at_offset(eIter, -1)
// Get the text between the text iterators
def text = cur_page.buffer.get_text(sIter, eIter, true)
// Save the text to the file (in case the user hasn't already saved it)
def file = io.open("files/" ++ cur_page_label, "w")
file.write(text)
file.close
// Run the program and pipe the output and errors into files to be read
io.system("../minigrace/minigrace " ++ "files/" ++ cur_page_label ++ " > output.txt 2> error.txt")
def outputFile = io.open("output.txt", "r")
def errorFile = io.open("error.txt", "r")
outText := outputFile.read
errorText := errorFile.read
io.system("rm -f output.txt error.txt")
var switched := false
// Change the console to output if there is output text
if((outText.size > 0) && (currentConsole != "output")) then {
switch_to_output()
switched := true
}
// Change the console to errors if there were errors
if((errorText.size > 0) && (currentConsole != "errors")) then {
switch_to_errors()
switched := true
}
// Remember to populate the console if it wasn't switched
if(!switched) then {
populateConsoles
}
}
clearButton.on "clicked" do {
clearConsoles()
}
outButton.on "clicked" do {
switch_to_output()
}
errorButton.on "clicked" do {
switch_to_errors()
}
popButton.on "clicked" do {
if(out) then {
popIn()
} else {
popOut()
}
}
// Gives a dialog to let the user create a new file to edit
newButton.on "clicked" do {
def new_window_class = dialog_factory.new.new(notebook, editor_map, scrolled_map, lighter)
def new_window = new_window_class.window()
new_window.show_all
}
// Gives a dialog that lets the user open a file to edit
openButton.on "clicked" do {
def open_window_class = dialog_factory.open.new(notebook, editor_map, scrolled_map, lighter)
def open_window = open_window_class.window()
open_window.show_all
}
// Saves the current file (if the name is Untitled.grace it will ask for a new name)
saveButton.on "clicked" do {
def cur_page_num = notebook.current_page
def cur_page = editor_map.get(cur_page_num)
def cur_scrolled = scrolled_map.get(cur_page_num)
def cur_page_label = notebook.get_tab_label_text(cur_scrolled)
if(cur_page_label == "Untitled.grace") then {
def saveAs_window_class = dialog_factory.save.new(notebook, editor_map, scrolled_map, true)
def saveAs_window = saveAs_window_class.window()
saveAs_window.show_all
} else {
// Initialise text iterators
def sIter = gtk.text_iter
def eIter = gtk.text_iter
// Set one at the beggining and one at the end of the text
cur_page.buffer.get_iter_at_offset(sIter, 0)
cur_page.buffer.get_iter_at_offset(eIter, -1)
// Get the text between the text iterators
def text = cur_page.buffer.get_text(sIter, eIter, true)
// Save the file
def file = io.open("files/" ++ cur_page_label, "w")
file.write(text)
file.close
}
}
// Gives a dialog that lets the user save the file with a new name
saveAsButton.on "clicked" do {
def saveAs_window_class = dialog_factory.save.new(notebook, editor_map, scrolled_map, false)
def saveAs_window = saveAs_window_class.window()
saveAs_window.show_all
}
// This will close a tab on the notebook
// It also "removes" the page from the map,
// by creating a new temporary map and putting all but
// the removed page in.
closeButton.on "clicked" do {
def page_num = notebook.current_page
def num_pages = notebook.n_pages
if(num_pages > 1) then {
deleteCompileFiles(page_num)
def e_map = collections.map.new
def s_map = collections.map.new
// Copy every page up to the current page into the new maps
var x := 0
while {x < page_num} do {
var eValue := editor_map.get(x)
var sValue := scrolled_map.get(x)
e_map.put(x, eValue)
s_map.put(x, sValue)
x := x + 1
}
// Copy every page after the current page into the new map (shifted one down)
x := page_num + 1
while {x < num_pages} do {
var eValue := editor_map.get(x)
var sValue := scrolled_map.get(x)
e_map.put((x - 1), eValue)
s_map.put((x - 1), sValue)
x := x + 1
}
editor_map := e_map
scrolled_map := s_map
notebook.remove_page(page_num)
notebook.show_all
}
}
// -------------
// Consoles:
// -------------
var outConsole := gtk.text_view
var outScroll := gtk.scrolled_window
var errorConsole := gtk.text_view
var errorScroll := gtk.scrolled_window
var errorTag := errorConsole.buffer.create_tag("fixed", "foreground", "red")
// Creates a new output console
method createOut {
outConsole := gtk.text_view
outScroll := gtk.scrolled_window
outScroll.add(outConsole)
if(out) then {
outConsole.set_size_request(400, 400)
outScroll.set_size_request(400, 400)
} else {
outConsole.set_size_request(700, 200)
outScroll.set_size_request(700, 200)
}
outConsole.editable := false
outConsole.buffer.set_text("[Output]:", -1)
}
createOut()
// Creates a new error console
method createError {
errorConsole := gtk.text_view
errorScroll := gtk.scrolled_window
errorScroll.add(errorConsole)
if(out) then {
errorConsole.set_size_request(400, 400)
errorScroll.set_size_request(400, 400)
} else {
errorConsole.set_size_request(700, 200)
errorScroll.set_size_request(700, 200)
}
errorConsole.editable := false
errorConsole.buffer.set_text("[Errors]:", -1)
errorTag := errorConsole.buffer.create_tag("fixed", "foreground", "red")
}
createError()
// Switches the console being shown to be output. This requires
// the output console to be remade as it would have been destroyed when
// it was switched previously
method switch_to_output {
if(currentConsole != "output") then {
currentConsole := "output"
consoleBox.remove(errorScroll) // This destroys the errorConsole
createOut()
consoleBox.add(outScroll)
populateConsoles()
if(out) then {
popped.show_all
} else {
window.show_all
}
}
}
// Switches the console being shown to be errors. This requires
// the error console to be remade as it would have been destroyed when
// it was switched previously
method switch_to_errors {
if(currentConsole != "errors") then {
currentConsole := "errors"
consoleBox.remove(outScroll) // This destroys the outConsole
createError()
consoleBox.add(errorScroll)
populateConsoles()
if(out) then {
popped.show_all
} else {
window.show_all
}
}
}
// If there is text to be put into the consoles this will add it
method populateConsoles {
if((outText.size > 0) && (currentConsole == "output")) then {
outConsole.buffer.set_text(outText, -1)
}
if((errorText.size > 0) && (currentConsole == "errors")) then {
def sIter = gtk.text_iter
def eIter = gtk.text_iter
errorConsole.buffer.set_text(errorText, -1)
errorConsole.buffer.get_iter_at_offset(sIter, 0)
errorConsole.buffer.get_iter_at_offset(eIter, -1)
errorConsole.buffer.apply_tag(errorTag, sIter, eIter)
}
}
method clearConsoles {
if(currentConsole == "output") then {
outConsole.buffer.set_text("[Output]:", -1)
outText := ""
}
if(currentConsole == "errors") then {
errorConsole.buffer.set_text("[Errors]:", -1)
errorText := ""
}
}
// Identical as the popIn method, but can be connected to the window's destroy button
def popInBlock = {
consoleBox.reparent(splitPane)
popButton.label := "Pop Out"
if(currentConsole == "output") then {
outConsole.set_size_request(700, 200)
outScroll.set_size_request(700, 200)
}
if(currentConsole == "errors") then {
errorConsole.set_size_request(700, 200)
errorScroll.set_size_request(700, 200)
}
def cur_page_num = notebook.current_page
def cur_scrolled = scrolled_map.get(cur_page_num)
def cur_page = editor_map.get(cur_page_num)
cur_page.set_size_request(700, 400)
cur_scrolled.set_size_request(700, 400)
out := false
popped.visible := false
}
// This pops the console out into a separate window
method popOut {
popped := gtk.window(gtk.GTK_WINDOW_TOPLEVEL)
consoleBox.reparent(popped)
popButton.label := "Pop In"
if(currentConsole == "output") then {
outConsole.set_size_request(400, 400)
outScroll.set_size_request(400, 400)
}
if(currentConsole == "errors") then {
errorConsole.set_size_request(400, 400)
errorScroll.set_size_request(400, 400)
}
def cur_page_num = notebook.current_page
def cur_scrolled = scrolled_map.get(cur_page_num)
def cur_page = editor_map.get(cur_page_num)
cur_page.set_size_request(700, 580)
cur_scrolled.set_size_request(700, 580)
out := true
popped.visible := true
popped.connect("destroy", popInBlock)
popped.show_all
}
// Puts the console back into the main window
method popIn {
consoleBox.reparent(splitPane)
popButton.label := "Pop Out"
if(currentConsole == "output") then {
outConsole.set_size_request(700, 200)
outScroll.set_size_request(700, 200)
}
if(currentConsole == "errors") then {
errorConsole.set_size_request(700, 200)
errorScroll.set_size_request(700, 200)
}
def cur_page_num = notebook.current_page
def cur_scrolled = scrolled_map.get(cur_page_num)
def cur_page = editor_map.get(cur_page_num)
cur_page.set_size_request(700, 400)
cur_scrolled.set_size_request(700, 400)
out := false
popped.visible := false
}
clearConsoles()
// -------------
// Patch everything together
var hSeparator1 := gtk.separator(gtk.GTK_ORIENTATION_HORIZONTAL)
var hSeparator2 := gtk.separator(gtk.GTK_ORIENTATION_HORIZONTAL)
menuBox.add(newButton)
menuBox.add(openButton)
menuBox.add(saveButton)
menuBox.add(saveAsButton)
buttonBox.add(runButton)
buttonBox.add(closeButton)
consoleButtons.add(outButton)
consoleButtons.add(errorButton)
consoleButtons.add(clearButton)
consoleButtons.add(popButton)
consoleBox.add(hSeparator1)
consoleBox.add(consoleButtons)
consoleBox.add(outScroll)
editorBox.add(hSeparator2)
notebook.add(scrolled_main)
notebook.set_tab_label_text(scrolled_main, "Untitled.grace")
editorBox.add(notebook)
splitPane.add1(editorBox)
splitPane.add2(consoleBox)
mBox.add(menuBox)
mBox.add(buttonBox)
mBox.add(splitPane)
window.add(mBox)
def exit = {
var x := 0
while {x < notebook.n_pages} do {
deleteCompileFiles(x)
x := x + 1
}
// Delete the compile files of the IDE
io.system("rm -f Grace_IDE.gct Grace_IDE.c Grace_IDE.gcn")
io.system("rm -f scanner.gct scanner.c scanner.gcn")
io.system("rm -f syntax_highlighter.gct syntax_highlighter.c syntax_highlighter.gcn")
io.system("rm -f syntax_colors.gct syntax_colors.c syntax_colors.gcn")
io.system("rm -f button_factory.gct button_factory.c button_factory.gcn")
io.system("rm -f dialog_factory.gct dialog_factory.c dialog_factory.gcn")
io.system("rm -f auto_completer.gct auto_completer.c auto_completer.gcn")
print "Grace IDE Closed Successfully"
gtk.main_quit
}
window.connect("destroy", exit)
window.show_all
gtk.main

View File

@@ -277,6 +277,10 @@ class TestBlob < Test::Unit::TestCase
# 'thirdparty' directory
assert blob("thirdparty/lib/main.c").vendored?
# 'extern(al)' directory
assert blob("extern/util/__init__.py").vendored?
assert blob("external/jquery.min.js").vendored?
# C deps
assert blob("deps/http_parser/http_parser.c").vendored?

View File

@@ -1,6 +1,7 @@
require 'linguist/heuristics'
require 'linguist/language'
require 'linguist/samples'
require 'linguist/file_blob'
require 'test/unit'
@@ -35,7 +36,8 @@ class TestHeuristcs < Test::Unit::TestCase
end
def test_detect_still_works_if_nothing_matches
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
match = Language.detect(blob)
assert_equal Language["Objective-C"], match
end

View File

@@ -3,22 +3,24 @@ require 'linguist/repository'
require 'test/unit'
class TestRepository < Test::Unit::TestCase
include Linguist
def repo(base_path)
Repository.from_directory(base_path)
def rugged_repository
@rugged ||= Rugged::Repository.new(File.expand_path("../../.git", __FILE__))
end
def linguist_repo
repo(File.expand_path("../..", __FILE__))
def master_oid
'd40b4a33deba710e2f494db357c654fbe5d4b419'
end
def linguist_repo(oid = master_oid)
Linguist::Repository.new(rugged_repository, oid)
end
def test_linguist_language
# assert_equal Language['Ruby'], linguist_repo.language
assert_equal 'Ruby', linguist_repo.language
end
def test_linguist_languages
# assert linguist_repo.languages[Language['Ruby']] > 10_000
assert linguist_repo.languages['Ruby'] > 10_000
end
def test_linguist_size
@@ -31,7 +33,18 @@ class TestRepository < Test::Unit::TestCase
assert linguist_repo.breakdown_by_file["Ruby"].include?("lib/linguist/language.rb")
end
def test_binary_override
assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"]
def test_incremental_stats
old_commit = '3d7364877d6794f6cc2a86b493e893968a597332'
old_repo = linguist_repo(old_commit)
assert old_repo.languages['Ruby'] > 10_000
assert old_repo.size > 30_000
new_repo = Linguist::Repository.incremental(rugged_repository, master_oid, old_commit, old_repo.cache)
assert new_repo.languages['Ruby'] > old_repo.languages['Ruby']
assert new_repo.size > old_repo.size
assert_equal linguist_repo.cache, new_repo.cache
end
end