turkish_banks 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +7 -1
- data/Gemfile +2 -2
- data/README.md +22 -21
- data/lib/turkish_banks.rb +8 -8
- data/lib/turkish_banks/bank.rb +18 -9
- data/lib/turkish_banks/branch.rb +14 -9
- data/lib/turkish_banks/turkish_banks.rb +25 -0
- data/lib/turkish_banks/version.rb +1 -1
- data/turkish_banks.gemspec +9 -9
- metadata +23 -40
- data/lib/turkish_banks/turkish_bank.rb +0 -36
- data/turkish_banks-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a4a1e3454cffe707870cf8ad1b4ae3cd0158b40ff58c3251028063e57c94c85
|
4
|
+
data.tar.gz: '09afc7a80cbb76814f595ebd89113697d28ab8e77a912fff8205a8ed4c2542b1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8552c337e65bb399cb91cb844d4ee5197e7314b854b59052719741bd84ea2b1ac6ebda409349d54cd43612dc825a310c55b53725243a1c0a2fd1db85d3c123a8
|
7
|
+
data.tar.gz: 636f245cc55b582d2539999788b653515322ff22a238eda3d73c59391eccadfe05a189bc55d1754153a9b25266bb7cd58592ff82fea59777839358f975a42831
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -24,33 +24,34 @@ Or install it yourself as:
|
|
24
24
|
## Usage
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
# Creates a TurkishBank object
|
28
|
-
turkish_bank = TurkishBanks::TurkishBank.new
|
29
|
-
|
30
27
|
# Gets last update date
|
31
|
-
|
28
|
+
TurkishBanks::LAST_UPDATE
|
32
29
|
|
33
30
|
# Gets all banks
|
34
|
-
|
31
|
+
TurkishBanks.banks
|
35
32
|
|
36
|
-
#
|
37
|
-
bank =
|
38
|
-
bank.name # => TÜRKİYE CUMHURİYETİ ZIRAAT BANKASI A.Ş.
|
33
|
+
# Create a bank from its name
|
34
|
+
bank = TurkishBanks::Bank.new("türkiye cumhuriyeti ziraat bankası a.ş.")
|
35
|
+
bank.name # => "TÜRKİYE CUMHURİYETİ ZIRAAT BANKASI A.Ş."
|
39
36
|
|
40
|
-
#
|
41
|
-
branches =
|
42
|
-
branches.first.name # => "ANKARA ŞUBESİ"
|
43
|
-
|
37
|
+
# Get a collection of branch objects
|
38
|
+
branches = bank.branches
|
39
|
+
branches.first.name # => "MERKEZ/ANKARA ŞUBESİ"
|
40
|
+
branches.size # => 1791
|
41
|
+
```
|
44
42
|
|
45
|
-
##
|
43
|
+
## Exception Handling
|
46
44
|
|
47
|
-
|
48
|
-
* New features. Please send some pull-request.
|
45
|
+
If you pass the wrong bank name to `Bank#new`, it raises `TurkishBanks::BankNotFoundError` exception. You can rescue this error, then do something else.
|
49
46
|
|
50
|
-
|
47
|
+
```ruby
|
48
|
+
begin
|
49
|
+
TurkishBanks::Bank.new('fake bank')
|
50
|
+
rescue TurkishBanks::BankNotFoundError
|
51
|
+
# do something here
|
52
|
+
end
|
53
|
+
```
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
-
5. Create a new Pull Request
|
55
|
+
## TODO
|
56
|
+
* Improve search part.
|
57
|
+
* New features. Please send some pull-request.
|
data/lib/turkish_banks.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'active_support/core_ext/hash'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require 'rubygems'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'turkish_banks/version'
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
8
|
+
require 'turkish_banks/turkish_banks'
|
9
|
+
require 'turkish_banks/branch'
|
10
|
+
require 'turkish_banks/bank'
|
11
11
|
|
12
12
|
module TurkishBanks
|
13
13
|
end
|
data/lib/turkish_banks/bank.rb
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
module TurkishBanks
|
2
|
-
class Bank
|
3
|
-
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
2
|
+
class Bank
|
3
|
+
attr_reader :name, :code, :city, :address
|
4
|
+
|
5
|
+
def initialize(bank_name)
|
6
|
+
bank_params = TurkishBanks.get_bank_params(bank_name)
|
7
|
+
@name = bank_params['bAd']
|
8
|
+
@code = bank_params['bKd']
|
9
|
+
@city = bank_params['bIlAd']
|
10
|
+
@address = bank_params['adr']
|
11
|
+
end
|
12
|
+
|
13
|
+
def branches
|
14
|
+
nodes = TurkishBanks::DOC.xpath("//sube[bKd= '#{@code}']")
|
15
|
+
nodes.map do |node|
|
16
|
+
branch_params = Hash.from_xml(node.to_s)['sube']
|
17
|
+
TurkishBanks::Branch.new(branch_params)
|
18
|
+
end
|
10
19
|
end
|
11
20
|
end
|
12
|
-
end
|
21
|
+
end
|
data/lib/turkish_banks/branch.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
module TurkishBanks
|
2
|
-
class Branch
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
2
|
+
class Branch
|
3
|
+
attr_reader :name, :code, :bank_code, :city_code,
|
4
|
+
:city, :district_code, :district, :phone
|
5
|
+
|
6
|
+
def initialize(branch_params)
|
7
|
+
@name = branch_params['sAd']
|
8
|
+
@code = branch_params['sKd']
|
9
|
+
@bank_code = branch_params['bKd']
|
10
|
+
@city_code = branch_params['sIlKd']
|
11
|
+
@city = branch_params['sIlAd']
|
12
|
+
@district_code = branch_params['sIlcKd']
|
13
|
+
@district = branch_params['sIlcAd']
|
14
|
+
@phone = branch_params['tlf']
|
10
15
|
end
|
11
16
|
end
|
12
|
-
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TurkishBanks
|
2
|
+
class BankNotFoundError < StandardError
|
3
|
+
def message
|
4
|
+
'Banka bulunamadı.'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
BANKS_URL = 'http://eftemkt.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml'.freeze
|
9
|
+
DOC = Nokogiri
|
10
|
+
.XML(::OpenURI.open_uri(BANKS_URL), nil, 'UTF-8')
|
11
|
+
.remove_namespaces!.freeze
|
12
|
+
LAST_UPDATE = DOC.at_xpath('//bankaSubeTumListe')['tarih'].freeze
|
13
|
+
|
14
|
+
def self.get_bank_params(bank_name)
|
15
|
+
node = DOC.at_xpath("//banka[bAd= '#{bank_name.upcase(:turkic)}']")
|
16
|
+
raise BankNotFoundError if node.nil?
|
17
|
+
|
18
|
+
Hash.from_xml(node.to_s)['banka']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.banks
|
22
|
+
nodes = DOC.xpath('//banka')
|
23
|
+
nodes.each.map { |node| Hash.from_xml(node.to_s)['banka'] }
|
24
|
+
end
|
25
|
+
end
|
data/turkish_banks.gemspec
CHANGED
@@ -4,10 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'turkish_banks/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.
|
10
|
-
spec.
|
7
|
+
spec.name = "turkish_banks"
|
8
|
+
spec.version = TurkishBanks::VERSION
|
9
|
+
spec.required_ruby_version = '>= 2.5.1'
|
10
|
+
spec.authors = ["Ender Ahmet Yurt"]
|
11
|
+
spec.email = ["enderyurt@gmail.com"]
|
11
12
|
|
12
13
|
# if spec.respond_to?(:metadata)
|
13
14
|
# spec.metadata['allowed_push_host'] = ""
|
@@ -23,9 +24,8 @@ Gem::Specification.new do |spec|
|
|
23
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
25
|
spec.require_paths = ["lib"]
|
25
26
|
|
26
|
-
spec.add_development_dependency "
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "nokogiri", "~> 1.
|
29
|
-
spec.add_development_dependency "
|
30
|
-
spec.add_development_dependency "turkish_support"
|
27
|
+
spec.add_development_dependency "activesupport", ">= 6.0.3.1"
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
29
|
+
spec.add_development_dependency "nokogiri", "~> 1.10.9"
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0.0"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turkish_banks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ender Ahmet Yurt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.3.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.10.9
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activesupport
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
54
|
+
version: 1.10.9
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: 13.0.0
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: 13.0.0
|
83
69
|
description: Fetch the all data about Turkish Banks and their branches.
|
84
70
|
email:
|
85
71
|
- enderyurt@gmail.com
|
@@ -100,15 +86,14 @@ files:
|
|
100
86
|
- lib/turkish_banks.rb
|
101
87
|
- lib/turkish_banks/bank.rb
|
102
88
|
- lib/turkish_banks/branch.rb
|
103
|
-
- lib/turkish_banks/
|
89
|
+
- lib/turkish_banks/turkish_banks.rb
|
104
90
|
- lib/turkish_banks/version.rb
|
105
|
-
- turkish_banks-0.1.0.gem
|
106
91
|
- turkish_banks.gemspec
|
107
92
|
homepage: https://github.com/enderahmetyurt/turkish_banks
|
108
93
|
licenses:
|
109
94
|
- MIT
|
110
95
|
metadata: {}
|
111
|
-
post_install_message:
|
96
|
+
post_install_message:
|
112
97
|
rdoc_options: []
|
113
98
|
require_paths:
|
114
99
|
- lib
|
@@ -116,17 +101,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
101
|
requirements:
|
117
102
|
- - ">="
|
118
103
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
104
|
+
version: 2.5.1
|
120
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
106
|
requirements:
|
122
107
|
- - ">="
|
123
108
|
- !ruby/object:Gem::Version
|
124
109
|
version: '0'
|
125
110
|
requirements: []
|
126
|
-
|
127
|
-
|
128
|
-
signing_key:
|
111
|
+
rubygems_version: 3.1.4
|
112
|
+
signing_key:
|
129
113
|
specification_version: 4
|
130
114
|
summary: Fetch Turkish Banks and their branches.
|
131
115
|
test_files: []
|
132
|
-
has_rdoc:
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "turkish_support"
|
2
|
-
|
3
|
-
module TurkishBanks
|
4
|
-
class TurkishBank
|
5
|
-
using TurkishSupport
|
6
|
-
attr_accessor :last_update_date, :banks
|
7
|
-
|
8
|
-
BANKS_URL = "http://eft.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml"
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
doc = Nokogiri.XML(open(BANKS_URL), nil, 'UTF-8')
|
12
|
-
doc.remove_namespaces!
|
13
|
-
response = Hash.from_xml(doc.to_s)
|
14
|
-
@last_update_date = response["bankaSubeTumListe"]["tarih"]
|
15
|
-
@banks = response["bankaSubeTumListe"]["bankaSubeleri"]
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_information_of bank_name
|
19
|
-
bank = get_bank(bank_name).first["banka"]
|
20
|
-
TurkishBanks::Bank.new bank
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_branches_of bank_name
|
24
|
-
branches = get_bank(bank_name).first["sube"]
|
25
|
-
branches.each do |branch|
|
26
|
-
TurkishBanks::Branch.new branch
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def get_bank bank_name
|
33
|
-
@banks.select {|b| b["banka"]["bAd"] == bank_name.upcase}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/turkish_banks-0.1.0.gem
DELETED
Binary file
|