ts_schema 0.1.4 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63ca27c32ffaa091d17e4bc7dcc6f2f6cd17b090474c17194e41a865dc37a3df
4
- data.tar.gz: 1e6e1a099da55952ff630cea38be5c00fc4082f4696ed26c7f4e8a805de11261
3
+ metadata.gz: 3c5b7352bbc0b12a6d1925a6a3a3bbbd5cd07cdf0cc2357bd8ffa78ae2a914ff
4
+ data.tar.gz: a64da9cdc3cf78a889bd5a627b7da1a0db7069ca2810656d4fc6c9b100d46005
5
5
  SHA512:
6
- metadata.gz: 6b2a1a3fe335a598d6c134af21d739648ef005dbf80510b66c042d4c995bad8766db5cd702f15b30ecf6d1bba4ae051c151aa0dbd986d59be47632fd0b8cacb4
7
- data.tar.gz: 0e3a43734a1214d4c11c4dbaa18cf8ce3527c99e796baa05d6eb41008424a7ee83742bb730dca5b3c410705f1f8fd7f16e82595f7fc03b11c8c26abcf7d9a49f
6
+ metadata.gz: d1fe180689d19ea43a0b1359bc1995dfe49432507c139b9253d89cd880810838b0c59b5e40b2fdc291fdf34921283f7e776dda5b24b0d5aa2ab1c6bc6a8544ed
7
+ data.tar.gz: 17c2297757977a80b4f311f5348f0892ebf7c645fc58d50324d75fd7cfd582b3a2e9ce22af26ae55e25c0f17a20695664a9f216736e923ecfd0aaa0d3860ff8f
@@ -41,6 +41,11 @@ TsSchema.setup do |config|
41
41
  # Whether to generate types for associations
42
42
  # config.include_associated = true
43
43
 
44
+ # Additional models to map which don't have a model file
45
+ # config.additional_models = [
46
+ #
47
+ # ]
48
+
44
49
  # Namespace
45
50
  # config.namespace = :schema
46
51
 
@@ -13,6 +13,7 @@ module TsSchema
13
13
  namespace: :schema,
14
14
  indent: :tab,
15
15
  spaces: 2,
16
+ additional_models: []
16
17
  }
17
18
 
18
19
  attr_accessor(*DEFAULTS.keys)
@@ -5,6 +5,7 @@ module TsSchema
5
5
  def initialize
6
6
  Rails.application.eager_load!
7
7
  @models = ApplicationRecord.send(:subclasses)
8
+ @models.concat(TsSchema.configuration.additional_models) unless TsSchema.configuration.additional_models.empty?
8
9
  @types = TsSchema.configuration.types.merge(TsSchema.configuration.custom_types || {})
9
10
  end
10
11
 
@@ -33,7 +34,7 @@ module TsSchema
33
34
  columns.concat(map_associations(model)) if TsSchema.configuration.include_associated
34
35
 
35
36
  type_template += <<~TYPESCRIPT
36
- interface #{model.model_name.name} {
37
+ interface #{model.model_name.param_key.camelize} {
37
38
  #{columns.map { |column| "#{indent_as_str}#{column_name_cased(column[:name])}: #{column[:ts_type]};" }.join("\n")}
38
39
  }\n
39
40
  TYPESCRIPT
@@ -1,3 +1,3 @@
1
1
  module TsSchema
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avram Walden