0.0
No commit activity in last 3 years
No release in over 3 years
CCLS Common Lib gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

CCLS Common Lib¶ ↑

After further pondering, I think that I’m just going to fork all of the jakewendt repo/gems into ccls and then to use the ccls-* gem instead.

I’ve included ruby_extension and rails_extension. Working on simply_helpful. Next up will be simply_authorized.

Some of these extensions and additions are not actually used on any of the CCLS sites, but were part of my original gems. There existance should not cause any problems.


This ruby gem ( ccls-common_lib ) is meant to include all of the current functionality provided by …

This gem would then be used by ALL of the ccls apps and the engine and the aforementioned gems can and should be removed from the machines to avoid accidental usage. The following would be kept separate and used only for testing only by this gem. SimplySessions might actually be includable within just the test environment of CommonLib.

And the following would be used by ALL ccls apps and gems and probably included in the config/environments/test.rb as “config.gem ‘ccls-html_test’”

Unfortunately, this has all gotten kinda muddled, making it a bit confusing. This would take at least a day of importing and merging and testing and installing and testing and …


Date.today¶ ↑

DO NOT USE Date.today, unless the following is what you want.

It will compute a Date and disregard the time zone.

In rails, this means that occassionally Date.today == Date.tomorrow or Date.today == Date.yesterday, depending on what time it is.

The Rails methods of Date.tomorrow and Date.yesterday reference Date.current, which uses the Time.zone, making them more accurate.

I think that DateTime.now and Time.now also ignore the timezone.

Use DateTime.current or Time.zone.now


validations_from_yaml_file¶ ↑

This ActiveRecord::Base method takes no arguments and is straight forward but deserves a few notes.

Firstly, it will look for a ‘.yml’ file in config/validations/ with the class name underscored.

Each entry is read in as a hash and passed to ‘validates’.

Most validations are straight forward, with 2 current exceptions. I tried many ways. Searched online for some time. Got a lot of negative feedback. Mostly “why do it”, “don’t do it”, “not standard”, blah, blah. So. Of course I did it anyway. The 2 objects that cause the most confusion are ranges, useful in length limitations, and regexps, useful in formatting emails, ssns, zip codes, phone numbers, … The solution is rather simple and built in to ruby. These things simply need a bit to declare what object they are.

  • Ranges

    • :in: !ruby/range 4..250

  • Regular Expressions

    • :with: !ruby/regexp ‘/^([w.%+-]+)@(\.)([w]{2,})$/i’

    • note that the single quotes around the regexp are unneccessary and problematic if the regex contains one.

For other references, see …

codereview.stackexchange.com/questions/159/use-of-a-regex-stored-inside-yaml-file

stackoverflow.com/questions/3337020/how-to-specify-ranges-in-yaml

www.opensource.apple.com/source/ruby/ruby-14/ruby/lib/yaml/rubytypes.rb

yaml4r.sourceforge.net/doc/page/objects_in_yaml.htm

Or …

/opt/local/lib/ruby1.9/1.9.1/syck/rubytypes.rb
/opt/local/lib/ruby1.9/1.9.1/psych/visitors/to_ruby.rb

Testing¶ ↑


sudo /opt/local/share/mariadb/support-files/mysql.server start

c ; /bin/rm -rf coverage* ; bundle exec rake ; mv coverage coverage-one-run ; open coverage-one-run/index.html ; nice +20 bundle exec autotest -v  --no-full-after-failed

FIX THESE … Unable to map class FormBuilderTest to a file Unable to map class BaseTest to a file


Gemified with Jeweler¶ ↑

vi Rakefile
rake version:write

rake version:bump:patch
rake version:bump:minor
rake version:bump:major

rake gemspec

rake install
rake release

Copyright © 2010 [Jake Wendt], released under the MIT license