dansguardian 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +4 -0
- data/example.rb +7 -5
- data/lib/dansguardian.rb +2 -2
- data/lib/dansguardian/list.rb +44 -0
- metadata +10 -10
- data/lib/dansguardian/inclusion.rb +0 -16
data/Changelog
CHANGED
data/example.rb
CHANGED
@@ -22,17 +22,19 @@ dgconf.main
|
|
22
22
|
|
23
23
|
dgconf.filtergroup(1, :cached => true)
|
24
24
|
|
25
|
-
|
25
|
+
listfile = dgconf.filtergroup(1)[:weightedphraselist]
|
26
|
+
listobject = DansGuardian::List.new(:file => listfile)
|
27
|
+
pp listobject
|
26
28
|
|
27
|
-
|
29
|
+
listfile2 = "/etc/dansguardian/lists/phraselists/goodphrases/weighted_news"
|
30
|
+
listobject2 = DansGuardian::List.new(listfile2)
|
31
|
+
listobject2.read!
|
32
|
+
pp listobject2
|
28
33
|
|
29
|
-
pp DansGuardian::Inclusion.get(wfl)
|
30
34
|
|
31
35
|
|
32
36
|
|
33
37
|
|
34
38
|
|
35
|
-
#dg.config.filtergroup(1).inclusiontree('weightedphraselist')
|
36
|
-
|
37
39
|
|
38
40
|
|
data/lib/dansguardian.rb
CHANGED
@@ -5,10 +5,10 @@ autoload :Set, 'set'
|
|
5
5
|
require 'configfiles'
|
6
6
|
|
7
7
|
module DansGuardian
|
8
|
-
VERSION = '0.1
|
8
|
+
VERSION = '0.2.1'
|
9
9
|
|
10
10
|
autoload :Config, 'dansguardian/config'
|
11
11
|
autoload :Parser, 'dansguardian/parser'
|
12
12
|
autoload :Updater, 'dansguardian/updater'
|
13
|
-
autoload :
|
13
|
+
autoload :List, 'dansguardian/list'
|
14
14
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module DansGuardian
|
2
|
+
# this class does not inherit from ConfigFiles::Base
|
3
|
+
class List
|
4
|
+
|
5
|
+
attr_reader :items, :includes, :listcategory
|
6
|
+
|
7
|
+
# DansGuardian::List.new(:file = '/path/to/list')
|
8
|
+
def initialize(h={})
|
9
|
+
if h.is_a? String
|
10
|
+
@init = {:file => h}
|
11
|
+
else
|
12
|
+
@init = h
|
13
|
+
end
|
14
|
+
@items = []
|
15
|
+
@includes = []
|
16
|
+
@listcategory = nil
|
17
|
+
|
18
|
+
#read! if @init[:file]
|
19
|
+
end
|
20
|
+
|
21
|
+
def filename; @init[:file]; end
|
22
|
+
|
23
|
+
# Reads the file and fill @items ad @includes .
|
24
|
+
# This method might be overridden for non-trivial list types (?)
|
25
|
+
def read!
|
26
|
+
File.foreach(@init[:file]) do |line|
|
27
|
+
line.strip!
|
28
|
+
# Special comment used to "categorize" DG message pages
|
29
|
+
if line =~ /^#listcategory:\s*"(.*)"/
|
30
|
+
@listcategory = $1
|
31
|
+
next
|
32
|
+
end
|
33
|
+
next if line =~ /^\s*#/
|
34
|
+
line.sub! /\s#.*$/, '' # remove comments but allow http://url#anchor
|
35
|
+
if line =~ /^\.Include<(.*)>/
|
36
|
+
@includes << $1
|
37
|
+
elsif line =~ /\S/
|
38
|
+
@items << line.strip
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 2
|
7
8
|
- 1
|
8
|
-
|
9
|
-
version: 0.1.0
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Guido De Rosa
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-15 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -39,18 +39,18 @@ extensions: []
|
|
39
39
|
extra_rdoc_files:
|
40
40
|
- README.rdoc
|
41
41
|
files:
|
42
|
-
- Changelog
|
43
|
-
- README.rdoc
|
44
|
-
- example.rb
|
45
|
-
- lib/dansguardian.rb
|
46
|
-
- lib/dansguardian/config/constants.rb
|
47
42
|
- lib/dansguardian/config/filtergroup.rb
|
48
43
|
- lib/dansguardian/config/main.rb
|
44
|
+
- lib/dansguardian/config/constants.rb
|
49
45
|
- lib/dansguardian/extensions/float.rb
|
50
|
-
- lib/dansguardian/config.rb
|
51
|
-
- lib/dansguardian/inclusion.rb
|
52
46
|
- lib/dansguardian/parser.rb
|
47
|
+
- lib/dansguardian/config.rb
|
53
48
|
- lib/dansguardian/updater.rb
|
49
|
+
- lib/dansguardian/list.rb
|
50
|
+
- lib/dansguardian.rb
|
51
|
+
- README.rdoc
|
52
|
+
- Changelog
|
53
|
+
- example.rb
|
54
54
|
has_rdoc: true
|
55
55
|
homepage: http://github.com/gderosa/dansguardian.rb
|
56
56
|
licenses: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module DansGuardian
|
2
|
-
module Inclusion
|
3
|
-
# no distinction between text parser and ConfigFile conversion here ...
|
4
|
-
def self.get(filename)
|
5
|
-
all = {}
|
6
|
-
File.foreach filename do |line|
|
7
|
-
if line =~ /^\s*\.Include\s*<(.*)>/
|
8
|
-
all[$1] = {:active => true}
|
9
|
-
elsif line =~ /^\s*#+\s*\.Include\s*<(.*)>/
|
10
|
-
all[$1] = {:active => false}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
return all
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|