mongoid_userstamp 0.1.4 → 0.2.0

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.
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p194
data/.travis.yml CHANGED
@@ -1,4 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
3
+ - 2.0.0
4
4
  - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+
8
+ services: mongodb
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## v0.2.0 (2013-03-24)
2
+
3
+ * Added some specs for test coverage
4
+ * Removed dependecy for `Mongoid::Timestamps`
data/Gemfile CHANGED
@@ -1,12 +1,9 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'mongoid', '~> 3.0.4'
3
+ gem 'mongoid', '>= 3.0.4'
4
4
 
5
5
  group :development do
6
- gem 'redcarpet', '~> 2.1.0'
7
- gem 'yard', '~> 0.8.2.1'
8
- gem 'jeweler', '~> 1.8.3'
9
- gem 'magic_encoding', '~> 0.0.2'
10
- gem 'whitespace', '~> 2.0.4'
6
+ gem 'rspec', '>= 2.13.0'
7
+ gem 'yard', '>= 0.8.2.1'
8
+ gem 'jeweler', '>= 1.8.3'
11
9
  end
12
-
data/Gemfile.lock CHANGED
@@ -1,45 +1,50 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.2.7)
5
- activesupport (= 3.2.7)
4
+ activemodel (3.2.13)
5
+ activesupport (= 3.2.13)
6
6
  builder (~> 3.0.0)
7
- activesupport (3.2.7)
8
- i18n (~> 0.6)
7
+ activesupport (3.2.13)
8
+ i18n (= 0.6.1)
9
9
  multi_json (~> 1.0)
10
- builder (3.0.0)
10
+ builder (3.0.4)
11
+ diff-lcs (1.2.1)
11
12
  git (1.2.5)
12
- i18n (0.6.0)
13
- jeweler (1.8.3)
13
+ i18n (0.6.1)
14
+ jeweler (1.8.4)
14
15
  bundler (~> 1.0)
15
16
  git (>= 1.2.5)
16
17
  rake
17
18
  rdoc
18
- json (1.6.6)
19
- magic_encoding (0.0.2)
20
- mongoid (3.0.4)
21
- activemodel (~> 3.1)
22
- moped (~> 1.1)
19
+ json (1.7.7)
20
+ mongoid (3.1.2)
21
+ activemodel (~> 3.2)
22
+ moped (~> 1.4.2)
23
23
  origin (~> 1.0)
24
24
  tzinfo (~> 0.3.22)
25
- moped (1.2.0)
26
- multi_json (1.3.6)
27
- origin (1.0.6)
28
- rake (0.9.2.2)
29
- rdoc (3.12)
25
+ moped (1.4.3)
26
+ multi_json (1.7.1)
27
+ origin (1.0.11)
28
+ rake (10.0.3)
29
+ rdoc (4.0.0)
30
30
  json (~> 1.4)
31
- redcarpet (2.1.1)
32
- tzinfo (0.3.33)
33
- whitespace (2.0.4)
34
- yard (0.8.2.1)
31
+ rspec (2.13.0)
32
+ rspec-core (~> 2.13.0)
33
+ rspec-expectations (~> 2.13.0)
34
+ rspec-mocks (~> 2.13.0)
35
+ rspec-core (2.13.1)
36
+ rspec-expectations (2.13.0)
37
+ diff-lcs (>= 1.1.3, < 2.0)
38
+ rspec-mocks (2.13.0)
39
+ tzinfo (0.3.37)
40
+ yard (0.8.5.2)
35
41
 
36
42
  PLATFORMS
37
43
  ruby
44
+ x86-mingw32
38
45
 
39
46
  DEPENDENCIES
40
- jeweler (~> 1.8.3)
41
- magic_encoding (~> 0.0.2)
42
- mongoid (~> 3.0.4)
43
- redcarpet (~> 2.1.0)
44
- whitespace (~> 2.0.4)
45
- yard (~> 0.8.2.1)
47
+ jeweler (>= 1.8.3)
48
+ mongoid (>= 3.0.4)
49
+ rspec (>= 2.13.0)
50
+ yard (>= 0.8.2.1)
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- # MongoidUserstamp [![Build Status](https://secure.travis-ci.org/tbpro/mongoid_userstamp.png)](https://secure.travis-ci.org/#!/tbpro/mongoid_userstamp)
1
+ # MongoidUserstamp [![Build Status](https://secure.travis-ci.org/tbpro/mongoid_userstamp.png)](https://travis-ci.org/tbpro/mongoid_userstamp) [![Code Climate](https://codeclimate.com/github/tbpro/mongoid_userstamp.png)](https://codeclimate.com/github/tbpro/mongoid_userstamp)
2
2
 
3
3
  MongoidUserstamp adds stamp columns for created by and updated by
4
- informations within rails applications.
4
+ informations within rails applications. Mongoid requires a ruby
5
+ version above 1.8, so i've written the gem on the new 1.9 hash syntax.
5
6
 
6
7
  ## Install
7
8
 
@@ -52,4 +53,4 @@ informations within rails applications.
52
53
 
53
54
  ## Credits
54
55
 
55
- Copyright (c) 2012 Thomas Boerger Programmierung <http://www.tbpro.de>
56
+ Copyright (c) 2012-2013 Thomas Boerger Programmierung <http://www.tbpro.de>
data/Rakefile CHANGED
@@ -6,6 +6,7 @@ begin
6
6
  rescue Bundler::BundlerError => e
7
7
  $stderr.puts e.message
8
8
  $stderr.puts 'Run `bundle install` to install missing gems'
9
+
9
10
  exit e.status_code
10
11
  end
11
12
 
@@ -29,4 +30,12 @@ end
29
30
  Jeweler::RubygemsDotOrgTasks.new
30
31
  YARD::Rake::YardocTask.new
31
32
 
32
- task :default => :version
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+
36
+ RSpec::Core::RakeTask.new(:spec) do |spec|
37
+ spec.pattern = FileList['spec/**/*_spec.rb']
38
+ spec.rspec_opts = '--color --format progress'
39
+ end
40
+
41
+ task default: :spec
@@ -5,8 +5,6 @@ module Mongoid
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- include Mongoid::Timestamps
9
-
10
8
  def current?
11
9
  !Thread.current[:user].nil? && self.id == Thread.current[:user].id
12
10
  end
@@ -3,8 +3,8 @@ module Mongoid
3
3
  module Userstamp
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 1
7
- PATCH = 4
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -9,8 +9,6 @@ module Mongoid
9
9
  autoload :User, 'mongoid/userstamp/user'
10
10
 
11
11
  included do
12
- include Mongoid::Timestamps
13
-
14
12
  field Mongoid::Userstamp.configuration.updated_column, :type => Object
15
13
  field Mongoid::Userstamp.configuration.created_column, :type => Object
16
14
 
@@ -18,11 +16,13 @@ module Mongoid
18
16
  before_create :set_creator
19
17
 
20
18
  define_method Mongoid::Userstamp.configuration.updated_accessor do
21
- Mongoid::Userstamp.configuration.user_model.find(self.send(Mongoid::Userstamp.configuration.updated_column))
19
+ updated_col = self.send(Mongoid::Userstamp.configuration.updated_column)
20
+ updated_col ? Mongoid::Userstamp.configuration.user_model.find(updated_col) : nil
22
21
  end
23
22
 
24
23
  define_method Mongoid::Userstamp.configuration.created_accessor do
25
- Mongoid::Userstamp.configuration.user_model.find(self.send(Mongoid::Userstamp.configuration.created_column))
24
+ created_col = self.send(Mongoid::Userstamp.configuration.created_column)
25
+ created_col ? Mongoid::Userstamp.configuration.user_model.find(created_col) : nil
26
26
  end
27
27
 
28
28
  protected
@@ -42,10 +42,6 @@ module Mongoid
42
42
  end
43
43
 
44
44
  class << self
45
- def configure(&block)
46
- @configuration = Mongoid::Userstamp::Config.new(&block)
47
- end
48
-
49
45
  def configuration
50
46
  @configuration ||= Mongoid::Userstamp::Config.new
51
47
  end
@@ -5,19 +5,20 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mongoid_userstamp"
8
- s.version = "0.1.4"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Boerger"]
12
- s.date = "2012-09-19"
12
+ s.date = "2013-03-24"
13
13
  s.email = "tboerger@tbpro.de"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.md",
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
- ".rvmrc",
19
+ ".rbenv-version",
20
20
  ".travis.yml",
21
+ "CHANGELOG.md",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.md",
@@ -30,7 +31,11 @@ Gem::Specification.new do |s|
30
31
  "lib/mongoid/userstamp/user.rb",
31
32
  "lib/mongoid/userstamp/version.rb",
32
33
  "lib/mongoid_userstamp.rb",
33
- "mongoid_userstamp.gemspec"
34
+ "mongoid_userstamp.gemspec",
35
+ "spec/mongoid/userstamp_spec.rb",
36
+ "spec/spec_helper.rb",
37
+ "spec/support/book.rb",
38
+ "spec/support/user.rb"
34
39
  ]
35
40
  s.homepage = "https://github.com/tbpro/mongoid_userstamp"
36
41
  s.licenses = ["MIT"]
@@ -42,27 +47,21 @@ Gem::Specification.new do |s|
42
47
  s.specification_version = 3
43
48
 
44
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<mongoid>, ["~> 3.0.4"])
46
- s.add_development_dependency(%q<redcarpet>, ["~> 2.1.0"])
47
- s.add_development_dependency(%q<yard>, ["~> 0.8.2.1"])
48
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
49
- s.add_development_dependency(%q<magic_encoding>, ["~> 0.0.2"])
50
- s.add_development_dependency(%q<whitespace>, ["~> 2.0.4"])
50
+ s.add_runtime_dependency(%q<mongoid>, [">= 3.0.4"])
51
+ s.add_development_dependency(%q<rspec>, [">= 2.13.0"])
52
+ s.add_development_dependency(%q<yard>, [">= 0.8.2.1"])
53
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
51
54
  else
52
- s.add_dependency(%q<mongoid>, ["~> 3.0.4"])
53
- s.add_dependency(%q<redcarpet>, ["~> 2.1.0"])
54
- s.add_dependency(%q<yard>, ["~> 0.8.2.1"])
55
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
56
- s.add_dependency(%q<magic_encoding>, ["~> 0.0.2"])
57
- s.add_dependency(%q<whitespace>, ["~> 2.0.4"])
55
+ s.add_dependency(%q<mongoid>, [">= 3.0.4"])
56
+ s.add_dependency(%q<rspec>, [">= 2.13.0"])
57
+ s.add_dependency(%q<yard>, [">= 0.8.2.1"])
58
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
58
59
  end
59
60
  else
60
- s.add_dependency(%q<mongoid>, ["~> 3.0.4"])
61
- s.add_dependency(%q<redcarpet>, ["~> 2.1.0"])
62
- s.add_dependency(%q<yard>, ["~> 0.8.2.1"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
64
- s.add_dependency(%q<magic_encoding>, ["~> 0.0.2"])
65
- s.add_dependency(%q<whitespace>, ["~> 2.0.4"])
61
+ s.add_dependency(%q<mongoid>, [">= 3.0.4"])
62
+ s.add_dependency(%q<rspec>, [">= 2.13.0"])
63
+ s.add_dependency(%q<yard>, [">= 0.8.2.1"])
64
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
66
65
  end
67
66
  end
68
67
 
@@ -0,0 +1,62 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe 'Mongoid::Userstamp' do
5
+ subject {
6
+ Book.new(
7
+ name: 'Crafting Rails Applications'
8
+ )
9
+ }
10
+
11
+ it { should respond_to :created_by }
12
+ it { should respond_to :creator }
13
+ it { should respond_to :updated_by }
14
+ it { should respond_to :updator }
15
+
16
+ context 'when created without a user' do
17
+ before {
18
+ subject.save!
19
+ }
20
+
21
+ it { subject.created_by.should be_nil }
22
+ it { subject.creator.should be_nil }
23
+ it { subject.updated_by.should be_nil }
24
+ it { subject.updator.should be_nil }
25
+ end
26
+
27
+ context 'when created by a user' do
28
+ let(:user_1) {
29
+ User.create!(
30
+ name: 'Charles Dikkens'
31
+ )
32
+ }
33
+
34
+ before {
35
+ User.current = user_1
36
+ subject.save
37
+ }
38
+
39
+ it { subject.created_by.should == user_1.id }
40
+ it { subject.creator.should == user_1 }
41
+ it { subject.updated_by.should == user_1.id }
42
+ it { subject.updator.should == user_1 }
43
+
44
+ context 'when updated by a user' do
45
+ let(:user_2) {
46
+ User.create!(
47
+ name: 'Edmund Wells'
48
+ )
49
+ }
50
+
51
+ before {
52
+ User.current = user_2
53
+ subject.save!
54
+ }
55
+
56
+ it { subject.created_by.should == user_1.id }
57
+ it { subject.creator.should == user_1 }
58
+ it { subject.updated_by.should == user_2.id }
59
+ it { subject.updator.should == user_2 }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rubygems'
3
+
4
+ $:.push File.expand_path('../../lib', __FILE__)
5
+
6
+ require 'active_support/all'
7
+ require 'mongoid'
8
+ require 'mongoid_userstamp'
9
+
10
+ Mongoid.configure do |config|
11
+ config.connect_to(
12
+ 'mongoid_userstamp_test'
13
+ )
14
+ end
15
+
16
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |f|
17
+ require f
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :rspec
22
+
23
+ config.after :suite do
24
+ Mongoid.purge!
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Book
3
+ include Mongoid::Document
4
+ include Mongoid::Userstamp
5
+
6
+ field :name
7
+ end
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class User
3
+ include Mongoid::Document
4
+ include Mongoid::Userstamp::User
5
+
6
+ field :name
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_userstamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2013-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.0.4
22
22
  type: :runtime
@@ -24,31 +24,31 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.0.4
30
30
  - !ruby/object:Gem::Dependency
31
- name: redcarpet
31
+ name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 2.1.0
37
+ version: 2.13.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 2.1.0
45
+ version: 2.13.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: yard
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.8.2.1
54
54
  type: :development
@@ -56,7 +56,7 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.8.2.1
62
62
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ~>
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.8.3
70
70
  type: :development
@@ -72,41 +72,9 @@ dependencies:
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: 1.8.3
78
- - !ruby/object:Gem::Dependency
79
- name: magic_encoding
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: 0.0.2
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 0.0.2
94
- - !ruby/object:Gem::Dependency
95
- name: whitespace
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 2.0.4
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 2.0.4
110
78
  description:
111
79
  email: tboerger@tbpro.de
112
80
  executables: []
@@ -115,8 +83,9 @@ extra_rdoc_files:
115
83
  - LICENSE.md
116
84
  - README.md
117
85
  files:
118
- - .rvmrc
86
+ - .rbenv-version
119
87
  - .travis.yml
88
+ - CHANGELOG.md
120
89
  - Gemfile
121
90
  - Gemfile.lock
122
91
  - LICENSE.md
@@ -130,6 +99,10 @@ files:
130
99
  - lib/mongoid/userstamp/version.rb
131
100
  - lib/mongoid_userstamp.rb
132
101
  - mongoid_userstamp.gemspec
102
+ - spec/mongoid/userstamp_spec.rb
103
+ - spec/spec_helper.rb
104
+ - spec/support/book.rb
105
+ - spec/support/user.rb
133
106
  homepage: https://github.com/tbpro/mongoid_userstamp
134
107
  licenses:
135
108
  - MIT
@@ -145,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
118
  version: '0'
146
119
  segments:
147
120
  - 0
148
- hash: 3314337246327258657
121
+ hash: 4199627598995250851
149
122
  required_rubygems_version: !ruby/object:Gem::Requirement
150
123
  none: false
151
124
  requirements:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use ruby-1.9.3-p194@mongoid_userstamp --create