paper_trail_changes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -80,7 +80,16 @@ class PaperTrailChanges
80
80
  changed = true if last_val.to_i != val.to_i
81
81
  changed = true if last_val == nil && val
82
82
  elsif type == :boolean
83
- bool_i = last_val ? 1 : 0
83
+ if last_val == true
84
+ bool_i = 1
85
+ elsif last_val == false
86
+ bool_i = 0
87
+ elsif last_val.to_i == 1
88
+ bool_i = 1
89
+ elsif last_val.to_i == 0
90
+ bool_i = 0
91
+ end
92
+
84
93
  changed = true if bool_i != val.to_i
85
94
  changed = true if last_val == nil && val
86
95
  else
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "paper_trail_changes"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kaspernj"]
12
- s.date = "2013-08-15"
12
+ s.date = "2013-09-12"
13
13
  s.description = "A gem to do various stuff with PaperTrail versions."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -9,14 +9,16 @@ end
9
9
  describe "PaperTrailChanges" do
10
10
  it "should handle booleans" do
11
11
  changes = PaperTrailChanges.changes_hash(
12
- :attributes => {"works" => "1", "fails" => 0, "doesnt_fail" => "1"},
13
- :version_hash => {"works" => true, "fails" => false, "doesnt_fail" => false},
14
- :column_types => {"works" => :boolean, "fails" => :boolean, "doesnt_fail" => :boolean}
12
+ :attributes => {"works" => "1", "fails" => 0, "doesnt_fail" => "1", "reverts_to_false" => ""},
13
+ :version_hash => {"works" => true, "fails" => false, "doesnt_fail" => false, "reverts_to_false" => true},
14
+ :column_types => {"works" => :boolean, "fails" => :boolean, "doesnt_fail" => :boolean, "reverts_to_false" => :boolean}
15
15
  )
16
16
 
17
- changes.length.should eql(1)
17
+ changes.length.should eql(2)
18
18
  changes.keys.first.should eql("doesnt_fail")
19
19
  changes.values.first.should eql("1")
20
+ changes.keys.should include("reverts_to_false")
21
+ changes["reverts_to_false"].should eql("")
20
22
  end
21
23
 
22
24
  it "should handle integers" do
metadata CHANGED
@@ -2,95 +2,95 @@
2
2
  name: paper_trail_changes
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - kaspernj
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ prerelease: false
16
+ name: string-cases
17
+ type: :runtime
15
18
  version_requirements: !ruby/object:Gem::Requirement
16
- none: false
17
19
  requirements:
18
20
  - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: '0'
21
- name: string-cases
22
- type: :runtime
23
- prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
25
23
  none: false
24
+ requirement: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: '0'
29
+ none: false
30
30
  - !ruby/object:Gem::Dependency
31
+ prerelease: false
32
+ name: rspec
33
+ type: :development
31
34
  version_requirements: !ruby/object:Gem::Requirement
32
- none: false
33
35
  requirements:
34
36
  - - ~>
35
37
  - !ruby/object:Gem::Version
36
38
  version: 2.8.0
37
- name: rspec
38
- type: :development
39
- prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
41
39
  none: false
40
+ requirement: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ~>
44
43
  - !ruby/object:Gem::Version
45
44
  version: 2.8.0
45
+ none: false
46
46
  - !ruby/object:Gem::Dependency
47
+ prerelease: false
48
+ name: rdoc
49
+ type: :development
47
50
  version_requirements: !ruby/object:Gem::Requirement
48
- none: false
49
51
  requirements:
50
52
  - - ~>
51
53
  - !ruby/object:Gem::Version
52
54
  version: '3.12'
53
- name: rdoc
54
- type: :development
55
- prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
57
55
  none: false
56
+ requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ~>
60
59
  - !ruby/object:Gem::Version
61
60
  version: '3.12'
61
+ none: false
62
62
  - !ruby/object:Gem::Dependency
63
+ prerelease: false
64
+ name: bundler
65
+ type: :development
63
66
  version_requirements: !ruby/object:Gem::Requirement
64
- none: false
65
67
  requirements:
66
68
  - - ! '>='
67
69
  - !ruby/object:Gem::Version
68
70
  version: 1.0.0
69
- name: bundler
70
- type: :development
71
- prerelease: false
72
- requirement: !ruby/object:Gem::Requirement
73
71
  none: false
72
+ requirement: !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - ! '>='
76
75
  - !ruby/object:Gem::Version
77
76
  version: 1.0.0
77
+ none: false
78
78
  - !ruby/object:Gem::Dependency
79
+ prerelease: false
80
+ name: jeweler
81
+ type: :development
79
82
  version_requirements: !ruby/object:Gem::Requirement
80
- none: false
81
83
  requirements:
82
84
  - - ~>
83
85
  - !ruby/object:Gem::Version
84
86
  version: 1.8.4
85
- name: jeweler
86
- type: :development
87
- prerelease: false
88
- requirement: !ruby/object:Gem::Requirement
89
87
  none: false
88
+ requirement: !ruby/object:Gem::Requirement
90
89
  requirements:
91
90
  - - ~>
92
91
  - !ruby/object:Gem::Version
93
92
  version: 1.8.4
93
+ none: false
94
94
  description: A gem to do various stuff with PaperTrail versions.
95
95
  email: k@spernj.org
96
96
  executables: []
@@ -119,20 +119,20 @@ rdoc_options: []
119
119
  require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
122
  requirements:
124
123
  - - ! '>='
125
124
  - !ruby/object:Gem::Version
126
125
  segments:
127
126
  - 0
128
- hash: -3375604828162703244
127
+ hash: 1568129255712246814
129
128
  version: '0'
130
- required_rubygems_version: !ruby/object:Gem::Requirement
131
129
  none: false
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  requirements:
133
132
  - - ! '>='
134
133
  - !ruby/object:Gem::Version
135
134
  version: '0'
135
+ none: false
136
136
  requirements: []
137
137
  rubyforge_project:
138
138
  rubygems_version: 1.8.23