-
Notifications
You must be signed in to change notification settings - Fork 13
Add Ruby 2.3, 2.4, 2.5, and 2.6 and Mongoid 6 and 7 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I had to drop builds for Ruby 1.9.3. It doesn't seem to install on Travis any more and it's very old, so I don't think there's a good reason to maintain support for that. |
This fixes the error below: An error occurred while loading ./spec/array_spec.rb. Failure/Error: include ActiveSupport::Callbacks NoMethodError: undefined method `class_attribute' for Mongoid::CachedJson::Config:Module
spec/support/json_manager.rb
Outdated
@@ -5,7 +5,12 @@ class JsonManager | |||
field :name | |||
field :ssn, default: '123-45-6789' | |||
has_many :json_employees | |||
belongs_to :supervisor, class_name: 'JsonSupervisor' | |||
|
|||
if Mongoid::VERSION < "6.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a valid comparison! Use https://github.com/mongoid/mongoid-compatibility 's Mongoid::Compatibility::Version.mongoid6_or_older?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is totally a valid comparison that people think is silly that works totally fine:
"6.0.1" < "6.0.0" # => false
"6.0.0" < "6.0.0" # => false
"5.10.10" < "6.0.0" # => true
"5.9.9" < "6.0.0" # => true
I don't think we need a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take a dependency?
"6.0.0" > "6.0"
# => true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that the dependency would only be for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example that fails.
"6.0.0" < "6.0.0.beta"
# => true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use Gem::Version
if a more accurate comparison is necessary:
Gem::Version.new("6.0.0") < Gem::Version.new("6.0") # => false
Gem::Version.new("6.0.1") < Gem::Version.new("6.0.0") # => false
Gem::Version.new("6.0.0") < Gem::Version.new("6.0.0") # => false
Gem::Version.new("5.10.10") < Gem::Version.new("6.0.0") # => true
Gem::Version.new("5.9.9") < Gem::Version.new("6.0.0") # => true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what mongoid-compatibility does, but smarter and future-proof as it checks major version only and has semantic verbs like mongoid6_or_older?
which are easier to read. It just has been convention in mongoid projects since we were doing these comparisons in 10 different ways all over the place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as it checks major version only and has semantic verbs like mongoid6_or_older? which are easier to read.
This doesn't sound like a strong counter objection when the Gem::Version
comparizon is very simple and easy to understand. Is this something that might take more than an hour to understand, or something that really requires encapsulation?
since we were doing these comparisons in 10 different ways all over the place.
Here we are not trying to understand 10 different sorting algorithms, but just a version comparison, basically a number comparison internally in Gem::Version
. Also, could you actually really list 10 different examples? I have seen a few, but I'm sure it doesn't exceed 10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed it's already a dependency of this project, so I just switched it anyway. However, I'm not convinced that this is a better way as Gem::Version
is a more generic abstraction that can be used almost anywhere else, and it doesn't require any specific knowledge about Mongoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's all a small deal and either works!
Rakefile
Outdated
@@ -1,7 +1,9 @@ | |||
# frozen_string_literal: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should go away, we either do it everywhere or nowhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubocop disagrees. What would you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it stopped complaining about it after running with a --auto-gen-config
config, so this should be good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with it.
Personally, I like these to be consistent. So I generally don't have the #frozen
in there and disable it in Rubocop or --auto-gen-config
. This was added in this diff, that's why I am calling it out. You could revert this file and re-run --auto-gen-config
and it would be better.
Rakefile
Outdated
@@ -31,4 +33,8 @@ end | |||
require 'rubocop/rake_task' | |||
RuboCop::RakeTask.new | |||
|
|||
task default: [:rubocop, :spec] | |||
if RUBY_VERSION >= '2.6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Just to save Running rubocop? This feels like it assumes content in .travis.yml and will be hard to debug. Furthermore anyone contributing on Ruby 2.5.3 will forget that Rubocop runs until they push and get a failure. How about changing the rake
parameters in .travis.yml
and running rubocop
for only one matrix line in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I was able to add a separate build that only runs rake rubocop
and the default rake
now only runs the spec
task.
CHANGELOG.md
Outdated
------------ | ||
|
||
* Your contribution here. | ||
* Compatibility with Ruby 2.3, 2.4, 2.5 and 2.6 - [@yuki24](http://github.com/yuki24). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Care to prefix these with a PR link?
[#20](https://github.com/mongoid/mongoid-cached-json/pull/20): Compatibility ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The README contains a Compatibility section that also needs to be updated. Also since it no longer works, please get rid of the gemnasium badge while you're there.
@yuki24 I also invited you to collaborators on this repo cause I know you're dying to co-maintain this and make the next release :) Drop me your rubygems email to dblock at dblock dot org? |
peon = manager.json_employees.create(name: 'Peon') | ||
manager.json_employees.create(name: 'Indentured servant') | ||
manager.json_employees.create(name: 'Serf', nickname: 'Vince') | ||
manager = JsonManager.create!(name: 'Boss') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
CHANGELOG.md
Outdated
@@ -1,7 +1,10 @@ | |||
1.5.4 (Next) | |||
2.0.0 (Next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump version.rb or undo.
Since the next version is actually compatible with newer mongoid's without changes, and the only "breaking" change is that we drop testing or support on 1.9.3, I would just leave it as 1.5.4, but up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the next version will probably be compatible with 1.9.3. What version would you prefer? 1.6.0
or you still prefer 1.5.4
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've picked up 1.6.0
to follow semver, but let me know if you have any other preferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works!
- rvm: 2.1.10 | ||
env: MONGOID_VERSION=7 | ||
allow_failures: | ||
- env: MONGOID_VERSION=7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, I couldn't get the builds for Mongoid 7 so leaving this here for now, but I would like to get them pass once I have enough time to fix them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's deal with that next.
@@ -31,4 +31,4 @@ end | |||
require 'rubocop/rake_task' | |||
RuboCop::RakeTask.new | |||
|
|||
task default: [:rubocop, :spec] | |||
task default: :spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dblock are you okay with this? I think this might be suprizing for people who use Rubocop regularly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave the default as is and run both. This is just because it has been this way for a long time and we like having rubocop in the mongoid org.
I merged this as is. Let's deal with the other issues next. |
Thanks for your good work @yuki24 ! |
For Mongoid 7, the changes should be minimal with |
It seems like this repo is a bit behind the pace and I thought we should test against more recent versions of Ruby and Mongoid. I got most of the new builds green except for Mongoid 7.