mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Detect KiCAD module files as generated
This commit is contained in:
@@ -68,7 +68,8 @@ module Linguist
|
||||
generated_protocol_buffer_go? ||
|
||||
generated_protocol_buffer? ||
|
||||
generated_jni_header? ||
|
||||
vcr_cassette?
|
||||
vcr_cassette? ||
|
||||
generated_kicad_module?
|
||||
end
|
||||
|
||||
# Internal: Is the blob an Xcode file?
|
||||
@@ -311,5 +312,18 @@ module Linguist
|
||||
return false unless lines.count > 1
|
||||
return lines[0].include?("Generated by Cython")
|
||||
end
|
||||
|
||||
# Internal: Is it a KiCAD module file?
|
||||
#
|
||||
# KiCAD module files contain:
|
||||
# PCBNEW-LibModule-V1 yyyy-mm-dd h:mm:ss XM
|
||||
# on the first line.
|
||||
#
|
||||
# Return true of false
|
||||
def generated_kicad_module?
|
||||
return false unless extname == '.mod'
|
||||
return false unless lines.count > 1
|
||||
return lines[0].include?("PCBNEW-LibModule-V")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
50
test/fixtures/Generated/ABM8G.mod
vendored
Normal file
50
test/fixtures/Generated/ABM8G.mod
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
PCBNEW-LibModule-V1 Wed 10 Aug 2011 05:57:27 PM COT
|
||||
# encoding utf-8
|
||||
$INDEX
|
||||
ABM8G
|
||||
$EndINDEX
|
||||
$MODULE ABM8G
|
||||
Po 0 0 0 15 4E430CBD 4E430CC5 ~~
|
||||
Li ABM8G
|
||||
Sc 4E430CC5
|
||||
AR
|
||||
Op 0 0 0
|
||||
T0 591 -1378 354 354 0 39 N V 21 N "ABM8G"
|
||||
T1 0 787 354 354 0 39 N V 21 N "VAL**"
|
||||
DS -591 394 1299 394 79 21
|
||||
DS 1299 394 1299 -1063 79 21
|
||||
DS 1299 -1063 -472 -1063 79 21
|
||||
DS -472 -1063 -472 472 79 21
|
||||
DS -472 472 -472 551 79 21
|
||||
DS -472 551 -591 551 79 21
|
||||
DS -591 551 -591 433 79 21
|
||||
$PAD
|
||||
Sh "1" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 0 0
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "2" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 866 0
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "3" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 866 -669
|
||||
$EndPAD
|
||||
$PAD
|
||||
Sh "4" R 551 472 0 0 0
|
||||
Dr 0 0 0
|
||||
At SMD N 00888000
|
||||
Ne 0 ""
|
||||
Po 0 -669
|
||||
$EndPAD
|
||||
$EndMODULE ABM8G
|
||||
$EndLIBRARY
|
||||
@@ -243,6 +243,9 @@ class TestBlob < Minitest::Test
|
||||
# Cython-generated C/C++
|
||||
assert sample_blob("C/sgd_fast.c").generated?
|
||||
assert sample_blob("C++/wrapper_inner.cpp").generated?
|
||||
|
||||
# KiCAD module files
|
||||
assert fixture_blob("Generated/ABM8G.mod").generated?
|
||||
end
|
||||
|
||||
def test_vendored
|
||||
@@ -536,6 +539,8 @@ class TestBlob < Minitest::Test
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user