mongoid_activity_tracker 0.2.0 → 0.2.1

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: c9449f842d58c48896d928ce30a44e8d5fcd2a69
4
- data.tar.gz: f4ba42b5635d1e6df11e7975bff69b12f1ef39d8
3
+ metadata.gz: 32a49fc10d42c73338ecf6b28d773809f33837d7
4
+ data.tar.gz: 022617ffb00f8062efd009fbfccc125db2ea7d13
5
5
  SHA512:
6
- metadata.gz: ced9a538eb779784a2bc76cd0662a50d7f63df5fb2984040285e4a4dd208e5ee63d205067de6e628e75213fb8db64615c841d507b9b241ccc6c701c4e310afe3
7
- data.tar.gz: 9637a2160e01f9f6377990e898cd8bf697538ba0eebcca4d89237cbd695fb5f52e85cf49397b8dae5c5de182640785ff467f000a5456afd9e5a708e4994f86bf
6
+ metadata.gz: bf49dd625363086dc207b5a4173d710837f3f4065755151d119f2e2d1e6ba77da569af03378d761851d9aba4f72e29203688e29418010005158747a953b9a581
7
+ data.tar.gz: f341051bd51fd9c22286d622332f870434cad04b4f1077ca89b7d749689b523073126f27dfd12b5832b8ab3f638bc94659423df217df616f07296c1505bdde7a
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  script: 'bundle exec rake'
4
+ sudo: false
4
5
  rvm:
5
- - 2.1.2
6
+ - 2.2.2
6
7
  services:
7
8
  - mongodb
8
9
 
@@ -11,4 +12,4 @@ notifications:
11
12
  recipients:
12
13
  - tomas.celizna@gmail.com
13
14
  on_failure: change
14
- on_success: never
15
+ on_success: never
@@ -1,3 +1,2 @@
1
1
  require 'mongoid_activity_tracker/version'
2
-
3
- require 'mongoid_activity_tracker/tracker'
2
+ require 'mongoid_activity_tracker/tracker'
@@ -3,20 +3,16 @@ require 'ostruct'
3
3
 
4
4
  module MongoidActivityTracker
5
5
  module Tracker
6
-
7
6
  attr_accessor :actor_cache_methods
8
7
 
9
8
  module ClassMethods
10
-
11
- def track _actor, _action, options={}
12
- self.create(
13
- { action: _action, actor: _actor }.merge(options)
14
- )
9
+ def track(_actor, _action, options = {})
10
+ create({ action: _action, actor: _actor }.merge(options))
15
11
  end
16
12
 
17
13
  # ---------------------------------------------------------------------
18
-
19
- def tracks relation_name, cache_methods: %i(to_s)
14
+
15
+ def tracks(relation_name, cache_methods: %i(to_s))
20
16
  belongs_to relation_name, polymorphic: true
21
17
 
22
18
  field "#{relation_name}_cache", type: Hash, default: {}
@@ -38,7 +34,7 @@ module MongoidActivityTracker
38
34
 
39
35
  # ---------------------------------------------------------------------
40
36
 
41
- def self.included base
37
+ def self.included(base)
42
38
  base.extend ClassMethods
43
39
  base.class_eval do
44
40
  include Mongoid::Document
@@ -50,26 +46,24 @@ module MongoidActivityTracker
50
46
  validates :actor, presence: true
51
47
  validates :action, presence: true
52
48
  end
53
-
54
49
  end
55
50
 
56
51
  # =====================================================================
57
52
 
58
53
  def created_at
59
- self.id.generation_time.in_time_zone(Time.zone)
54
+ id.generation_time.in_time_zone(Time.zone)
60
55
  end
61
56
 
62
57
  private # =============================================================
63
58
 
64
- def set_cache name
65
- return unless self.send("#{name}_cache_methods").present?
66
- return unless self.send(name).present?
59
+ def set_cache(name)
60
+ return unless send("#{name}_cache_methods").present?
61
+ return unless send(name).present?
67
62
 
68
- self.send("#{name}_cache_methods").each do |m|
69
- next if self.send("#{name}_cache")[m].present?
70
- self.send("#{name}_cache")[m] = self.send(name).send(m) if self.send(name).respond_to?(m)
63
+ send("#{name}_cache_methods").each do |m|
64
+ next if send("#{name}_cache")[m].present?
65
+ send("#{name}_cache")[m] = send(name).send(m) if send(name).respond_to?(m)
71
66
  end
72
67
  end
73
-
74
68
  end
75
69
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidActivityTracker
2
- VERSION = "0.2.0"
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -4,27 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mongoid_activity_tracker/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "mongoid_activity_tracker"
7
+ spec.name = 'mongoid_activity_tracker'
8
8
  spec.version = MongoidActivityTracker::VERSION
9
- spec.authors = ["Tomas Celizna"]
10
- spec.email = ["tomas.celizna@gmail.com"]
11
- spec.description = %q{Minimal set of classes and modules to help with activity tracking.}
12
- spec.summary = %q{Minimal set of classes and modules to help with activity tracking.}
13
- spec.homepage = "https://github.com/tomasc/mongoid_activity_tracker"
14
- spec.license = "MIT"
9
+ spec.authors = ['Tomas Celizna']
10
+ spec.email = ['tomas.celizna@gmail.com']
11
+ spec.description = 'Minimal set of classes and modules to help with activity tracking.'
12
+ spec.summary = 'Minimal set of classes and modules to help with activity tracking.'
13
+ spec.homepage = 'https://github.com/tomasc/mongoid_activity_tracker'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "mongoid", "~> 5.0"
21
+ spec.add_dependency 'mongoid', '~> 5'
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "coveralls"
25
- spec.add_development_dependency "database_cleaner", ">= 1.5.1"
26
- spec.add_development_dependency "guard"
27
- spec.add_development_dependency "guard-minitest"
28
- spec.add_development_dependency "minitest"
29
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'coveralls'
25
+ spec.add_development_dependency 'database_cleaner', '>= 1.5.1'
26
+ spec.add_development_dependency 'guard'
27
+ spec.add_development_dependency 'guard-minitest'
28
+ spec.add_development_dependency 'minitest'
29
+ spec.add_development_dependency 'rake'
30
30
  end
@@ -2,7 +2,6 @@ require 'test_helper'
2
2
 
3
3
  module MongoidActivityTracker
4
4
  describe Tracker do
5
-
6
5
  let(:actor) { TestActor.new }
7
6
  let(:sub) { TestSubject.new }
8
7
  subject { TestTracker.new }
@@ -24,7 +23,7 @@ module MongoidActivityTracker
24
23
  end
25
24
 
26
25
  # ---------------------------------------------------------------------
27
-
26
+
28
27
  describe '.track' do
29
28
  before do
30
29
  @result = TestTracker.track(actor, :create, subject: sub)
@@ -36,7 +35,7 @@ module MongoidActivityTracker
36
35
  @result.actor.must_equal actor
37
36
  end
38
37
  it 'sets the :actor_cache with :to_s by default' do
39
- @result.actor_cache.must_equal({ to_s: actor.to_s })
38
+ @result.actor_cache.must_equal(to_s: actor.to_s)
40
39
  end
41
40
  it 'sets the :action' do
42
41
  @result.action.must_equal :create
@@ -72,9 +71,9 @@ module MongoidActivityTracker
72
71
  subject.subject_cache.fetch(:to_s).must_equal test_subject.to_s
73
72
  end
74
73
  end
75
-
74
+
76
75
  # ---------------------------------------------------------------------
77
-
76
+
78
77
  describe ':created_at' do
79
78
  it 'infers time from BSON id' do
80
79
  subject.must_respond_to :created_at
@@ -110,6 +109,5 @@ module MongoidActivityTracker
110
109
  subject.actor_cache_object.must_respond_to :to_s
111
110
  end
112
111
  end
113
-
114
112
  end
115
- end
113
+ end
@@ -7,11 +7,13 @@ require 'minitest/spec'
7
7
  require 'mongoid'
8
8
  require 'mongoid_activity_tracker'
9
9
 
10
- if ENV["CI"]
11
- require "coveralls"
10
+ if ENV['CI']
11
+ require 'coveralls'
12
12
  Coveralls.wear!
13
13
  end
14
14
 
15
+ Mongoid.logger.level = Logger::INFO
16
+ Mongo::Logger.logger.level = Logger::INFO
15
17
  Mongoid.configure do |config|
16
18
  config.connect_to('mongoid_activity_tracker_test')
17
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_activity_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-03 00:00:00.000000000 Z
11
+ date: 2016-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '5'
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: '5.0'
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement