Refactor + New Features + All Specs passing #32

Merged
merged 40 commits into from Jan 14, 2014

Conversation

Projects
None yet
3 participants
Collaborator

johnnyshields commented Jan 11, 2014

This is a large set of changes but it is well tested, with spec count now at 286 (was ~150) and all specs passing. In a nutshell, I've greatly DRY'ed up the code and standardized methods, and added some useful features along the way.

Despite new functionality added there's about a 20% reduction in lines of code overall, and CodeClimate has also improved somewhat.

New Features

  • Support matching timespan-type objects with distinct start and end times (previously only point-in-time matching was supported). By default, will match objects which either start OR end within the desired period; you can change this to AND using the :strict => true
  • Add :offset option to all query methods, in order to offset the time the day begins/ends (for example supposing business cycle begins at 8:00 each day until 7:59:59 the next day)
  • Add Time kernel extensions for fortnight and calendar_month

Other Changes

  • Begin tracking CHANGELOG
  • Drop official support for Ruby <= 1.9.2
  • Add Ruby 2.1.0, Rubinius, and JRuby to Travis
  • Decouple gem from ActiveRecord, and put ActiveRecord and Mongoid specific methods in ORM modules.
  • Consolidate all normalization/parsing functions into new Normalization module
  • Remove meta-programming methods, e.g. send("by_week_#{time_klass}")
  • Make Chronic gem optional; use it only if user has included it externally
  • by_week always returns a calendar week (i.e. beginning Monday or as specified by Rails setting), regardless of whether Date or Fixnum is given as a parameter.
  • by_week and by_calendar_month now supports optional :start_day option (:monday, :tuesday, etc)
  • Separate by_calendar_month into it's own class
  • Rename between to between_times internally, as Mongoid already defines between. ActiveRecord has an alias of between to interface stays consistent.
  • by_weekend can now take a fixnum (parsing logic is same as by_week)
  • Two-digit year now considers 70 to be 1970, and 69 to be 2069 (was previously 40 -> 1940)
  • Add myself as a gem co-author

johnnyshields added some commits Nov 12, 2013

@johnnyshields johnnyshields - Support "Time-Range" type objects by allowing optional start and en…
…d time parameters such as:

   by_star_field :start_time, :end_time

(This is fully backwards compatible)
- Restructure classes/dirs to be more agnostic toward AR vs. Mongoid
- Consolidate shared methods between AR and Mongoid into a ByStar::Base object
- ActiveRecord should be dev dependency. ActiveSupport should be prod dependency
- Use ActiveSupport::Concern
0988bdb
@johnnyshields johnnyshields Simply start / end accessor methods e88aeeb
@johnnyshields johnnyshields Both before and after methods should reference start time for time-ra…
…nge type objects
52a0df6
@johnnyshields johnnyshields Change order of options precedence faef21b
@johnnyshields johnnyshields - Add strict mode for TimeRange type queries
- Non-strict mode (permissive) should use gt/lt rather than gte/lte
9e116a1
@johnnyshields johnnyshields * Drop official support for Ruby <= 1.9.2
* Add Ruby 2.1.0, Rubinius, and JRuby to Travis
b052e1e
@johnnyshields johnnyshields Move time_ext to kernel folder b31b947
@johnnyshields johnnyshields Cleanup Gemspec, add Johnny Shields as co-author a988269
@johnnyshields johnnyshields Add Ryan Bigg to license fe701b6
@johnnyshields johnnyshields Use more terse syntax in Gemfile e19217e
@johnnyshields johnnyshields * Begin tracking CHANGELOG
* Consolidate all normalization/parsing functions into new Normalization module
* Remove meta-programming methods, e.g. `send("by_week_#{time_klass}")`
* Make Chronic gem optional; use it only if user has included it externally
* by_week always returns a calendar week (i.e. beginning Monday or as specified by Rails setting), regardless of whether Date or Fixnum is given as a parameter.
* by_week and by_calendar_month now supports optional :start_day option (:monday, :tuesday, etc)
* by_weekend can now take a fixnum (parsing logic is same as by_week)
d258311
@johnnyshields johnnyshields Fix broken specs aa52f7d
@johnnyshields johnnyshields * Consolidate time/options parsing
* Separate by_calendar_month into it's own class
f9d4596
@johnnyshields johnnyshields Add Time kernel extension for beginning/end_of_fortnight 377bf5f
@johnnyshields johnnyshields Rename spec folder to "integration" 9f34ba4
@johnnyshields johnnyshields Cleanup extra methods b326542
@johnnyshields johnnyshields Code cleanup in ORM classes 7bb77df
@johnnyshields johnnyshields * Rename `between` to `between_times` internally, as Mongoid already …
…defines `between`. ActiveRecord has an alias of `between` to interface stays consistent.
b435d20
@johnnyshields johnnyshields Add Time kernel extensions spec 6395232
@johnnyshields johnnyshields Simplify beginning_of_weekend method 4f8add5
@johnnyshields johnnyshields Add note to changelog about :offset feature a72b183
@johnnyshields johnnyshields * Unit-test specs for normalization
* Two-digit year now considers 70 to be 1970, and 69 to be 2069 (was previously 40 -> 1940)
d59e451
@johnnyshields johnnyshields Delete unused model classes from specs 55db5f0
@johnnyshields johnnyshields All specs passing! 4d4b4fb
@johnnyshields johnnyshields Randomize timezone in spec runs 62bc105
@johnnyshields johnnyshields Add specs for :start_day option e792f3f
@johnnyshields johnnyshields Update README b868d57
@johnnyshields johnnyshields Specs: require of active_support is redundant with active_record/mongoid f6a7283
Collaborator

johnnyshields commented Jan 12, 2014

@fny please take a look

Contributor

fny commented Jan 13, 2014

Exciting. I'll have a look around later this evening.

Owner

radar commented Jan 14, 2014

FLAWLESS VICTORY.

❤️

@radar radar added a commit that referenced this pull request Jan 14, 2014

@radar radar Merge pull request #32 from johnnyshields/master
Refactor + New Features + All Specs passing
88131f4

@radar radar merged commit 88131f4 into radar:master Jan 14, 2014

1 check passed

default The Travis CI build passed
Details

johnnyshields referenced this pull request Jan 14, 2014

Closed

Make Specs Pass for v2.1.0 #30

1 of 9 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment