mongoid-userstamps 3.1.3 → 3.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fab675ceb96be422d7d026a7942152b48740d6d3
4
- data.tar.gz: 7af1bd67f73735fb89a834150359d560c9c0b5fc
2
+ SHA256:
3
+ metadata.gz: abd89e19a087c09f663588c80c5007cdc781985db52dffbc9af426574c161a76
4
+ data.tar.gz: fe286c80e6bf99589b02811a90eafa8026ab79d18ea39352f5144606df8236a2
5
5
  SHA512:
6
- metadata.gz: b3287832a48c42ce38b683cbb709669b0ed5834c648d91c7d3078014e804eea56173d18b9c4c81e2fe96ce516bfea92e0d18985e16576c0d9c2be3012aee7635
7
- data.tar.gz: 2ffa155f13651285dae206cd5a9be1fa213e996ef7bde185bcf08016de67f7ab300cc280d550a20fe15fb432b823b50dcb127e9ccab7bffbccd4f39560ac6774
6
+ metadata.gz: 7018b8e7ad31ff0f96f53a208dba6db14efd4c7e20bf4b9011a8cb66661104b7dfd9ce91038f63f810af8b47386635487d2bda7aaea5042b5f20dad0912dbd33
7
+ data.tar.gz: 32145a486f3d28690d69bd1d1d4ddfdd2703f760af8d5f7e2882b84853577224aa2cfa4e6bb118261340af6b853046eefd2265dd3271ad8a30688f8182a72200
@@ -0,0 +1,9 @@
1
+ inherit_gem:
2
+ standard: config/base.yml
3
+
4
+ require:
5
+ - standard
6
+ - rubocop-performance
7
+
8
+ Style/RedundantBegin:
9
+ Enabled: false
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.4.9
5
+ - 2.5.7
6
+ - 2.6.5
7
+ before_install:
8
+ - gem install bundler
9
+ install: bundle update --jobs=3 --retry=3
10
+ services:
11
+ - mongodb
12
+ env:
13
+ - "MONGOID_VERSION=6.2.0"
14
+ - "MONGOID_VERSION=6.3.0"
15
+ - "MONGOID_VERSION=6.4.0"
16
+ - "MONGOID_VERSION=7.0.0"
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.#
4
+
5
+ * Syntax bugfix for Ruby 2.4 with `rescue` on blocks
6
+
7
+ ## 3.2.0
8
+
9
+ * Mongoid 7.0 support
10
+
3
11
  ## 3.1.3
4
12
 
5
13
  * Mongoid 6.2 support
data/Gemfile CHANGED
@@ -1,9 +1,17 @@
1
- source 'http://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'request_store', require: false
5
+ mongoid_version = ENV["MONGOID_VERSION"] || "7.0.0"
6
6
 
7
- gem 'simplecov', :require => false
8
- gem 'pry-nav', '~> 0.2.4'
7
+ gem "rake"
8
+ gem "mongoid", "~> #{mongoid_version}"
9
+ gem "request_store", require: false
9
10
 
11
+ group :development do
12
+ gem "simplecov", require: false
13
+ gem "pry-nav", "~> 0.2.4"
14
+ gem "standard", "~> 0.1.0"
15
+ gem "rubocop"
16
+ gem "rubocop-performance"
17
+ end
data/Rakefile CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rake/testtask'
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
4
 
5
- desc 'Default: run unit tests'
6
- task :default => :test
5
+ desc "Default: run unit tests"
6
+ task default: :test
7
7
 
8
- desc 'Run tests'
8
+ desc "Run tests"
9
9
  Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
10
+ t.libs << "lib"
11
+ t.libs << "test"
12
+ t.pattern = "test/**/*_test.rb"
13
+ t.warning = false
14
14
  end
15
-
data/init.rb CHANGED
@@ -1,2 +1 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'mongoid_userstamp'
1
+ require "mongoid_userstamp"
@@ -1,4 +1 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require 'mongoid/userstamps'
4
-
1
+ require "mongoid/userstamps"
@@ -1,13 +1,11 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require 'mongoid/userstamps/version'
4
- require 'mongoid/userstamps/config'
5
- require 'mongoid/userstamps/user'
6
- require 'mongoid/userstamps/model'
7
- require 'mongoid/userstamps/created'
8
- require 'mongoid/userstamps/updated'
9
- require 'mongoid/userstamps/deleted'
10
- require 'mongoid/userstamps/railtie' if defined? Rails
1
+ require "mongoid/userstamps/version"
2
+ require "mongoid/userstamps/config"
3
+ require "mongoid/userstamps/user"
4
+ require "mongoid/userstamps/model"
5
+ require "mongoid/userstamps/created"
6
+ require "mongoid/userstamps/updated"
7
+ require "mongoid/userstamps/deleted"
8
+ require "mongoid/userstamps/railtie" if defined? Rails
11
9
 
12
10
  module Mongoid
13
11
  module Userstamps
@@ -27,4 +25,3 @@ module Mongoid
27
25
  end
28
26
  end
29
27
  end
30
-
@@ -1,7 +1,5 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require 'mongoid/userstamps/config/model'
4
- require 'mongoid/userstamps/config/user'
1
+ require "mongoid/userstamps/config/model"
2
+ require "mongoid/userstamps/config/user"
5
3
 
6
4
  module Mongoid
7
5
  module Userstamps
@@ -30,23 +28,20 @@ module Mongoid
30
28
  model_classes << klass
31
29
  end
32
30
 
33
- def created_name=(value)
34
- @created_name = value
35
- end
31
+ attr_writer :created_name
32
+
36
33
  def created_name
37
34
  @created_name ||= DEFAULT_CREATED_NAME
38
35
  end
39
36
 
40
- def updated_name=(value)
41
- @updated_name = value
42
- end
37
+ attr_writer :updated_name
38
+
43
39
  def updated_name
44
40
  @updated_name ||= DEFAULT_UPDATED_NAME
45
41
  end
46
42
 
47
- def deleted_name=(value)
48
- @deleted_name = value
49
- end
43
+ attr_writer :deleted_name
44
+
50
45
  def deleted_name
51
46
  @deleted_name ||= DEFAULT_DELETED_NAME
52
47
  end
@@ -60,7 +55,7 @@ module Mongoid
60
55
  end
61
56
 
62
57
  def store(model, value = false)
63
- return if !model
58
+ return unless model
64
59
  key = "mongoid-userstamps/#{model.to_s.underscore}".to_sym
65
60
  store = defined?(RequestStore) ? RequestStore.store : Thread.current
66
61
  if value == false
@@ -79,4 +74,3 @@ module Mongoid
79
74
  end
80
75
  end
81
76
  end
82
-
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  module Config
@@ -23,12 +21,20 @@ module Mongoid
23
21
  end
24
22
 
25
23
  def set_user_model!
26
- @model.relations[config.created_name.to_s].try(:[]=, :class_name, user_model)
27
- @model.relations[config.updated_name.to_s].try(:[]=, :class_name, user_model)
28
- @model.relations[config.deleted_name.to_s].try(:[]=, :class_name, user_model)
24
+ if Mongoid::VERSION.to_f < 7.0
25
+ %i[created_name updated_name deleted_name].each do |attr|
26
+ @model.relations[config.send(attr).to_s].try(:[]=, :class_name, user_model)
27
+ end
28
+ else
29
+ %i[created_name updated_name deleted_name].each do |attr|
30
+ if @model.relations[config.send(attr).to_s]
31
+ @model.relations[config.send(attr).to_s].instance_variable_set :@class_name, user_model
32
+ @model.relations[config.send(attr).to_s].options[:class_name] = user_model
33
+ end
34
+ end
35
+ end
29
36
  end
30
37
  end
31
38
  end
32
39
  end
33
40
  end
34
-
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  module Config
@@ -13,4 +11,3 @@ module Mongoid
13
11
  end
14
12
  end
15
13
  end
16
-
@@ -1,19 +1,17 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  module Created
6
4
  extend ActiveSupport::Concern
7
5
 
8
6
  included do
9
- if !self.included_modules.include?(Mongoid::Userstamps::Model)
7
+ unless included_modules.include?(Mongoid::Userstamps::Model)
10
8
  include Mongoid::Userstamps::Model
11
9
  end
12
10
 
13
11
  belongs_to userstamps_config.created_name, {
14
12
  class_name: userstamps_model.user_model,
15
13
  inverse_of: nil,
16
- optional: true
14
+ optional: true,
17
15
  }
18
16
 
19
17
  set_callback :create, :before, :set_created_by
@@ -21,10 +19,9 @@ module Mongoid
21
19
 
22
20
  def set_created_by
23
21
  user = self.class.current_user
24
- return if !user || self.public_send(userstamps_config.created_name)
25
- self.public_send("#{userstamps_config.created_name}=", user)
22
+ return if !user || public_send(userstamps_config.created_name)
23
+ public_send("#{userstamps_config.created_name}=", user)
26
24
  end
27
25
  end
28
26
  end
29
27
  end
30
-
@@ -1,19 +1,17 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  module Deleted
6
4
  extend ActiveSupport::Concern
7
5
 
8
6
  included do
9
- if !self.included_modules.include?(Mongoid::Userstamps::Model)
7
+ unless included_modules.include?(Mongoid::Userstamps::Model)
10
8
  include Mongoid::Userstamps::Model
11
9
  end
12
10
 
13
11
  belongs_to userstamps_config.deleted_name, {
14
12
  class_name: userstamps_model.user_model,
15
13
  inverse_of: nil,
16
- optional: true
14
+ optional: true,
17
15
  }
18
16
 
19
17
  set_callback :destroy, :before, :set_deleted_by
@@ -21,10 +19,9 @@ module Mongoid
21
19
 
22
20
  def set_deleted_by
23
21
  user = self.class.current_user
24
- return if !user || self.public_send("#{userstamps_config.deleted_name}_id_changed?")
25
- self.public_send("#{userstamps_config.deleted_name}=", user)
22
+ return if !user || public_send("#{userstamps_config.deleted_name}_id_changed?")
23
+ public_send("#{userstamps_config.deleted_name}=", user)
26
24
  end
27
25
  end
28
26
  end
29
27
  end
30
-
@@ -27,4 +27,3 @@ module Mongoid
27
27
  end
28
28
  end
29
29
  end
30
-
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  class Railtie < Rails::Railtie
@@ -17,4 +15,3 @@ module Mongoid
17
15
  end
18
16
  end
19
17
  end
20
-
@@ -1,19 +1,17 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
3
  module Updated
6
4
  extend ActiveSupport::Concern
7
5
 
8
6
  included do
9
- if !self.included_modules.include?(Mongoid::Userstamps::Model)
7
+ unless included_modules.include?(Mongoid::Userstamps::Model)
10
8
  include Mongoid::Userstamps::Model
11
9
  end
12
10
 
13
11
  belongs_to userstamps_config.updated_name, {
14
12
  class_name: userstamps_model.user_model,
15
13
  inverse_of: nil,
16
- optional: true
14
+ optional: true,
17
15
  }
18
16
 
19
17
  set_callback :save, :before, :set_updated_by
@@ -21,10 +19,9 @@ module Mongoid
21
19
 
22
20
  def set_updated_by
23
21
  user = self.class.current_user
24
- return if !user || self.public_send("#{userstamps_config.updated_name}_id_changed?")
25
- self.public_send("#{userstamps_config.updated_name}=", user)
22
+ return if !user || public_send("#{userstamps_config.updated_name}_id_changed?")
23
+ public_send("#{userstamps_config.updated_name}=", user)
26
24
  end
27
25
  end
28
26
  end
29
27
  end
30
-
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Mongoid
3
2
  module Userstamps
4
3
  module User
@@ -9,7 +8,7 @@ module Mongoid
9
8
  end
10
9
 
11
10
  def current?
12
- self.id == self.class.current.try(:id)
11
+ id == self.class.current.try(:id)
13
12
  end
14
13
 
15
14
  class_methods do
@@ -22,7 +21,7 @@ module Mongoid
22
21
  end
23
22
 
24
23
  def sudo(user)
25
- old = self.current
24
+ old = current
26
25
  self.current = user
27
26
  yield
28
27
  ensure
@@ -36,4 +35,3 @@ module Mongoid
36
35
  end
37
36
  end
38
37
  end
39
-
@@ -1,8 +1,5 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Mongoid
4
2
  module Userstamps
5
- VERSION = '3.1.3'
3
+ VERSION = "3.2.1"
6
4
  end
7
5
  end
8
-
@@ -1,26 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
1
+ $:.push File.expand_path("../lib", __FILE__)
3
2
 
4
- require 'mongoid/userstamps/version'
3
+ require "mongoid/userstamps/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = 'mongoid-userstamps'
8
- s.version = Mongoid::Userstamps::VERSION
9
- s.authors = ['Geoffroy Planquart', 'Thomas Boerger', 'Johnny Shields', 'Bharat Gupta']
10
- s.homepage = 'https://github.com/tbpro/mongoid_userstamp'
11
- s.license = 'MIT'
12
- s.summary = 'Userstamps for Mongoid'
13
- s.description = 'Userstamps for creator and updater fields using Mongoid'
14
- s.email = ['geoffroy@planquart.fr', 'tboerger@tbpro.de']
6
+ s.name = "mongoid-userstamps"
7
+ s.version = Mongoid::Userstamps::VERSION
8
+ s.authors = ["Geoffroy Planquart", "Thomas Boerger", "Johnny Shields", "Bharat Gupta"]
9
+ s.homepage = "https://github.com/tbpro/mongoid_userstamp"
10
+ s.license = "MIT"
11
+ s.summary = "Userstamps for Mongoid"
12
+ s.description = "Userstamps for creator and updater fields using Mongoid"
13
+ s.email = ["geoffroy@planquart.fr", "tboerger@tbpro.de"]
15
14
 
16
- s.files = `git ls-files`.split($/)
17
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
- s.require_paths = ['lib']
15
+ s.files = `git ls-files`.split($/)
16
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.require_paths = ["lib"]
20
19
 
21
- s.post_install_message = File.read('UPGRADING') if File.exist?('UPGRADING')
20
+ s.post_install_message = File.read("UPGRADING") if File.exist?("UPGRADING")
22
21
 
23
- s.add_dependency 'mongoid', '>= 5.0.0', '< 6.3.0'
24
- s.add_dependency 'activesupport', '>= 4.2.0', '< 5.2.0'
22
+ s.add_dependency "mongoid", ">= 5.0.0", "< 7.1.0"
23
+ s.add_dependency "activesupport", ">= 4.2.0", "< 5.2.0"
25
24
  end
26
-
@@ -1,24 +1,23 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'rubygems'
3
- require 'ostruct'
1
+ require "rubygems"
2
+ require "ostruct"
4
3
 
5
- $:.push File.expand_path('../../lib', __FILE__)
4
+ $:.push File.expand_path("../../lib", __FILE__)
6
5
 
7
- require 'active_support/all'
8
- require 'mongoid'
9
- require 'mongoid_userstamp'
6
+ require "active_support/all"
7
+ require "mongoid"
8
+ require "mongoid_userstamp"
10
9
 
11
- %w(admin user book post).each do |file_name|
10
+ %w[admin user book post].each do |file_name|
12
11
  require "support/#{file_name}"
13
12
  end
14
13
 
15
14
  Mongoid.configure do |config|
16
- config.connect_to 'mongoid_userstamp_test'
15
+ config.connect_to "mongoid_userstamp_test"
17
16
  end
18
17
 
19
18
  RSpec.configure do |config|
20
19
  config.mock_with :rspec
21
-
20
+
22
21
  config.after :suite do
23
22
  Mongoid.purge!
24
23
  end