temp_table 0.1.0 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44da43c646cffbe6a251c79f16469da742f609adb204503bb8b0dc73605d6a9f
4
- data.tar.gz: 39c4439c7934b9780522396cf5ad5763668fa0f4dcd5d23d4e93400edc3ad362
3
+ metadata.gz: 8278a9a1ca71258e88e17b7ed5b22d6669427e7e0d74264dc468e5c88e00aca4
4
+ data.tar.gz: af8465fb03c8d6e8c3af2ed0026f1037b2780f1468e32a9aebf9e4e6205f8107
5
5
  SHA512:
6
- metadata.gz: e8041d90092e7fd691affe89927f36bd8b194328a10d84455004d497c0ac20a5320ca38624bf83dcd5a92023107dcdb82cadc2feddea5d4285beaf1befb3ec30
7
- data.tar.gz: 702c147394ba3572b8fc2eea6bf671825752a6f9fe3f3b459b36da6d925ba95b90c47a1e0dd17e56824a2733f7e819309bd906daf5d979f51ee51e07cd206475
6
+ metadata.gz: d7ecad66ec4c3ed92ec6bfa9e0f560c26ffa5c2aac80776db6a8728b91bde7c984ee7a51e716a5607ecaaeb497afb6227393d35e1e90945126db6bf547dd7039
7
+ data.tar.gz: db23b7e6e3e93b98703a6f69e0ce1ff7aca5b667c49f2ce480b55d3e0e7a762a85594a07172e852e4a46892d1431fbdd30fd18f2afc9d19593aabeaf13b487cc
data/Gemfile CHANGED
@@ -6,3 +6,8 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
+ gem 'activerecord'
10
+ gem 'sqlite3'
11
+ group :development, :test do
12
+ gem 'byebug'
13
+ end
data/Gemfile.lock CHANGED
@@ -6,14 +6,66 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- rake (13.0.3)
9
+ activemodel (7.1.4.2)
10
+ activesupport (= 7.1.4.2)
11
+ activerecord (7.1.4.2)
12
+ activemodel (= 7.1.4.2)
13
+ activesupport (= 7.1.4.2)
14
+ timeout (>= 0.4.0)
15
+ activesupport (7.1.4.2)
16
+ base64
17
+ bigdecimal
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ connection_pool (>= 2.2.5)
20
+ drb
21
+ i18n (>= 1.6, < 2)
22
+ minitest (>= 5.1)
23
+ mutex_m
24
+ tzinfo (~> 2.0)
25
+ base64 (0.2.0)
26
+ bigdecimal (3.1.8)
27
+ byebug (11.1.3)
28
+ concurrent-ruby (1.3.4)
29
+ connection_pool (2.4.1)
30
+ diff-lcs (1.5.1)
31
+ drb (2.2.1)
32
+ i18n (1.14.6)
33
+ concurrent-ruby (~> 1.0)
34
+ mini_portile2 (2.8.7)
35
+ minitest (5.25.1)
36
+ mutex_m (0.2.0)
37
+ rake (13.2.1)
38
+ rspec (3.13.0)
39
+ rspec-core (~> 3.13.0)
40
+ rspec-expectations (~> 3.13.0)
41
+ rspec-mocks (~> 3.13.0)
42
+ rspec-core (3.13.2)
43
+ rspec-support (~> 3.13.0)
44
+ rspec-expectations (3.13.3)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.13.0)
47
+ rspec-mocks (3.13.2)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.13.0)
50
+ rspec-support (3.13.1)
51
+ sqlite3 (2.0.4)
52
+ mini_portile2 (~> 2.8.0)
53
+ sqlite3 (2.0.4-x86_64-linux-gnu)
54
+ timeout (0.4.1)
55
+ tzinfo (2.0.6)
56
+ concurrent-ruby (~> 1.0)
10
57
 
11
58
  PLATFORMS
59
+ ruby
12
60
  x86_64-linux
13
61
 
14
62
  DEPENDENCIES
63
+ activerecord
64
+ byebug
15
65
  rake (~> 13.0)
66
+ rspec (~> 3.0)
67
+ sqlite3
16
68
  temp_table!
17
69
 
18
70
  BUNDLED WITH
19
- 2.3.7
71
+ 2.5.22
@@ -0,0 +1,7 @@
1
+ # lib/temp_table/config/initializers/database.rb
2
+ require 'active_record'
3
+
4
+ ActiveRecord::Base.establish_connection(
5
+ adapter: 'sqlite3', # or 'postgresql', 'mysql2', etc.
6
+ database: 'db/development.sqlite3'
7
+ )
@@ -43,11 +43,11 @@ module TempTable
43
43
  #{column_definitions_string};
44
44
  SQL
45
45
 
46
- Rails.logger.info("Executing SQL: #{sql}")
46
+ $logger.info("Executing SQL: #{sql}")
47
47
 
48
48
  ActiveRecord::Base.connection.execute(sql)
49
49
  rescue ActiveRecord::StatementInvalid => e
50
- Rails.logger.info("SQL Error: #{e.message}")
50
+ $logger.info("SQL Error: #{e.message}")
51
51
  end
52
52
 
53
53
  def add_foreign_key
@@ -60,7 +60,7 @@ module TempTable
60
60
  FOREIGN KEY (original_id) REFERENCES #{original_table_name}(id);
61
61
  SQL
62
62
  else
63
- Rails.logger.info("Cannot add foreign key: #{original_table_name} is not a temporary table.")
63
+ $logger.info("Cannot add foreign key: #{original_table_name} is not a temporary table.")
64
64
  end
65
65
  end
66
66
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TempTable
4
- VERSION = "0.1.0"
4
+ # VERSION = "0.1.0"
5
+ VERSION = "1.0.0"
5
6
  end
data/lib/temp_table.rb CHANGED
@@ -1,30 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "temp_table/version"
4
+ require_relative "temp_table/config/initializers/database"
5
+ require_relative "temp_table/copy"
6
+ require_relative "temp_table/create"
7
+ require_relative "temp_table/fetch"
8
+ require_relative "temp_table/insert_row_from_original"
9
+ require_relative "temp_table/insert_row_from_reference"
10
+ require_relative "temp_table/insert"
11
+ require "logger"
4
12
 
5
13
  module TempTable
6
14
  class Error < StandardError; end
7
- def self.fetch(table_name, conditions = nil)
8
- TempTable::Fetch.new(table_name, conditions).perform
9
- end
15
+ $logger = Logger.new(STDOUT)
16
+ class << self
17
+ def fetch(table_name, conditions = nil)
18
+ TempTable::Fetch.new(table_name, conditions).perform
19
+ end
10
20
 
11
- def self.insert(table_name, data)
12
- TempTable::Insert.new(table_name, data).perform
13
- end
21
+ def insert(table_name, data)
22
+ TempTable::Insert.new(table_name, data).perform
23
+ end
14
24
 
15
- def self.insert_row_from_original(original_table_name, original_id, table_name)
16
- TempTable::InsertRowFromOriginal.new(original_table_name, original_id, table_name).perform
17
- end
25
+ def insert_row_from_original(original_table_name, original_id, table_name)
26
+ TempTable::InsertRowFromOriginal.new(original_table_name, original_id, table_name).perform
27
+ end
18
28
 
19
- def self.insert_row_from_reference(reference_column, reference_id, data, original_table_name, table_name)
20
- TempTable::InsertRowFromReferenceService.new(reference_column, reference_id, data, original_table_name, table_name).perform
21
- end
29
+ def insert_row_from_reference(reference_column, reference_id, data, original_table_name, table_name)
30
+ TempTable::InsertRowFromReferenceService.new(reference_column, reference_id, data, original_table_name, table_name).perform
31
+ end
22
32
 
23
- def self.create(table_name, columns)
24
- TempTable::Create.new(table_name, columns).perform
25
- end
33
+ def create(table_name, columns)
34
+ TempTable::Create.new(table_name, columns).perform
35
+ end
26
36
 
27
- def self.copy(original_table_name, table_name, extra_columns = nil)
28
- TempTable::Copy.new(original_table_name, table_name, extra_columns = nil).perform
37
+ def copy(original_table_name, table_name, extra_columns = nil)
38
+ TempTable::Copy.new(original_table_name, table_name, extra_columns).perform
39
+ end
29
40
  end
30
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temp_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shesh Nath Goswami
@@ -9,7 +9,35 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2024-10-27 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.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: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: You can create temporary tables using this gem to store data temporarily
14
42
  until the user's session is active.
15
43
  email:
@@ -23,6 +51,7 @@ files:
23
51
  - README.md
24
52
  - Rakefile
25
53
  - lib/temp_table.rb
54
+ - lib/temp_table/config/initializers/database.rb
26
55
  - lib/temp_table/copy.rb
27
56
  - lib/temp_table/create.rb
28
57
  - lib/temp_table/fetch.rb