mysqlaudit 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -137,7 +137,8 @@ $ mysqlaudit uninstall --host 127.0.0.1 \
137
137
  Drop testing table and database:
138
138
 
139
139
  ```SQL
140
- DROP DATABASE foo;
140
+ DROP TABLE foo;
141
+ DROP DATABASE audit;
141
142
  ```
142
143
 
143
144
  For more information:
data/bin/mysqlaudit CHANGED
@@ -17,24 +17,30 @@ program :help, 'Author', 'Nicola Strappazzon <nicola51980@gmail.com>'
17
17
 
18
18
  command :install do |c|
19
19
  c.description = 'Install audit table'
20
- c.syntax = 'audits install --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo]'
20
+ c.syntax = 'mysqlaudit install --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo]'
21
21
  c.option '--host STRING', String, 'Host'
22
22
  c.option '--user STRING', String, 'User'
23
23
  c.option '--pass STRING', String, 'Password'
24
24
  c.option '--schema STRING', String, 'Schema name'
25
25
  c.option '--table STRING', String, 'Table name'
26
26
  c.action do |args, options|
27
- Mysqlaudit::Actions.new({host: options.host,
28
- user: options.user,
29
- password: options.pass,
30
- schema: options.schema,
31
- table: options.table}).install
27
+ if options.host.nil? ||
28
+ options.user.nil? ||
29
+ options.schema.nil?
30
+ puts c.syntax
31
+ else
32
+ Mysqlaudit::Actions.new({host: options.host,
33
+ user: options.user,
34
+ password: options.pass,
35
+ schema: options.schema,
36
+ table: options.table}).install
37
+ end
32
38
  end
33
39
  end
34
40
 
35
41
  command :uninstall do |c|
36
42
  c.description = 'Uninstall audit table'
37
- c.syntax = 'audits uninstall --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo] [--[no-]drop-audit-table]'
43
+ c.syntax = 'mysqlaudit uninstall --host 127.0.0.1 --user root [--pass admin] --schema sakila [--table foo] [--[no-]drop-audit-table]'
38
44
  c.option '--host STRING', String, 'Host'
39
45
  c.option '--user STRING', String, 'User'
40
46
  c.option '--pass STRING', String, 'Password'
@@ -42,18 +48,24 @@ command :uninstall do |c|
42
48
  c.option '--table STRING', String, 'Table name'
43
49
  c.option '--[no-]drop-audit-table', 'Drop audit table'
44
50
  c.action do |args, options|
45
- Mysqlaudit::Actions.new({host: options.host,
46
- user: options.user,
47
- password: options.pass,
48
- schema: options.schema,
49
- table: options.table,
50
- drop: options.drop_audit_table}).uninstall
51
+ if options.host.nil? ||
52
+ options.user.nil? ||
53
+ options.schema.nil?
54
+ puts c.syntax
55
+ else
56
+ Mysqlaudit::Actions.new({host: options.host,
57
+ user: options.user,
58
+ password: options.pass,
59
+ schema: options.schema,
60
+ table: options.table,
61
+ drop: options.drop_audit_table}).uninstall
62
+ end
51
63
  end
52
64
  end
53
65
 
54
66
  command :rollback do |c|
55
67
  c.description = 'Rollback transaction cath in audit table'
56
- c.syntax = 'audits rollback --host 127.0.0.1 --user root [--pass admin] --schema sakila --table foo [--statement all]'
68
+ c.syntax = 'mysqlaudit rollback --host 127.0.0.1 --user root [--pass admin] --schema sakila --table foo [--statement all|insert|update|delete]'
57
69
  c.option '--host STRING', String, 'Host'
58
70
  c.option '--user STRING', String, 'User'
59
71
  c.option '--pass STRING', String, 'Password'
@@ -61,19 +73,24 @@ command :rollback do |c|
61
73
  c.option '--table STRING', String, 'Table name'
62
74
  c.option '--statement STRING', String, 'Statement operation: all, insert, update, delete'
63
75
  c.action do |args, options|
64
- if options.statement.nil?
65
- options.statement = :all
66
- end
76
+ options.default statement: :all
67
77
 
68
- if [:all, :insert, :update, :delete].include? options.statement.to_sym
69
- Mysqlaudit::Actions.new({host: options.host,
70
- user: options.user,
71
- password: options.pass,
72
- schema: options.schema,
73
- table: options.table,
74
- statement: options.statement.to_sym}).rollback
78
+ if options.host.nil? ||
79
+ options.user.nil? ||
80
+ options.schema.nil? ||
81
+ options.table.nil?
82
+ puts c.syntax
75
83
  else
76
- puts "Invalid values on argument: --statement."
84
+ if [:all, :insert, :update, :delete].include? options.statement.to_sym
85
+ Mysqlaudit::Actions.new({host: options.host,
86
+ user: options.user,
87
+ password: options.pass,
88
+ schema: options.schema,
89
+ table: options.table,
90
+ statement: options.statement.to_sym}).rollback
91
+ else
92
+ puts "Invalid values on argument: --statement."
93
+ end
77
94
  end
78
95
  end
79
96
  end
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'mysql2'
3
3
 
4
4
  # @todo Optimize passing params on methods with maps.
5
+ # @todo Add in rollback comment the name of database.
5
6
  # @todo Optimize is set params to execute methods.
6
7
  # @todo Passing as parameter the tables names to apply triggers.
7
8
  # @todo Change name for audit table.
@@ -1,3 +1,3 @@
1
1
  module Mysqlaudit
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysqlaudit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-24 00:00:00.000000000 Z
12
+ date: 2013-07-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: MySQL tool for audit all tables with triggers.
15
15
  email: nicola51980@gmail.com