ar_truncator 0.0.1 → 0.0.2
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/Gemfile +4 -0
- data/README.md +19 -2
- data/lib/ar_truncator/version.rb +1 -1
- data/lib/ar_truncator.rb +1 -1
- data/spec/lib/active_record/base_spec.rb +15 -0
- metadata +8 -6
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# ArTruncator
|
2
2
|
|
3
|
-
|
3
|
+
Now you can do tablename.truncate. This was not incorporated into AR
|
4
|
+
as a patch because SQLite does not support truncate statements. See this
|
5
|
+
pull request for more detail:
|
6
|
+
|
7
|
+
https://github.com/rails/rails/issues/5510
|
8
|
+
|
9
|
+
I'm releasing this as a gem, so I don't have to add it to my
|
10
|
+
config/initializers.
|
11
|
+
|
12
|
+
This has so far only been tested for mysql2 adapater/MySQL DB.
|
4
13
|
|
5
14
|
## Installation
|
6
15
|
|
@@ -18,7 +27,15 @@ Or install it yourself as:
|
|
18
27
|
|
19
28
|
## Usage
|
20
29
|
|
21
|
-
|
30
|
+
If you have a model called Dummy, to truncate it do:
|
31
|
+
|
32
|
+
Dummy.truncate
|
33
|
+
|
34
|
+
This will execute the following sql:
|
35
|
+
|
36
|
+
"Truncate tabel Dummies".
|
37
|
+
|
38
|
+
|
22
39
|
|
23
40
|
## Contributing
|
24
41
|
|
data/lib/ar_truncator/version.rb
CHANGED
data/lib/ar_truncator.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../../../lib/ar_truncator/active_record/base")
|
2
|
+
|
3
|
+
class DummyModel < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
describe ActiveRecord::Base do
|
6
|
+
|
7
|
+
let(:connection) { stub("connection")}
|
8
|
+
|
9
|
+
it "can truncate the table by executing SQL" do
|
10
|
+
DummyModel.stub(:connection).and_return(connection)
|
11
|
+
DummyModel.stub(:table_name).and_return("Dummies")
|
12
|
+
connection.should_receive(:execute).with("TRUNCATE table Dummies")
|
13
|
+
DummyModel.truncate
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_truncator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-03 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mysql2
|
16
|
-
requirement: &
|
16
|
+
requirement: &70222335186720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70222335186720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &70222335186300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70222335186300
|
36
36
|
description: Adds a truncate helper to AR
|
37
37
|
email:
|
38
38
|
- anjshenoy@gmail.com
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/ar_truncator.rb
|
50
50
|
- lib/ar_truncator/active_record/base.rb
|
51
51
|
- lib/ar_truncator/version.rb
|
52
|
+
- spec/lib/active_record/base_spec.rb
|
52
53
|
homepage: ''
|
53
54
|
licenses: []
|
54
55
|
post_install_message:
|
@@ -73,4 +74,5 @@ rubygems_version: 1.8.6
|
|
73
74
|
signing_key:
|
74
75
|
specification_version: 3
|
75
76
|
summary: Adds a truncate helper to AR
|
76
|
-
test_files:
|
77
|
+
test_files:
|
78
|
+
- spec/lib/active_record/base_spec.rb
|