validates_timeliness 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ = 1.1.7 [2009-03-26]
2
+ - Minor change to multiparameter attributes which I had not properly implemented for chaining
3
+
1
4
  = 1.1.6 [2009-03-19]
2
5
  - Rail 2.3 support
3
6
  - Added :with_date and :with_time options. They allow an attribute to be combined with another attribute or value to make a datetime value for validation against the temporal restrictions
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "validates_timeliness"
8
- GEM_VERSION = "1.1.6"
8
+ GEM_VERSION = "1.1.7"
9
9
  AUTHOR = "Adam Meehan"
10
10
  EMAIL = "adam.meehan@gmail.com"
11
11
  HOMEPAGE = "http://github.com/adzap/validates_timeliness"
data/TODO CHANGED
@@ -1,3 +1,7 @@
1
1
  - :format option
2
2
  - valid formats could come from locale file
3
3
  - add replace_formats instead add_formats :before
4
+ - array of values to all temporal options
5
+ - use tz value from time string?
6
+ - move make_time out of AR
7
+
@@ -16,18 +16,16 @@ module ValidatesTimeliness
16
16
  def execute_callstack_for_multiparameter_attributes_with_timeliness(callstack)
17
17
  errors = []
18
18
  callstack.each do |name, values|
19
- klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
20
- if values.empty?
21
- send(name + "=", nil)
22
- else
23
- column = column_for_attribute(name)
19
+ column = column_for_attribute(name)
20
+ if column && [:date, :time, :datetime].include?(column.type)
24
21
  begin
25
- value = if [:date, :time, :datetime].include?(column.type)
26
- time_array_to_string(values, column.type)
22
+ callstack.delete(name)
23
+ if values.empty?
24
+ send("#{name}=", nil)
27
25
  else
28
- klass.new(*values)
26
+ value = time_array_to_string(values, column.type)
27
+ send("#{name}=", value)
29
28
  end
30
- send(name + "=", value)
31
29
  rescue => ex
32
30
  errors << ::ActiveRecord::AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
33
31
  end
@@ -36,10 +34,11 @@ module ValidatesTimeliness
36
34
  unless errors.empty?
37
35
  raise ::ActiveRecord::MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
38
36
  end
37
+ execute_callstack_for_multiparameter_attributes_without_timeliness(callstack)
39
38
  end
40
39
 
41
40
  def time_array_to_string(values, type)
42
- values = values.map(&:to_s)
41
+ values = values.map {|v| v.to_s }
43
42
 
44
43
  case type
45
44
  when :date
@@ -57,7 +56,8 @@ module ValidatesTimeliness
57
56
  end
58
57
 
59
58
  def extract_time_from_multiparameter_attributes(values)
60
- values.last(3).map { |s| s.rjust(2, "0") }.join(":")
59
+ values = values.size > 3 ? values[3..5] : values
60
+ values.map { |s| s.rjust(2, "0") }.join(":")
61
61
  end
62
62
 
63
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_timeliness
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
@@ -9,7 +9,7 @@ autorequire: validates_timeliness
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-19 00:00:00 +11:00
12
+ date: 2009-03-26 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies: []
15
15