open-companies-house 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ Companies registered in England and Wales
2
+ --------------------------------------------------------------------------------
3
+ AC - Assurance companies
4
+
5
+ BR - UK Establishment of an overseas company
6
+
7
+ FC - Overseas companies
8
+
9
+ GE - EEIG - European Economic Interest Grouping
10
+
11
+ IP - Industrial and Provident Societies
12
+
13
+ LP - Limited Partnership
14
+
15
+ OC - Limited Liability Partnership
16
+
17
+ RC - Incorporated by Royal Charter or Letters Patent.
18
+
19
+ SE - Societas Europea - Refer queries to Overseas team
20
+
21
+ ZC - Unregistered company (Company registered under an Act other than the Companies Act).
22
+
23
+
24
+ Companies Registered in Scotland
25
+ --------------------------------------------------------------------------------
26
+ SC - Companies Registered under Part 1 of the Companies Act 1985
27
+
28
+ SA - Assurance Companies
29
+
30
+ SF - Overseas Companies which appear to have a place of business in Scotland
31
+
32
+ SL - Limited Partnerships
33
+
34
+ SZ - Companies Incorporated under other than Companies Acts
35
+
36
+ SP - Industrial and Provident Societies
37
+
38
+ SO - Other Companies and LLP's
39
+
40
+ SR - Incorporated by Royal Charter or Letters Patent
41
+
42
+
43
+
44
+ Companies Registered in Northern Ireland
45
+ ---------------------------------------------------------------------------
46
+ NI - Companies Registered under Part 1 of the Companies Act (Northern Ireland) 1960
47
+
48
+ NA - Assurance Companies
49
+
50
+ NF - Overseas Companies which appear to have a place of business in Northern Ireland
51
+
52
+ NL - Limited Partnerships
53
+
54
+ NZ - Companies Incorporated under other than Companies Acts
55
+
56
+ NP - Industrial and Provident Societies
57
+
58
+ NO - Other Companies
59
+
60
+ NR - Incorporated by Royal Charter or Letters Patent
@@ -4,6 +4,16 @@ module CompaniesHouse
4
4
 
5
5
  BASE_URI = 'http://data.companieshouse.gov.uk/doc/company/'
6
6
 
7
+ # White list of allowed prefixes for companies house numbers.
8
+ # 1st line is English and Welsh prefixes
9
+ # 2nd line is Scottish prefixes
10
+ # 3rd line is Northen Irish prefixes
11
+ # \d\d is the default prefix in regex notation.
12
+ ALLOWED_PREFIXES = %w(AC BR FC GE IP LP OC RC SE ZC
13
+ SC SA SF SL SZ SP SO SR
14
+ NI NA NF NL NZ NP NO NR
15
+ \d\d)
16
+
7
17
  # Don't call this directly. Instead, use CompaniesHouse.lookup "01234567"
8
18
  def initialize(registration_number)
9
19
  @registration_number = validate(registration_number)
@@ -29,10 +39,13 @@ module CompaniesHouse
29
39
 
30
40
  number = "0" + number if number.length == 7 # 0-pad for luck
31
41
 
42
+ companies_house_regex = Regexp.
43
+ new("\\A(#{ALLOWED_PREFIXES * '|'})\\d{6}\\z")
44
+
32
45
  msg = "#{number} is not a valid UK company registration number"
33
- raise InvalidRegistration.new(msg) unless number =~ /\A[A-Z0-9]{8}\z/
46
+ raise InvalidRegistration.new(msg) unless number =~ companies_house_regex
34
47
 
35
48
  number
36
49
  end
37
50
  end
38
- end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module CompaniesHouse
2
- VERSION = '0.2.2'.freeze
3
- end
2
+ VERSION = '0.2.3'.freeze
3
+ end
@@ -37,6 +37,15 @@ describe CompaniesHouse::Request do
37
37
  end
38
38
  end
39
39
 
40
+ CompaniesHouse::Request::ALLOWED_PREFIXES.each do |prefix|
41
+ it "allows a company registration number starting with #{prefix}" do
42
+ prefix = (prefix == '\d\d') ? '07' : prefix
43
+ company = subject.new "#{prefix}112233"
44
+ company.instance_variable_get(:@registration_number).
45
+ should == "#{prefix}112233"
46
+ end
47
+ end
48
+
40
49
  it "0-pads 7 digit registration numbers" do
41
50
  company = subject.new "7495895"
42
51
  company.instance_variable_get(:@registration_number).
@@ -70,4 +79,4 @@ describe CompaniesHouse::Request do
70
79
  @request.perform
71
80
  end
72
81
  end
73
- end
82
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-companies-house
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2012-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -103,6 +103,7 @@ files:
103
103
  - LICENSE
104
104
  - README.md
105
105
  - Rakefile
106
+ - companies_house_prefixes.txt
106
107
  - lib/companies_house.rb
107
108
  - lib/companies_house/request.rb
108
109
  - lib/companies_house/response.rb
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  version: '0'
134
135
  requirements: []
135
136
  rubyforge_project:
136
- rubygems_version: 1.8.24
137
+ rubygems_version: 1.8.23
137
138
  signing_key:
138
139
  specification_version: 3
139
140
  summary: A wrapper around Companies House Open API