scm_devise 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c37d7e3bb6eacb73e5d589653c76951a681415d
4
+ data.tar.gz: 7b7880d6fdfee17f9d60e5d9b4422cf872bc61b0
5
+ SHA512:
6
+ metadata.gz: 5bf6d1bf018514eb14f362133b082f844e57a4eda784aa03bf358d2c4f71dac8aa128edc9d19cce445ed71ff5850dbb6caacf5744d5a403c662c969293493217
7
+ data.tar.gz: 2255be270a36c86d64d11b301deee1f551a242175ee09c183ff51d1ed321a166843b4554c97e3f396e3f2d6e5893bcc36f3b218eb2f9f6ae6ea9dccd51e016b9
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.16.0.pre.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in scm_devise.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ scm_devise (0.1.1)
5
+ activerecord
6
+ railties (>= 4.1.0, < 5.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (5.1.4)
12
+ actionview (= 5.1.4)
13
+ activesupport (= 5.1.4)
14
+ rack (~> 2.0)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
+ actionview (5.1.4)
19
+ activesupport (= 5.1.4)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
+ activemodel (5.1.4)
25
+ activesupport (= 5.1.4)
26
+ activerecord (5.1.4)
27
+ activemodel (= 5.1.4)
28
+ activesupport (= 5.1.4)
29
+ arel (~> 8.0)
30
+ activesupport (5.1.4)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (~> 0.7)
33
+ minitest (~> 5.1)
34
+ tzinfo (~> 1.1)
35
+ arel (8.0.0)
36
+ builder (3.2.3)
37
+ concurrent-ruby (1.0.5)
38
+ crass (1.0.3)
39
+ diff-lcs (1.3)
40
+ erubi (1.7.0)
41
+ i18n (0.9.1)
42
+ concurrent-ruby (~> 1.0)
43
+ loofah (2.1.1)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (0.9.0)
47
+ mini_portile2 (2.3.0)
48
+ minitest (5.10.3)
49
+ nokogiri (1.8.1)
50
+ mini_portile2 (~> 2.3.0)
51
+ rack (2.0.3)
52
+ rack-test (0.8.2)
53
+ rack (>= 1.0, < 3)
54
+ rails-dom-testing (2.0.3)
55
+ activesupport (>= 4.2.0)
56
+ nokogiri (>= 1.6)
57
+ rails-html-sanitizer (1.0.3)
58
+ loofah (~> 2.0)
59
+ railties (5.1.4)
60
+ actionpack (= 5.1.4)
61
+ activesupport (= 5.1.4)
62
+ method_source
63
+ rake (>= 0.8.7)
64
+ thor (>= 0.18.1, < 2.0)
65
+ rake (12.3.0)
66
+ rspec (3.7.0)
67
+ rspec-core (~> 3.7.0)
68
+ rspec-expectations (~> 3.7.0)
69
+ rspec-mocks (~> 3.7.0)
70
+ rspec-core (3.7.0)
71
+ rspec-support (~> 3.7.0)
72
+ rspec-expectations (3.7.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.7.0)
75
+ rspec-mocks (3.7.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.7.0)
78
+ rspec-support (3.7.0)
79
+ sqlite3 (1.3.13)
80
+ thor (0.20.0)
81
+ thread_safe (0.3.6)
82
+ tzinfo (1.2.4)
83
+ thread_safe (~> 0.1)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ bundler
90
+ rspec
91
+ scm_devise!
92
+ sqlite3
93
+
94
+ BUNDLED WITH
95
+ 1.16.0.pre.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Lucas M
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Scm_devise
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/scm_devise`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'scm_devise'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install scm_devise
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/scm_devise.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "scm_devise"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ module Scm_devise
2
+ class Callback
3
+ def before_create(record)
4
+ record.creator = current_employee if record.respond_to?(:creator) && current_employee
5
+ record.updater = current_employee if record.respond_to?(:updater) && current_employee
6
+ end
7
+
8
+ def before_update(record)
9
+ record.updater = current_employee if record.respond_to?(:updater) && current_employee
10
+ end
11
+
12
+ # # relies on `include SentientUser` on User
13
+ # def current_user
14
+ # warn "User#current is not defined, are you including SentientUser on your User model?" unless User.respond_to?(:current)
15
+ # warn "User#current is nil, are you including SentientController on your ApplicationController?" unless User.current
16
+ #
17
+ # User.current
18
+ # end
19
+
20
+ #######
21
+ private
22
+ #######
23
+
24
+ def warn(message)
25
+ logger.warn "WARNING: #{message}" unless configuration.silence_warnings
26
+ end
27
+
28
+ def logger
29
+ configuration.logger
30
+ end
31
+
32
+ def configuration
33
+ Scm_devise.configuration
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_support/logger'
2
+
3
+ module Scm_devise
4
+ class << self
5
+ attr_accessor :configuration
6
+ end
7
+
8
+ def self.configure
9
+ self.configuration ||= Configuration.new
10
+ yield(configuration)
11
+ end
12
+
13
+ class Configuration
14
+ attr_accessor :silence_warnings,
15
+ :logger
16
+
17
+ def initialize
18
+ @silence_warnings = false
19
+ @logger = ActiveSupport::Logger.new(STDOUT)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ require 'scm_devise'
2
+ require 'rails/railtie'
3
+
4
+ module Scm_devise
5
+ class Railtie < Rails::Railtie
6
+ initializer 'scm_devise.ar_extensions' do |app|
7
+ ActiveRecord::Base.extend Scm_devise
8
+
9
+ Scm_devise.configure do |config|
10
+ config.silence_warnings = Rails.env.test?
11
+ config.logger = Rails.logger
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Scm_devise
2
+ VERSION = "0.1.1"
3
+ end
data/lib/scm_devise.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'active_record'
2
+ require 'sentient_user'
3
+ require 'scm_devise/version'
4
+ require 'scm_devise/configuration'
5
+ require 'scm_devise/callback'
6
+ require 'scm_devise/railtie'
7
+
8
+ module Scm_devise
9
+ def track_who_does_it(options = {})
10
+ before_create Scm_devise::Callback.new
11
+ before_update Scm_devise::Callback.new
12
+
13
+ creator_fk = options.fetch(:creator_foreign_key) { "created_by_id" }
14
+ updater_fk = options.fetch(:updater_foreign_key) { "updated_by_id" }
15
+
16
+ belongs_to :creator, :class_name => "Employee", :foreign_key => creator_fk, :optional => true
17
+ belongs_to :updater, :class_name => "Employee", :foreign_key => updater_fk, :optional => true
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "scm_devise/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scm_devise"
8
+ spec.version = Scm_devise::VERSION
9
+ spec.authors = ["Lucas Michalski"]
10
+ spec.email = ["lucas.michalski@epitech.eu"]
11
+ spec.summary = %q{gem to auto update created and updated by for models.}
12
+ spec.homepage = "https://github.com/LucasMichal/Scm_devise"
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.require_paths = ["lib"]
15
+ spec.licenses = ['MIT']
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'activerecord'
25
+ spec.add_dependency("railties", ">= 4.1.0", "< 5.2")
26
+
27
+
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'rspec'
30
+
31
+ if defined?(JRUBY_VERSION)
32
+ spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
33
+ spec.add_development_dependency 'jruby-openssl'
34
+ else
35
+ spec.add_development_dependency 'sqlite3'
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scm_devise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Lucas Michalski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5.2'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 4.1.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: sqlite3
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description:
90
+ email:
91
+ - lucas.michalski@epitech.eu
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - lib/scm_devise.rb
107
+ - lib/scm_devise/callback.rb
108
+ - lib/scm_devise/configuration.rb
109
+ - lib/scm_devise/railtie.rb
110
+ - lib/scm_devise/version.rb
111
+ - scm_devise.gemspec
112
+ homepage: https://github.com/LucasMichal/Scm_devise
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.5.1
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: gem to auto update created and updated by for models.
136
+ test_files: []