Skip to content

Commit 22169eb

Browse files
committed
Bump version to 1.0.0
1 parent 3c54c9e commit 22169eb

File tree

10 files changed

+220
-30
lines changed

10 files changed

+220
-30
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
/tmp/
99
/vendor
1010
/log
11-
/*.gem
11+
/*.gem
12+
.byebug_history
13+
.rspec
14+
/*db
15+
/db

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ source "https://rubygems.org"
66
gemspec
77

88
gem "rake", "~> 13.0"
9+
gem 'activerecord'
10+
gem 'sqlite3'
11+
group :development, :test do
12+
gem 'byebug'
13+
end

Gemfile.lock

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,66 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
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)
1057

1158
PLATFORMS
59+
ruby
1260
x86_64-linux
1361

1462
DEPENDENCIES
63+
activerecord
64+
byebug
1565
rake (~> 13.0)
66+
rspec (~> 3.0)
67+
sqlite3
1668
temp_table!
1769

1870
BUNDLED WITH
19-
2.3.7
71+
2.5.22

lib/temp_table.rb

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
# frozen_string_literal: true
22

33
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"
412

513
module TempTable
614
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
1020

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
1424

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
1828

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
2232

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
2636

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
2940
end
3041
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
)

lib/temp_table/copy.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ def add_columns_from_original
4343
#{column_definitions_string};
4444
SQL
4545

46-
Rails.logger.info("Executing SQL: #{sql}")
46+
$logger.info("Executing SQL: #{sql}")
4747

4848
ActiveRecord::Base.connection.execute(sql)
4949
rescue ActiveRecord::StatementInvalid => e
50-
Rails.logger.info("SQL Error: #{e.message}")
50+
$logger.info("SQL Error: #{e.message}")
5151
end
5252

5353
def add_foreign_key
@@ -60,7 +60,7 @@ def add_foreign_key
6060
FOREIGN KEY (original_id) REFERENCES #{original_table_name}(id);
6161
SQL
6262
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.")
6464
end
6565
end
6666

lib/temp_table/version.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

33
module TempTable
4-
VERSION = "0.1.0"
4+
# VERSION = "0.1.0"
5+
VERSION = "1.0.0"
56
end

spec/spec_helper.rb

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
require 'byebug'
2+
# This file was generated by the `rspec --init` command. Conventionally, all
3+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4+
# The generated `.rspec` file contains `--require spec_helper` which will cause
5+
# this file to always be loaded, without a need to explicitly require it in any
6+
# files.
7+
#
8+
# Given that it is always loaded, you are encouraged to keep this file as
9+
# light-weight as possible. Requiring heavyweight dependencies from this file
10+
# will add to the boot time of your test suite on EVERY test run, even for an
11+
# individual file that may not need all of that loaded. Instead, consider making
12+
# a separate helper file that requires the additional dependencies and performs
13+
# the additional setup, and require it from the spec files that actually need
14+
# it.
15+
#
16+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17+
RSpec.configure do |config|
18+
# rspec-expectations config goes here. You can use an alternate
19+
# assertion/expectation library such as wrong or the stdlib/minitest
20+
# assertions if you prefer.
21+
config.expect_with :rspec do |expectations|
22+
# This option will default to `true` in RSpec 4. It makes the `description`
23+
# and `failure_message` of custom matchers include text for helper methods
24+
# defined using `chain`, e.g.:
25+
# be_bigger_than(2).and_smaller_than(4).description
26+
# # => "be bigger than 2 and smaller than 4"
27+
# ...rather than:
28+
# # => "be bigger than 2"
29+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30+
end
31+
32+
# rspec-mocks config goes here. You can use an alternate test double
33+
# library (such as bogus or mocha) by changing the `mock_with` option here.
34+
config.mock_with :rspec do |mocks|
35+
# Prevents you from mocking or stubbing a method that does not exist on
36+
# a real object. This is generally recommended, and will default to
37+
# `true` in RSpec 4.
38+
mocks.verify_partial_doubles = true
39+
end
40+
41+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
42+
# have no way to turn it off -- the option exists only for backwards
43+
# compatibility in RSpec 3). It causes shared context metadata to be
44+
# inherited by the metadata hash of host groups and examples, rather than
45+
# triggering implicit auto-inclusion in groups with matching metadata.
46+
config.shared_context_metadata_behavior = :apply_to_host_groups
47+
48+
# The settings below are suggested to provide a good initial experience
49+
# with RSpec, but feel free to customize to your heart's content.
50+
=begin
51+
# This allows you to limit a spec run to individual examples or groups
52+
# you care about by tagging them with `:focus` metadata. When nothing
53+
# is tagged with `:focus`, all examples get run. RSpec also provides
54+
# aliases for `it`, `describe`, and `context` that include `:focus`
55+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56+
config.filter_run_when_matching :focus
57+
58+
# Allows RSpec to persist some state between runs in order to support
59+
# the `--only-failures` and `--next-failure` CLI options. We recommend
60+
# you configure your source control system to ignore this file.
61+
config.example_status_persistence_file_path = "spec/examples.txt"
62+
63+
# Limits the available syntax to the non-monkey patched syntax that is
64+
# recommended. For more details, see:
65+
# https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
66+
config.disable_monkey_patching!
67+
68+
# This setting enables warnings. It's recommended, but in some cases may
69+
# be too noisy due to issues in dependencies.
70+
config.warnings = true
71+
72+
# Many RSpec users commonly either run the entire suite or an individual
73+
# file, and it's useful to allow more verbose output when running an
74+
# individual spec file.
75+
if config.files_to_run.one?
76+
# Use the documentation formatter for detailed output,
77+
# unless a formatter has already been configured
78+
# (e.g. via a command-line flag).
79+
config.default_formatter = "doc"
80+
end
81+
82+
# Print the 10 slowest examples and example groups at the
83+
# end of the spec run, to help surface which specs are running
84+
# particularly slow.
85+
config.profile_examples = 10
86+
87+
# Run specs in random order to surface order dependencies. If you find an
88+
# order dependency and want to debug it, you can fix the order by providing
89+
# the seed, which is printed after each run.
90+
# --seed 1234
91+
config.order = :random
92+
93+
# Seed global randomization in this process using the `--seed` CLI option.
94+
# Setting this allows you to use `--seed` to deterministically reproduce
95+
# test failures related to randomization by passing the same `--seed` value
96+
# as the one that triggered the failure.
97+
Kernel.srand config.seed
98+
=end
99+
end

spec/temp_table_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'temp_table'
2+
3+
RSpec.describe TempTable do
4+
it 'does something expected' do
5+
debugger
6+
expect(TempTable.copy("test", "temp_test")).to eq('expected_result')
7+
end
8+
end

temp_table.gemspec

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,33 @@ Gem::Specification.new do |spec|
99
spec.email = ["sheshwork08@gmail.com"]
1010
spec.license = "MIT"
1111

12-
spec.summary = "To create temporary table."
13-
spec.description = "You can create the temporary table using this gem so that you can make a temp table and store its data temproraly until the user's session is active."
12+
spec.summary = "To create temporary tables."
13+
spec.description = "You can create temporary tables using this gem to store data temporarily until the user's session is active."
1414
spec.homepage = "https://github.com/Shesh-08/temp-table"
1515
spec.required_ruby_version = ">= 2.6.0"
1616

17-
spec.metadata["allowed_push_host"] = "https://github.com/Shesh-08/temp-table"
17+
# Change allowed_push_host to point to RubyGems
18+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
1819

1920
spec.metadata["homepage_uri"] = spec.homepage
20-
spec.metadata["source_code_uri"] = "https://github.com/Shesh-08/temp-table"
21-
spec.metadata["changelog_uri"] = "https://github.com/Shesh-08/temp-table/blob/master/README.md"
21+
spec.metadata["source_code_uri"] = spec.homepage # This can also point to your GitHub repo
22+
spec.metadata["changelog_uri"] = "https://github.com/Shesh-08/temp-table/blob/master/CHANGELOG.md" # Adjust if you have a changelog
2223

2324
# Specify which files should be added to the gem when it is released.
24-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
2525
spec.files = Dir.chdir(File.expand_path(__dir__)) do
2626
`git ls-files -z`.split("\x0").reject do |f|
2727
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
2828
end
2929
end
30+
3031
spec.bindir = "exe"
3132
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
3233
spec.require_paths = ["lib"]
3334

3435
# Uncomment to register a new dependency of your gem
3536
# spec.add_dependency "example-gem", "~> 1.0"
37+
spec.add_development_dependency 'rspec', '~> 3.0'
38+
spec.add_development_dependency 'activerecord'
3639

3740
# For more information and examples about making a new gem, check out our
3841
# guide at: https://bundler.io/guides/creating_gem.html

0 commit comments

Comments
 (0)