shiftable 0.1.1 → 0.2.0

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: 79602092714ac55294711f0a60012290a85b20f46039eec63a2b698fcd433f0e
4
- data.tar.gz: 61e2a2c47e9afe4c28b518d4ec6dc017e3a3441f2f7c513f17cc9630f04bb7cf
3
+ metadata.gz: 769e7ab8e27a7ea4a5ea0e9ea2b7efeda58865f11a15f6504e0e00f6db8f9ce9
4
+ data.tar.gz: 3caa7d81b477be16f016358e6412a300782688632ea640685bdda70e63df6231
5
5
  SHA512:
6
- metadata.gz: d14b60642c03f4576cfae6030efffbe8de8dc9b1ea0b9d7db9ccb7ceea88f2de2582510918998e2e82ef146ca6adaf94d4f2eb9c10522363d8f705bcc24c6747
7
- data.tar.gz: 6d4793fc03014121e8c4ab2eaf369bbdadb892c94b52c897b25b05c1c2903c82310c6256fc5ba57c47df688f15147294b7a3236994f477196bd747570165c87a
6
+ metadata.gz: 3055e1d7bb53da73830429a6d942c992aea32991412b3c97a281f5559a151a6ed9cf8f11cad868c83a7c329886f97c75db3cd69d4eb7bef5c8cd7114a9b3e894
7
+ data.tar.gz: e060753ad1c7190ca7047fa12040f6799f43d425762414e0201d424f63291f425c7354b7377fb3cc6fbee662ebc328b54fc63debbcc084fba08b2fcadfbac95c
data/CHANGELOG.md CHANGED
@@ -1,14 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2021-10-23
3
+ ## [0.2.0] - 2021-10-24
4
4
 
5
- ### Added
5
+ ### Changed
6
6
 
7
- - Initial release
8
- - feat: supports shifting of records associated as has_one / belongs_to and has_many / belongs_to, including with STI.
9
- - 100% test coverage
7
+ - option `before_save` is now `before_shift` as originally documented
10
8
 
11
- ## [0.1.0] - 2021-10-23
9
+ ### Updated
10
+
11
+ - Github Actions now test all supported Rubies
12
+ - Linting
13
+ - Documentation
14
+
15
+ ## [0.1.1] - 2021-10-23
12
16
 
13
17
  ### Fixed
14
18
 
@@ -18,5 +22,13 @@
18
22
 
19
23
  - Linting
20
24
 
25
+ ## [0.1.0] - 2021-10-23
26
+
27
+ ### Added
28
+
29
+ - Initial release
30
+ - feat: supports shifting of records associated as has_one / belongs_to and has_many / belongs_to, including with STI.
31
+ - 100% test coverage
32
+
21
33
  [0.1.0]: https://github.com/pboling/shiftable/releases/tag/v0.1.0
22
34
  [0.1.1]: https://github.com/pboling/shiftable/releases/tag/v0.1.1
data/README.md CHANGED
@@ -5,12 +5,38 @@ Do your Spaceships belong to Captains, but sometimes a Captain will retire, and
5
5
  We've all been there. This gem provides structure around the process of "shifting" your records from one associated
6
6
  record to a new record.
7
7
 
8
+ | Project | Shiftable |
9
+ |------------------------ | ----------------------- |
10
+ | gem name | [shiftable](https://rubygems.org/gems/shiftable) |
11
+ | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
12
+ | download rank | [![Downloads Today](https://img.shields.io/gem/rd/shiftable.svg)](https://github.com/pboling/shiftable) |
13
+ | version | [![Version](https://img.shields.io/gem/v/shiftable.svg)](https://rubygems.org/gems/shiftable) |
14
+ | dependencies | [![Depfu](https://badges.depfu.com/badges/0412727b7e3b740b950a683eebc708e2/count.svg)](https://depfu.com/github/pboling/shiftable?project_id=32594) |
15
+ | unit tests | [![unit tests](https://github.com/pboling/shiftable/actions/workflows/test.yml/badge.svg)](https://github.com/pboling/shiftable/actions) |
16
+ | lint status | [![lint status](https://github.com/pboling/shiftable/actions/workflows/style.yml/badge.svg)](https://github.com/pboling/shiftable/actions) |
17
+ | unsupported status | [![unsupported status](https://github.com/pboling/shiftable/actions/workflows/unsupported.yml/badge.svg)](https://github.com/pboling/shiftable/actions) |
18
+ | test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/a53aa8b7c413b950d519/test_coverage)](https://codeclimate.com/github/pboling/shiftable/test_coverage) |
19
+ | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/a53aa8b7c413b950d519/maintainability)](https://codeclimate.com/github/pboling/shiftable/maintainability) |
20
+ | code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/shiftable/badges/users.svg)](https://www.codetriage.com/pboling/shiftable) |
21
+ | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
22
+ | documentation | [on RDoc.info][documentation] |
23
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏][aboutme], [👼][angelme], [💻][coderme], [![Tweet @ Peter][followme-img]][tweetme], [🌹][politicme] |
24
+
25
+ ## Compatibility
26
+
27
+ Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.6, 2.7, and 3.0, but may work on older Rubies back
28
+ to 2.0, though it is limited to 2.5 in the gemspec. Feel free to fork if you need something older! Targeted ActiveRecord
29
+ (Rails not required) compatibility follows the same scheme
30
+ as [Rails Security Issue maintenance policy](https://guides.rubyonrails.org/maintenance_policy.html#security-issues),
31
+ currently 6.1, 6.0, 5.2, but it is highly likely that this code will work in any version of ActiveRecord/Rails that runs
32
+ on Ruby 2+.
33
+
8
34
  ## Installation
9
35
 
10
36
  Add this line to your application's Gemfile:
11
37
 
12
38
  ```ruby
13
- gem 'shiftable'
39
+ gem "shiftable"
14
40
  ```
15
41
 
16
42
  And then execute:
@@ -61,32 +87,84 @@ But how can you accomplish this? If you used the `shiftable` gem, won't take but
61
87
 
62
88
  class Spaceship < ActiveRecord::Base
63
89
  belongs_to :captain
64
- extend Shiftable::Single.new(
65
- belongs_to: :captain,
66
- has_one: :spaceship,
67
- preflight_checks: true,
68
- before_shift: ->(shifting:, shift_to:, shift_from:) { shifting.ownership_changes += 1 }
69
- )
90
+ extend Shiftable::Single.new belongs_to: :captain, has_one: :spaceship, preflight_checks: true,
91
+ before_shift: ->(shifting:, shift_to:, shift_from:) { shifting.ownership_changes += 1 }
92
+ end
93
+ ```
94
+
95
+ NOTE: It doesn't matter if the extend occurs before or after the association macro `belongs_to`. In fact, it doesn't matter so much that you can even do this...
96
+
97
+ ```ruby
98
+
99
+ class Spaceship < ActiveRecord::Base
100
+ belongs_to :captain
101
+
102
+ class << self
103
+ include Shiftable::Single.new belongs_to: :captain, has_one: :spaceship, preflight_checks: true,
104
+ before_shift: ->(shifting:, shift_to:, shift_from:) { shifting.ownership_changes += 1 }
105
+ end
70
106
  end
71
107
  ```
72
108
 
109
+ ### Single Table Inheritance
110
+
111
+ This works as you would expect with STI (single table inheritance) classes, i.e. when defined on a subclass, only the records of that class get shifted.
112
+
73
113
  ### Multiple association on a single class
74
114
 
75
- What if the Captain is really all that though? What if the captain and the spaceship have a boss... the space
76
- federation!
115
+ What if the captain and the spaceship have a boss... the space
116
+ federation! And in a run-in with their arch-Nemesis the Plinth-inth,
117
+ all federation spaceships are commandeered! You are ruined!
77
118
 
78
119
  ```ruby
79
120
 
121
+ class Spaceship < ActiveRecord::Base
122
+ belongs_to :space_federation
123
+ extend Shiftable::Collection.new belongs_to: :space_federation, has_one: :spaceship,
124
+ before_shift: lambda do |shifting_rel:, shift_to:, shift_from:|
125
+ shifting_rel.each { |spaceship| spaceship.federation_changes += 1 }
126
+ end
127
+ end
128
+
129
+ class SpaceFederation < ActiveRecord::Base
130
+ has_many :spaceships
131
+
132
+ def all_spaceships_commandeered_by(nemesis_federation)
133
+ Spaceship.shift_cx(shift_to: nemesis_federation, shift_from: self)
134
+ end
135
+ end
136
+ ```
137
+
138
+ ### Complete example
139
+
140
+ Putting it all together...
141
+
142
+ ```ruby
143
+ class Captain < ActiveRecord::Base
144
+ has_one :spaceship
145
+
146
+ def sell_spaceship_to(nemesis_captain)
147
+ Spaceship.shift_single(shift_to: nemesis_captain, shift_from: self)
148
+ end
149
+ end
150
+
80
151
  class Spaceship < ActiveRecord::Base
81
152
  belongs_to :captain
153
+ extend Shiftable::Single.new belongs_to: :captain, has_one: :spaceship, preflight_checks: true,
154
+ before_shift: ->(shifting:, shift_to:, shift_from:) { shifting.ownership_changes += 1 }
155
+
82
156
  belongs_to :space_federation
157
+ extend Shiftable::Collection.new belongs_to: :space_federation, has_one: :spaceship,
158
+ before_shift: lambda do |shifting_rel:, shift_to:, shift_from:|
159
+ shifting_rel.each { |spaceship| spaceship.federation_changes += 1 }
160
+ end
83
161
  end
84
162
 
85
163
  class SpaceFederation < ActiveRecord::Base
86
164
  has_many :captains
87
165
  has_many :spaceships
88
166
 
89
- def sell_spaceship_to(nemesis_federation)
167
+ def all_spaceships_commandeered_by(nemesis_federation)
90
168
  Spaceship.shift_cx(shift_to: nemesis_federation, shift_from: self)
91
169
  end
92
170
  end
@@ -105,12 +183,63 @@ push git commits and the created tag, and push the `.gem` file to [rubygems.org]
105
183
 
106
184
  ## Contributing
107
185
 
108
- Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/shiftable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pboling/shiftable/blob/master/CODE_OF_CONDUCT.md).
186
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/shiftable. This project is intended to
187
+ be a safe, welcoming space for collaboration, and contributors are expected to adhere to
188
+ the [code of conduct](https://github.com/pboling/shiftable/blob/master/CODE_OF_CONDUCT.md).
189
+
190
+ ## Code of Conduct
191
+
192
+ Everyone interacting in the Shiftable project's codebases, issue trackers, chat rooms and mailing lists is expected to
193
+ follow the [code of conduct](https://github.com/pboling/shiftable/blob/master/CODE_OF_CONDUCT.md).
194
+
195
+ ## Versioning
196
+
197
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
198
+ bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
199
+ immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
200
+ major versions.
201
+
202
+ As a result of this policy, you can (and should) specify a dependency on this gem using
203
+ the [Pessimistic Version Constraint][pvc] with two digits of precision.
204
+
205
+ For example:
206
+
207
+ ```ruby
208
+ spec.add_dependency "shiftable", "~> 0.2"
209
+ ```
109
210
 
110
211
  ## License
111
212
 
112
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
213
+ The gem is available as open source under the terms of
214
+ the [MIT License](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
215
+ .
113
216
 
114
- ## Code of Conduct
217
+ * Copyright (c) 2021 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
218
+
219
+ [license]: LICENSE
220
+
221
+ [semver]: http://semver.org/
222
+
223
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
224
+
225
+ [railsbling]: http://www.railsbling.com
226
+
227
+ [peterboling]: http://www.peterboling.com
228
+
229
+ [aboutme]: https://about.me/peter.boling
230
+
231
+ [angelme]: https://angel.co/peter-boling
232
+
233
+ [coderme]:http://coderwall.com/pboling
234
+
235
+ [followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
236
+
237
+ [tweetme]: http://twitter.com/galtzo
238
+
239
+ [politicme]: https://nationalprogressiveparty.org
240
+
241
+ [documentation]: http://rdoc.info/github/pboling/shiftable/frames
242
+
243
+ [homepage]: https://github.com/pboling/shiftable/
115
244
 
116
- Everyone interacting in the Shiftable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/shiftable/blob/master/CODE_OF_CONDUCT.md).
245
+ [blogpage]: http://www.railsbling.com/tags/shiftable/
@@ -15,7 +15,7 @@
15
15
  module Shiftable
16
16
  # Inheriting from Module is a powerful pattern. If you like it checkout the debug_logging gem!
17
17
  class Collection < Module
18
- def initialize(belongs_to:, has_many:, method_prefix: nil, preflight_checks: true, before_save: nil)
18
+ def initialize(belongs_to:, has_many:, method_prefix: nil, preflight_checks: true, before_shift: nil)
19
19
  super()
20
20
  raise ArgumentError, "belongs_to must be a symbol" unless belongs_to.is_a?(Symbol)
21
21
  raise ArgumentError, "has_many must be a symbol" unless has_many.is_a?(Symbol)
@@ -37,24 +37,24 @@ module Shiftable
37
37
 
38
38
  # will prevent the save if it returns false
39
39
  # allows for any custom logic to be run, such as setting shift_from attributes, prior to the shift is saved.
40
- @before_save = before_save
40
+ @before_shift = before_shift
41
41
  end
42
42
 
43
43
  def extended(base)
44
44
  shift_cx_modulizer = ShiftCollectionModulizer.to_mod(@belongs_to, @has_many, @method_prefix,
45
- @before_save)
45
+ @before_shift)
46
46
  base.singleton_class.send(:prepend, shift_cx_modulizer)
47
47
  end
48
48
 
49
49
  def included(base)
50
50
  shift_cx_modulizer = ShiftCollectionModulizer.to_mod(@belongs_to, @has_many, @method_prefix,
51
- @before_save)
51
+ @before_shift)
52
52
  base.send(:prepend, shift_cx_modulizer)
53
53
  end
54
54
 
55
55
  # Creates anonymous Ruby Modules, containing dynamically built methods
56
56
  module ShiftCollectionModulizer
57
- def to_mod(belongs_to, has_many, mepr, before_save)
57
+ def to_mod(belongs_to, has_many, mepr, before_shift)
58
58
  Module.new do
59
59
  define_method(:"#{mepr}shift_cx_column") do
60
60
  reflection = reflect_on_association(belongs_to).klass.reflect_on_association(has_many)
@@ -78,7 +78,7 @@ module Shiftable
78
78
  shifting_rel.each do |shifting|
79
79
  shifting.send("#{send("#{mepr}shift_cx_column")}=", shift_to.id)
80
80
  end
81
- before_save&.call(shifting_rel: shifting_rel, shift_to: shift_to, shift_from: shift_from)
81
+ before_shift&.call(shifting_rel: shifting_rel, shift_to: shift_to, shift_from: shift_from)
82
82
  shifting_rel.each(&:save)
83
83
  shifting_rel
84
84
  end
@@ -21,7 +21,7 @@
21
21
  module Shiftable
22
22
  # Inheriting from Module is a powerful pattern. If you like it checkout the debug_logging gem!
23
23
  class Single < Module
24
- def initialize(belongs_to:, has_one:, method_prefix: nil, preflight_checks: true, before_save: nil)
24
+ def initialize(belongs_to:, has_one:, method_prefix: nil, preflight_checks: true, before_shift: nil)
25
25
  super()
26
26
  raise ArgumentError, "belongs_to must be a symbol" unless belongs_to.is_a?(Symbol)
27
27
  raise ArgumentError, "has_one must be a symbol" unless has_one.is_a?(Symbol)
@@ -46,24 +46,24 @@ module Shiftable
46
46
 
47
47
  # will prevent the save if it returns false
48
48
  # allows for any custom logic to be run, such as setting shift_from attributes, prior to the shift is saved.
49
- @before_save = before_save
49
+ @before_shift = before_shift
50
50
  end
51
51
 
52
52
  def extended(base)
53
53
  shift_single_modulizer = ShiftSingleModulizer.to_mod(@belongs_to, @has_one, @method_prefix, @preflight_checks,
54
- @before_save)
54
+ @before_shift)
55
55
  base.singleton_class.send(:prepend, shift_single_modulizer)
56
56
  end
57
57
 
58
58
  def included(base)
59
59
  shift_single_modulizer = ShiftSingleModulizer.to_mod(@belongs_to, @has_one, @method_prefix, @preflight_checks,
60
- @before_save)
60
+ @before_shift)
61
61
  base.send(:prepend, shift_single_modulizer)
62
62
  end
63
63
 
64
64
  # Creates anonymous Ruby Modules, containing dynamically built methods
65
65
  module ShiftSingleModulizer
66
- def to_mod(belongs_to, has_one, mepr, preflight_checks, before_save)
66
+ def to_mod(belongs_to, has_one, mepr, preflight_checks, before_shift)
67
67
  Module.new do
68
68
  define_method(:"#{mepr}shift_column") do
69
69
  reflection = reflect_on_association(belongs_to).klass.reflect_on_association(has_one)
@@ -90,7 +90,8 @@ module Shiftable
90
90
  return false unless shifting
91
91
 
92
92
  shifting.send("#{send("#{mepr}shift_column")}=", shift_to.id)
93
- shifting.save if before_save.nil? || before_save.call(shifting: shifting, shift_to: shift_to, shift_from: shift_from)
93
+ shifting.save if before_shift.nil? || before_shift.call(shifting: shifting, shift_to: shift_to,
94
+ shift_from: shift_from)
94
95
  end
95
96
  end
96
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shiftable
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiftable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-23 00:00:00.000000000 Z
11
+ date: 2021-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,112 +16,112 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1'
20
20
  type: :runtime
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: '0'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '11.1'
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: '0'
40
+ version: '11.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: database_cleaner-active_record
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: factory_bot
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '6.2'
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'
68
+ version: '6.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faker
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.19'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '2.19'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '13'
89
+ version: '13.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '13'
96
+ version: '13.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3'
103
+ version: '3.10'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3'
110
+ version: '3.10'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec-block_is_expected
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '1.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '1.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -136,90 +136,160 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-faker
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.1'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rubocop-md
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - ">="
157
+ - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '0'
159
+ version: '1.0'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - ">="
164
+ - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '0'
166
+ version: '1.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-minitest
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.15'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.15'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-packaging
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.5'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.5'
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: rubocop-performance
155
197
  requirement: !ruby/object:Gem::Requirement
156
198
  requirements:
157
- - - ">="
199
+ - - "~>"
158
200
  - !ruby/object:Gem::Version
159
- version: '0'
201
+ version: '1.11'
160
202
  type: :development
161
203
  prerelease: false
162
204
  version_requirements: !ruby/object:Gem::Requirement
163
205
  requirements:
164
- - - ">="
206
+ - - "~>"
165
207
  - !ruby/object:Gem::Version
166
- version: '0'
208
+ version: '1.11'
167
209
  - !ruby/object:Gem::Dependency
168
210
  name: rubocop-rake
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
- - - ">="
213
+ - - "~>"
172
214
  - !ruby/object:Gem::Version
173
- version: '0'
215
+ version: '0.6'
174
216
  type: :development
175
217
  prerelease: false
176
218
  version_requirements: !ruby/object:Gem::Requirement
177
219
  requirements:
178
- - - ">="
220
+ - - "~>"
179
221
  - !ruby/object:Gem::Version
180
- version: '0'
222
+ version: '0.6'
181
223
  - !ruby/object:Gem::Dependency
182
224
  name: rubocop-rspec
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - "~>"
186
228
  - !ruby/object:Gem::Version
187
- version: '2.0'
229
+ version: '2.5'
188
230
  type: :development
189
231
  prerelease: false
190
232
  version_requirements: !ruby/object:Gem::Requirement
191
233
  requirements:
192
234
  - - "~>"
193
235
  - !ruby/object:Gem::Version
194
- version: '2.0'
236
+ version: '2.5'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop-rspec-focused
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '1.0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '1.0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rubocop-thread_safety
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0.4'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '0.4'
195
265
  - !ruby/object:Gem::Dependency
196
266
  name: simplecov
197
267
  requirement: !ruby/object:Gem::Requirement
198
268
  requirements:
199
- - - ">="
269
+ - - "~>"
200
270
  - !ruby/object:Gem::Version
201
- version: '0'
271
+ version: '0.21'
202
272
  type: :development
203
273
  prerelease: false
204
274
  version_requirements: !ruby/object:Gem::Requirement
205
275
  requirements:
206
- - - ">="
276
+ - - "~>"
207
277
  - !ruby/object:Gem::Version
208
- version: '0'
278
+ version: '0.21'
209
279
  - !ruby/object:Gem::Dependency
210
280
  name: sqlite3
211
281
  requirement: !ruby/object:Gem::Requirement
212
282
  requirements:
213
- - - ">="
283
+ - - "~>"
214
284
  - !ruby/object:Gem::Version
215
- version: '0'
285
+ version: '1'
216
286
  type: :development
217
287
  prerelease: false
218
288
  version_requirements: !ruby/object:Gem::Requirement
219
289
  requirements:
220
- - - ">="
290
+ - - "~>"
221
291
  - !ruby/object:Gem::Version
222
- version: '0'
292
+ version: '1'
223
293
  - !ruby/object:Gem::Dependency
224
294
  name: yard
225
295
  requirement: !ruby/object:Gem::Requirement
@@ -242,17 +312,10 @@ executables: []
242
312
  extensions: []
243
313
  extra_rdoc_files: []
244
314
  files:
245
- - ".rspec"
246
- - ".rubocop.yml"
247
- - ".rubocop_todo.yml"
248
315
  - CHANGELOG.md
249
316
  - CODE_OF_CONDUCT.md
250
- - Gemfile
251
317
  - LICENSE.txt
252
318
  - README.md
253
- - Rakefile
254
- - bin/console
255
- - bin/setup
256
319
  - lib/shiftable.rb
257
320
  - lib/shiftable/collection.rb
258
321
  - lib/shiftable/single.rb
@@ -272,7 +335,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
335
  requirements:
273
336
  - - ">="
274
337
  - !ruby/object:Gem::Version
275
- version: 2.6.0
338
+ version: '2.5'
276
339
  required_rubygems_version: !ruby/object:Gem::Requirement
277
340
  requirements:
278
341
  - - ">="
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,100 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- AllCops:
4
- NewCops: enable
5
- TargetRubyVersion: 2.6
6
-
7
- Gemspec/DateAssignment: # new in 1.10
8
- Enabled: true
9
- Layout/LineEndStringConcatenationIndentation: # new in 1.18
10
- Enabled: true
11
- Layout/SpaceBeforeBrackets: # new in 1.7
12
- Enabled: true
13
- Lint/AmbiguousAssignment: # new in 1.7
14
- Enabled: true
15
- Lint/AmbiguousOperatorPrecedence: # new in 1.21
16
- Enabled: true
17
- Lint/AmbiguousRange: # new in 1.19
18
- Enabled: true
19
- Lint/DeprecatedConstants: # new in 1.8
20
- Enabled: true
21
- Lint/DuplicateBranch: # new in 1.3
22
- Enabled: true
23
- Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
24
- Enabled: true
25
- Lint/EmptyBlock: # new in 1.1
26
- Enabled: true
27
- Lint/EmptyClass: # new in 1.3
28
- Enabled: true
29
- Lint/EmptyInPattern: # new in 1.16
30
- Enabled: true
31
- Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
32
- Enabled: true
33
- Lint/LambdaWithoutLiteralBlock: # new in 1.8
34
- Enabled: true
35
- Lint/NoReturnInBeginEndBlocks: # new in 1.2
36
- Enabled: true
37
- Lint/NumberedParameterAssignment: # new in 1.9
38
- Enabled: true
39
- Lint/OrAssignmentToConstant: # new in 1.9
40
- Enabled: true
41
- Lint/RedundantDirGlobSort: # new in 1.8
42
- Enabled: true
43
- Lint/RequireRelativeSelfPath: # new in 1.22
44
- Enabled: true
45
- Lint/SymbolConversion: # new in 1.9
46
- Enabled: true
47
- Lint/ToEnumArguments: # new in 1.1
48
- Enabled: true
49
- Lint/TripleQuotes: # new in 1.9
50
- Enabled: true
51
- Lint/UnexpectedBlockArity: # new in 1.5
52
- Enabled: true
53
- Lint/UnmodifiedReduceAccumulator: # new in 1.1
54
- Enabled: true
55
- Security/IoMethods: # new in 1.22
56
- Enabled: true
57
- Style/ArgumentsForwarding: # new in 1.1
58
- Enabled: true
59
- Style/CollectionCompact: # new in 1.2
60
- Enabled: true
61
- Style/DocumentDynamicEvalDefinition: # new in 1.1
62
- Enabled: true
63
- Style/EndlessMethod: # new in 1.8
64
- Enabled: true
65
- Style/HashConversion: # new in 1.10
66
- Enabled: true
67
- Style/HashExcept: # new in 1.7
68
- Enabled: true
69
- Style/IfWithBooleanLiteralBranches: # new in 1.9
70
- Enabled: true
71
- Style/InPatternThen: # new in 1.16
72
- Enabled: true
73
- Style/MultilineInPatternThen: # new in 1.16
74
- Enabled: true
75
- Style/NegatedIfElseCondition: # new in 1.2
76
- Enabled: true
77
- Style/NilLambda: # new in 1.3
78
- Enabled: true
79
- Style/NumberedParameters: # new in 1.22
80
- Enabled: true
81
- Style/NumberedParametersLimit: # new in 1.22
82
- Enabled: true
83
- Style/QuotedSymbols: # new in 1.16
84
- Enabled: true
85
- Style/RedundantArgument: # new in 1.4
86
- Enabled: true
87
- Style/RedundantSelfAssignmentBranch: # new in 1.19
88
- Enabled: true
89
- Style/SelectByRegexp: # new in 1.22
90
- Enabled: true
91
- Style/StringChars: # new in 1.12
92
- Enabled: true
93
- Style/StringLiterals:
94
- Enabled: true
95
- EnforcedStyle: double_quotes
96
- Style/StringLiteralsInInterpolation:
97
- Enabled: true
98
- EnforcedStyle: double_quotes
99
- Style/SwapValues: # new in 1.1
100
- Enabled: true
data/.rubocop_todo.yml DELETED
@@ -1,67 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2021-10-23 10:42:13 UTC using RuboCop version 1.22.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
12
- Lint/UnusedMethodArgument:
13
- Exclude:
14
- - 'lib/shiftable/collection.rb'
15
-
16
- # Offense count: 2
17
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
18
- Metrics/AbcSize:
19
- Max: 29
20
-
21
- # Offense count: 13
22
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
23
- # IgnoredMethods: refine
24
- Metrics/BlockLength:
25
- Max: 87
26
-
27
- # Offense count: 2
28
- # Configuration parameters: IgnoredMethods.
29
- Metrics/CyclomaticComplexity:
30
- Max: 11
31
-
32
- # Offense count: 2
33
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
34
- Metrics/MethodLength:
35
- Max: 25
36
-
37
- # Offense count: 2
38
- # Configuration parameters: IgnoredMethods.
39
- Metrics/PerceivedComplexity:
40
- Max: 11
41
-
42
- # Offense count: 1
43
- Style/CombinableLoops:
44
- Exclude:
45
- - 'spec/shiftable/collection_spec.rb'
46
-
47
- # Offense count: 4
48
- # Cop supports --auto-correct.
49
- Style/EvalWithLocation:
50
- Exclude:
51
- - 'spec/shiftable/collection_spec.rb'
52
- - 'spec/shiftable/single_spec.rb'
53
-
54
- # Offense count: 1
55
- # Cop supports --auto-correct.
56
- # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
57
- # AllowedMethods: present?, blank?, presence, try, try!
58
- Style/SafeNavigation:
59
- Exclude:
60
- - 'lib/shiftable/collection.rb'
61
-
62
- # Offense count: 7
63
- # Cop supports --auto-correct.
64
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
65
- # URISchemes: http, https
66
- Layout/LineLength:
67
- Max: 130
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in shiftable.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,12 +0,0 @@
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
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "shiftable"
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/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here