mongoid-undo 1.0.0 → 1.1.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: 19492347296216836cfe8a40b1994b0a49aaabc3
4
- data.tar.gz: 786e77d26b1a74aefeb94f5878d4c778dc65a191
3
+ metadata.gz: 23ccf468731385d0732bd4fdbe957902bf33ea8a
4
+ data.tar.gz: e1f5454370449d7c7c5c7ec63c9facee18ce3e8c
5
5
  SHA512:
6
- metadata.gz: 554821f592b475c4f591173d15879e70410a9f487a5aa11a9f8d8fa344dd2d79ece62c290fe334c1a6c051daa5ccede15b3b474d82a1a433cd3fe201a738d5fb
7
- data.tar.gz: 5f4297de289c8ee64076bc708d5477ff7cfebdbc0523942fb753783a34a91231472b2f07f5e55a5edb11ff3084e7c8e2d0e55c0f92b8399d584ce820254819da
6
+ metadata.gz: 7d5a5958173f42e4610ec5c5ac222a92696dfa36cb2f8211ceab2f9ccaadea7c252a05baa33458dc12ffc4d200e123355d85472f56af01591d7dc898c9844791
7
+ data.tar.gz: 1585c00dfc19903fa43aeb511a802ee1fe4e5944f6d0acc0aa1133b0b60b1e2d8cd9717d5911732f03b7d4ab22e91ed3542d05eddfe635a809b93351b7e877a0
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ services: mongodb
3
+
4
+ rvm:
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 2.2.0
8
+
9
+ gemfile:
10
+ - Gemfile
11
+ - gemfiles/mongoid_4.Gemfile
12
+ - gemfiles/mongoid_5.Gemfile
data/Gemfile CHANGED
@@ -1,6 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec
4
-
5
- gem 'minitest'
6
- gem 'rake'
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 - 2015 Mario Uher
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # mongoid-undo
1
+ # mongoid-undo [![Build Status](https://travis-ci.org/haihappen/mongoid-undo.svg?branch=master)](https://travis-ci.org/haihappen/mongoid-undo)
2
2
 
3
3
  Super simple undo for your Mongoid app, based on both great modules
4
4
  [Mongoid::Paranoia](http://mongoid.org/en/mongoid/docs/extras.html#paranoia) and
@@ -85,7 +85,7 @@ document.persisted? #=> false
85
85
 
86
86
  ### Callbacks
87
87
 
88
- Mongoid::Undo defines two callbacks which are called before and after `undo`, respectively `redo`. Both are based on `ActiveModel::Callbacks` which means they behave like the allready known Rails callbacks.
88
+ Mongoid::Undo defines two callbacks which are called before and after `undo`, respectively `redo`. Both are based on `ActiveModel::Callbacks` which means they behave like the already known Rails callbacks.
89
89
 
90
90
  ```ruby
91
91
  class Document
@@ -114,23 +114,6 @@ end
114
114
 
115
115
  (The MIT license)
116
116
 
117
- Copyright (c) 2012 - 2014 Mario Uher
118
-
119
- Permission is hereby granted, free of charge, to any person obtaining
120
- a copy of this software and associated documentation files (the
121
- "Software"), to deal in the Software without restriction, including
122
- without limitation the rights to use, copy, modify, merge, publish,
123
- distribute, sublicense, and/or sell copies of the Software, and to
124
- permit persons to whom the Software is furnished to do so, subject to
125
- the following conditions:
126
-
127
- The above copyright notice and this permission notice shall be
128
- included in all copies or substantial portions of the Software.
129
-
130
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
131
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
132
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
133
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
134
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
135
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
136
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
117
+ Copyright (c) 2012-2015 Mario Uher
118
+
119
+ See LICENSE.md.
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '../'
3
+
4
+ gem 'mongoid', '~> 4.0'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '../'
3
+
4
+ gem 'mongoid', '~> 5.0'
@@ -11,6 +11,7 @@ module Mongoid
11
11
  include Mongoid::Versioning
12
12
  include Mongoid::Interceptable
13
13
 
14
+ # @todo Remove Mongoid 4 support.
14
15
  included do
15
16
  # _id must be marked as not-versioned
16
17
  fields['_id'].options.merge!(versioned: false)
@@ -21,7 +22,10 @@ module Mongoid
21
22
  name = :"set_action_after_#{action}"
22
23
 
23
24
  define_method name do
24
- collection.find(atomic_selector).update('$set' => { action: action })
25
+ query = collection.find(atomic_selector)
26
+ set = { '$set' => { action: action }}
27
+
28
+ query.respond_to?(:update_one) ? query.update_one(set) : query.update(set)
25
29
  version = self.instance_variable_get(:@version)
26
30
  reload
27
31
  self.instance_variable_set :@version, version unless version.nil?
@@ -59,8 +63,10 @@ module Mongoid
59
63
  alias_method :redoable?, :undoable?
60
64
 
61
65
  private
66
+ # @todo Remove Mongoid 4 support.
62
67
  def retrieve
63
- update versions.last.versioned_attributes.except('version', 'updated_at')
68
+ attributes = versions.last.versioned_attributes.except('version', 'updated_at')
69
+ respond_to?(:update_one) ? update_one(attributes) : update(attributes)
64
70
  end
65
71
  end
66
72
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Undo
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -9,12 +9,16 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = 'https://github.com/haihappen/mongoid-undo'
10
10
  gem.summary = 'Super simple undo for your Mongoid app.'
11
11
  gem.description = 'mongoid-undo provides a super simple and easy to use undo system for Mongoid apps.'
12
+ gem.licenses = ['MIT']
12
13
 
13
14
  gem.files = `git ls-files`.split("\n")
14
15
  gem.require_path = 'lib'
15
16
 
16
- gem.add_dependency 'activesupport'
17
- gem.add_dependency 'mongoid', '~> 4.0.0'
18
- gem.add_dependency 'mongoid-paranoia', '~> 1.0.0'
19
- gem.add_dependency 'mongoid-versioning', '~> 1.0.0'
17
+ gem.add_dependency 'activesupport', '~> 4.0'
18
+ gem.add_dependency 'mongoid', '>= 4.0.0', '<= 6.0.0'
19
+ gem.add_dependency 'mongoid-paranoia', '>= 1.3.0', '~> 1.1'
20
+ gem.add_dependency 'mongoid-versioning', '>= 1.1.0', '~> 1.1'
21
+
22
+ gem.add_development_dependency 'minitest', '~> 5.0'
23
+ gem.add_development_dependency 'rake', '~> 10.0'
20
24
  end
@@ -1,4 +1,10 @@
1
1
  test:
2
+ clients:
3
+ default:
4
+ database: mongoid_undo_test
5
+ hosts:
6
+ - localhost:27017
7
+ # TODO Remove Mongoid 4.0 support
2
8
  sessions:
3
9
  default:
4
10
  database: mongoid_undo_test
@@ -6,10 +6,11 @@ require 'mongoid/undo'
6
6
 
7
7
  Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__), 'test')
8
8
 
9
- class MiniTest::Unit::TestCase
10
- alias_method :assert_not, :refute
11
- alias_method :assert_not_equal, :refute_equal
9
+ if defined?(Mongo)
10
+ Mongo::Logger.logger.level = Logger::WARN
11
+ end
12
12
 
13
+ class Minitest::Test
13
14
  # Copied from activesupport/lib/active_support/testing/assertions.rb
14
15
  def assert_difference(expression, difference = 1, message = nil, &block)
15
16
  expressions = Array(expression)
@@ -15,7 +15,7 @@ class Timestamped < Document
15
15
  include Mongoid::Timestamps
16
16
  end
17
17
 
18
- class UndoTest < Minitest::Unit::TestCase
18
+ class UndoTest < Minitest::Test
19
19
  def test_create
20
20
  document = Document.create(name: 'foo')
21
21
  assert_equal :create, document.action
@@ -26,7 +26,7 @@ class UndoTest < Minitest::Unit::TestCase
26
26
  document.undo
27
27
  assert_equal :create, document.action
28
28
  assert_equal 1, document.version
29
- assert_not document.persisted?
29
+ refute document.persisted?
30
30
  assert document.undoable?
31
31
 
32
32
  document.redo
@@ -41,7 +41,7 @@ class UndoTest < Minitest::Unit::TestCase
41
41
  document = Document.create(name: 'foo')
42
42
 
43
43
  document.save
44
- assert_not document.undoable?
44
+ refute document.undoable?
45
45
 
46
46
  document.update_attributes name: 'bar'
47
47
  assert_equal :update, document.action
@@ -69,7 +69,7 @@ class UndoTest < Minitest::Unit::TestCase
69
69
 
70
70
  document.destroy
71
71
  assert_equal :destroy, document.action
72
- assert_not document.persisted?
72
+ refute document.persisted?
73
73
  assert document.undoable?
74
74
 
75
75
  document.undo
@@ -79,7 +79,7 @@ class UndoTest < Minitest::Unit::TestCase
79
79
 
80
80
  document.redo
81
81
  assert_equal :destroy, document.action
82
- assert_not document.persisted?
82
+ refute document.persisted?
83
83
  assert document.undoable?
84
84
  end
85
85
 
@@ -115,13 +115,13 @@ class UndoTest < Minitest::Unit::TestCase
115
115
  updated_at = document.updated_at
116
116
 
117
117
  document.update_attributes(name: 'bar')
118
- assert_not_equal updated_at, document.updated_at
118
+ refute_equal updated_at, document.updated_at
119
119
 
120
120
  document.undo
121
- assert_not_equal updated_at, document.updated_at
121
+ refute_equal updated_at, document.updated_at
122
122
 
123
123
  document.redo
124
- assert_not_equal updated_at, document.updated_at
124
+ refute_equal updated_at, document.updated_at
125
125
  end
126
126
 
127
127
 
metadata CHANGED
@@ -1,71 +1,117 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-undo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Uher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '4.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: '0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongoid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.0.0
34
+ - - "<="
35
+ - !ruby/object:Gem::Version
36
+ version: 6.0.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 4.0.0
44
+ - - "<="
45
+ - !ruby/object:Gem::Version
46
+ version: 6.0.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: mongoid-paranoia
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.0
45
54
  - - "~>"
46
55
  - !ruby/object:Gem::Version
47
- version: 1.0.0
56
+ version: '1.1'
48
57
  type: :runtime
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.3.0
52
64
  - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: 1.0.0
66
+ version: '1.1'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: mongoid-versioning
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.1.0
59
74
  - - "~>"
60
75
  - !ruby/object:Gem::Version
61
- version: 1.0.0
76
+ version: '1.1'
62
77
  type: :runtime
63
78
  prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.1.0
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '1.1'
87
+ - !ruby/object:Gem::Dependency
88
+ name: minitest
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '5.0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '5.0'
101
+ - !ruby/object:Gem::Dependency
102
+ name: rake
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '10.0'
108
+ type: :development
109
+ prerelease: false
64
110
  version_requirements: !ruby/object:Gem::Requirement
65
111
  requirements:
66
112
  - - "~>"
67
113
  - !ruby/object:Gem::Version
68
- version: 1.0.0
114
+ version: '10.0'
69
115
  description: mongoid-undo provides a super simple and easy to use undo system for
70
116
  Mongoid apps.
71
117
  email: uher.mario@gmail.com
@@ -74,10 +120,13 @@ extensions: []
74
120
  extra_rdoc_files: []
75
121
  files:
76
122
  - ".gitignore"
77
- - CHANGELOG.md
123
+ - ".travis.yml"
78
124
  - Gemfile
125
+ - LICENSE.md
79
126
  - README.md
80
127
  - Rakefile
128
+ - gemfiles/mongoid_4.Gemfile
129
+ - gemfiles/mongoid_5.Gemfile
81
130
  - lib/mongoid/undo.rb
82
131
  - lib/mongoid/undo/version.rb
83
132
  - mongoid-undo.gemspec
@@ -85,7 +134,8 @@ files:
85
134
  - test/test_helper.rb
86
135
  - test/undo_test.rb
87
136
  homepage: https://github.com/haihappen/mongoid-undo
88
- licenses: []
137
+ licenses:
138
+ - MIT
89
139
  metadata: {}
90
140
  post_install_message:
91
141
  rdoc_options: []
@@ -103,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
153
  version: '0'
104
154
  requirements: []
105
155
  rubyforge_project:
106
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.5.0
107
157
  signing_key:
108
158
  specification_version: 4
109
159
  summary: Super simple undo for your Mongoid app.
@@ -1,51 +0,0 @@
1
- # 0.11.0 (June 29, 2014)
2
- * Adds undoable? (and respectively redoable?) methods to check whether a new version was saved or not.
3
-
4
- # 0.10.1 (April 16, 2014)
5
- * Switches to non anonymous callbacks.
6
-
7
- # 0.10.0 (March 30, 2014)
8
- * Adds both callbacks for undo and redo.
9
-
10
- # 0.9.1 (February 17, 2014)
11
- * We are still on minitest 4. 😞
12
-
13
- # 0.9.0 (February 17, 2014)
14
- * Whoa! Removes ruby version from Gemfile.
15
-
16
- # 0.8.0 (February 10, 2014)
17
- * Fixes \#2: updated_at-columns not working anymore.
18
-
19
- # 0.7.0 (February 8, 2014)
20
- * Simpler tests.
21
-
22
- # 0.6.0 (February 15, 2013)
23
- * Updated Gemfile for Bundler 1.2.4+.
24
- * Easier mongoid config.
25
-
26
- # 0.5.0 (February 14, 2013)
27
- * Use Rake::FileList.
28
- * \#1 Removed localization monkey patch. mongoid >= 3.0.10 is now required!
29
-
30
- # 0.4.0 (December 31, 2012)
31
- * Better specs structure.
32
- * Use require_relative.
33
-
34
- # 0.3.0 (December 22, 2012)
35
- * Revert "Renamed action field to _action."
36
-
37
- # 0.2.1 (December 22, 2012)
38
- * Typo. Upps.
39
-
40
- # 0.2.0 (December 22, 2012)
41
- * Fixed weird looking README.md.
42
-
43
- # 0.1.0 (December 22, 2012)
44
- * Refactored specs.
45
- * Renamed action field to _action.
46
-
47
- # 0.0.2 (December 22, 2012)
48
- * Added rake to Gemfile.
49
-
50
- # 0.0.1 (December 21, 2012)
51
- * First public version.