spf-query 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +7 -0
- data/lib/spf/query/macro_string.rb +8 -0
- data/lib/spf/query/parser.rb +9 -4
- data/lib/spf/query/version.rb +1 -1
- data/spec/parser_spec.rb +58 -0
- data/spec/query_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f08907e297e77ca52db4ffb426fa8d45fd5f87a
|
4
|
+
data.tar.gz: 36acdb178979d12cf7ad78a9a2f7627597dfff63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5095e9712837d7ab82489e6c30f90eeb87ad51801f3b849e4b499455b246d28f0bd16908d1d2430ebf3bd3cd36d3531cdd4a6b3518661e2081a51c5ff4f3c5a
|
7
|
+
data.tar.gz: bb9e67f1784092715923ff03abe85d1311841af967672e14396bc412de915ad8bd6e5cf9a1ef33496f3374c05d170da5b21f4b265004a1ad99dbcd485ff18de8
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.1.2 / 2015-07-07
|
2
|
+
|
3
|
+
#### parser
|
4
|
+
|
5
|
+
* Convert all chars and literals to Strings.
|
6
|
+
* Properly transform macro_strings that contain a single literal into a String.
|
7
|
+
|
1
8
|
### 0.1.1 / 2015-07-06
|
2
9
|
|
3
10
|
* Raise {SPF::Query::SenderIDFound} from {SPF::Query::Record.parse} if
|
data/lib/spf/query/parser.rb
CHANGED
@@ -224,16 +224,21 @@ module SPF
|
|
224
224
|
IP.new(address,cidr_length.to_i)
|
225
225
|
end
|
226
226
|
|
227
|
-
rule(char: simple(:c)) { c }
|
228
|
-
rule(literal: simple(:text)) { text }
|
227
|
+
rule(char: simple(:c)) { c.to_s }
|
228
|
+
rule(literal: simple(:text)) { text.to_s }
|
229
229
|
rule(macro: subtree(:options)) do
|
230
230
|
letter = options.fetch(:letter).to_sym
|
231
231
|
|
232
232
|
Macro.new(letter,options)
|
233
233
|
end
|
234
234
|
|
235
|
-
rule(macro_string:
|
236
|
-
|
235
|
+
rule(macro_string: sequence(:elements)) do
|
236
|
+
if elements.length == 1 && elements.first.kind_of?(String)
|
237
|
+
elements.first
|
238
|
+
else
|
239
|
+
MacroString.new(elements)
|
240
|
+
end
|
241
|
+
end
|
237
242
|
|
238
243
|
rule(modifier: {name: simple(:name)}) do
|
239
244
|
Modifier.new(name.to_sym)
|
data/lib/spf/query/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -575,6 +575,64 @@ describe Parser do
|
|
575
575
|
end
|
576
576
|
|
577
577
|
describe Parser::Transform do
|
578
|
+
describe "c" do
|
579
|
+
let(:char) { 'c' }
|
580
|
+
|
581
|
+
subject { super().apply(char: char) }
|
582
|
+
|
583
|
+
it "should convert to a String" do
|
584
|
+
expect(subject).to be_kind_of(String)
|
585
|
+
expect(subject).to be == char
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
describe "literal" do
|
590
|
+
let(:string) { '_spf.google.com' }
|
591
|
+
|
592
|
+
subject { super().apply(literal: string) }
|
593
|
+
|
594
|
+
it "should convert to a String" do
|
595
|
+
expect(subject).to be_kind_of(String)
|
596
|
+
expect(subject).to be == string
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
describe "macro_string" do
|
601
|
+
context "containing a single literal string" do
|
602
|
+
let(:string) { '_spf.google.com' }
|
603
|
+
|
604
|
+
subject { super().apply(macro_string: [{literal: string}]) }
|
605
|
+
|
606
|
+
it "should convert to a String" do
|
607
|
+
expect(subject).to be == string
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
context "containing a mix of macro_expands and literals" do
|
612
|
+
let(:string1) { 'foo' }
|
613
|
+
let(:macro) { 's' }
|
614
|
+
let(:string2) { 'bar' }
|
615
|
+
|
616
|
+
subject do
|
617
|
+
super().apply(
|
618
|
+
macro_string: [
|
619
|
+
{literal: string1},
|
620
|
+
{macro: {letter: macro}},
|
621
|
+
{literal: string2}
|
622
|
+
]
|
623
|
+
)
|
624
|
+
end
|
625
|
+
|
626
|
+
it "should convert to a String" do
|
627
|
+
expect(subject).to be_kind_of(MacroString)
|
628
|
+
expect(subject[0]).to be == string1
|
629
|
+
expect(subject[1]).to be_kind_of(Macro)
|
630
|
+
expect(subject[1].letter).to be == macro.to_sym
|
631
|
+
expect(subject[2]).to be == string2
|
632
|
+
end
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
578
636
|
describe "directive" do
|
579
637
|
subject do
|
580
638
|
super().apply(directive: {qualifier: '~', name: 'all'})
|
data/spec/query_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe SPF::Query do
|
|
23
23
|
let(:domain) { 'getlua.com' }
|
24
24
|
|
25
25
|
it "should prefer the SPF type record over other TXT records" do
|
26
|
-
expect(subject.query(domain)).to be == %{v=spf1 include:
|
26
|
+
expect(subject.query(domain)).to be == %{v=spf1 include:_spf.google.com include:mail.zendesk.com include:servers.mcsv.net -all}
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spf-query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nicktitle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|