models_auditor 0.1.1 → 0.2.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: 48a7e08268e6af1064f7f77660ede51f8f5dca9d
4
- data.tar.gz: 4fc60442b137cb0b2020791bd071b53db36c5213
3
+ metadata.gz: 8eefac2c75092c811395c67fbf5731b6bbf9cae0
4
+ data.tar.gz: fc29fe418d8f1943acb71da82388b802e7e15cd7
5
5
  SHA512:
6
- metadata.gz: 7d862f438b570336df4796b99cecf60f4d3136633c5cc33239c15ff4bcf62ef36425df3915940e5f37d9cdb14209f50c97482f8b846f80e765dcb318ee1187f4
7
- data.tar.gz: b8bfbc137c0f5ac1cbf136c81d2a45643149c44aa7339db40647ec6d2fdd7a2df2a1bb0ed559a46f0ce561d92fd2294aa3ff1d1acb0694a96d38edbca3b1aad9
6
+ metadata.gz: a0fd677022be453b8d61bcde43aa491186c8e61f0accc2e4cbc4d17c50484be725d9366ca93354e03bf90ff23cd9ba18d171afc9ec2cf7ecb70eb1497d126e55
7
+ data.tar.gz: 06457a6d6ac6c0a9ef8e23e5b85153ecf82f606d77ef8e58af0411feaeca7d892c6f0ae1b4eed049cf99d88f1be6d74f5ab5e03458dcc4b4c4c2a3ec9900123d
data/README.md CHANGED
@@ -108,5 +108,22 @@ If you want to use a database prefix not from config. You may specify it as an a
108
108
 
109
109
  `rake db:audit:create[audit_shmaudit]`
110
110
 
111
+ ## Capistrano
112
+
113
+ Add line to the Capfile
114
+
115
+ `require 'models_auditor/capistrano/rails/audit_migrations'`
116
+
117
+ **Migrate**
118
+
119
+ The capistrano migrate task
120
+
121
+ `cap deploy:audit_migrate`
122
+
123
+ will be executed automatically after `deploy:migrate` cap task
124
+
125
+ **Rollback**
126
+
127
+ `cap deploy:audit_rollback`
111
128
 
112
129
  This project rocks and uses MIT-LICENSE.
@@ -0,0 +1 @@
1
+ load File.expand_path('../../tasks/audit_migrations.rake', __FILE__)
@@ -0,0 +1,33 @@
1
+ namespace :deploy do
2
+
3
+ desc 'Runs rake db:audit:migrate if migrations are set'
4
+ task :audit_migrate do
5
+ on primary fetch(:migration_role) do
6
+ info '[deploy:audit_migrate] Checking changes in /db/audit_migrate'
7
+ if test("diff -q #{release_path}/db/audit_migrate #{current_path}/db/audit_migrate")
8
+ info '[deploy:audit_migrate] Skip `deploy:audit_migrate` (nothing changed in db/audit_migrate)'
9
+ else
10
+ info '[deploy:audit_migrate] Run `rake db:audit:migrate`'
11
+ within release_path do
12
+ with rails_env: fetch(:rails_env) do
13
+ execute :rake, 'db:audit:migrate'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ desc 'Runs rake db:audit:rollback'
21
+ task :audit_rollback do
22
+ on primary fetch(:migration_role) do
23
+ info '[deploy:audit_rollback] Run `rake db:audit:rollback`'
24
+ within release_path do
25
+ with rails_env: fetch(:rails_env) do
26
+ execute :rake, 'db:audit:rollback'
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ after 'deploy:migrate', 'deploy:audit_migrate'
33
+ end
@@ -85,7 +85,7 @@ module ModelsAuditor
85
85
  ModelsAuditor.log_error(record.errors.full_messages)
86
86
  end
87
87
  end
88
- rescue Exception => e
88
+ rescue StandardError => e
89
89
  ModelsAuditor.log_error("Couldn't logged changes of #{self.class.name} id: #{self.try(:id)}")
90
90
  ModelsAuditor.log_error(e.message)
91
91
  ModelsAuditor.log_error(e.backtrace.take(100).join("\n"))
@@ -1,3 +1,3 @@
1
1
  module ModelsAuditor
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: models_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Gorbunov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -133,6 +133,8 @@ files:
133
133
  - app/views/models_auditor/audit/index.html.erb
134
134
  - config/config_option_descriptions.yml
135
135
  - config/routes.rb
136
+ - lib/capistrano/rails/audit_migrations.rb
137
+ - lib/capistrano/tasks/audit_migrations.rake
136
138
  - lib/generators/models_auditor/db_config/USAGE
137
139
  - lib/generators/models_auditor/db_config/db_config_generator.rb
138
140
  - lib/generators/models_auditor/install/USAGE