kaca 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kaca +2 -1
- data/lib/kaca.rb +27 -26
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c9ee60c27cd58885a11de25a5a7ba0836ee7c4d
|
4
|
+
data.tar.gz: 81a0865ee003842b03f93bba90d3abf75b01284e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03626f2f990da57f6ee202ebd88d2bc008993e721f46c1b18b991ca158058224617e290105e2ba9516cfbcd9ceeaa879fde9e924ddc4a979232261ead7f853d9
|
7
|
+
data.tar.gz: b40924bb5d2a2636042cccb1975e923a2eec70618d7664f3b31f5e9c877c87ea62e9104b3053fd229c121d88248631320bc9ba178b4f4f62b02d4fb6f6fa2cb7
|
data/bin/kaca
CHANGED
data/lib/kaca.rb
CHANGED
@@ -1,34 +1,35 @@
|
|
1
|
+
require 'fuzzy_match'
|
1
2
|
require 'net/http'
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
class Kaca
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
6
|
+
def initialize(opts)
|
7
|
+
urls = {
|
8
|
+
altin: 'http://www.doviz.com/api/v1/golds/all/latest',
|
9
|
+
doviz: 'http://www.doviz.com/api/v1/currencies/all/latest'
|
10
|
+
}
|
11
|
+
|
12
|
+
altinlar = %w(ceyrek-altin yarim-altin tam-altin cumhuriyet-altini ata-altin besli-altin gumus)
|
13
|
+
birimler = %w(amerikan-dolari euro sterlin isvicre-frangi rus-rublesi japon-yeni)
|
14
|
+
ne = FuzzyMatch.new(altinlar + birimler).find(opts[0].downcase)
|
15
|
+
url = if altinlar.include? ne
|
16
|
+
urls[:altin]
|
17
|
+
else
|
18
|
+
urls[:doviz]
|
19
|
+
end
|
20
|
+
|
21
|
+
islem = if FuzzyMatch.new(%w(almak alabilirim alırım)).find(opts[1])
|
22
|
+
'selling'
|
23
|
+
else
|
24
|
+
'buying'
|
25
|
+
end
|
26
|
+
|
27
|
+
getir(url, ne, islem)
|
28
|
+
rescue => e
|
29
|
+
puts "Errör: #{e}"
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
+
def getir(url, ne, islem)
|
32
33
|
uri = URI.parse(url)
|
33
34
|
http = Net::HTTP.new(uri.host)
|
34
35
|
req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
|
@@ -36,7 +37,7 @@ class Kaca
|
|
36
37
|
result = JSON.parse(res.body)
|
37
38
|
|
38
39
|
aranan = result.select { |r| r['name'] == ne }.first
|
39
|
-
sonuc = "Bugün #{aranan['full_name'].downcase!} #{aranan[islem].to_f.round(2)} TRY e #{islem == 'buying' ? '
|
40
|
+
sonuc = "Bugün #{aranan['full_name'].downcase!} #{aranan[islem].to_f.round(2)} TRY e #{islem == 'buying' ? 'satabilirsin' : 'alabilirsin'}."
|
40
41
|
puts sonuc
|
41
42
|
rescue => e
|
42
43
|
puts "Errör: #{e}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murat Bastas
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-05-16 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fuzzy_match
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
13
27
|
description: Kaça altın alırım? Kaça dolar satarım? Terminal üzerinden döviz hesabı
|
14
28
|
yapabileceğiniz bir uygulama.
|
15
29
|
email:
|
@@ -41,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
55
|
version: '0'
|
42
56
|
requirements: []
|
43
57
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.6.12
|
45
59
|
signing_key:
|
46
60
|
specification_version: 4
|
47
61
|
summary: Kaca alır satarım?
|