irv 0.2.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '094a4e98ba00996613d8394a7a784c5e42452ccec63ca480f8f0bbd1e23923ff'
4
- data.tar.gz: e8303a420c2e50c800a8b42cb99e86d3e93a74e6e5d4bae6066d3dcc916304c9
3
+ metadata.gz: dfd57ec8dac2bec1cd4013e868af058d3ed72756892bd27d3f6754d53a656d46
4
+ data.tar.gz: 9b28df1aa3ba19e1368f436ddcf8a9c5fcb2eeb039313c24b4b475f1f5685995
5
5
  SHA512:
6
- metadata.gz: 0ded7eb4aef961ae5e4a5a29bc7b5689ce5b3ae115b072272450e8dca849472164bb94daaed81dbc88dfd27550357814a79882fab9cd64639a9a69450577ab54
7
- data.tar.gz: 5154140b71dcd1b5611ee95eb430f080317d96d1fe13c65b42ee22fb5aef7e21507a80d3107a534507f7315955aa0ef0f5c004aa82be36d90754dde935606a15
6
+ metadata.gz: c22afbebe3eeff2e89a0b86251948539d763b2b40daff33a72bd2d77b7243216e527be5d673a43b29ff1f230c1862b089d2642e0de406928b52fcbbdb9a94bb7
7
+ data.tar.gz: d3bdd5286d392b9ac62c45658c4d071b9e7240c1c1e746ee9881ce38401908d1a2f33638b0ec46bc029c634059fcc6d8852caa5074ca34ecced843770e59eaa5
@@ -0,0 +1,31 @@
1
+ name: RSpec and RuboCop
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 3.3
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ gem install bundler
25
+ bundle install --jobs 4 --retry 3
26
+
27
+ - name: Run RSpec tests
28
+ run: bundle exec rspec
29
+
30
+ - name: Run RuboCop
31
+ run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 3.3
3
3
  DisplayCopNames: true
4
4
 
5
5
  Layout/ExtraSpacing:
@@ -44,7 +44,7 @@ Metrics/ClassLength:
44
44
  Metrics/CyclomaticComplexity:
45
45
  Enabled: false
46
46
 
47
- Metrics/LineLength:
47
+ Layout/LineLength:
48
48
  Enabled: false
49
49
 
50
50
  Metrics/MethodLength:
data/Gemfile.lock CHANGED
@@ -1,51 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- irv (0.2.0)
4
+ irv (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
10
- diff-lcs (1.3)
11
- jaro_winkler (1.5.2)
12
- parallel (1.17.0)
13
- parser (2.6.3.0)
14
- ast (~> 2.4.0)
15
- rainbow (3.0.0)
16
- rake (10.5.0)
17
- rspec (3.8.0)
18
- rspec-core (~> 3.8.0)
19
- rspec-expectations (~> 3.8.0)
20
- rspec-mocks (~> 3.8.0)
21
- rspec-core (3.8.1)
22
- rspec-support (~> 3.8.0)
23
- rspec-expectations (3.8.4)
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.7.1)
12
+ language_server-protocol (3.17.0.3)
13
+ parallel (1.24.0)
14
+ parser (3.3.0.2)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.7.3)
18
+ rainbow (3.1.1)
19
+ rake (13.1.0)
20
+ regexp_parser (2.9.0)
21
+ rexml (3.2.6)
22
+ rspec (3.12.0)
23
+ rspec-core (~> 3.12.0)
24
+ rspec-expectations (~> 3.12.0)
25
+ rspec-mocks (~> 3.12.0)
26
+ rspec-core (3.12.2)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-expectations (3.12.3)
24
29
  diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.8.0)
26
- rspec-mocks (3.8.1)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-mocks (3.12.6)
27
32
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.8.0)
29
- rspec-support (3.8.2)
30
- rubocop (0.71.0)
31
- jaro_winkler (~> 1.5.1)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-support (3.12.1)
35
+ rubocop (1.59.0)
36
+ json (~> 2.3)
37
+ language_server-protocol (>= 3.17.0)
32
38
  parallel (~> 1.10)
33
- parser (>= 2.6)
39
+ parser (>= 3.2.2.4)
34
40
  rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.8, < 3.0)
42
+ rexml (>= 3.2.5, < 4.0)
43
+ rubocop-ast (>= 1.30.0, < 2.0)
35
44
  ruby-progressbar (~> 1.7)
36
- unicode-display_width (>= 1.4.0, < 1.7)
37
- ruby-progressbar (1.10.1)
38
- unicode-display_width (1.6.0)
45
+ unicode-display_width (>= 2.4.0, < 3.0)
46
+ rubocop-ast (1.30.0)
47
+ parser (>= 3.2.1.0)
48
+ ruby-progressbar (1.13.0)
49
+ unicode-display_width (2.5.0)
39
50
 
40
51
  PLATFORMS
41
52
  ruby
53
+ x86_64-darwin-22
42
54
 
43
55
  DEPENDENCIES
44
- bundler (~> 1.17)
56
+ bundler (~> 2.4)
45
57
  irv!
46
- rake (~> 10.0)
58
+ rake (~> 13.0)
47
59
  rspec (~> 3.0)
48
- rubocop (~> 0.71.0)
60
+ rubocop (~> 1.59.0)
49
61
 
50
62
  BUNDLED WITH
51
- 1.17.2
63
+ 2.5.4
data/irv.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = 'Instant-runoff Voting is a type of ranked preferential voting method. This gem makes it enable Ruby program.'
15
15
  spec.homepage = 'https://github.com/highwide/irv'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 2.4.0'
17
+ spec.required_ruby_version = '>= 3.3.0'
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.17'
29
- spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'bundler', '~> 2.4'
29
+ spec.add_development_dependency 'rake', '~> 13.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'rubocop', '~> 0.71.0'
31
+ spec.add_development_dependency 'rubocop', '~> 1.59.0'
32
32
  end
data/lib/irv/result.rb CHANGED
@@ -11,7 +11,7 @@ module Irv
11
11
  round_order = 1
12
12
  round = Round.new(round_order, candidates, ballots)
13
13
 
14
- (candidates.count - 1).times do
14
+ candidates.count.times do
15
15
  @process << round
16
16
  break if round.exist_majority?
17
17
 
data/lib/irv/round.rb CHANGED
@@ -46,7 +46,7 @@ module Irv
46
46
  tallied_votes = []
47
47
  max_ranked_votes_count(votes).times do |n|
48
48
  nth_ranked_votes = votes.map { |vote| vote[n] }
49
- tallied_votes << @candidates.each_with_object({}) { |candidate, hash| hash[candidate.to_sym] = nth_ranked_votes.count(candidate) }
49
+ tallied_votes << @candidates.to_h { |c| [c.to_s.to_sym, nth_ranked_votes.count(c)] }
50
50
  end
51
51
  tallied_votes
52
52
  end
@@ -79,7 +79,7 @@ module Irv
79
79
  end
80
80
 
81
81
  # if last ranked votes can't decide loser, choose it at random
82
- target_candidates.sample
82
+ target_candidates.sample.to_s
83
83
  end
84
84
  end
85
85
  end
data/lib/irv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Irv
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - highwide
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-04 00:00:00.000000000 Z
11
+ date: 2024-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.71.0
61
+ version: 1.59.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.71.0
68
+ version: 1.59.0
69
69
  description: Instant-runoff Voting is a type of ranked preferential voting method.
70
70
  This gem makes it enable Ruby program.
71
71
  email:
@@ -74,10 +74,10 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".github/workflows/test.yaml"
77
78
  - ".gitignore"
78
79
  - ".rspec"
79
80
  - ".rubocop.yml"
80
- - ".travis.yml"
81
81
  - CODE_OF_CONDUCT.md
82
82
  - Gemfile
83
83
  - Gemfile.lock
@@ -96,7 +96,7 @@ homepage: https://github.com/highwide/irv
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -104,15 +104,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: 2.4.0
107
+ version: 3.3.0
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.0.3
115
- signing_key:
114
+ rubygems_version: 3.5.3
115
+ signing_key:
116
116
  specification_version: 4
117
117
  summary: Providing a Instant-runoff Voting.
118
118
  test_files: []
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
- before_install: gem install bundler -v 1.17.2
10
- script:
11
- - bundle exec rubocop
12
- - bundle exec rake spec