temporary_tables 0.0.2 → 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/temporary_tables/methods.rb +53 -0
- data/lib/temporary_tables/version.rb +1 -1
- data/lib/temporary_tables.rb +4 -2
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a46bc6a8b3572ec7139f728d8ff8eaedf93b9cb34a96b9b57fc19199cdfe82
|
4
|
+
data.tar.gz: bdaa133c476f449bbca179bac98696c92a53213f35f8e35622135988e807888a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a8b9449fb89ee1556434b711ded07482945c6ad0b526f75f6a44176499302b8f6cc4a376000c4ef57f2ef70c89f9e112e6f59e2ebbb880419d756c27437cf0
|
7
|
+
data.tar.gz: e3fdbdfc2e4921c1ead4784a2a49d51cb2dfc5a58d9b304013aaee73e68c972b209233fa3ad0b281fcc3a7e99f3bcff980f86cd9ad3df4cb5e77dbb55e5d0216
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TemporaryTables
|
4
|
+
module Methods
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
class_methods do
|
8
|
+
def temporary_table(name, ...)
|
9
|
+
table_name = name.to_s.pluralize
|
10
|
+
|
11
|
+
before do
|
12
|
+
ActiveRecord::Migration.suppress_messages do
|
13
|
+
ActiveRecord::Migration.create_table(table_name, ...)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
ActiveRecord::Migration.suppress_messages do
|
19
|
+
ActiveRecord::Migration.drop_table(table_name, if_exists: true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def temporary_model(name, table_name: name.to_s.pluralize, base_class: ActiveRecord::Base, &extension)
|
25
|
+
class_name = name.to_s.classify
|
26
|
+
|
27
|
+
before do |example|
|
28
|
+
klass = Class.new *base_class do
|
29
|
+
define_singleton_method(:table_name) { table_name } unless table_name.nil?
|
30
|
+
define_singleton_method(:name) { class_name }
|
31
|
+
end
|
32
|
+
|
33
|
+
unless extension.nil?
|
34
|
+
# pass in an example context so that vars can be accessed
|
35
|
+
context = Class.new do
|
36
|
+
define_method(:respond_to_missing?) do |method_name|
|
37
|
+
example.instance_exec { respond_to?(method_name) }
|
38
|
+
end
|
39
|
+
|
40
|
+
define_method(:method_missing) do |method_name|
|
41
|
+
example.instance_exec { send(method_name) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
klass.module_exec(context.new, &extension)
|
46
|
+
end
|
47
|
+
|
48
|
+
stub_const(class_name, klass)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/temporary_tables.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: temporary_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 1.0.0.pre.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zeke Gabrielse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.4'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.4'
|
41
41
|
description: Create temporary tables for Rspec tests.
|
42
42
|
email:
|
43
43
|
- oss@keygen.sh
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- SECURITY.md
|
53
53
|
- lib/temporary_tables.rb
|
54
|
+
- lib/temporary_tables/methods.rb
|
54
55
|
- lib/temporary_tables/version.rb
|
55
56
|
homepage: https://github.com/keygen-sh/temporary_tables
|
56
57
|
licenses:
|
@@ -67,9 +68,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
68
|
version: '3.1'
|
68
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
70
|
requirements:
|
70
|
-
- - "
|
71
|
+
- - ">"
|
71
72
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
73
|
+
version: 1.3.1
|
73
74
|
requirements: []
|
74
75
|
rubygems_version: 3.4.13
|
75
76
|
signing_key:
|