vat_number_validator 0.0.4 → 1.0.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
  SHA1:
3
- metadata.gz: 21f71a631e6dc07ab612c1e57c685697872108dc
4
- data.tar.gz: 1f198faa7e5c9dbe9650ba6113cbd33be55028d8
3
+ metadata.gz: bffd18caa1b31ff87c01fac99ba44cd4b7684a9e
4
+ data.tar.gz: 5c0b5f14a3744745debe846dc63cd4fcb17abc24
5
5
  SHA512:
6
- metadata.gz: d9fc346a317af51e949308e7678ab57d430f6b936db078dbc2d94475a1979423128f112aea069ccdae336d20bb3fb84cc6036ed1d081e5e851704c30c5554b51
7
- data.tar.gz: e83fdb4fb0ccbb4f416d7fc4ed50c7293be2b59b22a9286a0a2c35e8ce2057b1ffa83529ad2edee2250bc4d8b7ec80104792fa19cac1bb50081e48bcc146a451
6
+ metadata.gz: e7797c07fa3af029de54a774f592601d906dafa5f88e868ad07e693834775399401d62674d153a5fe5d6273d68d6891961afe98d9e8117f9d541492d71803b23
7
+ data.tar.gz: db536285a42b57c66fb67819dbcd16f480415427719de74e0714d3e0c444b4790bb47e1da8963e9e6f0714ae8ab165c483fa916c6b5d36477aa1027f732b4c99
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # vat_number_validator
2
+ Validate vat number format with vatlayer.com API
3
+
4
+ ## Usage
5
+ Add to your Gemfile:
6
+ ```Ruby
7
+ gem 'vat_number_validator'
8
+ ```
9
+ Run:
10
+ ```Ruby
11
+ bundle install
12
+ ```
13
+ In your `config/initializers/vat_number_validator.rb`:
14
+ ```Ruby
15
+ yaml_path = 'config/vat_number_validator.yml'
16
+ VatNumberValidator::Configuration.configure yaml: yaml_path
17
+ ```
18
+ In your `config/vat_number_validator.yml`:
19
+ ```YAML
20
+ access_key: your_vatlayer_access_key
21
+ use_https: true # use this if your vatlayer plan allows secure connection
22
+ ```
23
+ Then add the following to your model:
24
+ ```Ruby
25
+ validates :my_vat_number_attribute, vat_number: true
26
+ ```
@@ -4,6 +4,6 @@ class VatNumberValidator
4
4
  class Configuration
5
5
  include Confiture::Configuration
6
6
 
7
- confiture_allowed_keys(:access_key, :use_https)
7
+ confiture_allowed_keys(:access_key, :use_https, :http_options)
8
8
  end
9
9
  end
@@ -13,8 +13,7 @@ class VatNumberValidator < ActiveModel::EachValidator
13
13
  private
14
14
 
15
15
  def base_uri
16
- use_https = Configuration.use_https
17
- protocol = use_https ? 'https' : 'http'
16
+ protocol = Configuration.use_https ? 'https' : 'http'
18
17
  "#{protocol}://apilayer.net/api"
19
18
  end
20
19
 
@@ -25,11 +24,16 @@ class VatNumberValidator < ActiveModel::EachValidator
25
24
  end
26
25
 
27
26
  def http_options(value)
28
- {
27
+ default_options = Configuration.http_options
28
+ query_options = {
29
29
  query: {
30
- access_key: Configuration.access_key,
31
- vat_number: value
30
+ access_key: Configuration.access_key, vat_number: value
32
31
  }
33
32
  }
33
+ if default_options && default_options.is_a?(Hash)
34
+ default_options.merge(query_options).with_indifferent_access
35
+ else
36
+ query_options.with_indifferent_access
37
+ end
34
38
  end
35
39
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'vat_number_validator'
3
- s.version = '0.0.4'
3
+ s.version = '1.0.0'
4
4
  s.authors = 'Marek Lipka'
5
5
  s.summary = 'Vat number validator'
6
6
  s.description = 'Vat number validator for Rails 3+ using vatlayer.com API'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vat_number_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Lipka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -60,6 +60,7 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - ".gitignore"
62
62
  - LICENSE
63
+ - README.md
63
64
  - lib/vat_number_validator.rb
64
65
  - lib/vat_number_validator/configuration.rb
65
66
  - lib/vat_number_validator/errors.rb