sasin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +8 -0
- data/bin/sasin +14 -0
- data/lib/sasin.rb +8 -0
- data/lib/sasin/converter.rb +16 -0
- data/lib/sasin/monkey_patches.rb +6 -0
- data/lib/sasin/monkey_patches/big_decimal.rb +8 -0
- data/lib/sasin/monkey_patches/float.rb +8 -0
- data/lib/sasin/monkey_patches/integer.rb +8 -0
- data/lib/sasin/monkey_patches/string.rb +8 -0
- data/lib/sasin/version.rb +5 -0
- data/sasin.gemspec +26 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 72f6db441ce3fe3cf7dc74604250fef610e9d34e38880f809bc16a026754d0df
|
4
|
+
data.tar.gz: 3f064bdef8efc855e71f69fb243d4a6ae1dd8b3f868cd115842820c47e5f199d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 970d2ea196c5ccd0d74716245a66b89be6440c44abe50af551b5dc5187a9b59553714244c879f149701c3973754e950bf3fbe5c9695b6656d5df2676c81e2d33
|
7
|
+
data.tar.gz: 4d9f363e295a4cc9c1bee61457c26a744f9189d71aca25ef63c79488c43ae47a6976df24c9f20d6f781c81c48b4337a3747ab75852732ffcd95a0fc2e4f72124
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sasin (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.1)
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
docile (1.3.2)
|
12
|
+
fuubar (2.5.0)
|
13
|
+
rspec-core (~> 3.0)
|
14
|
+
ruby-progressbar (~> 1.4)
|
15
|
+
parallel (1.19.2)
|
16
|
+
parser (2.7.2.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
rainbow (3.0.0)
|
19
|
+
rake (13.0.1)
|
20
|
+
regexp_parser (1.8.2)
|
21
|
+
rexml (3.2.4)
|
22
|
+
rspec (3.9.0)
|
23
|
+
rspec-core (~> 3.9.0)
|
24
|
+
rspec-expectations (~> 3.9.0)
|
25
|
+
rspec-mocks (~> 3.9.0)
|
26
|
+
rspec-core (3.9.3)
|
27
|
+
rspec-support (~> 3.9.3)
|
28
|
+
rspec-expectations (3.9.4)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-mocks (3.9.1)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.9.0)
|
34
|
+
rspec-support (3.9.4)
|
35
|
+
rubocop (1.1.0)
|
36
|
+
parallel (~> 1.10)
|
37
|
+
parser (>= 2.7.1.5)
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
regexp_parser (>= 1.8)
|
40
|
+
rexml
|
41
|
+
rubocop-ast (>= 1.0.1)
|
42
|
+
ruby-progressbar (~> 1.7)
|
43
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
44
|
+
rubocop-ast (1.1.0)
|
45
|
+
parser (>= 2.7.1.5)
|
46
|
+
ruby-progressbar (1.10.1)
|
47
|
+
simplecov (0.19.1)
|
48
|
+
docile (~> 1.1)
|
49
|
+
simplecov-html (~> 0.11)
|
50
|
+
simplecov-html (0.12.3)
|
51
|
+
unicode-display_width (1.7.0)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
fuubar (~> 2.5.0)
|
58
|
+
rake (~> 13.0.1)
|
59
|
+
rspec (~> 3.9.0)
|
60
|
+
rubocop (~> 1.1.0)
|
61
|
+
sasin!
|
62
|
+
simplecov (~> 0.19.1)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Piotr "Phitherek_" Żurek
|
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,64 @@
|
|
1
|
+
# Sasin
|
2
|
+
|
3
|
+
This is a Ruby gem that implements a converter to a universal sasin unit.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sasin'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sasin
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Regular
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'sasin'
|
27
|
+
|
28
|
+
Sasin::Converter.convert(1) # => 0.0000000142857142860000008
|
29
|
+
```
|
30
|
+
|
31
|
+
### With monkey patches
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'sasin/monkey_patches'
|
35
|
+
|
36
|
+
1.to_sasin # => 0.0000000142857142860000008
|
37
|
+
```
|
38
|
+
|
39
|
+
Supports String, Integer, Float and BigDecimal.
|
40
|
+
|
41
|
+
### Binary
|
42
|
+
|
43
|
+
Run `sasin` and enter input to get the result.
|
44
|
+
|
45
|
+
Run `sasin INPUT` to get the result.
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
Run `rake spec` to run the tests.
|
50
|
+
|
51
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and merge requests are welcome on GitLab at https://gitlab.com/Phitherek_/sasin.
|
56
|
+
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
61
|
+
|
62
|
+
## Disclaimer
|
63
|
+
|
64
|
+
Yes, this gem is kind of a joke. It refers to a Polish minister of assets Jacek Sasin that spent a 70 million of Polish zloty on an election that didn't finally happen. It was also kind of inspired by a Python package of the same name.
|
data/Rakefile
ADDED
data/bin/sasin
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/sasin'
|
5
|
+
|
6
|
+
puts "sasin v. #{Sasin::VERSION} (c) 2020 Phitherek_"
|
7
|
+
input = if ARGV.any?
|
8
|
+
ARGV[0]
|
9
|
+
else
|
10
|
+
print 'Input: '
|
11
|
+
gets
|
12
|
+
end.chomp
|
13
|
+
result = Sasin::Converter.convert(input)
|
14
|
+
puts format('Result: %.25f sasin', result)
|
data/lib/sasin.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
module Sasin
|
5
|
+
class Converter
|
6
|
+
RATE = 70_000_000 # This is 1 sasin in PLN, but for simplicity we adopt it as a universal rate
|
7
|
+
def self.convert(param)
|
8
|
+
coerced_param = if param.is_a?(BigDecimal)
|
9
|
+
param
|
10
|
+
else
|
11
|
+
BigDecimal(param.to_s)
|
12
|
+
end
|
13
|
+
(coerced_param / RATE).to_f.round(25)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/sasin.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/sasin/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'sasin'
|
7
|
+
spec.version = Sasin::VERSION
|
8
|
+
spec.authors = ['Phitherek_']
|
9
|
+
spec.email = ['phitherek@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'A converter to an universal sasin unit'
|
12
|
+
spec.description = 'This is a Ruby implementation of a converter to a universal sasin unit'
|
13
|
+
spec.homepage = 'https://gitlab.com/Phitherek_/sasin'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://gitlab.com/Phitherek_/sasin'
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'bin'
|
24
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sasin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phitherek_
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This is a Ruby implementation of a converter to a universal sasin unit
|
14
|
+
email:
|
15
|
+
- phitherek@gmail.com
|
16
|
+
executables:
|
17
|
+
- sasin
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/sasin
|
30
|
+
- lib/sasin.rb
|
31
|
+
- lib/sasin/converter.rb
|
32
|
+
- lib/sasin/monkey_patches.rb
|
33
|
+
- lib/sasin/monkey_patches/big_decimal.rb
|
34
|
+
- lib/sasin/monkey_patches/float.rb
|
35
|
+
- lib/sasin/monkey_patches/integer.rb
|
36
|
+
- lib/sasin/monkey_patches/string.rb
|
37
|
+
- lib/sasin/version.rb
|
38
|
+
- sasin.gemspec
|
39
|
+
homepage: https://gitlab.com/Phitherek_/sasin
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata:
|
43
|
+
homepage_uri: https://gitlab.com/Phitherek_/sasin
|
44
|
+
source_code_uri: https://gitlab.com/Phitherek_/sasin
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.4.0
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubygems_version: 3.1.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: A converter to an universal sasin unit
|
64
|
+
test_files: []
|