mongoid_delorean 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7df0efa1af0ba01ca6bbb2b5625d0d03e3637d5
4
- data.tar.gz: d781202b5b614f3e911921a5cee6355f3be06c54
3
+ metadata.gz: d89635c5c36aabaef1bdd83898a7104cf9029c34
4
+ data.tar.gz: c46c14d4d780adccef0f20cf67578ea3f5d1daeb
5
5
  SHA512:
6
- metadata.gz: 5f58c034a757c4f02f6ada2e5a6cf56b516352dbfb544c92eae6a7f31b7d4f93c21dcb853b94e56c54f3718992d71654bc5c976b17b264ab41520248447dd5ba
7
- data.tar.gz: 96ac147ef9a1261f5aeacbbff1cc856f6fde19d28e0a2594a4aa23dc70ded5b72dc80bcfc3688b1b6bf44f3a9f2161a62bc3a8e3a6c1d292b67e9d80edaead9c
6
+ metadata.gz: b36ee74f554eb6654736c038051d2231290dbe4ed4a4cb00c7c004df6c18fab7d55e070d7ded83ed1739077d1c537a2796e1a2d1bbd3dbf03343bd351f22e091
7
+ data.tar.gz: 2de5857b660bf4a8bc7e7b556bf60ee5a39affdab1ef173eeb47e386fad22702754e91729d1b0cefa579c8b4f8b4f5a47d587e9f9391acdf48f1e10c01892498
data/.travis.yml CHANGED
@@ -2,6 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.1
5
6
  - jruby-19mode
6
- - rbx-19mode
7
7
  services: mongodb
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongoid_delorean (1.3.0)
5
+ mongoid
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.17)
11
+ activesupport (= 3.2.17)
12
+ builder (~> 3.0.0)
13
+ activesupport (3.2.17)
14
+ i18n (~> 0.6, >= 0.6.4)
15
+ multi_json (~> 1.0)
16
+ builder (3.0.4)
17
+ database_cleaner (0.8.0)
18
+ diff-lcs (1.1.3)
19
+ i18n (0.6.9)
20
+ mongoid (3.0.23)
21
+ activemodel (~> 3.1)
22
+ moped (~> 1.2)
23
+ origin (~> 1.0)
24
+ tzinfo (~> 0.3.22)
25
+ moped (1.5.2)
26
+ multi_json (1.9.3)
27
+ origin (1.1.0)
28
+ rake (10.1.0)
29
+ rspec (2.11.0)
30
+ rspec-core (~> 2.11.0)
31
+ rspec-expectations (~> 2.11.0)
32
+ rspec-mocks (~> 2.11.0)
33
+ rspec-core (2.11.1)
34
+ rspec-expectations (2.11.3)
35
+ diff-lcs (~> 1.1.3)
36
+ rspec-mocks (2.11.2)
37
+ tzinfo (0.3.39)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ database_cleaner
44
+ mongoid_delorean!
45
+ rake
46
+ rspec
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Mongoid::Delorean
2
2
 
3
- A simple Mongoid 3 versioning system that works with embedded documents.
3
+ [![Build Status](https://travis-ci.org/crafters/mongoid_delorean.svg?branch=master)](https://travis-ci.org/crafters/mongoid_delorean)
4
4
 
5
- Tracking document changes can be really important to a lot of systems, unfortunately all of the Mongoid versioning plugins either only work with Mongoid 2.x, don't handle embedded document changes, or worse, just don't work. <code>Mongoid::Delorean</code> solves those problems.
5
+ A simple Mongoid 3 and 4 versioning system that works with embedded documents.
6
6
 
7
- <code>Mongoid::Delorean</code> is a simple plugin that does just what it sets out to do. It stores each version of your document as you make changes and then allows you to revert to earlier versions of the document.
7
+ Tracking document changes can be really important to a lot of systems, unfortunately all of the Mongoid versioning plugins either only work with Mongoid 2.x, don't handle embedded document changes, or worse, just don't work. `Mongoid::Delorean` solves those problems.
8
8
 
9
- If this wasn't great already, <code>Mongoid::Delorean</code> will even track changes made to any embedded documents, or documents that those embedded documents may have, and so on.
9
+ `Mongoid::Delorean` is a simple plugin that does just what it sets out to do. It stores each version of your document as you make changes and then allows you to revert to earlier versions of the document.
10
+
11
+ If this wasn't great already, `Mongoid::Delorean` will even track changes made to any embedded documents, or documents that those embedded documents may have, and so on.
10
12
 
11
13
  ## Installation
12
14
 
@@ -24,13 +26,13 @@ Or install it yourself as:
24
26
 
25
27
  ## Usage
26
28
 
27
- Using Mongoid::Delorean is very simple. Just include the <code>Mongoid::Delorean::Trackable</code> module into the <code>Mongoid::Document</code> you want to track. There is no need to include it in embedded documents, the parent document will handle that for you.
29
+ Using Mongoid::Delorean is very simple. Just include the `Mongoid::Delorean::Trackable` module into the `Mongoid::Document` you want to track. There is no need to include it in embedded documents, the parent document will handle that for you.
28
30
 
29
31
  Now, when you save, or update, the parent (or any of the embedded documents) a new version will be saved for you.
30
32
 
31
33
  ### Example
32
34
 
33
- <pre><code>
35
+ ```ruby
34
36
  class Article
35
37
  include Mongoid::Document
36
38
  include Mongoid::Timestamps
@@ -80,17 +82,17 @@ a.version # => 6
80
82
  page.name # => "Page 1"
81
83
  page.sections.size # => 0
82
84
  a.versions.size # => 6
83
- </code></pre>
85
+ ```
84
86
 
85
- If you don't want to track changes you can wrap it with <code>without_history_tracking</code>:
87
+ If you don't want to track changes you can wrap it with `without_history_tracking`:
86
88
 
87
- <pre><code>
89
+ ```ruby
88
90
  a = Article.create(name: "Article 1")
89
91
  a.without_history_tracking do
90
92
  a.update_attributes(name: "The Article 1")
91
93
  end
92
94
  a.version # => 1
93
- </code></pre>
95
+ ```
94
96
 
95
97
  ## Contributing
96
98
 
@@ -106,3 +108,4 @@ a.version # => 1
106
108
  * Mark Bates
107
109
  * Nick Muerdter
108
110
  * Felipe Rodrigues
111
+ * Felipe Rodrigues de Almeida
@@ -27,8 +27,13 @@ module Mongoid
27
27
  Mongoid::Delorean::History.create(original_class: self.class.name, original_class_id: self.id, version: _version, altered_attributes: _changes, full_attributes: _attributes)
28
28
  self.without_history_tracking do
29
29
  self.version = _version
30
+ # self.save!
30
31
  unless(self.new_record?)
31
- self.set(:version, _version)
32
+ if ::Mongoid.const_defined? :Observer
33
+ self.set(:version, _version)
34
+ else
35
+ self.set(version: _version)
36
+ end
32
37
  end
33
38
  end
34
39
 
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Delorean
3
- VERSION = "1.2.1"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency("mongoid", ">=3.0.0")
20
+ gem.add_dependency("mongoid")
21
21
 
22
22
  gem.add_development_dependency("rake")
23
23
  gem.add_development_dependency("rspec")
data/spec/config.yml CHANGED
@@ -5,7 +5,7 @@ test:
5
5
  hosts:
6
6
  - localhost:27017
7
7
  options:
8
- safe: true
9
- consistency: :strong
10
8
  max_retries: 1
11
9
  retry_interval: 0
10
+ # safe: true
11
+ # consistency: :strong
@@ -155,6 +155,7 @@ describe Mongoid::Delorean::Trackable do
155
155
  version.altered_attributes.should eql({"pages"=>[{"name"=>["Page 1", "The Page 1"]}], "version"=>[1, 2]})
156
156
 
157
157
  section = page.sections.build(body: "some body text")
158
+ page.save!
158
159
  a.save!
159
160
 
160
161
  version = a.versions.last
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_delorean
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Bates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: database_cleaner
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: A simple Mongoid 3 versioning system that works with embedded documents.
@@ -73,9 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Gemfile
79
+ - Gemfile.lock
79
80
  - LICENSE.txt
80
81
  - README.md
81
82
  - Rakefile
@@ -99,17 +100,17 @@ require_paths:
99
100
  - lib
100
101
  required_ruby_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
- - - '>='
103
+ - - ">="
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
- - - '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.1.11
113
+ rubygems_version: 2.2.2
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: A simple Mongoid 3 versioning system that works with embedded documents.