ballot 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/Contributing.md +68 -0
  3. data/History.md +5 -0
  4. data/Licence.md +27 -0
  5. data/Manifest.txt +68 -0
  6. data/README.rdoc +264 -0
  7. data/Rakefile +71 -0
  8. data/bin/ballot_generator +9 -0
  9. data/lib/ballot.rb +25 -0
  10. data/lib/ballot/action_controller.rb +32 -0
  11. data/lib/ballot/active_record.rb +152 -0
  12. data/lib/ballot/active_record/votable.rb +145 -0
  13. data/lib/ballot/active_record/vote.rb +35 -0
  14. data/lib/ballot/active_record/voter.rb +99 -0
  15. data/lib/ballot/railtie.rb +19 -0
  16. data/lib/ballot/sequel.rb +170 -0
  17. data/lib/ballot/sequel/vote.rb +99 -0
  18. data/lib/ballot/votable.rb +445 -0
  19. data/lib/ballot/vote.rb +129 -0
  20. data/lib/ballot/voter.rb +320 -0
  21. data/lib/ballot/words.rb +32 -0
  22. data/lib/generators/ballot.rb +40 -0
  23. data/lib/generators/ballot/install/install_generator.rb +27 -0
  24. data/lib/generators/ballot/install/templates/active_record/migration.rb +19 -0
  25. data/lib/generators/ballot/install/templates/sequel/migration.rb +25 -0
  26. data/lib/generators/ballot/standalone.rb +89 -0
  27. data/lib/generators/ballot/standalone/support.rb +70 -0
  28. data/lib/generators/ballot/summary/summary_generator.rb +27 -0
  29. data/lib/generators/ballot/summary/templates/active_record/migration.rb +15 -0
  30. data/lib/generators/ballot/summary/templates/sequel/migration.rb +20 -0
  31. data/lib/sequel/plugins/ballot_votable.rb +180 -0
  32. data/lib/sequel/plugins/ballot_voter.rb +125 -0
  33. data/test/active_record/ballot_votable_test.rb +16 -0
  34. data/test/active_record/ballot_voter_test.rb +13 -0
  35. data/test/active_record/rails_generator_test.rb +28 -0
  36. data/test/active_record/votable_voter_test.rb +19 -0
  37. data/test/generators/rails-activerecord/Rakefile +2 -0
  38. data/test/generators/rails-activerecord/app/.keep +0 -0
  39. data/test/generators/rails-activerecord/bin/rails +5 -0
  40. data/test/generators/rails-activerecord/config/application.rb +17 -0
  41. data/test/generators/rails-activerecord/config/boot.rb +3 -0
  42. data/test/generators/rails-activerecord/config/database.yml +12 -0
  43. data/test/generators/rails-activerecord/config/environment.rb +3 -0
  44. data/test/generators/rails-activerecord/config/routes.rb +3 -0
  45. data/test/generators/rails-activerecord/config/secrets.yml +5 -0
  46. data/test/generators/rails-activerecord/db/seeds.rb +1 -0
  47. data/test/generators/rails-activerecord/log/.keep +0 -0
  48. data/test/generators/rails-sequel/Rakefile +2 -0
  49. data/test/generators/rails-sequel/app/.keep +0 -0
  50. data/test/generators/rails-sequel/bin/rails +5 -0
  51. data/test/generators/rails-sequel/config/application.rb +14 -0
  52. data/test/generators/rails-sequel/config/boot.rb +3 -0
  53. data/test/generators/rails-sequel/config/database.yml +12 -0
  54. data/test/generators/rails-sequel/config/environment.rb +3 -0
  55. data/test/generators/rails-sequel/config/routes.rb +3 -0
  56. data/test/generators/rails-sequel/config/secrets.yml +5 -0
  57. data/test/generators/rails-sequel/db/seeds.rb +1 -0
  58. data/test/generators/rails-sequel/log/.keep +0 -0
  59. data/test/minitest_config.rb +14 -0
  60. data/test/sequel/ballot_votable_test.rb +45 -0
  61. data/test/sequel/ballot_voter_test.rb +42 -0
  62. data/test/sequel/rails_generator_test.rb +25 -0
  63. data/test/sequel/votable_voter_test.rb +19 -0
  64. data/test/sequel/vote_test.rb +105 -0
  65. data/test/support/active_record_setup.rb +145 -0
  66. data/test/support/generators_setup.rb +129 -0
  67. data/test/support/sequel_setup.rb +164 -0
  68. data/test/support/shared_examples/votable_examples.rb +630 -0
  69. data/test/support/shared_examples/voter_examples.rb +600 -0
  70. metadata +333 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e3564be4388ab88e50ea55774e611d5d0598c9d
4
+ data.tar.gz: da67d065297bcc36f747a3cd4467451571c6c100
5
+ SHA512:
6
+ metadata.gz: 95bf6920d2045a5f42d1c5037801828d18b0f353d8fc2d029691b16e9528606edef1d009f2d83a21217cd25d8a66c6de1d80e062138a061b25fe52aac33309b0
7
+ data.tar.gz: d1b34a989316f61be094b22a9763c1f4d7ba35132a9d4f1b737815395498f06f144cb456cd320bfa0c4d8fd6d054dd08e4315bef56fe864b8170a077e59ed157
@@ -0,0 +1,68 @@
1
+ ## Contributing
2
+
3
+ We value any contribution to Ballot you can provide: a bug report, a feature
4
+ request, or code contributions. Your contribution
5
+
6
+ Ballot is reasonably complex code, so there are a few code guidelines:
7
+
8
+ * Changes *will not* be accepted without tests. The test suite is written
9
+ with [Minitest][].
10
+ * Changes *probably* require documentation updates.
11
+ * Match our coding style.
12
+ * Use a thoughtfully-named topic branch that contains your change. Rebase your
13
+ commits into logical chunks as necessary.
14
+ * Use [quality commit messages][].
15
+ * Do not change the version number; when your patch is accepted and a release
16
+ is made, the version will be updated at that point.
17
+ * Submit a GitHub pull request with your changes.
18
+
19
+ ### Test Dependencies
20
+
21
+ Ballot uses Ryan Davis’s [Hoe][] to manage the release process, and it adds a
22
+ number of rake tasks. You will mostly be interested in:
23
+
24
+ $ rake
25
+
26
+ which runs the tests the same way that:
27
+
28
+ $ rake test
29
+ $ rake travis
30
+
31
+ will do.
32
+
33
+ To assist with the installation of the development dependencies for Ballot, I
34
+ have provided the simplest possible Gemfile pointing to the (generated)
35
+ `ballot.gemspec` file. This will permit you to do:
36
+
37
+ $ bundle install
38
+
39
+ to get the development dependencies. If you aleady have `hoe` installed, you
40
+ can accomplish the same thing with:
41
+
42
+ $ rake newb
43
+
44
+ This task will install any missing dependencies, run the tests/specs, and
45
+ generate the RDoc.
46
+
47
+ ### Workflow
48
+
49
+ Here's the most direct way to get your work merged into the project:
50
+
51
+ * Fork the project.
52
+ * Clone down your fork (`git clone git://github.com/KineticCafe/ruby-ballot.git`).
53
+ * Create a topic branch to contain your change (`git checkout -b my_awesome_feature`).
54
+ * Hack away, add tests. Not necessarily in that order.
55
+ * Make sure everything still passes by running `rake`.
56
+ * If necessary, rebase your commits into logical chunks, without errors.
57
+ * Push the branch up (`git push origin my_awesome_feature`).
58
+ * Create a pull request against KineticCafe/ruby-ballot and describe
59
+ what your change does and the why you think it should be merged.
60
+
61
+ === Contributors
62
+
63
+ * Austin Ziegler created Ballot.
64
+
65
+ [Minitest]: https://github.com/seattlerb/minitest
66
+ [quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
67
+ [Hoe]: https://github.com/seattlerb/hoe
68
+ [kccoc]: https://github.com/KineticCafe/code-of-conduct
@@ -0,0 +1,5 @@
1
+ ### 1.0 / 2016-05-12
2
+
3
+ * 1 major enhancement!
4
+
5
+ * Birthday! Forked from acts_as_votable 0.10.
@@ -0,0 +1,27 @@
1
+ ## Licence
2
+
3
+ This software is available under an MIT-style licence.
4
+
5
+ * Copyright 2016 Kinetic Cafe
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ Contributing.md
2
+ History.md
3
+ Licence.md
4
+ Manifest.txt
5
+ README.rdoc
6
+ Rakefile
7
+ bin/ballot_generator
8
+ lib/ballot.rb
9
+ lib/ballot/action_controller.rb
10
+ lib/ballot/active_record.rb
11
+ lib/ballot/active_record/votable.rb
12
+ lib/ballot/active_record/vote.rb
13
+ lib/ballot/active_record/voter.rb
14
+ lib/ballot/railtie.rb
15
+ lib/ballot/sequel.rb
16
+ lib/ballot/sequel/vote.rb
17
+ lib/ballot/votable.rb
18
+ lib/ballot/vote.rb
19
+ lib/ballot/voter.rb
20
+ lib/ballot/words.rb
21
+ lib/generators/ballot.rb
22
+ lib/generators/ballot/install/install_generator.rb
23
+ lib/generators/ballot/install/templates/active_record/migration.rb
24
+ lib/generators/ballot/install/templates/sequel/migration.rb
25
+ lib/generators/ballot/standalone.rb
26
+ lib/generators/ballot/standalone/support.rb
27
+ lib/generators/ballot/summary/summary_generator.rb
28
+ lib/generators/ballot/summary/templates/active_record/migration.rb
29
+ lib/generators/ballot/summary/templates/sequel/migration.rb
30
+ lib/sequel/plugins/ballot_votable.rb
31
+ lib/sequel/plugins/ballot_voter.rb
32
+ test/active_record/ballot_votable_test.rb
33
+ test/active_record/ballot_voter_test.rb
34
+ test/active_record/rails_generator_test.rb
35
+ test/active_record/votable_voter_test.rb
36
+ test/generators/rails-activerecord/Rakefile
37
+ test/generators/rails-activerecord/app/.keep
38
+ test/generators/rails-activerecord/bin/rails
39
+ test/generators/rails-activerecord/config/application.rb
40
+ test/generators/rails-activerecord/config/boot.rb
41
+ test/generators/rails-activerecord/config/database.yml
42
+ test/generators/rails-activerecord/config/environment.rb
43
+ test/generators/rails-activerecord/config/routes.rb
44
+ test/generators/rails-activerecord/config/secrets.yml
45
+ test/generators/rails-activerecord/db/seeds.rb
46
+ test/generators/rails-activerecord/log/.keep
47
+ test/generators/rails-sequel/Rakefile
48
+ test/generators/rails-sequel/app/.keep
49
+ test/generators/rails-sequel/bin/rails
50
+ test/generators/rails-sequel/config/application.rb
51
+ test/generators/rails-sequel/config/boot.rb
52
+ test/generators/rails-sequel/config/database.yml
53
+ test/generators/rails-sequel/config/environment.rb
54
+ test/generators/rails-sequel/config/routes.rb
55
+ test/generators/rails-sequel/config/secrets.yml
56
+ test/generators/rails-sequel/db/seeds.rb
57
+ test/generators/rails-sequel/log/.keep
58
+ test/minitest_config.rb
59
+ test/sequel/ballot_votable_test.rb
60
+ test/sequel/ballot_voter_test.rb
61
+ test/sequel/rails_generator_test.rb
62
+ test/sequel/votable_voter_test.rb
63
+ test/sequel/vote_test.rb
64
+ test/support/active_record_setup.rb
65
+ test/support/generators_setup.rb
66
+ test/support/sequel_setup.rb
67
+ test/support/shared_examples/votable_examples.rb
68
+ test/support/shared_examples/voter_examples.rb
@@ -0,0 +1,264 @@
1
+ = Ballot by Kinetic Cafe
2
+
3
+ code :: https://github.com/KineticCafe/ruby-ballot/
4
+ issues :: https://github.com/KineticCafe/ruby-ballot/issues
5
+ docs :: http://www.rubydoc.info/github/KineticCafe/ruby-ballot/master
6
+ continuous integration :: {<img src="https://travis-ci.org/KineticCafe/ruby-ballot.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/KineticCafe/ruby-ballot]
7
+
8
+ == Description
9
+
10
+ Ballot provides a two-way polymorphic scoped voting mechanism for both
11
+ ActiveRecord (4 or later) and Sequel (4 or later).
12
+
13
+ === Overview
14
+
15
+ - Two-way polymorphic: any model can be a voter or a votable.
16
+ - Scoped: multiple votes can be recorded for a votable, under different
17
+ scopes.
18
+
19
+ Ballot started as an opinionated port of
20
+ {acts_as_votable}[https://github.com/ryanto/acts_as_votable] to
21
+ {Sequel}[http://sequel.jeremyevans.net/]. As the port formed, we made
22
+ aggressive changes to both the data models and API which we wanted to share
23
+ between our various applications, whether they used ActiveRecord or Sequel. The
24
+ design decisions made here may not suit your needs, and we heartily recommend
25
+ acts\_as\_votable if they do not.
26
+
27
+ Ballot has been written to be able to coexist with acts\_as\_votable.
28
+
29
+ Ballot does not provide a direct migration from acts\_as\_votable; it uses a
30
+ different table (+ballot_votes+), so can coexist with acts\_as\_votable.
31
+
32
+ == Synopsis
33
+
34
+ The API for Ballot is consistent for both ActiveRecord and Sequel.
35
+
36
+ === ActiveRecord
37
+
38
+ class Post < ActiveRecord::Base
39
+ acts_as_ballot :votable # or acts_as_ballot_votable
40
+ end
41
+
42
+ class User < ActiveRecord::Base
43
+ acts_as_ballot :voter # or acts_as_ballot_voter
44
+ end
45
+
46
+ post = Post.create(name: 'My amazing post!')
47
+ current_user.cast_ballot_for post # An up-vote by current_user!
48
+ post.ballots_for.count # => 1
49
+ current_user.ballots_by.count # => 1
50
+ current_user.remove_ballot_for post # Remove the vote! :(
51
+ post.ballots_for.any? # => false
52
+ current_user.ballots_by.none? # => true
53
+
54
+ === Sequel
55
+
56
+ class Post < Sequel::Model
57
+ plugin :ballot_votable
58
+ # or acts_as_ballot :votable or acts_as_ballot_votable
59
+ end
60
+
61
+ class User < Sequel::Model
62
+ plugin :ballot_voter
63
+ # or acts_as_ballot :voter or acts_as_ballot_voter
64
+ end
65
+
66
+ post = Post.create(title: 'My amazing post!')
67
+ current_user.cast_ballot_for post # An up-vote by current_user!
68
+ post.ballots_for_dataset.count # => 1
69
+ current_user.ballots_by_dataset.count # => 1
70
+ current_user.remove_ballot_for post # Remove the vote! :(
71
+ post.ballots_for_dataset.any? # => false
72
+ current_user.ballots_by_dataset.none? # => true
73
+
74
+ === Exploring the API
75
+
76
+ ==== Ballot Words
77
+
78
+ Unless otherwise specified, votes are positive. This can be specified by using
79
+ the `vote` parameter, which will be parsed through Ballot::Words#truthy? for
80
+ interpretation.
81
+
82
+ # All of these mean the same thing
83
+ post.ballot_by current_user, vote: 'bad'
84
+ post.ballot_by current_user, vote: '0'
85
+ post.ballot_by current_user, vote: 'false'
86
+ post.ballot_by current_user, vote: false
87
+ post.ballot_by current_user, vote: -1
88
+ post.down_ballot_by current_user
89
+ current_user.cast_down_ballot_for(post)
90
+
91
+ ==== Scoped Votes
92
+
93
+ Scopes provide _purpose_ or _reasons_ for votes. These are isolated vote
94
+ collections. One could emulate Facebook reactions with scopes:
95
+
96
+ current_user.ballot_for post # default, unspecified scope
97
+ current_user.ballot_for post, scope: 'love' # 'love' scope
98
+ current_user.ballot_for post, scope: 'haha' # 'haha' scope
99
+ current_user.ballot_for post, scope: 'wow' # 'wow' scope
100
+ current_user.ballot_for post, scope: 'sad' # 'sad' scope
101
+ current_user.ballot_for post, scope: 'angry' # 'angry' scope
102
+
103
+ Ballot does not provide uniqueness across scopes so that a voter can only have
104
+ one reaction to a votable.
105
+
106
+ Queries are segregated by scopes as well:
107
+
108
+ current_user.cast_ballot_for? post # default, unspecified scope
109
+ current_user.cast_ballot_for? post, scope: 'love' # 'love' scope
110
+
111
+ ==== Weighted Votes
112
+
113
+ Votes may be weighted so that some votes count more than others (the default
114
+ weight is 1). This affects the _score_ of ballots, which is a distinct concept
115
+ from the _count_ of ballots.
116
+
117
+ current_user.cast_ballot_for post, weight: 2
118
+ post.total_ballots # => 1
119
+ post.ballot_score # => 2
120
+
121
+ ==== Registered Votes and Duplicate Votes
122
+
123
+ By default, voters can only vote a particular once per model in a given vote
124
+ scope.
125
+
126
+ current_user.cast_ballot_for post
127
+ current_user.cast_ballot_for post
128
+ post.total_ballots # => 1
129
+
130
+ A votable can be checked after voting to see if the vote counted; this is true
131
+ only when a vote has been _created_ or _changed_.
132
+
133
+ current_user.cast_ballot_for post
134
+ post.vote_registered? # => true
135
+ current_user.cast_ballot_for post
136
+ post.vote_registered? # => false
137
+ current_user.cast_down_ballot_for post
138
+ post.vote_registered? # => true
139
+ post.total_ballots # => 1
140
+
141
+ Duplicate votes may be permitted through the use of the keyword argument
142
+ +duplicate+ when casting the vote:
143
+
144
+ current_user.cast_ballot_for post
145
+ post.vote_registered? # => true
146
+ current_user.cast_ballot_for post, duplicate: true
147
+ post.vote_registered? # => true
148
+ current_user.cast_down_ballot_for post, duplicate: true
149
+ post.vote_registered? # => true
150
+ post.total_ballots # => 3
151
+
152
+ Not all methods properly handle duplicate votes (as the
153
+ <tt>post.total_ballots</tt> line demonstrates), and it has a negative impact on
154
+ performance at a large enough scale. Its use is discouraged.
155
+
156
+ ==== Cached Ballot Summary
157
+
158
+ Performance for some common queries can be sped up by adding a JSON field to a
159
+ Votable model, +cached_ballot_summary+. This is updated after each vote on a
160
+ votable. When added, this caches the results for *all* vote scopes.
161
+
162
+ user1.cast_ballot_for post, weight: 4
163
+ user2.cast_ballot_for post, vote: false
164
+ post.total_ballots # => 2
165
+ post.total_up_ballots # => 1
166
+ post.total_down_ballots # => 1
167
+ post.ballot_score # => 0
168
+ post.weighted_ballot_total # => 5
169
+ post.weighted_ballot_score # => 3
170
+ post.weighted_ballot_average # => 1.5
171
+
172
+ === API Differences with acts\_as\_votable
173
+
174
+ There are a number of API differences between acts\_as\_votable and
175
+ Ballot:
176
+
177
+ 1. Ballot has an orthogonal API between Votable and Voter objects. Votable
178
+ objects receive <tt>#ballot_by</tt> to cast a vote, Voter objects receive
179
+ <tt>#cast_ballot_for</tt> to cast a vote (or <tt>#ballot_for</tt>). None of
180
+ the aliases added by acts\_as\_votable exist in Ballot.
181
+
182
+ 2. Votable objects are associated on <tt>#ballots_for</tt> (themselves) and
183
+ ask whether a ballot was cast <tt>*_by</tt> Voter objects. Voter objects
184
+ are associated on <tt>#ballots_by</tt> (themselves) and ask whether a
185
+ ballot was cast <tt>*_for</tt> Votable objects.
186
+
187
+ 3. Validation is performed on the votables or voters passed to vote methods,
188
+ ensuring that the object is a Votable or a Voter.
189
+
190
+ 4. Votables can cache summary data about votes made for the votable, enabled
191
+ with a *single* JSON column per votable, +cached_ballot_summary+. It
192
+ implicitly provides caching for all scopes.
193
+
194
+ 5. Vote scopes are completely isolated, even on queries. The _unspecified_
195
+ (default) vote scope is independent of named vote scopes. Under
196
+ acts\_as\_votable, you could ask <tt>votable.voted_on_by?(voter)</tt> and
197
+ the answer would be provided without regard to the vote scope. This is not
198
+ supported by Ballot, where the same question
199
+ (<tt>votable.ballot_by?(voter)</tt>) is explicitly in the _unspecified_
200
+ vote scope. If this behaviour is required, it is easy enough to ask
201
+ using query methods provided by \ActiveRecord or \Sequel:
202
+
203
+ # ActiveRecord
204
+ votable.ballots_for(voter_id: voter.id, voter_type: voter.type).any?
205
+ # Sequel
206
+ votable.ballots_for_dataset(voter_id: voter.id, voter_type: voter.type).any?
207
+
208
+ == Planned Improvements
209
+
210
+ * Batch voting.
211
+
212
+ == Install
213
+
214
+ Add Ballot to your Gemfile:
215
+
216
+ gem 'ballot', '~> 1.0'
217
+
218
+ Or manually install:
219
+
220
+ % gem install ballot
221
+
222
+ === Supported Versions
223
+
224
+ Ballot is written using Ruby 2 syntax and supports Active Record 4, Active
225
+ Record 5, and Sequel 4.
226
+
227
+ Ballot is tested with these combinations of Ruby interpreters and ORMs:
228
+
229
+ - Ruby 2.0, 2.1; ActiveRecord 4; Sequel 4
230
+ - Ruby 2.2; ActiveRecord 4, 5; Sequel 4
231
+ - JRuby 9.0, 9.1; ActiveRecord 4; Sequel 4
232
+
233
+ === Database Migrations
234
+
235
+ Ballot uses a table (+ballot_votes+) to store all votes. When using Rails, you
236
+ can generate the migration as normal:
237
+
238
+ rails generate ballot:install
239
+ rake db:migrate
240
+
241
+ Performance can be increased by adding the +cached_ballot_summary+ column to
242
+ your votable tables. This can be added with a different migration:
243
+
244
+ rails generate ballot:summary VOTABLE
245
+
246
+ When not using Rails, you can use the ballot_generator binary.
247
+
248
+ ballot_generator [--orm ORM] --install
249
+ ballot_generator [--orm ORM] --summary NAME
250
+
251
+ == Ballot Semantic Versioning
252
+
253
+ Ballot uses a {Semantic Versioning}[http://semver.org/] scheme with one
254
+ significant change:
255
+
256
+ * When PATCH is zero (+0+), it will be omitted from version references.
257
+
258
+ == Community and Contributing
259
+
260
+ Ballot welcomes your contributions as described in
261
+ {Contributing.md}[https://github.com/KineticCafe/ballot/blob/master/Contributing.md].
262
+ This project, like all Kinetic Cafe {open source
263
+ projects}[https://github.com/KineticCafe], is under the Kinetic Cafe Open
264
+ Source {Code of Conduct}[https://github.com/KineticCafe/code-of-conduct].
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'rake/clean'
6
+
7
+ Hoe.plugin :doofus
8
+ Hoe.plugin :email unless ENV['CI'] || ENV['TRAVIS']
9
+ Hoe.plugin :gemspec2
10
+ Hoe.plugin :git
11
+ Hoe.plugin :minitest
12
+ Hoe.plugin :rubygems
13
+ Hoe.plugin :travis
14
+
15
+ spec = Hoe.spec 'ballot' do
16
+ developer('Austin Ziegler', 'aziegler@kineticcafe.com')
17
+
18
+ self.history_file = 'History.md'
19
+ self.readme_file = 'README.rdoc'
20
+
21
+ license 'MIT'
22
+
23
+ ruby20!
24
+
25
+ extra_dev_deps << ['rake', '>= 10.0']
26
+ extra_dev_deps << ['rdoc', '~> 4.2']
27
+ extra_dev_deps << ['hoe-doofus', '~> 1.0']
28
+ extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
29
+ extra_dev_deps << ['hoe-git', '~> 1.5']
30
+ extra_dev_deps << ['hoe-travis', '~> 1.2']
31
+ extra_dev_deps << ['minitest', '~> 5.4']
32
+ extra_dev_deps << ['minitest-autotest', '~> 1.0']
33
+ extra_dev_deps << ['minitest-bisect', '~> 1.2']
34
+ extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
35
+ extra_dev_deps << ['minitest-focus', '~> 1.1']
36
+ extra_dev_deps << ['minitest-hooks', '~> 1.4']
37
+ extra_dev_deps << ['minitest-moar', '~> 0.0']
38
+ extra_dev_deps << ['simplecov', '~> 0.7']
39
+ end
40
+
41
+ ENV['RDOCOPT'] = "-x #{%r{lib/generators/.+/templates/.+\.rb}}"
42
+ ENV['RUBYOPT'] = '-W0'
43
+
44
+ module Hoe::Publish #:nodoc:
45
+ alias __make_rdoc_cmd__ballot__ make_rdoc_cmd
46
+
47
+ def make_rdoc_cmd(*extra_args) # :nodoc:
48
+ spec.extra_rdoc_files.delete_if { |f| f == 'Manifest.txt' }
49
+ __make_rdoc_cmd__ballot__(*extra_args)
50
+ end
51
+ end
52
+
53
+ namespace :test do
54
+ if File.exist?('.simplecov-prelude.rb')
55
+ task :coverage do
56
+ spec.test_prelude = 'load ".simplecov-prelude.rb"'
57
+
58
+ Rake::Task['test'].execute
59
+ end
60
+ end
61
+
62
+ desc 'Include the generator tests'
63
+ task :generators do
64
+ ENV['TEST_GENERATORS'] = '1'
65
+ Rake::Task['test'].execute
66
+ end
67
+
68
+ CLOBBER << 'coverage'
69
+ end
70
+
71
+ CLOBBER << 'tmp'