sagan_crafter 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sagan_crafter/backends/sqlite.rb +9 -4
- data/lib/sagan_crafter/main.rb +1 -0
- data/lib/sagan_crafter/ruleset.rb +8 -3
- data/lib/sagan_crafter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d7bb24c4114f2d7c6d33e69d7408d1eeb77a07
|
4
|
+
data.tar.gz: 58ab491faa2df6568dbe94a1953e37af47d39311
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72b348e2adf6bd76c338916b977079c4a8acb2275918771bf0f86a98b7b9a91d1fb8ee819ae2545b85c1d57dd149a380524f585efd904a929941e3475b77bb6
|
7
|
+
data.tar.gz: 56ff929ce63782ad216b8bff3c134709fb2c4650833edf0bf0aa605e0009e221c9968bdce63f40d43f53e3c2aa32020a2d91d3920ae5a09bd8c7e3c7a8b4fe81
|
@@ -17,16 +17,21 @@ module SaganCrafter
|
|
17
17
|
|
18
18
|
attr_reader :rule_collection
|
19
19
|
|
20
|
-
def initialize(factory)
|
21
|
-
|
20
|
+
def initialize(factory, existing_db_connection = nil)
|
21
|
+
if existing_db_connection
|
22
|
+
@db = existing_db_connection
|
23
|
+
else
|
24
|
+
@db = connect(SaganCrafter::Settings.sql_file_location)
|
25
|
+
end
|
22
26
|
@factory = factory
|
23
27
|
@db.results_as_hash = true
|
24
28
|
@rule_collection = []
|
25
29
|
end
|
26
30
|
|
27
31
|
def size
|
28
|
-
count = db.get_first_value("select count(DISTINCT name) from #{SaganCrafter::Settings.sql_table_name}")
|
29
|
-
puts "
|
32
|
+
count = @db.get_first_value("select count(DISTINCT name) from #{SaganCrafter::Settings.sql_table_name}")
|
33
|
+
puts "count(*): #{count}" if SaganCrafter::Settings.verbose
|
34
|
+
count
|
30
35
|
end
|
31
36
|
|
32
37
|
def validate!
|
data/lib/sagan_crafter/main.rb
CHANGED
@@ -2,9 +2,10 @@ module SaganCrafter
|
|
2
2
|
class Ruleset
|
3
3
|
attr_reader :rules
|
4
4
|
|
5
|
-
def initialize(rule_sources)
|
5
|
+
def initialize(rule_sources, existing_connection=nil)
|
6
6
|
@rules_builders = []
|
7
7
|
@rules = []
|
8
|
+
@connection = existing_connection
|
8
9
|
rule_sources.each do |source|
|
9
10
|
@rules << new_rule_source(source)
|
10
11
|
end
|
@@ -15,12 +16,16 @@ module SaganCrafter
|
|
15
16
|
@rules.to_s
|
16
17
|
end
|
17
18
|
|
19
|
+
def new_rule_source(source)
|
20
|
+
raise TemplateError, "new_rule_source called on template class Ruleset"
|
21
|
+
end
|
22
|
+
|
18
23
|
end
|
19
24
|
|
20
25
|
class FQDNRuleset < Ruleset
|
21
26
|
def new_rule_source(source)
|
22
27
|
puts "#[sagan-crafter] #{self.class} - #{source}" if SaganCrafter::Settings.verbose
|
23
|
-
printer = SaganCrafter::Backends::SQLite.new(SaganCrafter::Factory::FQDNlogger.new )
|
28
|
+
printer = SaganCrafter::Backends::SQLite.new(SaganCrafter::Factory::FQDNlogger.new, @connection)
|
24
29
|
printer.validate!
|
25
30
|
return printer.build
|
26
31
|
end
|
@@ -29,7 +34,7 @@ module SaganCrafter
|
|
29
34
|
class IPRuleset < Ruleset
|
30
35
|
def new_rule_source(source)
|
31
36
|
puts "#[sagan-crafter] #{self.class} - #{source}" if SaganCrafter::Settings.verbose
|
32
|
-
printer = SaganCrafter::Backends::SQLite.new(SaganCrafter::Factory::IPlogger.new )
|
37
|
+
printer = SaganCrafter::Backends::SQLite.new(SaganCrafter::Factory::IPlogger.new, @connection)
|
33
38
|
printer.validate!
|
34
39
|
return printer.build
|
35
40
|
end
|