kaca 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/kaca +4 -0
- data/lib/kaca.rb +44 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37bef440fd7f084d3b0f6914c341a9fe902ff020
|
4
|
+
data.tar.gz: 1d2ae65c333b64872f7309c2adcb5e30785af9b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4eb778d8e1ef2509ff040bfbe66b34fbad6d49aab92959a58abd5594dfd3d6dfd87b741ab1fce6357597e6c49a2f715de5dff8186a50eb7cf28ce7a38355198
|
7
|
+
data.tar.gz: 169c57db4650b40fa241486586eb1ddff41c589ba82b9791d72c06d842b3d65fd7c4f521397893511dec53e10c0bccd7fefa449286bb4b9026da2f3e8e2e93a0
|
data/bin/kaca
ADDED
data/lib/kaca.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Kaca
|
5
|
+
def initialize(ne, islem)
|
6
|
+
puts "Kaça #{ne} #{islem}?"
|
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
|
+
ne = ne.downcase.gsub(/(?<=\w)/, '').gsub(' ', '-')
|
13
|
+
islem = islem.downcase.gsub(/(?<=\w)/, '').gsub(' ', '-')
|
14
|
+
|
15
|
+
|
16
|
+
url = if ne =~ /altin|altın|ceyrek|çeyrek|yarim|yarım|tam|cumhuriyet|ata/
|
17
|
+
urls[:altin]
|
18
|
+
else
|
19
|
+
urls[:doviz]
|
20
|
+
end
|
21
|
+
|
22
|
+
islem = if islem =~ /al|almak|alabilirim|alirim/
|
23
|
+
'buying'
|
24
|
+
else
|
25
|
+
'selling'
|
26
|
+
end
|
27
|
+
|
28
|
+
return hesapla(url, ne, islem)
|
29
|
+
end
|
30
|
+
|
31
|
+
def hesapla(url, ne, islem)
|
32
|
+
uri = URI.parse(url)
|
33
|
+
http = Net::HTTP.new(uri.host)
|
34
|
+
req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
|
35
|
+
res = http.request(req)
|
36
|
+
result = JSON.parse(res.body)
|
37
|
+
|
38
|
+
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' ? 'alabilirsin' : 'satabilirsin'}."
|
40
|
+
puts sonuc
|
41
|
+
rescue => e
|
42
|
+
puts "Errör: #{e}"
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kaca
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Murat Bastas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Kaça altın alırım? Kaça dolar satarım? Terminal üzerinden döviz hesabı
|
14
|
+
yapabileceğiniz bir uygulama.
|
15
|
+
email:
|
16
|
+
- muratbsts@gmaıl.com
|
17
|
+
executables:
|
18
|
+
- kaca
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- bin/kaca
|
23
|
+
- lib/kaca.rb
|
24
|
+
homepage: https://github.com/muratbsts/kaca
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.5.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Kaca alır satarım?
|
48
|
+
test_files: []
|