vote-schulze 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e2da9c1fc160ba635a97deaf2c56940ff7be7926394ea7ab1d96fb535b997be1
4
+ data.tar.gz: 381d587847112eb9d0262ff89cac9ed50c4bace349bca2a17fb87bf4b382d8c8
5
+ SHA512:
6
+ metadata.gz: 1a2f49b36dda81c9b7e1bf6a1d37e8c6b97a2319576fc04605d86a0a54e44a890f3bb510a15a966840e12dd6283cb3b13142aee5a0c635603dde5fbee6bf4379
7
+ data.tar.gz: 24a4311754fb2d984ca37e482898b4b1668e950f7fd04d9566cf1d2ae0d7d8159df25925dec69c10f6fa7927a15aa03fbe3f606fd3e769f85117fceb9559beb4
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ charset = utf-8
9
+ indent_style = space
10
+ indent_size = 2
11
+ end_of_line = lf
12
+ insert_final_newline = true
@@ -0,0 +1,14 @@
1
+ # https://docs.github.com/en/code-security/supply-chain-security/configuration-options-for-dependency-updates
2
+ version: 2
3
+
4
+ updates:
5
+
6
+ - package-ecosystem: bundler
7
+ directory: "/"
8
+ schedule:
9
+ interval: daily # default: 05:00 UTC
10
+
11
+ - package-ecosystem: github-actions
12
+ directory: "/"
13
+ schedule:
14
+ interval: daily # default: 05:00 UTC
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+ pull_request:
9
+ branches:
10
+ - main
11
+ - master
12
+
13
+ jobs:
14
+ test:
15
+ name: '[Test] Ruby ${{matrix.ruby}} | OS ${{matrix.os}}'
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby:
21
+ - '3.2'
22
+ - '3.1'
23
+ - '3.0'
24
+ # JRuby skipped for now until rubocop-rspec/-capybara are split up;
25
+ # @see https://github.com/rubocop/rubocop-rspec/discussions/1440
26
+ # - jruby
27
+ - truffleruby
28
+ os:
29
+ - ubuntu-latest
30
+ - macos-latest
31
+ - windows-latest
32
+ exclude:
33
+ - os: windows-latest
34
+ ruby: truffleruby
35
+ steps:
36
+ - uses: actions/checkout@v3
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+ bundler-cache: true
41
+ - run: bin/rspec
42
+
43
+ lint:
44
+ name: Lint
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v3
48
+ - uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: '3.0'
51
+ bundler-cache: true
52
+ - run: bin/rubocop
@@ -0,0 +1,21 @@
1
+ # https://github.com/ahmadnassri/action-dependabot-auto-merge
2
+ name: Dependabot Auto Merge
3
+
4
+ on:
5
+ # more info:
6
+ # https://securitylab.github.com/research/github-actions-preventing-pwn-requests
7
+ pull_request_target:
8
+
9
+ jobs:
10
+ approval:
11
+ runs-on: ubuntu-20.04
12
+ if: github.actor == 'dependabot[bot]'
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: ahmadnassri/action-dependabot-auto-merge@v2.6
16
+ with:
17
+ target: patch
18
+ # Note: This needs to be a PAT with (public) repo rights,
19
+ # PAT-owning user needs to have write access to this repo
20
+ # (dependabot needs to recognize the comment as coming from an allowed reviewer)
21
+ github-token: ${{ secrets.BOT_TOKEN }}
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec CHANGED
@@ -1 +1,3 @@
1
+ --format documentation
1
2
  --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,32 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ DisplayCopNames: true
8
+ TargetRubyVersion: 3.0
9
+ NewCops: enable
10
+
11
+ Layout/EndOfLine:
12
+ EnforcedStyle: lf
13
+
14
+ Layout/LineLength:
15
+ Max: 120
16
+
17
+ # TODO: Eventually this library should be better documented; sadly it is not yet
18
+ # NOTE: Good first contribution!
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ # I prefer reduce/inject most of the time.
23
+ Style/EachWithObject:
24
+ Enabled: false
25
+
26
+ # Sorry, community, but I don't think it's a good choice.
27
+ Style/GlobalStdStream:
28
+ Enabled: false
29
+
30
+ # some rubocop versions report on this, but we don't want to change the code for this;
31
+ Style/ComparableClamp:
32
+ Enabled: false
@@ -0,0 +1,129 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ `coc-report@mannaz.cc`.
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
121
+
122
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
123
+ enforcement ladder](https://github.com/mozilla/diversity).
124
+
125
+ [homepage]: https://www.contributor-covenant.org
126
+
127
+ For answers to common questions about this code of conduct, see the FAQ at
128
+ https://www.contributor-covenant.org/faq. Translations are available at
129
+ https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
- source "http://rubygems.org"
2
- group :development do
3
- gem "bundler", "~> 1.0.0"
4
- gem "jeweler", "~> 1.6.0"
5
- gem "rspec", "~> 2.3.0"
6
- end
1
+ # frozen_string_literal: true
7
2
 
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in vote-schulze.gemspec
8
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,26 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vote-schulze (0.3.0)
5
+ matrix (>= 0.4.2)
6
+
1
7
  GEM
2
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
3
9
  specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.6.0)
7
- bundler (~> 1.0.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.8.7)
11
- rspec (2.3.0)
12
- rspec-core (~> 2.3.0)
13
- rspec-expectations (~> 2.3.0)
14
- rspec-mocks (~> 2.3.0)
15
- rspec-core (2.3.1)
16
- rspec-expectations (2.3.0)
17
- diff-lcs (~> 1.1.2)
18
- rspec-mocks (2.3.0)
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ json (2.6.3)
13
+ matrix (0.4.2)
14
+ parallel (1.23.0)
15
+ parser (3.2.2.1)
16
+ ast (~> 2.4.1)
17
+ rainbow (3.1.1)
18
+ rake (13.0.6)
19
+ regexp_parser (2.8.0)
20
+ rexml (3.2.5)
21
+ rspec (3.12.0)
22
+ rspec-core (~> 3.12.0)
23
+ rspec-expectations (~> 3.12.0)
24
+ rspec-mocks (~> 3.12.0)
25
+ rspec-core (3.12.2)
26
+ rspec-support (~> 3.12.0)
27
+ rspec-expectations (3.12.3)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.12.0)
30
+ rspec-mocks (3.12.5)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.12.0)
33
+ rspec-support (3.12.0)
34
+ rubocop (1.50.2)
35
+ json (~> 2.3)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.2.0.0)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
+ rexml (>= 3.2.5, < 4.0)
41
+ rubocop-ast (>= 1.28.0, < 2.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 2.4.0, < 3.0)
44
+ rubocop-ast (1.28.1)
45
+ parser (>= 3.2.1.0)
46
+ rubocop-capybara (2.18.0)
47
+ rubocop (~> 1.41)
48
+ rubocop-factory_bot (2.22.0)
49
+ rubocop (~> 1.33)
50
+ rubocop-performance (1.10.2)
51
+ rubocop (>= 0.90.0, < 2.0)
52
+ rubocop-ast (>= 0.4.0)
53
+ rubocop-rake (0.6.0)
54
+ rubocop (~> 1.0)
55
+ rubocop-rspec (2.22.0)
56
+ rubocop (~> 1.33)
57
+ rubocop-capybara (~> 2.17)
58
+ rubocop-factory_bot (~> 2.22)
59
+ ruby-progressbar (1.13.0)
60
+ unicode-display_width (2.4.2)
19
61
 
20
62
  PLATFORMS
21
63
  ruby
64
+ x64-mingw32
22
65
 
23
66
  DEPENDENCIES
24
- bundler (~> 1.0.0)
25
- jeweler (~> 1.6.0)
26
- rspec (~> 2.3.0)
67
+ bundler (~> 2.4)
68
+ rake (~> 13.0)
69
+ rspec (~> 3.12)
70
+ rubocop (~> 1.50)
71
+ rubocop-performance (~> 1.10)
72
+ rubocop-rake (~> 0.6)
73
+ rubocop-rspec (~> 2.22)
74
+ vote-schulze!
75
+
76
+ BUNDLED WITH
77
+ 2.4.12
data/LICENSE.txt CHANGED
@@ -1,20 +1,21 @@
1
- Copyright (c) 2011 Christoph Grabo
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2011—2020 Christoph Grabo
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
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:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 CHANGED
@@ -1,10 +1,8 @@
1
- # vote-schulze
1
+ # vote-schulze [![ci](https://github.com/asaaki/vote-schulze/actions/workflows/ci.yml/badge.svg)](https://github.com/asaaki/vote-schulze/actions/workflows/ci.yml)
2
2
 
3
3
  This gem is a Ruby implementation of the Schulze voting method (with help of the Floyd–Warshall algorithm), a type of the Condorcet voting methods.
4
4
 
5
- **Very alpha! Only basic functionality. No tests yet!**
6
-
7
- (If you want to write the tests: fork, write, test, push request - Thanks!)
5
+ **It's usable, but not production grade.**
8
6
 
9
7
  Wikipedia:
10
8
 
@@ -21,13 +19,11 @@ gem install vote-schulze
21
19
 
22
20
  ``` ruby
23
21
  require 'vote-schulze'
24
- vs = SchulzeBasic.do vote_list, candidate_count
22
+ vs = Vote::Schulze::Basic.call(vote_list, candidate_count)
25
23
  vs.ranks
26
- vs.ranks_abc
24
+ vs.ranking_abc
27
25
  ```
28
26
 
29
- `SchulzeBasic.do` - SchulzeBasic is a short term for `Vote::Condorcet::Schulze::Basic` and `.do` is a method of this class!
30
-
31
27
  Input:
32
28
 
33
29
  * `vote_list`
@@ -84,8 +80,8 @@ See it as an visual reminder while coding with this gem.
84
80
  ``` ruby
85
81
  require 'vote-schulze'
86
82
  vote_list_array = [[3,2,1],[1,3,2],[3,1,2]]
87
- vs = SchulzeBasic.do vote_list_array, 3
88
- vs.ranks_abc #=> result
83
+ vs = Vote::Schulze::Basic.call(vote_list_array, 3)
84
+ vs.ranking_abc #=> result
89
85
  ```
90
86
 
91
87
  #### String
@@ -99,16 +95,17 @@ A;C;B
99
95
  A,C,B
100
96
  4=C;A;B
101
97
  EOF
102
- vs = SchulzeBasic.do vote_list_string, 3
103
- vs.ranks_abc #=> result
98
+ vs = Vote::Schulze::Basic.call(vote_list_string, 3)
99
+ vs.ranking_abc #=> result
104
100
  ```
105
101
 
106
102
  #### File
107
103
 
108
104
  ``` ruby
109
105
  require 'vote-schulze'
110
- vs = SchulzeBasic.do File.open('path/to/vote.list')
111
- vs.ranks_abc #=> result
106
+ voting_list = File.open('path/to/vote.list')
107
+ vs = Vote::Schulze::Basic.call(voting_list)
108
+ vs.ranking_abc #=> result
112
109
  ```
113
110
 
114
111
  ### _preference order to weight_ example
@@ -127,18 +124,12 @@ D is on second position == 3
127
124
  Later versions will have an automatic Preference-to-Weight algorithm.
128
125
  (Internally only integers are used for calculation of ranking.)
129
126
 
130
- ### _SchulzeBasic_
131
-
132
- It doesn't matter if you start counting at 0 (zero) or 1 (one).
127
+ ### It doesn't matter if you start counting at 0 (zero) or 1 (one).
133
128
 
134
129
  Also it's not important, if you use jumps (like `1 3 5 9`).
135
130
 
136
131
  Internally it will only check if candidate X > candidate Y
137
132
 
138
- Output:
139
-
140
- * `.ranking_array` Array: numbers of total wins for each candidate `[candidate A, candidate B, candidate C, ...]`
141
-
142
133
  ## Example
143
134
 
144
135
  Reference calculation: [Schulze Methode | blog.cgiesel.de (german)](http://blog.cgiesel.de/schulze-methode/)
@@ -146,9 +137,11 @@ Reference calculation: [Schulze Methode | blog.cgiesel.de (german)](http://blog.
146
137
  Example file under `examples/vote4.list`
147
138
 
148
139
  Result should be:
140
+
149
141
  ``` ruby
150
- sb = SchulzeBasic.do File.open('../examples/vote4.list')
151
- sb.rank_abc
142
+ voting_list = File.open('examples/vote4.list')
143
+ voting = Vote::Schulze::Basic.call(voting_list)
144
+ voting.ranking_abc
152
145
  #=> ["C:1", "D:2", "B:3", "A:4"]
153
146
  ```
154
147
 
@@ -156,18 +149,15 @@ which is the same result of the reference above.
156
149
 
157
150
  The result strings are always in format `Candidate:Position`, because it's possible that multiple candidates can be on the same rank.
158
151
 
159
- ## Contributing to vote-schulze
152
+ ## Contributing
153
+
154
+ Bug reports and pull requests are welcome on GitHub at https://github.com/asaaki/vote-schulze.
155
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
160
156
 
161
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
162
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
163
- * Fork the project
164
- * Use git-flow
165
- * Start a feature/bugfix branch
166
- * Commit and push until you are happy with your contribution
167
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
168
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
157
+ ## Code of Conduct
169
158
 
170
- ## Copyright
159
+ Everyone interacting in the vote-schulze project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/asaaki/vote-schulze/blob/master/CODE_OF_CONDUCT.md).
171
160
 
172
- Copyright (c) 2011 Christoph Grabo. See LICENSE.txt for further details.
161
+ ## License
173
162
 
163
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,45 +1,8 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "vote-schulze"
18
- gem.homepage = "http://github.com/asaaki/vote-schulze"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Schulze method implementation in Ruby (Condorcet voting method)}
21
- gem.description = %Q{This gem is a Ruby implementation of the Schulze voting method (with help of the Floyd–Warshall algorithm), a type of the Condorcet voting methods.}
22
- gem.email = "chris@dinarrr.com"
23
- gem.authors = ["Christoph Grabo"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rspec/core'
3
+ require 'bundler/gem_tasks'
29
4
  require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
32
- end
33
-
34
- task :default => :spec
35
-
36
- require 'rake/rdoctask'
37
- Rake::RDocTask.new do |rdoc|
38
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
39
5
 
40
- rdoc.rdoc_dir = 'rdoc'
41
- rdoc.title = "vote-schulze #{version}"
42
- rdoc.rdoc_files.include('README*')
43
- rdoc.rdoc_files.include('lib/**/*.rb')
44
- end
6
+ RSpec::Core::RakeTask.new(:spec)
45
7
 
8
+ task default: :spec
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 'vote/schulze'
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/rspec ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
+
13
+ bundle_binstub = File.expand_path('bundle', __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require 'rubygems'
25
+ require 'bundler/setup'
26
+
27
+ load Gem.bin_path('rspec-core', 'rspec')