callcredit 0.3.4 → 0.3.5

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: 53b5cefad92f98c5380ed32a4898b210c73cd455
4
- data.tar.gz: 7afe3319d5e548c209f758d05bb6e859245e6619
3
+ metadata.gz: fa5511f62db44e4945ee93b3f8be5bdc295ee064
4
+ data.tar.gz: 4cee4c1eaca735897d678190311dc9ff62383aab
5
5
  SHA512:
6
- metadata.gz: 1db3d187a7e5bae829f89760ba02a04aec5ca562c5c1b1b9be105e7cd1268bd51f2266d5d3ae12b873181590ce4c0a400a56630fa31f161a8dd3a62c87786b1a
7
- data.tar.gz: 13b1835f96b0e1fceb556d5bab3e255082fcfcdeab18e73cb6d3ccacb1dd15e61c8ea3512574c8860411bd00eb38a2a8aabd888ac961650751ee1227c97ca2ca
6
+ metadata.gz: 3b63ca88889c45fba9f6369c647e54168b266563c47f237230563992fe3e348b0e2d60dc0f5cada2d6b0e8e887e960ed560a2fd5f15ea0ce4df261258e25dab8
7
+ data.tar.gz: e4e06bc0571ce0f04c5277843330184e73f70333024253007e32c06ea8533a22470ef011b7e417d8d172717047ad9debdbe1d11f557fb3f2166cc7a0d2efaf91
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.5 - February 24, 2014
2
+
3
+ - Remove insistence on inclusion of date_of_birth, postcode and names
4
+
1
5
  ## 0.3.4 - February 24, 2014
2
6
 
3
7
  - Validate input (including converting non-ASCII characters in names)
@@ -4,12 +4,12 @@ module Callcredit
4
4
  module Validations
5
5
 
6
6
  VALIDATIONS = {
7
- date_of_birth: ->(value) { clean_date_of_birth(value) },
8
- title: ->(value) { value || "Unknown" },
9
- first_name: ->(value) { clean_first_name(value) },
10
- last_name: ->(value) { clean_last_name(value) },
11
- middle_names: ->(value) { clean_middle_names(value) },
12
- postcode: ->(value) { clean_postcode(value) }
7
+ date_of_birth: ->(value) { clean_date_of_birth(value) },
8
+ title: ->(value) { value || "Unknown" },
9
+ first_name: ->(value) { clean_first_name(value) },
10
+ last_name: ->(value) { clean_last_name(value) },
11
+ middle_names: ->(value) { clean_middle_names(value) },
12
+ postcode: ->(value) { clean_postcode(value) }
13
13
  }
14
14
 
15
15
  def self.clean_param(key, value)
@@ -18,6 +18,7 @@ module Callcredit
18
18
  end
19
19
 
20
20
  def self.clean_date_of_birth(date_of_birth)
21
+ return unless date_of_birth
21
22
  date_of_birth = Date.parse(date_of_birth) if date_of_birth.is_a? String
22
23
  date_of_birth.strftime("%d/%m/%Y")
23
24
  rescue
@@ -25,13 +26,15 @@ module Callcredit
25
26
  end
26
27
 
27
28
  def self.clean_first_name(name)
28
- name = name && name.to_ascii
29
+ return unless name
30
+ name = name.to_ascii
29
31
  input_error(:first_name, name) unless name =~ /\A[a-z A-Z'-]{1,30}\z/
30
32
  name
31
33
  end
32
34
 
33
35
  def self.clean_last_name(name)
34
- name = name && name.to_ascii
36
+ return unless name
37
+ name = name.to_ascii
35
38
  input_error(:last_name, name) unless name =~ /\A[a-z A-Z'-]{1,30}\z/
36
39
  name
37
40
  end
@@ -44,7 +47,8 @@ module Callcredit
44
47
  end
45
48
 
46
49
  def self.clean_postcode(postcode)
47
- postcode = postcode && postcode.upcase.strip
50
+ return unless postcode
51
+ postcode = postcode.upcase.strip
48
52
  input_error(:postcode, postcode) unless postcode =~ /\A[A-Z 0-9]{5,8}\z/
49
53
  postcode
50
54
  end
@@ -1,3 +1,3 @@
1
1
  module Callcredit
2
- VERSION = '0.3.4'.freeze
2
+ VERSION = '0.3.5'.freeze
3
3
  end
@@ -16,6 +16,11 @@ describe Callcredit::Validations do
16
16
  describe '#clean_date_of_birth' do
17
17
  subject { Callcredit::Validations.clean_date_of_birth(date_of_birth) }
18
18
 
19
+ context "without a date of birth" do
20
+ let(:date_of_birth) { nil }
21
+ it { should == nil }
22
+ end
23
+
19
24
  context "with a date object" do
20
25
  let(:date_of_birth) { Date.parse("01/01/2000") }
21
26
  it { should == date_of_birth.strftime("%d/%m/%Y") }
@@ -39,9 +44,7 @@ describe Callcredit::Validations do
39
44
 
40
45
  context "without a first name" do
41
46
  let(:first_name) { nil }
42
- it "raises an error" do
43
- expect { subject }.to raise_error Callcredit::InvalidRequestError
44
- end
47
+ it { should == nil }
45
48
  end
46
49
 
47
50
  context "with a simple first name" do
@@ -54,14 +57,14 @@ describe Callcredit::Validations do
54
57
  it { should == "Grey" }
55
58
  end
56
59
 
57
- context "without a very long first name" do
60
+ context "with a very long first name" do
58
61
  let(:first_name) { "A" * 31 }
59
62
  it "raises an error" do
60
63
  expect { subject }.to raise_error Callcredit::InvalidRequestError
61
64
  end
62
65
  end
63
66
 
64
- context "without a first name with numbers in it" do
67
+ context "with a first name with numbers in it" do
65
68
  let(:first_name) { "David the 3rd" }
66
69
  it "raises an error" do
67
70
  expect { subject }.to raise_error Callcredit::InvalidRequestError
@@ -83,9 +86,7 @@ describe Callcredit::Validations do
83
86
 
84
87
  context "without a post code" do
85
88
  let(:postcode) { nil }
86
- it "raises an error" do
87
- expect { subject }.to raise_error Callcredit::InvalidRequestError
88
- end
89
+ it { should == nil }
89
90
  end
90
91
 
91
92
  context "with a correct post code" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callcredit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker