rails-domino 0.2.9.1 → 0.2.9.3

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: f051893c17c7d60139d794dbd423e385d39253a917c606ef58d740ad2dceb02d
4
- data.tar.gz: '0319ae33ac061847b3e40e70153e27738983f9c332c125e5584f29671655bfc5'
3
+ metadata.gz: 9ad8b002c5b3dbc3acaacd130c2aa856a37fd9fadea0d159b0a7153f45f7a362
4
+ data.tar.gz: 5a34dc2bbc0462735e0fd32be3a55c64179dc0f84e811f423fae3a8807eb98cf
5
5
  SHA512:
6
- metadata.gz: e93880ccaa2572aade5ecea504e0dacc6c0d50185a2dfb01299995e123581fbd57c9950a8fbb8b0f1dd50eb60e2c64a2e9511add1af3cbf21c610384df063e69
7
- data.tar.gz: 328eb38658e11ba8626b5d4ddaffe71f7804d2fe4b79b0cb530c07554a89fabce909624d1e1464ab0d76bada8961283264277ba3f7472e10ba8cc83a08820ff0
6
+ metadata.gz: 386ebca7ab3f1134f0f19d3f804152401358ac1c8cd90cb26295d343c9fd222fb7b9631e9d91fb98c244a69899379616b971f3399c1b37c627c1c3d21ae0c032
7
+ data.tar.gz: b14b99a9ec6750e925748d55c3a98accd60ff885c2e613a8f51fc994198c5ecc2f9caa663f56e1253c059ef09712dc6468b3276f20af52be09c279cebb779257
@@ -10,7 +10,8 @@ module Domino
10
10
  # @param generate_model [Boolean] whether to run model generation
11
11
  def self.scaffold(tables: nil, namespace: nil, generate_model: true)
12
12
  connection = ActiveRecord::Base.connection
13
- tables ||= connection.tables.reject { |t| t == "schema_migrations" }
13
+ tables ||= connection.tables.reject { |t| %w[schema_migrations ar_internal_metadata].include?(t) }
14
+ # tables ||= connection.tables.reject { |t| t == "schema_migrations" }
14
15
 
15
16
  tables.each do |table|
16
17
  klass = table.singularize.camelize
@@ -41,11 +42,33 @@ module Domino
41
42
  end
42
43
 
43
44
  def generate_model_file
44
- system("rails generate model #{@model_name} #{column_args.join(" ")}")
45
+ cmd = ["rails", "generate", "model", @model_name] + column_args
46
+ system(*cmd)
47
+ # system("rails generate model #{@model_name} #{column_args.join(" ")}")
45
48
  end
46
49
 
47
50
  def column_args
48
- @columns.map { |col| "#{col.name}:#{col.sql_type}" unless col.name == "id" }.compact
51
+ # @columns.map { |col| "#{col.name}:#{col.sql_type}" unless col.name == "id" }.compact
52
+ @columns.map do |col|
53
+ next if col.name == "id"
54
+
55
+ rails_type = map_sql_type(col.sql_type)
56
+ "#{col.name}:#{rails_type}" if rails_type
57
+ end.compact
58
+ end
59
+
60
+ def map_sql_type(sql_type) # rubocop:disable Metrics/MethodLength
61
+ case sql_type
62
+ when /nvarchar|varchar|text/ then "string"
63
+ when /int/ then "integer"
64
+ when /timestamp/ then "datetime"
65
+ when /bool/ then "boolean"
66
+ when /decimal|numeric/ then "decimal"
67
+ when /date/ then "date"
68
+ else
69
+ puts "Warning: unknown SQL type #{sql_type}, skipping."
70
+ nil
71
+ end
49
72
  end
50
73
 
51
74
  def generate_file(type) # rubocop:disable Metrics/MethodLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Domino
4
- VERSION = "0.2.9.1"
4
+ VERSION = "0.2.9.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-domino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9.1
4
+ version: 0.2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kiebor81