breathing 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2dd890230542703d28a6dcc8e7b6f1213cabf089027ebddc91280edda54cb322
4
+ data.tar.gz: e29abf8900cc93a231c8ac1d12763d89bc8719ded8ddcb1fb68f5d7d7de6aa61
5
+ SHA512:
6
+ metadata.gz: 8ebf6e138f187609e34aee5f26f16b33a94efd98afb248a69c43286e4fe00e8496b176d8b3d8baa2a6dd59485b8ea7958dd1982c4ee329475f3bef04de1b3b86
7
+ data.tar.gz: 798a892f5c78b97b4b7b7b61c6de09c74488953476901cd640da8e77e90d436d909e4873b9bc99f36f8d42db7ab53adf1a8fc7bad1be117e82f11af5432e36ad
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Akira Kusumoto
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.
@@ -0,0 +1,47 @@
1
+ # breathing
2
+
3
+ Audit logging for database.
4
+ Logging mechanism using database triggers to store the old and new row states in JSON column types.
5
+
6
+ ## Install
7
+
8
+ Put this line in your Gemfile:
9
+
10
+ ```
11
+ gem 'breathing'
12
+ ```
13
+
14
+ Then bundle:
15
+ ```
16
+ % bundle
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Install
22
+
23
+ Just run the following command.
24
+
25
+ ```
26
+ % DATABASE_URL="mysql2://user:pass@host:port/database" breathing install
27
+ ```
28
+
29
+ - Create table `change_logs`
30
+ - Create triggers
31
+ - breathing_insert_{table_name}
32
+ - breathing_update_{table_name}
33
+ - breathing_delete_{table_name}
34
+
35
+ ### Uninstall
36
+
37
+ Cleanup command.
38
+
39
+ ```
40
+ % DATABASE_URL="mysql2://user:pass@host:port/database" breathing uninstall
41
+ ```
42
+
43
+ - Drop table `change_logs` and triggers
44
+
45
+ ## Copyright
46
+
47
+ Copyright (c) 2020 Akira Kusumoto. See MIT-LICENSE file for further details.
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path('lib', __dir__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'breathing'
5
+ s.version = '0.0.1'
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ['Akira Kusumoto']
8
+ s.email = ['akirakusumo10@gmail.com']
9
+ s.homepage = 'https://github.com/bluerabbit/breathing'
10
+ s.summary = 'audit logging for database'
11
+ s.description = 'audit logging for database'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
+ s.require_paths = ['lib']
17
+ s.licenses = ['MIT']
18
+
19
+ s.bindir = 'exe'
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ s.add_runtime_dependency 'thor'
22
+
23
+ s.add_dependency 'activerecord', ['>= 5.0.0']
24
+ s.add_development_dependency 'mysql2'
25
+ s.add_development_dependency 'pry-byebug'
26
+ s.add_development_dependency 'rspec', '~> 3.9'
27
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'breathing/cli'
3
+
4
+ Breathing::Cli.start
@@ -0,0 +1,3 @@
1
+ class Breathing
2
+ VERSION = Gem.loaded_specs['breathing'].version.to_s
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'thor'
2
+ require 'breathing'
3
+
4
+ class Breathing
5
+ class Cli < Thor
6
+ default_command :version
7
+
8
+ desc 'version', 'Show Version'
9
+ def version
10
+ say "Version: #{Breathing::VERSION}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'active_record'
2
+ require 'breathing'
3
+
4
+ ActiveRecord::Base.establish_connection(
5
+ YAML.load(ERB.new(File.read('spec/database.yml')).result)['test']
6
+ )
7
+
8
+ ActiveRecord::Schema.define version: 0 do
9
+ create_table :users, force: true do |t|
10
+ t.string :name, null: false
11
+ t.integer :age, null: false
12
+ t.timestamps null: false
13
+ end
14
+ end
15
+
16
+ class User < ActiveRecord::Base
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Breathing do
4
+ it 'has a version number' do
5
+ expect(Breathing::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ test:
2
+ adapter: mysql2
3
+ encoding: utf8mb4
4
+ charset: utf8mb4
5
+ collation: utf8mb4_general_ci
6
+ pool: 5
7
+ username: <%= ENV.fetch("DB_USER") { 'root' } %>
8
+ password: <%= ENV.fetch("DB_PASS") { '' } %>
9
+ host: <%= ENV.fetch("DB_HOST") { '127.0.0.1' } %>
10
+ socket: /tmp/mysql.sock
11
+ database: breathing_test
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
+ require 'pry'
3
+ require 'active_record'
4
+ require 'breathing'
5
+ require_relative 'app'
6
+
7
+ RSpec.configure do |config|
8
+ config.around do |example|
9
+ ActiveRecord::Base.transaction do
10
+ example.run
11
+
12
+ raise ActiveRecord::Rollback
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: breathing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Akira Kusumoto
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
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: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 5.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: mysql2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ description: audit logging for database
84
+ email:
85
+ - akirakusumo10@gmail.com
86
+ executables:
87
+ - breathing
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - MIT-LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - breathing.gemspec
97
+ - exe/breathing
98
+ - lib/breathing.rb
99
+ - lib/breathing/cli.rb
100
+ - spec/app.rb
101
+ - spec/breathing_spec.rb
102
+ - spec/database.yml
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/bluerabbit/breathing
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubygems_version: 3.0.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: audit logging for database
127
+ test_files:
128
+ - spec/app.rb
129
+ - spec/breathing_spec.rb
130
+ - spec/database.yml
131
+ - spec/spec_helper.rb