rsodx 0.0.3 → 0.0.5

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: 74be3af36e2f6319995f69ec786e1067923306f658d57147902cbaca1e285387
4
- data.tar.gz: 8434da27ab813e8b757f4d5a3c6acc71cf9b9522987aea52b119c97aa8dcfda6
3
+ metadata.gz: b217ac144c8fbb46a2bb7925dd8bb24c6d994527e395cc5b80d692678b0aafc3
4
+ data.tar.gz: 94a126bcac19393eb9eeefdb0188e20003f5c7d2e71dd4e0f609b9525727cfaf
5
5
  SHA512:
6
- metadata.gz: 40244cd860d2e0e3f9010a2abca202c3c4f87720b2f99122071c240330e9d54ad82398c0f78fef94388ed6336dbdd162c0956bb24ba847c5270966488539b21a
7
- data.tar.gz: 72f2e95d4a9ed42bbe82f3c013471a9b3aa4789568013dcb038edf9e514249e2b06591cfa99be7c14408c1a6f7b5bded9fa99118cfbaf430157bc37568d990d3
6
+ metadata.gz: afaf0f6269158079ce894bb3ae483c0414bd9c0a76797c0bc2ffa9b958f235a9bbc739205ec7ababae85a1f2d76cc1f27805828b8e920e275eea9ee7e1e645b1
7
+ data.tar.gz: 6bc50511150506c1736888779f0564b6c1896b6811c0f0b818f07573431fe733ecc0b21bd2470338e4f156e9d303a96fffdf9ffeef46fc6e85e94167a0019d6a
@@ -52,7 +52,12 @@ module Rsodx::Cli::Commands::ScaffoldCommon
52
52
  ENV_LOADER = <<~ENV_LOADER.freeze
53
53
  require "rsodx"
54
54
  Rsodx::Environment.load_dotenv(ENV["RACK_ENV"] || "development")
55
- Rsodx::Connect.connect ENV["DATABASE_URL"]
55
+
56
+ Rsodx.configure do |config|
57
+ config.database_url = ENV["DATABASE_URL"]
58
+ end
59
+ Rsodx::Connect.connect
60
+
56
61
  Rsodx::Environment.load_initializers(File.expand_path("../..", __FILE__))
57
62
  Rsodx::Boot.load_app_structure(File.expand_path("../..", __FILE__))
58
63
  ENV_LOADER
@@ -0,0 +1,9 @@
1
+ module Rsodx
2
+ class Configuration
3
+ attr_accessor :database_url
4
+
5
+ def initialize
6
+ @database_url = ENV["DATABASE_URL"]
7
+ end
8
+ end
9
+ end
data/lib/rsodx/connect.rb CHANGED
@@ -2,12 +2,18 @@ require "sequel"
2
2
 
3
3
  module Rsodx
4
4
  module Connect
5
- def self.connect(url)
5
+ @db = nil
6
+
7
+ def self.connect(url = Rsodx.config.database_url)
6
8
  raise "Missing DATABASE_URL" unless url
9
+ return @db if @db
10
+
11
+ @db = Sequel.connect(url)
12
+ Sequel::Model.db = @db
13
+ end
7
14
 
8
- db = Sequel.connect(url)
9
- Sequel::Model.db = db
10
- db
15
+ def self.db
16
+ @db || connect
11
17
  end
12
18
  end
13
19
  end
@@ -5,8 +5,8 @@ module Rsodx
5
5
  Dotenv.load('.env', ".env.#{env}") if env
6
6
  end
7
7
 
8
- def self.load_initializers(config_path)
9
- Dir[File.join(config_path, "initializers", "*.rb")].sort.each { |file| require file }
8
+ def self.load_initializers(app_root)
9
+ Dir[File.join(app_root, "config", "initializers", "*.rb")].sort.each { |file| require file }
10
10
  end
11
11
  end
12
12
  end
data/lib/rsodx/tasks.rb CHANGED
@@ -5,11 +5,11 @@ require "sequel/extensions/migration"
5
5
 
6
6
  namespace :db do
7
7
  task :migrate do
8
- Sequel::Migrator.run(DB.connect, "db/migrations")
8
+ Sequel::Migrator.run(Rsodx::Connect.db, "db/migrations")
9
9
  end
10
10
 
11
11
  task :rollback do
12
- target = Sequel::Migrator.apply(DB.connect, "db/migrations", :down) - 1
13
- Sequel::Migrator.run(DB.connect, "db/migrations", target: target)
12
+ target = Sequel::Migrator.apply(Rsodx::Connect.db, "db/migrations", :down) - 1
13
+ Sequel::Migrator.run(Rsodx::Connect.db, "db/migrations", target: target)
14
14
  end
15
15
  end
data/lib/rsodx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rsodx
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.5"
5
5
  end
data/lib/rsodx.rb CHANGED
@@ -14,4 +14,14 @@ Dir.glob("#{base}/rsodx/**/*.rb").sort.each do |file|
14
14
  end
15
15
 
16
16
  module Rsodx
17
+ class << self
18
+ attr_accessor :config
19
+
20
+ def configure
21
+ self.config ||= Configuration.new
22
+ yield(config)
23
+ end
24
+ end
17
25
  end
26
+
27
+ Rsodx.config ||= Rsodx::Configuration.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsodx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Pervushin
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-15 00:00:00.000000000 Z
10
+ date: 2025-04-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -220,6 +220,7 @@ files:
220
220
  - lib/rsodx/cli/commands/scaffold.rb
221
221
  - lib/rsodx/cli/commands/scaffold_common.rb
222
222
  - lib/rsodx/cli/commands/server.rb
223
+ - lib/rsodx/configuration.rb
223
224
  - lib/rsodx/connect.rb
224
225
  - lib/rsodx/constants.rb
225
226
  - lib/rsodx/contract.rb