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
Full support for Mongoid support + by_quarter + by_calendar_month + fixes for using Date class #14
Commits on Jan 5, 2013
-
Added support for Mongoid (adapter for MongoDB). It's basically a mon…
…key-patch file (see: lib/mongoid/by_star.rb) with a small change at the end of lib/by_star.rb to detect inclusion of ActiveRecord and/or Mongoid. I refactored the specs so that the exact same specs can be run by both Mongoid and ActiveRecord seamlessly (core specs now moved to /spec/by_star/generic). I am able to pass 49/60 ActiveRecord specs (i.e. prior to this commit; I have not introduced any regressions) and 50/60 Mongoid test--basically the same ones fail, the only exception is "by year/should be able to order the result set" which I believe is genuinely broken on Mongoid due to API differences. Updated readme as well.
-
Moved failing Mongoid case to ActiveRecord only. After investigation …
…seems the case is failing due to how the test code is written (AR-specific), not due to Mongoid features.
Commits on Jan 6, 2013
-
Refactoring of test specs so that both ActiveRecord and Mongoid tests…
… can be run cleanly in one master run
-
Add test cases to verify that the object return type of Model.between…
… method is correct for both AR and Mongoid
Commits on Jan 7, 2013
Commits on Jan 27, 2013
-
Adding support for by_month as Date datatype (in addition to Time dat…
…atype currently supported)
-
Added #between_times as an alias of #between, since between is likely…
… to be used by other gems (it was in my case).
-
Added new method "by_calendar_month". This is similar to by_month, bu…
…t it also includes any results which fall in the same week as the first and last of the month. Useful for displaying monthly calendars. (This is based on a real-world use case I encountered in my app).
-
Bug fix: when by_month and by_week accept a Date, must convert date.t…
…o_time first. The reason is this is that Date.end_of_week and Date.end_of_month under some conditions yield the *beginning* of the last day, rather than the end, so the query misses the last day of the period. Probably this fix is required everywhere Date type is used.
-
Added new by_quarter method for 3-month quarter period. Following a s…
…imilar pattern as other methods: x.by_quarter() gets all results from current quarter x.by_quarter(n) gets all results from the nth quarter of current year (e.g. n=2 means Apr thru Jun). Optional :year parameter can be given. x.by_quarter(date) gets all results from the quarter of date given