valnzbn 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed4b3415f1c6c2a2a8484dcc7d533c90aa209e7d
4
- data.tar.gz: 187dd240f0af524edd476e359b56bbf3ab3bffac
3
+ metadata.gz: 7ccd1f4b435bc4088a5ed806318d9407653cfeea
4
+ data.tar.gz: 46e3445400588a2234fecf14f3b511eceb4dc332
5
5
  SHA512:
6
- metadata.gz: ecd0d32a25f51403a020ae79774a319d8f6d1b3668d41c630e7b5917c514ec5c21d898c5bf10d444750f852bd0834ab105f79efabb4f8454f43fffa109cc9d8c
7
- data.tar.gz: 82a4a20513999767032d73936941e99b4eeb29ecb24adf638e11093d7385f5eee826cb963599691cdb0c9e3de51ce43aa054ac93c9bc2b0241b96dee67c3c611
6
+ metadata.gz: 8d0944c68fb896ad644c610431afcd225d7d2aba35110d0c9f3dfae34d571bb423cc2746cd84fc71b61d74e4d91f6da117df59f6e717819c09aef8ca38a77f0d
7
+ data.tar.gz: e767c89bd51b7d66b3260fff78eefaad2a11826efa79d15ed9d30935e9816df6649c6dc9d6d07be84b19e8e381525944c5314b0c21e229c22c2a632046d0f2a3
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Valnzbn
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/valnzbn`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A simple wrapper to check New Zealand business numbers.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
@@ -22,22 +21,52 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
24
+ If you just need to check the format of the ABN, just use:
26
25
 
27
- ## Development
26
+ ```ruby
27
+ require 'valnzbn'
28
+
29
+ Valnzbn::Utils.validate_format(number) #=> Boolean
30
+ ```
31
+
32
+ In order to lookup real NZBN, you'll need to get an access token. Once you've got one initialize the gem like this:
33
+
34
+ ```ruby
35
+ require 'valnzbn'
36
+
37
+ Valnzbn::Lookup.configure do |config|
38
+ config.access_token = 'your_access_token'
39
+ config.mode = :production # (optional):production or :sandbox
40
+ config.cache_host = 'localhost' # (optional) The host of the redis server
41
+ config.cache_port = '6379' # (optional) The port of the redis server
42
+ end
43
+ ```
28
44
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ `cache_host` and `cache_port` are optional configuration attributes in order to keep a cache on a redis database. The current cache configuration lives up to two hours.
30
46
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+ After that, you can invoke
32
48
 
33
- ## Contributing
49
+ ```ruby
50
+ Valabn::Lookup.validate(abn) #=> Hash or nil
51
+
52
+ # or
53
+
54
+ number = Valabn.new(abn)
55
+ number.exists? #=> Boolean
56
+ number.exists?(details: true) #=> Hash, false or nil
57
+ ```
58
+
59
+ `nil` is a value that should be rarely returned. Just check it if the NZBN API endpoint has issues.
34
60
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/xxswingxx/valnzbn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
61
 
37
62
  ## License
38
63
 
39
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
64
+ (The MIT License)
65
+
66
+ Copyright © 2018 Quaderno
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
40
69
 
41
- ## Code of Conduct
70
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
42
71
 
43
- Everyone interacting in the Valnzbn project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xxswingxx/valnzbn/blob/master/CODE_OF_CONDUCT.md).
72
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -34,7 +34,7 @@ class Valnzbn
34
34
  end
35
35
 
36
36
  def self.validate(number, options = {})
37
- url = @@mode == :sandbox ? PRODUCTION_URL : SANDBOX_URL
37
+ url = @@mode == :sandbox ? SANDBOX_URL : PRODUCTION_URL
38
38
  number = number.to_s.gsub(/\W/, '')
39
39
 
40
40
  if Valnzbn::Utils.valid_format?(number)
data/lib/valnzbn/utils.rb CHANGED
@@ -5,5 +5,6 @@ class Valnzbn
5
5
 
6
6
  !!(number =~/\A94\d{11}\z/)
7
7
  end
8
+ alias_method :validate_format, :valid_format?
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  class Valnzbn
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valnzbn
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
  - xxswingxx