-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version 1.1 | ||
@totalColumns 5 | ||
@separator ',' | ||
Transaction_Date: xDate | ||
Transaction_ID: notEmpty | ||
Originator_Name: notEmpty | ||
Originator_Address: any("yes","no") | ||
Originator_Country: notEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- # | ||
# frozen_string_literal: true | ||
|
||
module Rouge | ||
module Lexers | ||
class CSVS < RegexLexer | ||
tag 'csvs' | ||
title "csvs" | ||
desc 'The CSV Schema Language (digital-preservation.github.io)' | ||
filenames '*.csvs' | ||
|
||
state :root do | ||
rule %r/\s+/m, Text | ||
|
||
rule %r(//[\S\t ]*), Comment::Single | ||
rule %r(/\*[^*]*\*/)m, Comment::Multiline | ||
|
||
rule %r/(version)( )(\d+\.\d+)/ do | ||
groups Keyword, Text::Whitespace, Num::Float | ||
end | ||
|
||
rule %r/T?\d{2}:\d{2}:\d{2}(\.\d{5})?(Z|(?:[-+]\d{2}:\d{2}))?/, Literal::Date | ||
rule %r/\d{4}-\d{2}-\d{2}/, Literal::Date | ||
rule %r/\d{2}\/\d{2}\/\d{4}/, Literal::Date | ||
|
||
rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float | ||
rule %r/\d+/, Num::Integer | ||
|
||
rule %r/@\w+/, Keyword::Pseudo | ||
|
||
rule %r/[-.\w]+:/, Name::Variable | ||
rule %r/^"[^"]+"/, Name::Variable | ||
rule %r/\$([-.\w]+|("[^"]+"))\/?/, Name::Variable | ||
|
||
rule %r/[A-Z]+/i, Keyword | ||
|
||
rule %r/"[^"]*"/, Str::Double | ||
rule %r/'[^\r\n\f']'/, Str::Char | ||
|
||
rule %r/[,()*]/, Punctuation | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- # | ||
# frozen_string_literal: true | ||
|
||
describe Rouge::Lexers::CSVS do | ||
let(:subject) { Rouge::Lexers::CSVS.new } | ||
|
||
describe 'guessing' do | ||
include Support::Guessing | ||
|
||
it 'guesses by filename' do | ||
assert_guess :filename => 'foo.csvs' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version 1.2 | ||
@totalColumns 3 | ||
name: notEmpty | ||
age: range(0, 120) | ||
gender: is("m") or is("f") or is("t") or is("n") | ||
|
||
@separator TAB | ||
@quoted | ||
@totalColumns 21 | ||
@permitEmpty | ||
@ignoreColumnNameCase | ||
|
||
//This Comment is a Single Line Comment it terminates at this line break | ||
a_column: | ||
|
||
/*This Comment is a Multi Line Comment: | ||
it can go on for as many lines as you like, until you type*/ | ||
a_column: | ||
|
||
a_column: is("some string") and $b_column/starts("some string") //here two tests are combined on a single line, the second test here looks to the second column | ||
b_column: //to check it's value starts with "some string" | ||
|
||
a_column: is("some string") //the contents of a_column must be the string "some string" | ||
a_column: is($a_column) //the contents of a_column must be the value held in a_column, treated as a string | ||
|
||
a_column: range(*, 10) | ||
|
||
a_column: xDateTime(2014-10-04T00:00:01Z,2015-12-03T23:59:59) //the value of a_column must be a valid xDateTime and between the two xDateTimes shown (inclusive) | ||
a_column: xDateTime(2014-10-04T00:00:01+02:00,2015-12-03T23:59:59+02:00) //the value of a_column must be a valid xDateTime and between the two xDateTimes shown (inclusive) | ||
a_column: xDateTime(2014-10-04,2015-12-03) //the value of a_column must be a valid xDate and between the two xDates shown (inclusive) | ||
a_column: xTime(00:00:01+02:00,2015-12-03T23:59:59+02:00) //the value of a_column must be a valid xTime and between the two xTimes shown (inclusive) | ||
a_column: ukDate(04/10/2014,03/12/2015) //the value of a_column must be a valid ukDate and between the two ukDates shown (inclusive) |