splittable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ba1d6d16997bdc50cceb7bfb3fbd4d8725171c8c5e945673042216245d614089
4
+ data.tar.gz: 290622d97e60bf50749db770057fbe14d9bfdd7fe5c6ecc952d11a5baf9c3f59
5
+ SHA512:
6
+ metadata.gz: 10a4210eb291b4cadd03c041700df948dab6dcf1bdb92e51db862d01440ed98536eb89b41847c9c8933bbe9900ef52c2943e41e729574aa00b4777f03e1115cf
7
+ data.tar.gz: 48cd265bee2d9263c2ceacf618903cc8a557151baf5129496f28939234c75fc73c6e7fa790d6b50be511d0fa2723e4490e83ac03a714634333d67d83e9fd007d
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+ ---
8
+
9
+ **Describe the bug**
10
+ A clear and concise description of what the bug is.
11
+
12
+ **To Reproduce**
13
+ Steps to reproduce the behavior:
14
+
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+
28
+ - OS: [e.g. iOS]
29
+ - Browser [e.g. chrome, safari]
30
+ - Version [e.g. 22]
31
+
32
+ **Smartphone (please complete the following information):**
33
+
34
+ - Device: [e.g. iPhone6]
35
+ - OS: [e.g. iOS8.1]
36
+ - Browser [e.g. stock browser, safari]
37
+ - Version [e.g. 22]
38
+
39
+ **Additional context**
40
+ Add any other context about the problem here.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+ ---
8
+
9
+ **Is your feature request related to a problem? Please describe.**
10
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11
+
12
+ **Describe the solution you'd like**
13
+ A clear and concise description of what you want to happen.
14
+
15
+ **Describe alternatives you've considered**
16
+ A clear and concise description of any alternative solutions or features you've considered.
17
+
18
+ **Additional context**
19
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Security vulnerability
3
+ about: Create a report to help us improve our security
4
+ title: ''
5
+ labels: vulnerability
6
+ assignees: ''
7
+ ---
8
+
9
+ **Describe the vulnerability**
10
+ A clear and concise description of what the vulnerability is.
11
+
12
+ **To Reproduce**
13
+ Steps to reproduce the behavior:
14
+
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+
28
+ - OS: [e.g. iOS]
29
+ - Browser [e.g. chrome, safari]
30
+ - Version [e.g. 22]
31
+
32
+ **Smartphone (please complete the following information):**
33
+
34
+ - Device: [e.g. iPhone6]
35
+ - OS: [e.g. iOS8.1]
36
+ - Browser [e.g. stock browser, safari]
37
+ - Version [e.g. 22]
38
+
39
+ **Additional context**
40
+ Add any other context about the problem here.
@@ -0,0 +1,32 @@
1
+ <!--- Provide a general summary of your changes in the Title above -->
2
+
3
+ ## Description
4
+
5
+ Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
6
+
7
+ Fixes # (issue)
8
+
9
+ ## Types of changes
10
+
11
+ <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
12
+
13
+ - [ ] Bug fix (non-breaking change which fixes an issue)
14
+ - [ ] New feature (non-breaking change which adds functionality)
15
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
16
+ - [ ] This change requires a documentation update
17
+
18
+ ## How Has This Been Tested?
19
+
20
+ Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
21
+
22
+ ## Screenshots (if appropriate):
23
+
24
+ ## Checklist:
25
+
26
+ - [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
27
+ - [ ] I have performed a self-review of my own code
28
+ - [ ] My changes generate no new warnings
29
+ - [ ] My changes work in Chrome, Edge, and Firefox
30
+ - [ ] I have made corresponding changes to the documentation (if appropriate)
31
+ - [ ] I have added tests that prove my fix is effective or that my feature works
32
+ - [ ] All new and existing tests passed
@@ -0,0 +1,33 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ push:
7
+ branches:
8
+ - master
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby version specified in `.ruby-version`
18
+ with:
19
+ ruby-version: 2.6.6
20
+ uses: eregon/use-ruby-action@master
21
+
22
+ - name: Install dependencies
23
+ run: bundle install --jobs 4 --retry 3
24
+
25
+ - name: Run Rubocop
26
+ env:
27
+ RAILS_ENV: test
28
+ run: bundle exec rubocop --config .rubocop.yml
29
+
30
+ - name: Run tests with RSpec
31
+ env:
32
+ RAILS_ENV: test
33
+ run: bundle exec rspec
@@ -0,0 +1,19 @@
1
+ # Ignore bundler config.
2
+ /.bundle
3
+ /vendor/bundle
4
+
5
+ /.yardoc
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
16
+ # rspec
17
+ /spec/examples.txt
18
+
19
+ .tool-versions
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,55 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ NewCops: enable
8
+ TargetRubyVersion: 2.6.6
9
+ Exclude:
10
+ - 'Rakefile'
11
+ - 'bin/**/*'
12
+ - 'vendor/**/*'
13
+ UseCache: false
14
+
15
+ Gemspec/RequiredRubyVersion:
16
+ Enabled: false
17
+
18
+ Layout/DotPosition:
19
+ EnforcedStyle: trailing
20
+
21
+ Layout/SpaceAroundMethodCallOperator:
22
+ Enabled: true
23
+
24
+ Lint/RaiseException:
25
+ Enabled: true
26
+
27
+ Lint/StructNewOverride:
28
+ Enabled: true
29
+
30
+ Metrics/BlockLength:
31
+ IgnoredMethods: ['describe', 'context', 'feature', 'scenario', 'let']
32
+
33
+ RSpec/ExampleLength:
34
+ Enabled: false
35
+
36
+ RSpec/MultipleExpectations:
37
+ Enabled: false
38
+
39
+ Style/ClassAndModuleChildren:
40
+ EnforcedStyle: compact
41
+
42
+ Style/Documentation:
43
+ Enabled: false
44
+
45
+ Style/ExponentialNotation:
46
+ Enabled: false
47
+
48
+ Style/HashEachMethods:
49
+ Enabled: true
50
+
51
+ Style/HashTransformKeys:
52
+ Enabled: true
53
+
54
+ Style/HashTransformValues:
55
+ Enabled: true
@@ -0,0 +1 @@
1
+ 2.6.6
@@ -0,0 +1,8 @@
1
+
2
+ ## splittable 0.0.1 (Jan 14, 2021)
3
+
4
+ * The first version of the gem was created, where it is possible to divide values
5
+ ​​with many decimal places into equal plots or different plots and the difference
6
+ is attributed to the first plot.
7
+
8
+ *Arthur Brandão, Marcelo Toledo*
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team. All complaints will be reviewed and
59
+ investigated and will result in a response that is deemed necessary and
60
+ appropriate to the circumstances. The project team is obligated to maintain
61
+ confidentiality with regard to the reporter of an incident. Further details
62
+ of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -0,0 +1,110 @@
1
+ # How to Contribute
2
+
3
+ :+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
4
+
5
+ The following is a set of guidelines for contributing to Splittable. Please take a moment to review this document in order to make the contribution process straightforward and effective for everyone involved.
6
+
7
+ ### Table Of Contents
8
+
9
+ - [Code of Conduct](#code-of-conduct)
10
+ - [Issues](#issues)
11
+ - [Your First Contribution](#your-first-contribution)
12
+ - [Pull Requests](#pull-requests)
13
+ - [Setup](#setup)
14
+ - [Styleguides](#styleguides)
15
+ - [Releasing](#releasing)
16
+
17
+ ## Code of Conduct
18
+
19
+ We adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
20
+
21
+ ## Issues
22
+
23
+ A great way to contribute to the project is to send a detailed report when you encounter an issue. We always appreciate a well-written, thorough bug report, and will thank you for it!
24
+
25
+ These is the location to report or find an issue [here on Github](https://github.com/Pagnet/splittable/issues).
26
+
27
+ Check that our issue database doesn't already include that problem or suggestion before submitting an issue. If you find a match, you can use the "subscribe" button to get notified on updates. Do not leave random "+1" or "I have this too" comments, as they only clutter the discussion, and don't help resolving it. However, if you have ways to reproduce the issue or have additional information that may help resolving the issue, please leave a comment.
28
+
29
+ ### Security Issues
30
+
31
+ If you discover a potential point of failure, please bring it to their attention immediately, create a issue.
32
+
33
+ ## Your First Contribution
34
+
35
+ First of all, you will need to create an [issue](#issues) for the feature or bugfix that you want to work on. When you open a new issue, there will be a template that will be automatically added to the text of the issue, which you would need to fill in. Doing this will help us to understand better what the ticket is about.
36
+
37
+ Unsure where to begin contributing? You can start by looking through these issues:
38
+
39
+ - [Good first issues](https://github.com/Pagnet/splittable/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-desc+label%3A%22good+first+issue%22) - issues which should only require a few lines of code, and a test or two.
40
+ - [Bug issues](https://github.com/Pagnet/splittable/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-desc+label%3Abug) - issues which should be an error.
41
+
42
+ ### Making Changes
43
+
44
+ - We adopted [Github Flow](https://guides.github.com/introduction/flow/).
45
+ - Assigns the issue to you. Let everyone know that you took that issue to settle.
46
+ - Fork the repo and create your branch from master. A guide on how to fork a repository: https://help.github.com/articles/fork-a-repo/
47
+ - Make commits of logical and atomic units.
48
+ - Submit a pull request.
49
+
50
+ ## Pull Requests
51
+
52
+ After getting some feedback, push to your fork and submit a pull request. We may suggest some changes, improvements or implementation alternatives.
53
+
54
+ In case you've got a small change in most of the cases, your pull request would be accepted quicker :wink:.
55
+
56
+ Please follow these steps to have your contribution considered by the maintainers:
57
+
58
+ 1. Follow all instructions in [the template](.github/PULL_REQUEST_TEMPLATE.md)
59
+ 2. Follow the [styleguides](#styleguides)
60
+ 3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing <details><summary>What if the status checks are failing?</summary>If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.</details>
61
+
62
+ While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.
63
+
64
+ ### Code review guidelines
65
+
66
+ It’s important that every piece of code is reviewed by at least one core contributor familiar with that codebase. Here are some things we look for:
67
+
68
+ 1. **Required CI checks pass.** This is a prerequisite for the review, and it is the PR author's responsibility. As long as the tests don’t pass, the PR won't get reviewed.
69
+ 2. **Simplicity.** Is this the simplest way to achieve the intended goal? If there are too many files, redundant functions, or complex lines of code, suggest a simpler way to do the same thing. In particular, avoid implementing an overly general solution when a simple, small, and pragmatic fix will do.
70
+ 3. **Testing.** Do the tests ensure this code won’t break when other stuff changes around it? When it does break, will the tests added help us identify which part of the library has the problem? Did we cover an appropriate set of edge cases? Look at the test coverage report if there is one. Are all significant code paths in the new code exercised at least once?
71
+ 4. **No unnecessary or unrelated changes.** PRs shouldn’t come with random formatting changes, especially in unrelated parts of the code. If there is some refactoring that needs to be done, it should be in a separate PR from a bug fix or feature, if possible.
72
+ 5. **Code has appropriate comments.** Code should be commented, or written in a clear “self-documenting” way.
73
+
74
+ ## Setup
75
+
76
+ You need ruby 2.6.6+ _(if you need other versions we recommend the [asdf](https://github.com/asdf-vm/asdf))_
77
+
78
+ ```bash
79
+ git clone git@github.com:Pagnet/splittable.git # bonus: use your own fork for this step
80
+ cd splittable
81
+ bundle install # install dependencies
82
+ ```
83
+
84
+ ## Styleguides
85
+
86
+ ### Language
87
+
88
+ The development language is English. All comments and documentation should be written in English, so we can share our knowledge with developers around the world.
89
+
90
+ ### Commit Message
91
+
92
+ We adopted [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary). This improves the readability of the git history.
93
+
94
+ - Use the present tense ("add xyz" not "added xyz").
95
+ - Use the imperative mood ("move cursor to..." not "Moves cursor to...").
96
+
97
+ ### Linter
98
+
99
+ We use [rubocop](https://rubocop.org/) to guarantee the same code format in the project.
100
+
101
+ - `bundle exec robucop -a` will automatically format files with rubocop.
102
+ - Your code will be automatically formatted when you run the command.
103
+
104
+ ### Testing
105
+
106
+ The code that is written needs to be tested to ensure that it achieves the desired behavior. Tests either fall into a unit test or an integration test.
107
+
108
+ - We use [Rspec](https://rspec.info/) as our official framework test.
109
+ - Use [better specs](https://www.betterspecs.org/) on your tests.
110
+ - All source files must be 100% coverage with tests.
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby '2.6.6'
6
+
7
+ gemspec
8
+
9
+ gem 'pry-byebug', '~> 3.9'
10
+ gem 'rake', '~> 13.0.3'
11
+ gem 'rspec', '~> 3.10'
12
+
13
+ group :development, :test do
14
+ gem 'rubocop', require: false
15
+ gem 'rubocop-performance', require: false
16
+ gem 'rubocop-rake', require: false
17
+ gem 'rubocop-rspec', require: false
18
+ gem 'simplecov'
19
+ end
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ splittable (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.1)
10
+ byebug (11.1.3)
11
+ coderay (1.1.3)
12
+ diff-lcs (1.4.4)
13
+ docile (1.3.5)
14
+ method_source (1.0.0)
15
+ parallel (1.20.1)
16
+ parser (3.0.0.0)
17
+ ast (~> 2.4.1)
18
+ pry (0.13.1)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ pry-byebug (3.9.0)
22
+ byebug (~> 11.0)
23
+ pry (~> 0.13.0)
24
+ rainbow (3.0.0)
25
+ rake (13.0.3)
26
+ regexp_parser (2.0.3)
27
+ rexml (3.2.4)
28
+ rspec (3.10.0)
29
+ rspec-core (~> 3.10.0)
30
+ rspec-expectations (~> 3.10.0)
31
+ rspec-mocks (~> 3.10.0)
32
+ rspec-core (3.10.1)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-expectations (3.10.1)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.10.0)
37
+ rspec-mocks (3.10.1)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.10.0)
40
+ rspec-support (3.10.1)
41
+ rubocop (1.8.1)
42
+ parallel (~> 1.10)
43
+ parser (>= 3.0.0.0)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.8, < 3.0)
46
+ rexml
47
+ rubocop-ast (>= 1.2.0, < 2.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 1.4.0, < 3.0)
50
+ rubocop-ast (1.4.0)
51
+ parser (>= 2.7.1.5)
52
+ rubocop-performance (1.9.2)
53
+ rubocop (>= 0.90.0, < 2.0)
54
+ rubocop-ast (>= 0.4.0)
55
+ rubocop-rake (0.5.1)
56
+ rubocop
57
+ rubocop-rspec (2.1.0)
58
+ rubocop (~> 1.0)
59
+ rubocop-ast (>= 1.1.0)
60
+ ruby-progressbar (1.11.0)
61
+ simplecov (0.21.2)
62
+ docile (~> 1.1)
63
+ simplecov-html (~> 0.11)
64
+ simplecov_json_formatter (~> 0.1)
65
+ simplecov-html (0.12.3)
66
+ simplecov_json_formatter (0.1.2)
67
+ unicode-display_width (2.0.0)
68
+
69
+ PLATFORMS
70
+ ruby
71
+
72
+ DEPENDENCIES
73
+ pry-byebug (~> 3.9)
74
+ rake (~> 13.0.3)
75
+ rspec (~> 3.10)
76
+ rubocop
77
+ rubocop-performance
78
+ rubocop-rake
79
+ rubocop-rspec
80
+ simplecov
81
+ splittable!
82
+
83
+ RUBY VERSION
84
+ ruby 2.6.6p146
85
+
86
+ BUNDLED WITH
87
+ 2.2.5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 BLU
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ # Splittable
2
+
3
+ ## Goal
4
+
5
+ This gem solves the problem of several decimal places in divisions where the result must be presented in cents, that is converting the division result to only two decimal places and the difference is attributed to the first plot.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'splittable'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install splittable
22
+
23
+ ## Usage
24
+
25
+ Using `division` method:
26
+
27
+ ``` ruby
28
+ Splittable.division(value: 0.1188888, quantity: 3)
29
+ ```
30
+
31
+ Result: the total truncated value was divided by the number of plots informed and attributed the difference in the first installment:
32
+
33
+ ```ruby
34
+ => [0.5e-1, 0.3e-1, 0.3e-1] # => [0.05, 0.03, 0.03]
35
+ ```
36
+
37
+ Using `normalize` method:
38
+
39
+ ```ruby
40
+ Splittable.normalize(value: 100.003, installments: [33.33, 21.433, 43.33333])
41
+ ```
42
+
43
+ Result: all values are truncated and them the difference is attributed in the first installment:
44
+
45
+ ```ruby
46
+ => [0.3524e2, 0.2143e2, 0.4333e2] # => [35.24, 21.43, 43.33]
47
+ ```
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ 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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Pagnet/splittable/blob/master/CONTRIBUTING.md.
58
+
59
+ ## Code of Conduct
60
+
61
+ Welcome on GitHub at https://github.com/Pagnet/splittable/blob/master/CODE_OF_CONDUCT.md.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'splittable'
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,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'splittable/version'
4
+ require 'bigdecimal/util'
5
+
6
+ module Splittable
7
+ class << self
8
+ # receive total value and to quantity installments are required to equal division
9
+ # just the first installment will receive the difference cents
10
+ def division(value:, quantity:)
11
+ convert_params!(value: value, quantity: quantity)
12
+ params_validation!(@quantity)
13
+ partial_value = (@value / @quantity).truncate(2)
14
+ decimal_difference = @value - (@quantity * partial_value)
15
+ installments = [partial_value] * @quantity
16
+ installments[0] += decimal_difference
17
+
18
+ installments
19
+ end
20
+
21
+ # receive total value and specific value of installments are required to specific division
22
+ # just the first installment will receive the difference cents
23
+ def normalize(value:, installments:)
24
+ convert_params!(value: value, installments: installments)
25
+ decimal_difference = @value - @installments.sum
26
+ @installments[0] += decimal_difference
27
+
28
+ @installments
29
+ end
30
+
31
+ private
32
+
33
+ attr_accessor :value, :quantity, :installments
34
+
35
+ def params_validation!(quantity)
36
+ return if quantity.positive?
37
+
38
+ raise ArgumentError, 'quantity should be positive'
39
+ end
40
+
41
+ def convert_params!(value: nil, quantity: nil, installments: nil)
42
+ @value = BigDecimal(value.truncate(2), 15) unless value.nil?
43
+ @quantity = BigDecimal(quantity.to_i, 15) unless quantity.nil?
44
+ @installments = installments.map { |installment| BigDecimal(installment.round(2), 15) } unless installments.nil?
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Splittable
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,7 @@
1
+ sonar.projectKey=Pagnet_splittable
2
+ sonar.organization=pagnet
3
+ sonar.ruby.coverage.reportPaths=./coverage/.resultset.json
4
+ sonar.sources=app
5
+ sonar.coverage.exclusions=**/concerns/*.rb
6
+ sonar.exclusions=**/*.scss,**/*.java
7
+ sonar.sourceEncoding=UTF-8
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/splittable/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'splittable'
7
+ spec.version = Splittable::VERSION
8
+ spec.authors = ['Arthur Brandão', 'Marcelo Toledo']
9
+ spec.email = ['arthur_aebc@hotmail.com', 'marcelotoledo5000@gmail.com']
10
+
11
+ spec.license = 'MIT'
12
+
13
+ spec.summary = 'Calculate division and normalize parcels.'
14
+ spec.description = 'Calculate division and normalize parcels to use just cents.'
15
+ spec.homepage = 'https://github.com/Pagnet/splittable'
16
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.3')
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/Pagnet/splittable'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/Pagnet/splittable/blob/master/CHANGELOG.md'
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: splittable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Arthur Brandão
8
+ - Marcelo Toledo
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2021-01-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Calculate division and normalize parcels to use just cents.
15
+ email:
16
+ - arthur_aebc@hotmail.com
17
+ - marcelotoledo5000@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
23
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
24
+ - ".github/ISSUE_TEMPLATE/security_vulnerability.md"
25
+ - ".github/PULL_REQUEST_TEMPLATE.md"
26
+ - ".github/workflows/ruby.yml"
27
+ - ".gitignore"
28
+ - ".rspec"
29
+ - ".rubocop.yml"
30
+ - ".ruby-version"
31
+ - CHANGELOG.md
32
+ - CODE_OF_CONDUCT.md
33
+ - CONTRIBUTING.md
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - bin/console
40
+ - bin/setup
41
+ - lib/splittable.rb
42
+ - lib/splittable/version.rb
43
+ - sonar-project.properties
44
+ - splittable.gemspec
45
+ homepage: https://github.com/Pagnet/splittable
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ homepage_uri: https://github.com/Pagnet/splittable
50
+ source_code_uri: https://github.com/Pagnet/splittable
51
+ changelog_uri: https://github.com/Pagnet/splittable/blob/master/CHANGELOG.md
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.5.3
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.0.3
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Calculate division and normalize parcels.
71
+ test_files: []