siteguard_lite-custom_signature 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 620a9a897b60fad5a8d1a5c220e77b0fa839ec29ccc7b396b63f855462105829
4
- data.tar.gz: 37dd3fcaeacf86b82e579a8c6dd6e92a0faab701f96f5d94a98260bff280bc7d
3
+ metadata.gz: 2afd93f858fa218143f84c0f9f17d1193240151c01143e957eb486441072b415
4
+ data.tar.gz: 29790f84d51e9781f1d50c1dda38b37475b7a0d568e5690b04ecd73f4b5261cd
5
5
  SHA512:
6
- metadata.gz: 824194ec96956d8aed714a3d3017e4eae3766ab5d7c843c690d9e6a38bb6c3f4bc809a284dff4cece8897cf61336a15627105ed38a9d68fc4ee41a083b849c97
7
- data.tar.gz: f62f14b812d333dc7cf91db36efecc4bc6301a55ae8844900c6e49a05d0a6bc6d1c7a29d21da8bcc5227b3d7956f62a08d43fabd2f15756bb15bbb96cff6946d
6
+ metadata.gz: 29d812d5abbc1935b228a3bc1035359302ff1a07314e52d2fc5dd750fac7a6fe6331426b32feccae819eead5383bd146ef803eef0eca8d56d2f107cbf0d8c332
7
+ data.tar.gz: b9d2fccf098915d39214cbed4293f58503d7b328c58b1a55ec01152cda27f682a1004854bd29214dad911c3f5012485712cf4e31d6bea9a754f1f6d7a0c88bf4
@@ -1,6 +1,6 @@
1
1
  class BytesizeValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- if value.bytesize > options[:maximum]
3
+ if value && value.bytesize > options[:maximum]
4
4
  record.errors.add(attribute, :too_long, count: options[:maximum])
5
5
  end
6
6
  end
@@ -20,7 +20,7 @@ module SiteguardLite
20
20
 
21
21
  [
22
22
  rule.enable_str,
23
- 'NONE',
23
+ rule.action,
24
24
  '',
25
25
  rule.name,
26
26
  @key,
@@ -42,14 +42,13 @@ module SiteguardLite
42
42
  private
43
43
 
44
44
  def comparison_str(rule, last)
45
- if last
46
- [
47
- @comparison_methods,
48
- "#{rule.exclusion_action}(#{rule.signature})"
49
- ].flatten.join(',')
50
- else
51
- @comparison_methods.join(',')
45
+ str = @comparison_methods.join(',')
46
+
47
+ if last && rule.exclusion_action && rule.signature
48
+ str << ",#{rule.exclusion_action}(#{rule.signature})"
52
49
  end
50
+
51
+ str
53
52
  end
54
53
  end
55
54
  end
@@ -3,17 +3,19 @@ module SiteguardLite
3
3
  class Rule
4
4
  include ActiveModel::Validations
5
5
 
6
- attr_reader :name, :comment, :enable, :conditions
6
+ attr_reader :name, :action, :comment, :enable, :conditions
7
7
  attr_accessor :exclusion_action, :signature
8
8
 
9
9
  validates :name, bytesize: { maximum: 29 }
10
10
  validates :signature, bytesize: { maximum: 999 }
11
+ validates :action, inclusion: %w(BLOCK NONE WHITE) # TODO support FILTER action
11
12
 
12
13
  def initialize(args)
13
14
  @name = args[:name]
14
15
  @comment = args[:comment]
15
16
  @exclusion_action = args[:exclusion_action]
16
17
  @signature = args[:signature]
18
+ @action = args[:action] || 'NONE'
17
19
 
18
20
  @enable = true
19
21
 
@@ -42,6 +44,7 @@ module SiteguardLite
42
44
  def to_hash
43
45
  {
44
46
  name: @name,
47
+ action: @action,
45
48
  comment: @comment,
46
49
  exclusion_action: @exclusion_action,
47
50
  signature: @signature,
@@ -1,5 +1,5 @@
1
1
  module SiteguardLite
2
2
  module CustomSignature
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -7,6 +7,7 @@ module SiteguardLite
7
7
  y['rules'].each do |r|
8
8
  rule = SiteguardLite::CustomSignature::Rule.new(
9
9
  name: r['name'],
10
+ action: r['action'],
10
11
  comment: r['comment'],
11
12
  exclusion_action: r['exclusion_action'],
12
13
  signature: r['signature']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siteguard_lite-custom_signature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takatoshi Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel