spf-query 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: ad212d3a18fdf143d0a478c9b703a51fd790b704
4
- data.tar.gz: 85e5eaf89a001162b200707971c1aeeccf59fac8
3
+ metadata.gz: 3f08907e297e77ca52db4ffb426fa8d45fd5f87a
4
+ data.tar.gz: 36acdb178979d12cf7ad78a9a2f7627597dfff63
5
5
  SHA512:
6
- metadata.gz: ebdda6c3f7346574531cdcd5c2739e5424077fe768712298cc239a6c7f46e68fc799b2d0921d63b528ad78102a5424e2f03312818d4c9586472a0e8d569849b3
7
- data.tar.gz: e3a139ead34ca81521bd4ff91696d5152db75b9380d364f39acdfc9d3a98f047bb1344933d372c2dddf083732c131239d6564e6964a23e463f73e836c3930bd1
6
+ metadata.gz: f5095e9712837d7ab82489e6c30f90eeb87ad51801f3b849e4b499455b246d28f0bd16908d1d2430ebf3bd3cd36d3531cdd4a6b3518661e2081a51c5ff4f3c5a
7
+ data.tar.gz: bb9e67f1784092715923ff03abe85d1311841af967672e14396bc412de915ad8bd6e5cf9a1ef33496f3374c05d170da5b21f4b265004a1ad99dbcd485ff18de8
@@ -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
@@ -16,6 +16,14 @@ module SPF
16
16
  @elements[*arguments]
17
17
  end
18
18
 
19
+ def to_a
20
+ @elements
21
+ end
22
+
23
+ def to_ary
24
+ @elements
25
+ end
26
+
19
27
  def to_s
20
28
  @elements.join
21
29
  end
@@ -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: [simple(:text)]) { text }
236
- rule(macro_string: sequence(:elements)) { MacroString.new(elements) }
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)
@@ -1,5 +1,5 @@
1
1
  module SPF
2
2
  module Query
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
@@ -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'})
@@ -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:mail.zendesk.com include:servers.mcsv.net include:_spf.google.com include:sendgrid.net include:mktomail.com -all}
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.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-06 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet