atotk 0.9.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a918eb4bc42636c96c6080e019d4691344b76790
4
+ data.tar.gz: b967351d4e240034101d0c796437fd7379c5b081
5
+ SHA512:
6
+ metadata.gz: 6c3ef54d85cb83134657516be4d013095308b0ed1eca3a2e1d4d8cad8e2bba3c6ee9971c802ba61dbe8df40f40c040da55b55ad9bedce44dc4a861814718fcfe
7
+ data.tar.gz: 3e21618dbf415cbec3db8acefbc72716b4b13760dc39af000bb0a6c112330a610b3824643ac1a94193c3f50d4e73bb349c329c7dc6f0c073a9bd8eb0b8fb4372
@@ -0,0 +1 @@
1
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in atotk.gemspec
4
+ gemspec
@@ -0,0 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ atotk (0.9.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ httpclient (2.8.3)
11
+ logger-application (0.0.2)
12
+ mini_portile2 (2.1.0)
13
+ nokogiri (1.7.2)
14
+ mini_portile2 (~> 2.1.0)
15
+ rake (10.4.2)
16
+ rspec (3.6.0)
17
+ rspec-core (~> 3.6.0)
18
+ rspec-expectations (~> 3.6.0)
19
+ rspec-mocks (~> 3.6.0)
20
+ rspec-core (3.6.0)
21
+ rspec-support (~> 3.6.0)
22
+ rspec-expectations (3.6.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.6.0)
25
+ rspec-mocks (3.6.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.6.0)
28
+ rspec-support (3.6.0)
29
+ soap4r-ng (2.0.3)
30
+ httpclient (~> 2.6)
31
+ logger-application (~> 0.0.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ atotk!
38
+ bundler (~> 1.15)
39
+ nokogiri (~> 1.7)
40
+ rake (~> 10.0)
41
+ rspec (~> 3.5)
42
+ soap4r-ng (~> 2.0)
43
+
44
+ BUNDLED WITH
45
+ 1.15.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 AtoTk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # AtoTk
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/atotk`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'atotk'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install atotk
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
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.
30
+
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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/atotk. 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
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Atotk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/atotk/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'atotk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'atotk'
8
+ spec.version = AtoTk::VERSION
9
+ spec.authors = ['Ashley Angell']
10
+ spec.email = ['ash@ashleyangell.com']
11
+
12
+ spec.summary = %q{Atotk is a toolkit for interfacing with numbers and services of the Australian Tax Department, including Tax File Numbers (TFN) and Australian Business Numbers (ABN).}
13
+ spec.description = %q{Atotk was created to provide an number of mechanisms to help validate and use ABNs anf TFNs as well as the ABN Business Lookup API for Ruby programmers.}
14
+ spec.homepage = 'https://github.com/Meroal/atotk'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.15'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.5'
27
+ spec.add_development_dependency 'soap4r-ng', '~> 2.0'
28
+ spec.add_development_dependency 'nokogiri', '~> 1.7'
29
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "atotk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,10 @@
1
+ module AtoTk
2
+ module Common
3
+
4
+ WEIGHTS = {8 => [10, 7, 8, 4, 6, 3, 5, 1], 9 => [10, 7, 8, 4, 6, 3, 5, 2, 1], 11 => [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]}
5
+
6
+ end
7
+ end
8
+
9
+ # Require everything from the atotk directory.
10
+ Dir[File.expand_path('../atotk/*.rb', __FILE__)].each{|f| require f }
@@ -0,0 +1,42 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ module AtoTk
4
+ class Abn
5
+ include AtoTk::Common
6
+
7
+ def initialize(val)
8
+ @value = val
9
+ @digits = @value.to_digits if (@value.class == Fixnum || @value.class == Bignum)
10
+ @wsdl = 'http://www.abn.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx?WSDL'
11
+ end
12
+
13
+ def valid?
14
+ return false if !(@value.class == Fixnum || @value.class == Bignum)
15
+ return false if @digits.size != 11
16
+ @digits[0] -= 1
17
+ @digits.map.with_index {|digit, index| digit * WEIGHTS[@digits.size][index]}.inject {|sum, digit| sum + digit} % 89 == 0
18
+ end
19
+
20
+ alias_method :is_valid?, :valid?
21
+
22
+ def to_s
23
+ valid? ? '%s%s %s%s%s %s%s%s %s%s%s' % @digits : ''
24
+ end
25
+
26
+ def lookup(authentication_guid)
27
+ if valid?
28
+ soap_client = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
29
+ options = {:searchString => @value.to_s, :includeHistoricalDetails => 'n', authenticationGuid: authentication_guid}
30
+ result = soap_client.ABRSearchByABN(options)
31
+ {
32
+ status: result['ABRPayloadSearchResults']['response']['businessEntity']['entityStatus']['entityStatusCode'],
33
+ asic_number: result['ABRPayloadSearchResults']['response']['businessEntity']['ASICNumber'],
34
+ name: result['ABRPayloadSearchResults']['response']['businessEntity']['mainName']['organisationName'],
35
+ type: result['ABRPayloadSearchResults']['response']['businessEntity']['entityType']['entityDescription'],
36
+ state: result['ABRPayloadSearchResults']['response']['businessEntity']['mainBusinessPhysicalAddress']['stateCode'],
37
+ postcode: result['ABRPayloadSearchResults']['response']['businessEntity']['mainBusinessPhysicalAddress']['postcode']
38
+ }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ class Fixnum
2
+
3
+ def to_digits
4
+ Math.log10(self).floor.downto(0).map { |i| (self / 10**i) % 10 }
5
+ end
6
+
7
+ def abn?
8
+ abn = AtoTk::Abn.new self
9
+ abn.valid?
10
+ end
11
+
12
+ def tfn?
13
+ abn = AtoTk::Tfn.new self
14
+ abn.valid?
15
+ end
16
+
17
+ end
@@ -0,0 +1,32 @@
1
+ module AtoTk
2
+ class Tfn
3
+ include AtoTk::Common
4
+
5
+ def initialize(val)
6
+ @value = val
7
+ @digits = @value.to_digits if (@value.class == Fixnum || @value.class == Bignum)
8
+ end
9
+
10
+ def valid?
11
+ return false if !(@value.class == Fixnum || @value.class == Bignum)
12
+ return false if (@digits.size < 8 || @digits.size > 9)
13
+ @digits.map.with_index {|digit, index| digit * WEIGHTS[@digits.size][index]}.inject {|sum, digit| sum + digit} % 11 == 0
14
+ end
15
+
16
+ alias_method :is_valid?, :valid?
17
+
18
+ def to_s
19
+ if valid?
20
+ case @digits.size
21
+ when 8
22
+ '%s%s%s %s%s%s %s%s%s' % @digits
23
+ when 9
24
+ '%s%s %s%s%s %s%s%s' % @digits
25
+ end
26
+ else
27
+ ''
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module AtoTk
2
+ VERSION = '0.9.2'
3
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atotk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ platform: ruby
6
+ authors:
7
+ - Ashley Angell
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: soap4r-ng
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ description: Atotk was created to provide an number of mechanisms to help validate
84
+ and use ABNs anf TFNs as well as the ABN Business Lookup API for Ruby programmers.
85
+ email:
86
+ - ash@ashleyangell.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - atotk.gemspec
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/atotk.rb
101
+ - lib/atotk/abn.rb
102
+ - lib/atotk/fixnum.rb
103
+ - lib/atotk/tfn.rb
104
+ - lib/atotk/version.rb
105
+ homepage: https://github.com/Meroal/atotk
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.12
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Atotk is a toolkit for interfacing with numbers and services of the Australian
129
+ Tax Department, including Tax File Numbers (TFN) and Australian Business Numbers
130
+ (ABN).
131
+ test_files: []