utsusemi 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eda04c8204ea8a2181605aa3f21eca01bdb94acd
4
+ data.tar.gz: 284ec4ed3ec23180c75a14cf7f075517fb262fbb
5
+ SHA512:
6
+ metadata.gz: bf9d6f95eff26e70deaaf54ef7eb784c694929ae13d13dd1f314118d3c28d934a7781c3ab2570ec4f1e230038b10f070865ea74f1103cdd2f5442dfe2c4b5e76
7
+ data.tar.gz: bfd18a3ff3aba4ec705ab8308c30f72310cd7fd42162c053fea41c64c8b725337e4307c3327ef473027fcd1f39cac5fe33658e4341378a182f13a060574d25ba
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /debug.log
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1
5
+ - 2.2.2
6
+ - ruby-head
7
+ env:
8
+ - "AR_VERSION=4.0.13"
9
+ - "AR_VERSION=4.1.10"
10
+ - "AR_VERSION=4.2.1"
11
+ before_install:
12
+ - gem install bundler
13
+ - mysql -e "create database utsusemi_unittest;"
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "activerecord", "~> #{ENV['AR_VERSION']}" if ENV['AR_VERSION']
4
+
5
+ # Specify your gem's dependencies in utsusemi.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ryuta Kamizono
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,37 @@
1
+ # Utsusemi [![Build Status](https://travis-ci.org/kamipo/utsusemi.svg)](https://travis-ci.org/kamipo/utsusemi)
2
+
3
+ Utsusemi is a soft deleted as efficiently approach.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'utsusemi'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install utsusemi
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/kamipo/utsusemi/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
@@ -0,0 +1,89 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ require File.expand_path(File.dirname(__FILE__)) + "/test/config"
5
+ require File.expand_path(File.dirname(__FILE__)) + "/test/support/config"
6
+
7
+ desc 'Run mysql2 tests by default'
8
+ task :default => :test
9
+
10
+ desc 'Run mysql2 tests'
11
+ task :test => :test_mysql2
12
+
13
+ desc 'Build MySQL and PostgreSQL test databases'
14
+ namespace :db do
15
+ task :create => ['db:mysql:build', 'db:postgresql:build']
16
+ task :drop => ['db:mysql:drop', 'db:postgresql:drop']
17
+ end
18
+
19
+ %w( mysql2 postgresql sqlite3 ).each do |adapter|
20
+ namespace :test do
21
+ Rake::TestTask.new(adapter => "#{adapter}:env") { |t|
22
+ t.libs << 'test'
23
+ t.test_files = Dir.glob( "test/cases/**/*_test.rb" ).sort
24
+
25
+ t.warning = true
26
+ t.verbose = true
27
+ }
28
+ end
29
+
30
+ namespace adapter do
31
+ task :test => "test_#{adapter}"
32
+
33
+ # Set the connection environment for the adapter
34
+ task(:env) { ENV['ARCONN'] = adapter }
35
+ end
36
+
37
+ # Make sure the adapter test evaluates the env setting task
38
+ task "test_#{adapter}" => ["#{adapter}:env", "test:#{adapter}"]
39
+ end
40
+
41
+ namespace :db do
42
+ namespace :mysql do
43
+ desc 'Build the MySQL test databases'
44
+ task :build do
45
+ config = ARTest.config['connections']['mysql2']
46
+ %x( mysql --user=#{config['arunit']['username']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8" )
47
+ end
48
+
49
+ desc 'Drop the MySQL test databases'
50
+ task :drop do
51
+ config = ARTest.config['connections']['mysql2']
52
+ %x( mysqladmin --user=#{config['arunit']['username']} -f drop #{config['arunit']['database']} )
53
+ end
54
+
55
+ desc 'Rebuild the MySQL test databases'
56
+ task :rebuild => [:drop, :build]
57
+ end
58
+
59
+ namespace :postgresql do
60
+ desc 'Build the PostgreSQL test databases'
61
+ task :build do
62
+ config = ARTest.config['connections']['postgresql']
63
+ %x( createdb -E UTF8 -T template0 #{config['arunit']['database']} )
64
+ %x( createdb -E UTF8 -T template0 #{config['arunit2']['database']} )
65
+
66
+ # prepare hstore
67
+ if %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2") < "9.1.0"
68
+ puts "Please prepare hstore data type. See http://www.postgresql.org/docs/current/static/hstore.html"
69
+ end
70
+ end
71
+
72
+ desc 'Drop the PostgreSQL test databases'
73
+ task :drop do
74
+ config = ARTest.config['connections']['postgresql']
75
+ %x( dropdb #{config['arunit']['database']} )
76
+ end
77
+
78
+ desc 'Rebuild the PostgreSQL test databases'
79
+ task :rebuild => [:drop, :build]
80
+ end
81
+ end
82
+
83
+ task :build_mysql_databases => 'db:mysql:build'
84
+ task :drop_mysql_databases => 'db:mysql:drop'
85
+ task :rebuild_mysql_databases => 'db:mysql:rebuild'
86
+
87
+ task :build_postgresql_databases => 'db:postgresql:build'
88
+ task :drop_postgresql_databases => 'db:postgresql:drop'
89
+ task :rebuild_postgresql_databases => 'db:postgresql:rebuild'
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "utsusemi"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ require 'active_support'
2
+
3
+ begin
4
+ require 'rails'
5
+ rescue LoadError
6
+ # nothing to do! yay!
7
+ end
8
+
9
+ if defined? Rails
10
+ require 'utsusemi/railtie'
11
+ else
12
+ ActiveSupport.on_load :active_record do
13
+ require 'utsusemi/base'
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Utsusemi
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ def acts_as_utsusemi(callback: nil)
6
+ after_destroy callback || -> (caller) {
7
+ deleted_class = caller.class.deleted_class
8
+ attributes = caller.attributes.slice(*deleted_class.column_names)
9
+ attributes.merge!(deleted_at: Time.current)
10
+ deleted_class.create(attributes)
11
+ }
12
+ end
13
+
14
+ def only_deleted
15
+ deleted_class.all
16
+ end
17
+ alias :deleted :only_deleted
18
+
19
+ def deleted_class
20
+ "deleted_#{table_name}".classify.constantize
21
+ end
22
+ end
23
+ end
24
+
25
+ class ActiveRecord::Base
26
+ include Utsusemi
27
+ end
@@ -0,0 +1,9 @@
1
+ module Utsusemi
2
+ class Railtie < Rails::Railtie
3
+ initializer 'utsusemi' do
4
+ ActiveSupport.on_load :active_record do
5
+ require 'utsusemi/base'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Utsusemi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'utsusemi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "utsusemi"
8
+ spec.version = Utsusemi::VERSION
9
+ spec.authors = ["Ryuta Kamizono"]
10
+ spec.email = ["kamipo@gmail.com"]
11
+
12
+ spec.summary = %q{Utsusemi is a soft deleted as efficiently approach.}
13
+ spec.description = %q{Utsusemi is a soft deleted as efficiently approach.}
14
+ spec.homepage = "https://github.com/kamipo/utsusemi"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = '>= 2.0.0'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "mysql2", ">= 0.3.18"
27
+ spec.add_runtime_dependency "activesupport", "~> 4.0"
28
+ spec.add_runtime_dependency "activerecord", "~> 4.0"
29
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: utsusemi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryuta Kamizono
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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.3.18
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.18
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ description: Utsusemi is a soft deleted as efficiently approach.
84
+ email:
85
+ - kamipo@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/utsusemi.rb
99
+ - lib/utsusemi/base.rb
100
+ - lib/utsusemi/railtie.rb
101
+ - lib/utsusemi/version.rb
102
+ - utsusemi.gemspec
103
+ homepage: https://github.com/kamipo/utsusemi
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.0.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.5
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Utsusemi is a soft deleted as efficiently approach.
127
+ test_files: []