Domain_Handler 0.0.17 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/domain_handler.rb +42 -34
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2288d19503f34db2e033f33a9222e8801266819b48dfdedd9ce275cc10f7cf0
4
- data.tar.gz: 95e1181df5de19cd4b44c759b4511df189145bde4a90ad29b3310279a3613489
3
+ metadata.gz: b5388e6098b20e3a270abbc2ddb57ae34a6019181dbc745b07f10c05a33b10ac
4
+ data.tar.gz: 3d22f4700b849b794924aef5b0f79b233bba14c64b573aefce6b0911981ebc78
5
5
  SHA512:
6
- metadata.gz: bb354e63e7ff8001f9681dbf55c1900032608332deb9d21d280e36a2157efe8ba0ed75eb6c025e9c74edb51ef833f5b3f938313648b956810b723a6ca2c4e84c
7
- data.tar.gz: 1b357125d933a46e0a2d47fc9869f0195f77a0d9c40ec765c5ba0925af291e76b5da840eaae1cd44ed0143ac96f2c716bf11a250be59f9ab8a23aa1ada0f126e
6
+ metadata.gz: 4bd847d76fe25afec4304c8b9fc7a0f63b595bd33f76b328381d8b09936d284d2a4becedccdf3d2bf3f884aade2b0f4a22f8b2ac39e871c52246a2555741247e
7
+ data.tar.gz: 640c1e604aead80ec89f06a8536ee71d62b8d30f9db5c3b85655387a5845981ccc8752c0ce31f4a00031571f03ab1e75c309123acac5900b12649dec01e78759
@@ -68,40 +68,48 @@ class DomainHandler
68
68
  )
69
69
  end
70
70
 
71
- def self.generate_migration
72
- require 'active_record'
73
- require 'active_record/migration'
74
- # Connect to your database
75
- ActiveRecord::Base.establish_connection(
76
- database: ENV['DB_NAME'],
77
- username: ENV['DB_USER'],
78
- password: ENV['DB_PWD'],
79
- host: 'http://localhost:5432',
80
- adapter: ENV['DB_ADAPTER']
81
- )
82
-
83
- timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
84
- migration_file = "db/migrate/#{timestamp}_create_domains.rb"
85
-
86
- migration_context = ActiveRecord::MigrationContext.new("db/migrate")
87
-
88
- # Generate the migration file using the create_table method
89
- migration_context.migrate("CreateDomains", nil, target_version: nil)
90
- end
91
- end
71
+ def self.create_migration
72
+ migration_name = 'create_domains'
73
+
74
+ # Generate a timestamp to use as the migration version
75
+ timestamp = Time.now.strftime('%Y%m%d%H%M%S')
76
+
77
+ # Generate the migration file name
78
+ migration_file_name = "#{timestamp}_#{migration_name}.rb"
79
+
80
+ # Specify the migration class name
81
+ migration_class_name = migration_name.camelize
82
+
83
+ # Specify the migration file path
84
+ migration_file_path = Rails.root.join('db', 'migrate', migration_file_name)
85
+ # Create the migration file
86
+ File.open(migration_file_path, 'w') do |file|
87
+ file.write("class #{migration_class_name} < ActiveRecord::Migration[6.1]\n")
88
+ file.write(" def change\n")
89
+ file.write(" create_table :domains, id: false, primary_key: :domain_id do |t|\n")
90
+ file.write(" # Define your table columns here\n")
91
+ file.write(" t.references :shop, foreign_key: true\n")
92
+ file.write(" t.string :host, null: false, default: ''\n")
93
+ file.write(" t.string :localization\n")
94
+ file.write(" t.string :market_web_presence\n")
95
+ file.write(" t.boolean :ssl_enabled, null: false\n")
96
+ file.write(" t.string :url\n")
97
+ file.write(" t.string :domain_id\n")
98
+ file.write(" t.index :domain_id, unique: true\n")
99
+ file.write(" t.timestamps\n")
100
+ file.write(" end\n")
101
+ file.write(" end\n")
102
+ file.write("end\n")
103
+ end
92
104
 
93
- class CreateDomains < ActiveRecord::Migration[5.0]
94
- def change
95
- create_table :domains, id: false, primary_key: :domain_id do |t|
96
- t.references :shop, foreign_key: true
97
- t.string :host, null: false, default: ''
98
- t.string :localization
99
- t.string :market_web_presence
100
- t.boolean :ssl_enabled, null: false
101
- t.string :url
102
- t.string :domain_id
103
- t.index :domain_id, unique: true
104
- t.timestamps
105
+ model_name = 'domain.rb'
106
+ model_file_path = Rails.root.join('app', 'models', model_name)
107
+ File.open(model_file_path, 'w') do |file|
108
+ file.write("class Domain < ApplicationRecord \n")
109
+ file.write(" self.primary_key = :domain_id \n")
110
+ file.write(" belongs_to :shop \n")
111
+ file.write(" belongs_to :shop \n")
112
+ file.write("end \n")
105
113
  end
106
114
  end
107
- end
115
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Domain_Handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arun Sahu
@@ -31,7 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/domain_handler.rb
34
- homepage: https://rubygems.org/gems/hola
34
+ homepage: https://rubygems.org
35
35
  licenses:
36
36
  - MIT
37
37
  metadata: {}