Dont throw EncodingFoundException unless asked to. Should remove the occassional...
[beagle.git] / Filters / FilterRuby.cs
blobfcc62ef35084ea3a2f72e2f74d8d021cc431a529
1 //
2 // FilterRuby.cs
3 //
4 // Author: Uwe Hermann <uwe@hermann-uwe.de>
5 //
6 // Copyright (C) 2005 Uwe Hermann
7 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
17 // The above copyright notice and this permission notice shall be included in
18 // all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 // DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Collections;
31 using System.IO;
32 using System.Text;
34 using Beagle.Daemon;
36 namespace Beagle.Filters {
38 public class FilterRuby : FilterSource {
40 static string [] strKeyWords = { "BEGIN", "END", "alias", "and", "begin", "break", "case",
41 "class", "def", "defined", "do", "else", "elsif", "end",
42 "ensure", "false", "for", "if", "in", "module", "next",
43 "nil", "not", "or", "redo", "rescue", "retry", "return",
44 "self", "super", "then", "true", "undef", "unless", "until",
45 "when", "while", "yield" };
47 public FilterRuby ()
49 AddSupportedFlavor (FilterFlavor.NewFromMimeType ("text/x-ruby"));
53 override protected void DoOpen (FileInfo info)
55 foreach (string keyword in strKeyWords)
56 KeyWordsHash [keyword] = true;
57 // Ruby also supports "#" as comment, so,
58 // adding Python_Style will process that as well.
59 SrcLangType = LangType.Python_Style;
62 override protected void DoPull ()
64 string str = TextReader.ReadLine ();
65 if (str == null)
66 Finished ();
67 else
68 ExtractTokens (str);