coin-market 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c9be0ef5ce58c0040b1440851a69f245cb612e4b
4
+ data.tar.gz: e49e6b1f8b10bd4a9f1c07fadbed2f8b6444a7cf
5
+ SHA512:
6
+ metadata.gz: c4049b1bd97d675cba02081748a6c8054d88035e54d415ae238c23a0d91b47172a9702217ad94073e6227048b5f2731bf297a37de9657a8d094b70e519a374ef
7
+ data.tar.gz: 9d2e438cfac8c061c569d4380bfcc0fcc9584b189fc1807915d64eedb8532723f62981094b0aac4e1306d6764e512d198eb3fb30af078be968e33cdca678880a
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coin-market.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2017 suhanlee
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # coin-market.rb - simple Library for accessing Coin Market API
2
+
3
+
4
+ A simple Library for accessing Coin Market API
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'coin-market'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install coin-market
21
+
22
+ ## Usage
23
+
24
+ ### Korbit
25
+ ```ruby
26
+ require 'coin-market'
27
+
28
+ korbit = Coin::Market::Korbit.new
29
+ response = korbit.get_ticker_btc_krw
30
+ => {"timestamp"=>1512415955593, "last"=>"13357500"}
31
+
32
+ response = korbit.get_ticker_bch_krw
33
+ => {"timestamp"=>1512415826306, "last"=>"1777000"}
34
+
35
+ response = korbit.get_ticker_eth_krw
36
+ => {"timestamp"=>1512415997850, "last"=>"33940"}
37
+
38
+ response = korbit.get_ticker_xrp_krw
39
+ => {"timestamp"=>1512415720622, "last"=>"286"}
40
+
41
+ ```
42
+
43
+ ### Coinone
44
+ ### Bithumb
45
+ ### Coinnest
46
+ ### Upbit
47
+
48
+ ## Development
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/suhanlee/coin-market.rb.
53
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coin/market"
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__)
@@ -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,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'coin/market/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "coin-market"
8
+ spec.version = Coin::Market::VERSION
9
+ spec.authors = ["suhanlee"]
10
+ spec.email = ["suhan.lee.k@gmail.com"]
11
+
12
+ spec.license = 'MIT'
13
+ spec.summary = %q{Coin Markets API Library}
14
+ spec.description = %q{Coin Marekts API Libary including korbit, bitthumb, coinone, coinnest}
15
+ spec.homepage = "https://github.com/suhanlee/coin-market.rb"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.14"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.2"
28
+
29
+ spec.add_dependency "rest-client", "~> 2.1"
30
+ spec.required_ruby_version = ">= 2.0.0"
31
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/coin/market'
@@ -0,0 +1,54 @@
1
+ require 'coin/market/version'
2
+ require 'coin/market/exceptions'
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ module Coin
7
+ module Market
8
+ BTC_KRW = "btc_krw"
9
+ ETC_KRW = "etc_krw"
10
+ XRP_KRW = "xrp_krw"
11
+ BCH_KRW = "bch_krw"
12
+
13
+ class Korbit
14
+ GET_TICKER = "https://api.korbit.co.kr/v1/ticker"
15
+
16
+ def get_ticker_btc_krw()
17
+ get_ticker(BTC_KRW)
18
+ end
19
+
20
+ def get_ticker_eth_krw()
21
+ get_ticker(ETC_KRW)
22
+ end
23
+
24
+ def get_ticker_xrp_krw()
25
+ get_ticker(XRP_KRW)
26
+ end
27
+
28
+ def get_ticker_bch_krw()
29
+ get_ticker(BCH_KRW)
30
+ end
31
+
32
+ def get_ticker(currency_pair)
33
+ unless is_supported_ticker(currency_pair)
34
+ raise Exceptions::CannotSupportException, 'get_ticker_' + currency_pair
35
+ end
36
+ http_response = RestClient.get(make_currency_pair(currency_pair))
37
+ ticker = JSON.parse(http_response.body)
38
+ if ticker.nil?
39
+ raise Exceptions::NetworkException, 'get_ticker_' + currency_pair
40
+ end
41
+ ticker
42
+ end
43
+
44
+ def make_currency_pair(currency_pair)
45
+ GET_TICKER + "?=currency_pair=" + currency_pair
46
+ end
47
+
48
+ def is_supported_ticker(currency_pair)
49
+ currency_pair == BTC_KRW || currency_pair == ETC_KRW || currency_pair == XRP_KRW || currency_pair == BCH_KRW
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,12 @@
1
+ module Coin
2
+ module Market
3
+ module Exceptions
4
+ class NetworkException < RuntimeError
5
+ end
6
+
7
+ class CannotSupportException < RuntimeError
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Coin
2
+ module Market
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coin-market
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - suhanlee
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-04 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: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ description: Coin Marekts API Libary including korbit, bitthumb, coinone, coinnest
70
+ email:
71
+ - suhan.lee.k@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".idea/vcs.xml"
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - coin-market.gemspec
85
+ - lib/coin-market.rb
86
+ - lib/coin/market.rb
87
+ - lib/coin/market/exceptions.rb
88
+ - lib/coin/market/version.rb
89
+ homepage: https://github.com/suhanlee/coin-market.rb
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 2.0.0
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.6.12
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Coin Markets API Library
113
+ test_files: []