tcmb_exchange 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f17f4c0c5f91df73a95c0471ce05635227e9a0a6dcc4c5f7028eeffc0a3e6edb
4
+ data.tar.gz: 50eeb2f4df7fff7c1ad2f60ec2d42a679fe7bd08ee99f0eb068e406ccbb0daad
5
+ SHA512:
6
+ metadata.gz: 3ea37d8fd90776fc8f47bc0c7a56990bf495f78320c291a06dffaf845ce48016afae041cef3e88efa943ac3a096467e06ac566aac6e3c7f237712e7db00cd614
7
+ data.tar.gz: c402bbd07bf8e9d517b66362d64e9beaa258f0890cd41260d4a48d4e8b23a398074842dc5cd6d1dd2a6df4f35fd200e777384e1821d74ddb7f6e0e1e27f36d17
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in tcmb_exchange.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tcmb_exchange (0.1.0)
5
+ nokogiri (>= 1.8.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ mini_portile2 (2.3.0)
11
+ nokogiri (1.8.4)
12
+ mini_portile2 (~> 2.3.0)
13
+ rake (10.5.0)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.16)
20
+ rake (~> 10.0)
21
+ tcmb_exchange!
22
+
23
+ BUNDLED WITH
24
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 hamityay
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.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Tcmb Exchange
2
+
3
+ http://www.tcmb.gov.tr/kurlar/today.xml adresindeki verileri güncel olarak almanızı sağlar. Tüm Döviz kurlarını birden alabildiğiniz gibi istediğiniz döviz kurunu kodunu belirterek alabilirsiniz.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tcmb_exchange'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tcmb_exchange
20
+
21
+ ## Usage
22
+
23
+ $ require "tcmb_exchange"
24
+
25
+ Tüm döviz verilaerini almak için;
26
+
27
+ $ result = TcmbExchange.get
28
+ ```ruby
29
+ =>{"ABD DOLARI"=>{"Birim"=>"1", "Alış"=>4.5304, "Satış"=>4.5385}, "AVUSTRALYA DOLARI"=>{"Birim"=>"1", "Alış"=>3.378, "Satış"=>3.4}, "DANİMARKA KRONU"=>{"Birim"=>"1", "Alış"=>0.71444, "Satış"=>0.71795}, "EURO"=>{"Birim"=>"1", "Alış"=>5.3334, "Satış"=>5.343}, "İNGİLİZ STERLİNİ"=>{"Birim"=>"1", "Alış"=>6.0311, "Satış"=>6.0625}, "İSVİÇRE FRANGI"=>{"Birim"=>"1", "Alış"=>4.5774, "Satış"=>4.6068}, "İSVEÇ KRONU"=>{"Birim"=>"1", "Alış"=>0.51869, "Satış"=>0.52406}, "KANADA DOLARI"=>{"Birim"=>"1", "Alış"=>3.4588, "Satış"=>3.4744}, "KUVEYT DİNARI"=>{"Birim"=>"1", "Alış"=>14.8996, "Satış"=>15.0945}, "NORVEÇ KRONU"=>{"Birim"=>"1", "Alış"=>0.5649, "Satış"=>0.5687}, "SUUDİ ARABİSTAN RİYALİ"=>{"Birim"=>"1", "Alış"=>1.208, "Satış"=>1.2102}, "JAPON YENİ"=>{"Birim"=>"100", "Alış"=>4.0918, "Satış"=>4.1189}, "BULGAR LEVASI"=>{"Birim"=>"1", "Alış"=>2.7113, "Satış"=>2.7468}, "RUMEN LEYİ"=>{"Birim"=>"1", "Alış"=>1.1382, "Satış"=>1.1531}, "RUS RUBLESİ"=>{"Birim"=>"1", "Alış"=>0.07176, "Satış"=>0.0727}, "İRAN RİYALİ"=>{"Birim"=>"100", "Alış"=>0.01049, "Satış"=>0.01063}, "ÇİN YUANI"=>{"Birim"=>"1", "Alış"=>0.68067, "Satış"=>0.68958}, "PAKİSTAN RUPİSİ"=>{"Birim"=>"1", "Alış"=>0.03701, "Satış"=>0.03749}, "KATAR RİYALİ"=>{"Birim"=>"1", "Alış"=>1.2369, "Satış"=>1.2531}}
30
+ ```
31
+ ```ruby
32
+ result.keys.each do |k|
33
+ puts k
34
+ br = result[k].keys.first
35
+ al = result[k].keys[1]
36
+ sat = result[k].keys.last
37
+ puts "#{result[k][br]} birim " + k + " için alış: " + result[k][al].to_s + ", satış: " + result[k][sat].to_s + " TL."
38
+ end
39
+ ```
40
+ Belirli bir dövizi almak için;
41
+
42
+ $ result = TcmbExchange.get_by_code "USD"
43
+ ```ruby
44
+ => {"ABD DOLARI"=>{"Birim"=>"1", "Alış"=>4.5304, "Satış"=>4.5385}}
45
+ ```
46
+
47
+ # Döviz Kodları :
48
+
49
+ 1. USD -> ABD DOLARI
50
+ 2. AUD -> AVUSTRALYA DOLARI
51
+ 3. DKK -> DANİMARKA KRONU
52
+ 4. EUR -> EURO
53
+ 5. GBP -> İNGİLİZ STERLİNİ
54
+ 6. CHF -> İSVİÇRE FRANGI
55
+ 7. SEK -> İSVEÇ KRONU
56
+ 8. CAD -> KANADA DOLARI
57
+ 9. KWD -> KUVEYT DİNARI
58
+ 10. NOK -> NORVEÇ KRONU
59
+ 11. SAR -> SUUDİ ARABİSTAN RİYALİ
60
+ 12. JPY -> JAPON YENİ
61
+ 13. BGN -> BULGAR LEVASI
62
+ 14. RON -> RUMEN LEYİ
63
+ 15. RUB -> RUS RUBLESİ
64
+ 16. IRR -> İRAN RİYALİ
65
+ 17. CNY -> ÇİN YUANI
66
+ 18. PKR -> PAKİSTAN RUPİSİ
67
+ 19. QAR -> KATAR RİYALİ
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hamityay/tcmb_exchange.
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tcmb_exchange"
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__)
data/bin/setup ADDED
@@ -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,3 @@
1
+ module TcmbExchange
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,49 @@
1
+ require "tcmb_exchange/version"
2
+ require "open-uri"
3
+ require "nokogiri"
4
+
5
+ module TcmbExchange
6
+ def self.get
7
+ begin
8
+ d = open("http://www.tcmb.gov.tr/kurlar/today.xml", 'User-Agent' => "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36")
9
+
10
+ parsed = Nokogiri::XML(d.read, nil, "UTF-8")
11
+
12
+ currency = Hash.new
13
+ parsed.css("Currency").each do |c|
14
+ name = c.css("Isim").to_s.gsub("/","").gsub("<Isim>","")
15
+ next if name.include? "SDR"
16
+ code = c.css("CurrencyCode").to_s.gsub("/","").gsub("<CurrencyCode>","")
17
+ unit = c.css("Unit").to_s.gsub("/","").gsub("<Unit>","")
18
+ al = c.css("ForexBuying").to_s.gsub("/","").gsub("<ForexBuying>","").to_f
19
+ sat = c.css("ForexSelling").to_s.gsub("/","").gsub("<ForexSelling>","").to_f
20
+ currency[name] = { "Birim" => unit, "Alış" => al, "Satış" => sat }
21
+ end
22
+ return currency
23
+ rescue => error
24
+ msg = "Hata oluştu. Lütfen github sayfasında, hangi durumda hatanın oluştuğunu belirten issue açınız."
25
+ return error, msg
26
+ end
27
+ end
28
+
29
+ def self.get_by_code(kod)
30
+ begin
31
+ d = open("http://www.tcmb.gov.tr/kurlar/today.xml", 'User-Agent' => "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36")
32
+
33
+ currency = Hash.new
34
+ parsed = Nokogiri::XML(d.read, nil, "UTF-8")
35
+ c = parsed.css("Currency[Kod=#{kod}]").first
36
+
37
+ name = c.css("Isim").to_s.gsub("/","").gsub("<Isim>","")
38
+ code = c.css("CurrencyCode").to_s.gsub("/","").gsub("<CurrencyCode>","")
39
+ unit = c.css("Unit").to_s.gsub("/","").gsub("<Unit>","")
40
+ al = c.css("ForexBuying").to_s.gsub("/","").gsub("<ForexBuying>","").to_f
41
+ sat = c.css("ForexSelling").to_s.gsub("/","").gsub("<ForexSelling>","").to_f
42
+ currency[name] = { "Birim" => unit, "Alış" => al, "Satış" => sat }
43
+ return currency
44
+ rescue => error
45
+ msg = "Hata oluştu. Lütfen github sayfasında, hangi durumda hatanın oluştuğunu belirten issue açınız."
46
+ return error, msg
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "tcmb_exchange/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tcmb_exchange"
8
+ spec.version = TcmbExchange::VERSION
9
+ spec.authors = ["hamityay"]
10
+ spec.email = ["hamityay@hotmail.com"]
11
+ spec.add_runtime_dependency "nokogiri",
12
+ [">= 1.8.0"]
13
+
14
+ spec.summary = %q{Anlık olarak tcmb.gov.tr üzerinden döviz kurlarını almanızı sağlar. TCMB tcmb_currency}
15
+ spec.description = %q{http://www.tcmb.gov.tr/kurlar/today.xml adreasindeki verileri dinamik olarak almanızı sağlar.TCMB tcmb_currency}
16
+ spec.homepage = "https://rubygems.org/gems/tcmb_exchange"
17
+ spec.metadata = { "source_code_uri" => "https://github.com/hamityay/tcmb_exchange" }
18
+ spec.license = "MIT"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tcmb_exchange
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hamityay
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: http://www.tcmb.gov.tr/kurlar/today.xml adreasindeki verileri dinamik
56
+ olarak almanızı sağlar.TCMB tcmb_currency
57
+ email:
58
+ - hamityay@hotmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/tcmb_exchange.rb
72
+ - lib/tcmb_exchange/version.rb
73
+ - tcmb_exchange.gemspec
74
+ homepage: https://rubygems.org/gems/tcmb_exchange
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ source_code_uri: https://github.com/hamityay/tcmb_exchange
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.7.6
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Anlık olarak tcmb.gov.tr üzerinden döviz kurlarını almanızı sağlar. TCMB
99
+ tcmb_currency
100
+ test_files: []