bit_converter 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 +7 -0
- data/.gitignore +56 -0
- data/.rspec +3 -0
- data/.rspec_status +10 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +121 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +6 -0
- data/bit_converter.gemspec +42 -0
- data/cucumber.yml +1 -0
- data/exe/bit +5 -0
- data/lib/bit_converter.rb +8 -0
- data/lib/bit_converter/cli.rb +24 -0
- data/lib/bit_converter/coinbase_wrapper.rb +22 -0
- data/lib/bit_converter/convert.rb +21 -0
- data/lib/bit_converter/food.rb +19 -0
- data/lib/bit_converter/version.rb +5 -0
- metadata +213 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2eb71713960145a2fe047edbc7c843b1e775852c06dfc7a37c71ef56332c02cf
|
|
4
|
+
data.tar.gz: 28d8d6b891f47da00e1c1c19ff2a04838ecbb02238ba6fe5ccd077acf5054592
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1dfa7bae7efeb747ae7512a5615bef83393aacb86a57abfd439f39ad5bff88a6e276d9adb6a0d0e4f6e18fef3f6bfe7b3aa67a9f70e2bf1b083f613d85b06709
|
|
7
|
+
data.tar.gz: 7dd06299c898310fe5084c6cd784e92edc4344dd83d4b9d12ce1bcd18feb163add099e5ef8ce9ff3aa696f8abb174de40cd842be0c1a7abb294d84aba3b74197
|
data/.gitignore
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
# .env
|
|
15
|
+
|
|
16
|
+
# Ignore Byebug command history file.
|
|
17
|
+
.byebug_history
|
|
18
|
+
|
|
19
|
+
## Specific to RubyMotion:
|
|
20
|
+
.dat*
|
|
21
|
+
.repl_history
|
|
22
|
+
build/
|
|
23
|
+
*.bridgesupport
|
|
24
|
+
build-iPhoneOS/
|
|
25
|
+
build-iPhoneSimulator/
|
|
26
|
+
|
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
28
|
+
#
|
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
32
|
+
#
|
|
33
|
+
# vendor/Pods/
|
|
34
|
+
|
|
35
|
+
## Documentation cache and generated files:
|
|
36
|
+
/.yardoc/
|
|
37
|
+
/_yardoc/
|
|
38
|
+
/doc/
|
|
39
|
+
/rdoc/
|
|
40
|
+
|
|
41
|
+
## Environment normalization:
|
|
42
|
+
/.bundle/
|
|
43
|
+
/vendor/bundle
|
|
44
|
+
/lib/bundler/man/
|
|
45
|
+
|
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
48
|
+
# Gemfile.lock
|
|
49
|
+
# .ruby-version
|
|
50
|
+
# .ruby-gemset
|
|
51
|
+
|
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
53
|
+
.rvmrc
|
|
54
|
+
|
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
|
56
|
+
# .rubocop-https?--*
|
data/.rspec
ADDED
data/.rspec_status
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
---------------------------------------------------- | ------ | --------------- |
|
|
3
|
+
./spec/bit_converter/coinbase_wrapper_spec.rb[1:1:1] | passed | 0.01462 seconds |
|
|
4
|
+
./spec/bit_converter/convert_spec.rb[1:1:2] | passed | 0.00349 seconds |
|
|
5
|
+
./spec/bit_converter/convert_spec.rb[1:1:3] | passed | 0.00376 seconds |
|
|
6
|
+
./spec/bit_converter/convert_spec.rb[1:1:4] | passed | 0.00404 seconds |
|
|
7
|
+
./spec/bit_converter/food_spec.rb[1:1] | passed | 0.00116 seconds |
|
|
8
|
+
./spec/bit_converter/food_spec.rb[1:2] | passed | 0.00007 seconds |
|
|
9
|
+
./spec/bit_converter/food_spec.rb[1:3] | passed | 0.0001 seconds |
|
|
10
|
+
./spec/bit_converter_spec.rb[1:1] | passed | 0.00124 seconds |
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
bit_converter (0.1.0)
|
|
5
|
+
httparty (~> 0.18.1)
|
|
6
|
+
money (~> 6.16)
|
|
7
|
+
rake (~> 13.0)
|
|
8
|
+
thor
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (4.2.10)
|
|
14
|
+
i18n (~> 0.7)
|
|
15
|
+
minitest (~> 5.1)
|
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
17
|
+
tzinfo (~> 1.1)
|
|
18
|
+
addressable (2.8.0)
|
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
20
|
+
aruba (2.0.0)
|
|
21
|
+
bundler (>= 1.17, < 3.0)
|
|
22
|
+
childprocess (>= 2.0, < 5.0)
|
|
23
|
+
contracts (>= 0.16.0, < 0.18.0)
|
|
24
|
+
cucumber (>= 4.0, < 8.0)
|
|
25
|
+
rspec-expectations (~> 3.4)
|
|
26
|
+
thor (~> 1.0)
|
|
27
|
+
builder (3.2.4)
|
|
28
|
+
byebug (11.1.3)
|
|
29
|
+
childprocess (4.1.0)
|
|
30
|
+
concurrent-ruby (1.1.9)
|
|
31
|
+
contracts (0.16.1)
|
|
32
|
+
crack (0.4.5)
|
|
33
|
+
rexml
|
|
34
|
+
cucumber (7.0.0)
|
|
35
|
+
builder (~> 3.2, >= 3.2.4)
|
|
36
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
|
37
|
+
cucumber-create-meta (~> 6.0, >= 6.0.1)
|
|
38
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
|
39
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
|
40
|
+
cucumber-html-formatter (~> 16.0, >= 16.0.1)
|
|
41
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
42
|
+
cucumber-wire (~> 6.0, >= 6.0.1)
|
|
43
|
+
diff-lcs (~> 1.4, >= 1.4.4)
|
|
44
|
+
mime-types (~> 3.3, >= 3.3.1)
|
|
45
|
+
multi_test (~> 0.1, >= 0.1.2)
|
|
46
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
|
47
|
+
cucumber-core (10.0.1)
|
|
48
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
|
49
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
50
|
+
cucumber-tag-expressions (~> 3.0, >= 3.0.1)
|
|
51
|
+
cucumber-create-meta (6.0.1)
|
|
52
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
53
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
|
54
|
+
cucumber-cucumber-expressions (12.1.2)
|
|
55
|
+
cucumber-gherkin (20.0.1)
|
|
56
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
57
|
+
cucumber-html-formatter (16.0.1)
|
|
58
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
59
|
+
cucumber-messages (17.0.1)
|
|
60
|
+
cucumber-tag-expressions (3.0.1)
|
|
61
|
+
cucumber-wire (6.1.0)
|
|
62
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
|
63
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
|
64
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
65
|
+
diff-lcs (1.4.4)
|
|
66
|
+
ffi (1.15.3)
|
|
67
|
+
hashdiff (1.0.1)
|
|
68
|
+
httparty (0.18.1)
|
|
69
|
+
mime-types (~> 3.0)
|
|
70
|
+
multi_xml (>= 0.5.2)
|
|
71
|
+
i18n (0.9.5)
|
|
72
|
+
concurrent-ruby (~> 1.0)
|
|
73
|
+
mime-types (3.3.1)
|
|
74
|
+
mime-types-data (~> 3.2015)
|
|
75
|
+
mime-types-data (3.2021.0704)
|
|
76
|
+
minitest (5.14.4)
|
|
77
|
+
money (6.16.0)
|
|
78
|
+
i18n (>= 0.6.4, <= 2)
|
|
79
|
+
multi_test (0.1.2)
|
|
80
|
+
multi_xml (0.6.0)
|
|
81
|
+
public_suffix (4.0.6)
|
|
82
|
+
rake (13.0.6)
|
|
83
|
+
rexml (3.2.5)
|
|
84
|
+
rspec (3.10.0)
|
|
85
|
+
rspec-core (~> 3.10.0)
|
|
86
|
+
rspec-expectations (~> 3.10.0)
|
|
87
|
+
rspec-mocks (~> 3.10.0)
|
|
88
|
+
rspec-core (3.10.1)
|
|
89
|
+
rspec-support (~> 3.10.0)
|
|
90
|
+
rspec-expectations (3.10.1)
|
|
91
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
92
|
+
rspec-support (~> 3.10.0)
|
|
93
|
+
rspec-mocks (3.10.2)
|
|
94
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
95
|
+
rspec-support (~> 3.10.0)
|
|
96
|
+
rspec-support (3.10.2)
|
|
97
|
+
sys-uname (1.2.2)
|
|
98
|
+
ffi (~> 1.1)
|
|
99
|
+
thor (1.1.0)
|
|
100
|
+
thread_safe (0.3.6)
|
|
101
|
+
tzinfo (1.2.9)
|
|
102
|
+
thread_safe (~> 0.1)
|
|
103
|
+
webmock (3.14.0)
|
|
104
|
+
addressable (>= 2.8.0)
|
|
105
|
+
crack (>= 0.3.2)
|
|
106
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
107
|
+
|
|
108
|
+
PLATFORMS
|
|
109
|
+
x86_64-darwin-19
|
|
110
|
+
|
|
111
|
+
DEPENDENCIES
|
|
112
|
+
activesupport (~> 4.2.0)
|
|
113
|
+
aruba
|
|
114
|
+
bit_converter!
|
|
115
|
+
byebug (~> 11.1, >= 11.1.3)
|
|
116
|
+
cucumber
|
|
117
|
+
rspec (~> 3.2)
|
|
118
|
+
webmock (~> 3.14)
|
|
119
|
+
|
|
120
|
+
BUNDLED WITH
|
|
121
|
+
2.2.25
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Nguyen Viet Tuang
|
|
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,65 @@
|
|
|
1
|
+
# BitConverter
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bit_converter`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'bit_converter'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install bit_converter
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bit_converter.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# bit-converter
|
|
43
|
+
|
|
44
|
+
crypto and fiat CLI converter
|
|
45
|
+
|
|
46
|
+
# todo
|
|
47
|
+
|
|
48
|
+
- [ ] cache data to make it faster
|
|
49
|
+
- [ ] better test organize
|
|
50
|
+
- [ ] one import to rule them all?
|
|
51
|
+
- [ ] currency format
|
|
52
|
+
- [ ] portfolio
|
|
53
|
+
- [x] basic convert pairs: fiat-fait, coin-coin, coin-fait
|
|
54
|
+
- [x] export as rubygem
|
|
55
|
+
|
|
56
|
+
# learn
|
|
57
|
+
|
|
58
|
+
- make gem
|
|
59
|
+
- fully tdd
|
|
60
|
+
- command line
|
|
61
|
+
- wrap api call (binance, and one more)
|
|
62
|
+
- design pattern
|
|
63
|
+
|
|
64
|
+
- in hindsignt, should have know how to organzie files, how does rails link
|
|
65
|
+
it all together without having to explicitly require
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "bit_converter"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/bit_converter/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "bit_converter"
|
|
7
|
+
spec.version = BitConverter::VERSION
|
|
8
|
+
spec.authors = ["Tuan Nguyen"]
|
|
9
|
+
spec.email = ["hi@tuanguyen.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Crypto and fiat currencies converter"
|
|
12
|
+
spec.description = "A simple crypto and fiat currency converter "\
|
|
13
|
+
"which can also serve as a minimal portfolio tracker."
|
|
14
|
+
spec.homepage = "https://github.com/tuang3142/bit-converter"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
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(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = "exe"
|
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.required_ruby_version = ">= 2.4.0"
|
|
30
|
+
spec.add_dependency "httparty", "~> 0.18.1"
|
|
31
|
+
spec.add_dependency "thor"
|
|
32
|
+
spec.add_dependency "rake", "~> 13.0"
|
|
33
|
+
spec.add_dependency "money", "~> 6.16"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
|
35
|
+
spec.add_development_dependency "cucumber"
|
|
36
|
+
spec.add_development_dependency "aruba"
|
|
37
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
|
38
|
+
spec.add_development_dependency "byebug", "~> 11.1", ">= 11.1.3"
|
|
39
|
+
|
|
40
|
+
# for the pluralize method in dummy test
|
|
41
|
+
spec.add_development_dependency "activesupport", "~> 4.2.0"
|
|
42
|
+
end
|
data/cucumber.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
default: --publish-quiet
|
data/exe/bit
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "thor"
|
|
2
|
+
require "bit_converter"
|
|
3
|
+
|
|
4
|
+
module BitConverter
|
|
5
|
+
class CLI < Thor
|
|
6
|
+
desc "portray ITEM", "Determines if a piece of food is gross or delicious"
|
|
7
|
+
def portray(name)
|
|
8
|
+
puts BitConverter::Food.portray(name)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "pluralize", "Pluralizes a word"
|
|
12
|
+
method_option :word, :aliases => :word
|
|
13
|
+
def pluralize
|
|
14
|
+
puts BitConverter::Food.pluralize(options[:word])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "convert AMOUNT FROM TO", "Converts between fiat and cypto currencies"
|
|
18
|
+
def convert(amount, from, to)
|
|
19
|
+
puts BitConverter::Convert.convert(amount: amount.to_f,
|
|
20
|
+
from: from,
|
|
21
|
+
to: to)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "httparty"
|
|
4
|
+
module BitConverter
|
|
5
|
+
class CoinbaseWrapper
|
|
6
|
+
class << self
|
|
7
|
+
def usd_exchange_rates
|
|
8
|
+
get_exchange_rates("USD")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def get_exchange_rates(coin)
|
|
14
|
+
url = "https://api.coinbase.com/v2/exchange-rates?currency=#{coin}"
|
|
15
|
+
response = HTTParty.get(url)
|
|
16
|
+
|
|
17
|
+
JSON.parse(response.body)["data"]["rates"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BitConverter
|
|
4
|
+
class Convert
|
|
5
|
+
class << self
|
|
6
|
+
def convert(amount:, from:, to:)
|
|
7
|
+
rate_of(to.upcase) / rate_of(from.upcase) * amount
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def rate_of(currency)
|
|
13
|
+
rates[currency].to_f
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def rates
|
|
17
|
+
CoinbaseWrapper.usd_exchange_rates
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/inflector"
|
|
4
|
+
|
|
5
|
+
module BitConverter
|
|
6
|
+
class Food
|
|
7
|
+
def self.portray(food)
|
|
8
|
+
if food.downcase == "broccoli"
|
|
9
|
+
"Gross!"
|
|
10
|
+
else
|
|
11
|
+
"Delicious!"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.pluralize(food)
|
|
16
|
+
food.pluralize
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bit_converter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tuan Nguyen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-08-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.18.1
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.18.1
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: thor
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
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: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '13.0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '13.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: money
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '6.16'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '6.16'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.2'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.2'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: cucumber
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: aruba
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: webmock
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '3.14'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '3.14'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: byebug
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '11.1'
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: 11.1.3
|
|
135
|
+
type: :development
|
|
136
|
+
prerelease: false
|
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
138
|
+
requirements:
|
|
139
|
+
- - "~>"
|
|
140
|
+
- !ruby/object:Gem::Version
|
|
141
|
+
version: '11.1'
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: 11.1.3
|
|
145
|
+
- !ruby/object:Gem::Dependency
|
|
146
|
+
name: activesupport
|
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - "~>"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: 4.2.0
|
|
152
|
+
type: :development
|
|
153
|
+
prerelease: false
|
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - "~>"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: 4.2.0
|
|
159
|
+
description: A simple crypto and fiat currency converter which can also serve as a
|
|
160
|
+
minimal portfolio tracker.
|
|
161
|
+
email:
|
|
162
|
+
- hi@tuanguyen.com
|
|
163
|
+
executables:
|
|
164
|
+
- bit
|
|
165
|
+
extensions: []
|
|
166
|
+
extra_rdoc_files: []
|
|
167
|
+
files:
|
|
168
|
+
- ".gitignore"
|
|
169
|
+
- ".rspec"
|
|
170
|
+
- ".rspec_status"
|
|
171
|
+
- Gemfile
|
|
172
|
+
- Gemfile.lock
|
|
173
|
+
- LICENSE.txt
|
|
174
|
+
- README.md
|
|
175
|
+
- Rakefile
|
|
176
|
+
- bin/console
|
|
177
|
+
- bin/setup
|
|
178
|
+
- bit_converter.gemspec
|
|
179
|
+
- cucumber.yml
|
|
180
|
+
- exe/bit
|
|
181
|
+
- lib/bit_converter.rb
|
|
182
|
+
- lib/bit_converter/cli.rb
|
|
183
|
+
- lib/bit_converter/coinbase_wrapper.rb
|
|
184
|
+
- lib/bit_converter/convert.rb
|
|
185
|
+
- lib/bit_converter/food.rb
|
|
186
|
+
- lib/bit_converter/version.rb
|
|
187
|
+
homepage: https://github.com/tuang3142/bit-converter
|
|
188
|
+
licenses:
|
|
189
|
+
- MIT
|
|
190
|
+
metadata:
|
|
191
|
+
homepage_uri: https://github.com/tuang3142/bit-converter
|
|
192
|
+
source_code_uri: https://github.com/tuang3142/bit-converter
|
|
193
|
+
post_install_message:
|
|
194
|
+
rdoc_options: []
|
|
195
|
+
require_paths:
|
|
196
|
+
- lib
|
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
|
+
requirements:
|
|
199
|
+
- - ">="
|
|
200
|
+
- !ruby/object:Gem::Version
|
|
201
|
+
version: 2.4.0
|
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
|
+
requirements:
|
|
204
|
+
- - ">="
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
version: '0'
|
|
207
|
+
requirements: []
|
|
208
|
+
rubyforge_project:
|
|
209
|
+
rubygems_version: 2.7.6.2
|
|
210
|
+
signing_key:
|
|
211
|
+
specification_version: 4
|
|
212
|
+
summary: Crypto and fiat currencies converter
|
|
213
|
+
test_files: []
|