ethereum_unit_converter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7fb532ab5c4c60424366af349aa39d67052683488bb1fe13fe718d19defc98d
4
- data.tar.gz: 2ca2a32732b0e6d022f2dd10fb4ad348f2c535334107069a365c5e01c3422b2f
3
+ metadata.gz: b4a7591d6cd92974cabee436537375e1676ac8bfb8a9406eb7064a6feb91355e
4
+ data.tar.gz: f4f8ba2c90de2e20b6ab010d866d602aeb7d9a4c0db166f5d8a34165219decec
5
5
  SHA512:
6
- metadata.gz: bfb81ebae308c5be9b2f82fc6eccfd0537968d243b82c8432104df5b944e4f76121040c9205acfc1141129d224c4b29ee3a25f269a789fd7cb9853d334f3ba4f
7
- data.tar.gz: 2d65cea859e5cba8ec12cb8875ac0db1b2c346079ab129b9d639cc1fd4c4f82f7407627481c82e7fdff69c1ba910c1840bcd639604e02e9c9c47e5f288a7017f
6
+ metadata.gz: e48ec4f143ef4339c9f20f239502a1e1275c4f20a2546def8d5d87f67bf86a21e8f8ab1c17a6026e9451fed8500945501ff3e930b1d05e7c3896b649491bb95f
7
+ data.tar.gz: 58137397ca20af96f087ce7be55a644041cbf3ae6be0e6af42b516b41ac84a4442c54c5f5864a0ef105f125b27565c48a1391a488da23b6f2da9271cf0e8bbdd
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
data/Gemfile CHANGED
@@ -4,7 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in ethereum_unit_converter.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "minitest", "~> 5.0"
data/Gemfile.lock CHANGED
@@ -1,15 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ethereum_unit_converter (0.1.0)
4
+ ethereum_unit_converter (0.1.1)
5
5
  bigdecimal (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ansi (1.5.0)
10
11
  bigdecimal (3.0.0)
12
+ builder (3.2.4)
11
13
  minitest (5.14.2)
14
+ minitest-reporters (1.5.0)
15
+ ansi
16
+ builder
17
+ minitest (>= 5.0)
18
+ ruby-progressbar
12
19
  rake (13.0.3)
20
+ ruby-progressbar (1.11.0)
13
21
 
14
22
  PLATFORMS
15
23
  x86_64-darwin-20
@@ -17,6 +25,7 @@ PLATFORMS
17
25
  DEPENDENCIES
18
26
  ethereum_unit_converter!
19
27
  minitest (~> 5.0)
28
+ minitest-reporters (~> 1.5)
20
29
  rake (~> 13.0)
21
30
 
22
31
  BUNDLED WITH
data/README.md CHANGED
@@ -27,7 +27,7 @@ EthereumUnitConverter.convert(1, 'eth', 'wei') # "1000000000000000000.0"
27
27
  EthereumUnitConverter.convert(1, 'eth', 'tether') # "0.000000000001"
28
28
  EthereumUnitConverter.convert(100, 'ada', 'eth') # "0.0000000000001"
29
29
  ```
30
- ### Supported Unit
30
+ ### Supported Units
31
31
  ```
32
32
  UNITS = {
33
33
  wei: 1,
Binary file
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/ethereum_unit_converter/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ethereum_unit_converter"
7
+ spec.version = EthereumUnitConverter::VERSION
8
+ spec.authors = ["Serigne Mouhamadou Bassirou Diaby"]
9
+ spec.email = ["bayevels@gmail.com"]
10
+
11
+ spec.summary = "Ethereum unit converter in Ruby"
12
+ spec.homepage = "https://github.com/bayevels/ethereum_unit_converter"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+ spec.metadata = {
16
+ 'documentation_uri' => spec.homepage.to_s,
17
+ 'homepage_uri' => spec.homepage.to_s,
18
+ 'source_code_uri' => spec.homepage.to_s,
19
+ }
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'bigdecimal', '~> 3.0'
33
+ spec.add_development_dependency "minitest", "~> 5.0"
34
+ spec.add_development_dependency "rake", "~> 13.0"
35
+ spec.add_development_dependency "minitest-reporters", '~> 1.5'
36
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EthereumUnitConverter
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'ethereum_unit_converter/version'
4
+ require 'bigdecimal'
4
5
 
5
6
  module EthereumUnitConverter
6
7
  UNITS = {
@@ -35,16 +36,16 @@ module EthereumUnitConverter
35
36
  def convert(amount, unit = 'wei', to_unit = 'ether')
36
37
  return nil if amount.nil?
37
38
 
38
- return from_wei(amount, to_unit) if unit == 'wei'
39
+ return from_wei(amount, to_unit).to_s('F').delete_suffix('.0') if unit == 'wei'
39
40
 
40
- from_wei(to_wei(amount, unit), to_unit)
41
+ from_wei(to_wei(amount, unit), to_unit).to_s('F').delete_suffix('.0')
41
42
  end
42
43
 
43
44
  def to_wei(amount, unit = 'ether')
44
45
  return nil if amount.nil?
45
46
 
46
47
  begin
47
- BigDecimal(UNITS[unit.to_sym] * amount, 16).to_s.to_i
48
+ BigDecimal(UNITS[unit.to_sym] * amount, 16)
48
49
  rescue StandardError => e
49
50
  raise e.class
50
51
  end
@@ -54,7 +55,7 @@ module EthereumUnitConverter
54
55
  return nil if amount.nil?
55
56
 
56
57
  begin
57
- (BigDecimal(amount, 16) / BigDecimal(UNITS[unit.to_sym], 16)).to_s
58
+ (BigDecimal(amount, 16) / BigDecimal(UNITS[unit.to_sym], 16))
58
59
  rescue StandardError => e
59
60
  raise e.class
60
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethereum_unit_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serigne Mouhamadou Bassirou Diaby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.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: :development
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: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
27
69
  description:
28
70
  email:
29
71
  - bayevels@gmail.com
@@ -31,6 +73,7 @@ executables: []
31
73
  extensions: []
32
74
  extra_rdoc_files: []
33
75
  files:
76
+ - ".ruby-version"
34
77
  - Gemfile
35
78
  - Gemfile.lock
36
79
  - LICENSE.txt
@@ -38,6 +81,8 @@ files:
38
81
  - Rakefile
39
82
  - bin/console
40
83
  - bin/setup
84
+ - ethereum_unit_converter-0.1.0.gem
85
+ - ethereum_unit_converter.gemspec
41
86
  - lib/ethereum_unit_converter.rb
42
87
  - lib/ethereum_unit_converter/version.rb
43
88
  - sig/ethereum_unit_converter.rbs
@@ -45,7 +90,9 @@ homepage: https://github.com/bayevels/ethereum_unit_converter
45
90
  licenses:
46
91
  - MIT
47
92
  metadata:
93
+ documentation_uri: https://github.com/bayevels/ethereum_unit_converter
48
94
  homepage_uri: https://github.com/bayevels/ethereum_unit_converter
95
+ source_code_uri: https://github.com/bayevels/ethereum_unit_converter
49
96
  post_install_message:
50
97
  rdoc_options: []
51
98
  require_paths:
@@ -61,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
108
  - !ruby/object:Gem::Version
62
109
  version: '0'
63
110
  requirements: []
64
- rubygems_version: 3.2.3
111
+ rubygems_version: 3.2.22
65
112
  signing_key:
66
113
  specification_version: 4
67
114
  summary: Ethereum unit converter in Ruby