EGP_Rates_CLI 0.0.1
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 +7 -0
- data/bin/egp +10 -0
- data/lib/EGP_Rates_CLI/config.rb +57 -0
- data/lib/EGP_Rates_CLI.rb +75 -0
- data/spec/EGP_Rates_CLI_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b97aea7826139e31e425a720e4fa65a81b680459
|
4
|
+
data.tar.gz: '0283ceb2e67e87da8b3166be292be88e1758c2ec'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 275d3fb64f636d110043ff82a554bbbf37081e082d6de8e6fd3da90a9681d076a8eca4ec14d15dd6595a72a58b96a50abf774601c83f7894307ba5ca6d0099d5
|
7
|
+
data.tar.gz: 8c82b05cf0d677032b8f3285415dad667f71fea834f3e4beaffac7b539f149b2cdd8a6bee7d28446ac683c0608041d2fa21d2cd4143cdd14c7ae32ba8190a4f4
|
data/bin/egp
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
module EGPRatesCLI
|
2
|
+
class Config
|
3
|
+
def self.config
|
4
|
+
prompt = TTY::Prompt.new
|
5
|
+
prompt.collect do
|
6
|
+
key(:interval).ask('Update Interval (default 1 minute): ') do |q|
|
7
|
+
q.default 1
|
8
|
+
q.convert :int
|
9
|
+
end
|
10
|
+
|
11
|
+
key(:bank).multi_select('Which Bank to show data from ? (default all) ') do |q|
|
12
|
+
q.choice '(CBE) Central Bank of Egypt' , :CBE
|
13
|
+
q.choice '(NBE) National Bank of Egypt' , :NBE
|
14
|
+
q.choice '(CIB) Commercial International Bank' , :CIB
|
15
|
+
q.choice '(AAIB) Arab African International Bank' , :AAIB
|
16
|
+
q.choice ' Banque Du Caire' , :BanqueDuCaire
|
17
|
+
q.choice ' Banque Misr' , :BanqueMisr
|
18
|
+
q.choice ' Suez Canal Bank' , :SuezCanalBank
|
19
|
+
q.choice ' Al Baraka Bank' , :AlBarakaBank
|
20
|
+
q.choice ' Al Ahli Bank of Kuwait' , :AlAhliBankOfKuwait
|
21
|
+
q.choice '(SAIB) Société Arabe Internationale de Banque' , :SAIB
|
22
|
+
q.choice '(MIDB) Misr Iran Development Bank' , :MIDB
|
23
|
+
q.choice '(UBE) The United Bank of Egypt' , :UBE
|
24
|
+
q.choice '(CAE) Crédit Agricole Egypt' , :CAE
|
25
|
+
q.choice '(EDBE) Export Development Bank of Egypt' , :EDBE
|
26
|
+
q.choice ' Bank of Alexandria' , :AlexBank
|
27
|
+
q.choice '(BLOM) Blom Bank Egypt' , :Blom
|
28
|
+
q.choice '(ADIB) Abu Dhabi Islamic Bank' , :ADIB
|
29
|
+
q.choice '(EGB) Egyptian Gulf Bank' , :EGB
|
30
|
+
q.choice '(NBG) National Bank of Greece' , :NBG
|
31
|
+
q.choice ' Faisal Islamic Bank' , :FaisalBank
|
32
|
+
end
|
33
|
+
|
34
|
+
key(:currency).multi_select('Which Currencies? (default all)') do |q|
|
35
|
+
q.choice 'USD'
|
36
|
+
q.choice 'EUR'
|
37
|
+
q.choice 'GBP'
|
38
|
+
q.choice 'CHF'
|
39
|
+
q.choice 'SAR'
|
40
|
+
q.choice 'JPY'
|
41
|
+
q.choice 'KWD'
|
42
|
+
q.choice 'AED'
|
43
|
+
q.choice 'AUD'
|
44
|
+
q.choice 'BHD'
|
45
|
+
q.choice 'CAD'
|
46
|
+
q.choice 'DKK'
|
47
|
+
q.choice 'JOD'
|
48
|
+
q.choice 'NOK'
|
49
|
+
q.choice 'OMR'
|
50
|
+
q.choice 'QAR'
|
51
|
+
q.choice 'SEK'
|
52
|
+
q.choice 'CNY'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'EGP_Rates'
|
3
|
+
require 'tty'
|
4
|
+
require 'tty-prompt'
|
5
|
+
require 'tty-command'
|
6
|
+
require 'tty-table'
|
7
|
+
require 'tty-spinner'
|
8
|
+
require 'EGP_Rates_CLI/config'
|
9
|
+
|
10
|
+
# CLI
|
11
|
+
module EGPRatesCLI
|
12
|
+
BANKS = %i(CBE NBE CIB AAIB BanqueDuCaire BanqueMisr SuezCanalBank
|
13
|
+
AlBarakaBank AlAhliBankOfKuwait SAIB MIDB UBE CAE EDBE AlexBank
|
14
|
+
Blom ADIB EGB NBG FaisalBank)
|
15
|
+
|
16
|
+
CURRENCIES = %i(USD EUR GBP CHF SAR JPY KWD AED AUD BHD CAD DKK JOD NOK OMR
|
17
|
+
QAR SEK CNY)
|
18
|
+
|
19
|
+
def self.config
|
20
|
+
@@configurtion ||= Config.config
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.start
|
24
|
+
run(config)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.stop
|
28
|
+
TTY::Prompt.new.say("\nGoodbye ;)")
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.run(config)
|
33
|
+
table = TTY::Table.new(
|
34
|
+
header: [
|
35
|
+
{ value: 'Bank', alignment: :left },
|
36
|
+
{ value: 'Currency', alignment: :center },
|
37
|
+
{ value: 'Buy', alignment: :left },
|
38
|
+
{ value: 'Sell', alignment: :left}
|
39
|
+
]
|
40
|
+
)
|
41
|
+
banks = config[:bank].empty? ? BANKS : config[:bank]
|
42
|
+
currencies = config[:currency].empty? ? CURRENCIES : config[:currency]
|
43
|
+
|
44
|
+
banks.each do |bank|
|
45
|
+
currencies.each do |currency|
|
46
|
+
begin
|
47
|
+
rates = EGPRates.const_get(bank).new.exchange_rates
|
48
|
+
table << [
|
49
|
+
{ value: bank.to_s, alignment: :left },
|
50
|
+
{ value: currency.to_s, alignment: :center },
|
51
|
+
{ value: rates[:buy][currency.to_sym], alignment: :left },
|
52
|
+
{ value: rates[:sell][currency.to_sym], alignment: :left }
|
53
|
+
]
|
54
|
+
rescue EGPRates::ResponseError
|
55
|
+
table << [
|
56
|
+
{ value: bank.to_s, alignment: :left },
|
57
|
+
{ value: currency.to_s, alignment: :center },
|
58
|
+
{ value: 'N/A', alignment: :center },
|
59
|
+
{ value: 'N/A', alignment: :center }
|
60
|
+
]
|
61
|
+
next
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
render(table)
|
66
|
+
sleep config[:interval] * 60
|
67
|
+
run(config)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.render(table)
|
71
|
+
TTY::Command.new(printer: :quiet).run('clear')
|
72
|
+
TTY::Prompt.new.say("Updated at: #{Time.now}")
|
73
|
+
puts table.render(:unicode, width: 80, resize: true)
|
74
|
+
end
|
75
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: EGP_Rates_CLI
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ahmed Abdel-Razzak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-03 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: EGP_Rates
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tty
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.5'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.5'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- abdelrazzak.ahmed@gmail.com
|
100
|
+
executables:
|
101
|
+
- egp
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- bin/egp
|
106
|
+
- lib/EGP_Rates_CLI.rb
|
107
|
+
- lib/EGP_Rates_CLI/config.rb
|
108
|
+
- spec/EGP_Rates_CLI_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
homepage: https://github.com/mad-raz/EGP-Rates-CLI
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.3.0
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.5.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Show EGP exchange rates in terminal
|
134
|
+
test_files: []
|