Revision 1298:4f746d8966dd lib/redmine/core_ext
| lib/redmine/core_ext/active_record.rb | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| ... | ... | |
| 38 | 38 |
end |
| 39 | 39 |
end |
| 40 | 40 |
end |
| 41 |
|
|
| 42 |
class DateValidator < ActiveModel::EachValidator |
|
| 43 |
def validate_each(record, attribute, value) |
|
| 44 |
before_type_cast = record.attributes_before_type_cast[attribute.to_s] |
|
| 45 |
if before_type_cast.is_a?(String) && before_type_cast.present? |
|
| 46 |
# TODO: #*_date_before_type_cast returns a Mysql::Time with ruby1.8+mysql gem |
|
| 47 |
unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value
|
|
| 48 |
record.errors.add attribute, :not_a_date |
|
| 49 |
end |
|
| 50 |
end |
|
| 51 |
end |
|
| 52 |
end |
|
| lib/redmine/core_ext/date/calculations.rb | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| lib/redmine/core_ext/string/conversions.rb | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| lib/redmine/core_ext/string/inflections.rb | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
Also available in: Unified diff