rails_wipe 1.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
+ SHA1:
3
+ metadata.gz: e9d4620b214e0cb34b08988e0f331fc23d67cbc1
4
+ data.tar.gz: 792730f96b41289aa1a3f5cba7c8fd9464ac4267
5
+ SHA512:
6
+ metadata.gz: b78c8aa51d8ecf258421140c6387cd6e171f8213d62bd3641fdbcf423fa1c5cbfe1367630400f607929f7404be0473c89d78fb3e0b72649b88c780bcddff74ab
7
+ data.tar.gz: 53979b556a06180137f368b23bef50b04de727af1c46617d58ecec74fb244f2cf3a07c669a239bac64706cce50c3e2cffde3c37e6bc00ba2e1695e129fc0fcdf
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,49 @@
1
+ # Rails Wipe
2
+
3
+ A rake task for Rails to truncate your database without having to drop it.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "rails_wipe"
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ You'll have two additional rake tasks, `rake -T`:
16
+
17
+ ```
18
+
19
+ rake db:wipe # Truncate the database (from rails_wipe gem)
20
+ rake db:wipe:environment # An overridable environment for rails_wipe gem
21
+
22
+ ```
23
+
24
+ **Warning:** this will wipe your database, be careful! By default `db:wipe:environment` will
25
+ abort in production.
26
+
27
+ ### Overriding environment check
28
+
29
+ Sometimes you want to wipe in production, e.g. if you run staging on the production environment. While
30
+ scary, it is possible to override the environment check by putting the following code in your Rakefile:
31
+
32
+ ```ruby
33
+ Rake::Task["db:wipe:environment"].clear
34
+
35
+ task "db:wipe:environment" => [:environment] do
36
+ # Replace the below code with whatever madness you prefer.
37
+ abort "[ERROR] Cannot wipe #{Rails.env} environment." if Rails.env.production?
38
+ end
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies.
44
+
45
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/Burgestrand/rails_wipe>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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,9 @@
1
+ require "rails_wipe/version"
2
+
3
+ module RailsWipe
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load "rails_wipe/task.rake"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ namespace :db do
2
+ namespace :wipe do
3
+ desc "An overridable environment for rails_wipe gem"
4
+ task environment: [:environment] do
5
+ abort "[ERROR] Cannot wipe #{Rails.env} environment." if Rails.env.production?
6
+ end
7
+ end
8
+
9
+ desc "Truncate the database (from rails_wipe gem)"
10
+ task wipe: ["wipe:environment"] do
11
+ Rails.application.eager_load!
12
+
13
+ connection = ActiveRecord::Base.connection
14
+ quoted_table_names = (ActiveRecord::Base.descendants - [ActiveRecord::SchemaMigration])
15
+ .select(&:table_exists?)
16
+ .map(&:quoted_table_name)
17
+
18
+ sql = <<-SQL.strip_heredoc
19
+ TRUNCATE TABLE #{quoted_table_names.join(",")}
20
+ SQL
21
+
22
+ $stderr.puts sql
23
+ connection.execute(sql)
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module RailsWipe
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_wipe/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_wipe"
8
+ spec.version = RailsWipe::VERSION
9
+ spec.authors = ["Kim Burge Strand"]
10
+ spec.email = ["kim@burgestrand.se"]
11
+
12
+ spec.summary = %q{A rake task for Rails to truncate your database.}
13
+ spec.homepage = "https://github.com/Burgestrand/rails_wipe"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails", ">= 4"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_wipe
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kim Burge Strand
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - kim@burgestrand.se
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - bin/setup
67
+ - lib/rails_wipe.rb
68
+ - lib/rails_wipe/task.rake
69
+ - lib/rails_wipe/version.rb
70
+ - rails_wipe.gemspec
71
+ homepage: https://github.com/Burgestrand/rails_wipe
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.5.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A rake task for Rails to truncate your database.
95
+ test_files: []
96
+ has_rdoc: