typelizer 0.1.3 → 0.1.4

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: 883dbe72ef62317bf7561ca3bc91fde04264c479433b8b8db93e04533a34e017
4
- data.tar.gz: 72ce93cdf283d81378278a465ac20627b0e5a89237246c953039cfe3aab9f7aa
3
+ metadata.gz: 45bdcfd99663e0a61f6d70b5825f4ee29db4bc70927676c162fab5e8557675d6
4
+ data.tar.gz: ff3df8f4e1433bf7e8eb2f88318c117d58f86d14b974d6c1100fafe04988edc6
5
5
  SHA512:
6
- metadata.gz: 35ea6330569e25236a7a77a89d86558eb260c24fc93ca21f2c07191a299e47bc5798c86fda6a0c1c82ac1c1f8ef00eafb2007962fa2219a724d31e2653cb686a
7
- data.tar.gz: dbdf51e50c2f327e31785be7f3e60f2b016136b7ca9fb282be3e63935f96b6217758a308e305bb4e75d4a58bc5d41d330df26cd27a2eb514fd920295f5a2f151
6
+ metadata.gz: ed256b928dd5621f2a573c74997bcb2dd072af8ed02e79919e3f0506056bfd579405d234257136d87a3840393cc6fa625f2b50c1e9362eabcb5b7682e0d0eb00
7
+ data.tar.gz: ba1dab8fa94374dc25b02ac67b7e995f4a5d10c9492ceddf7bb866f22abaf609d148393af8a6c1eb899ccb553f0b2be542618811b58e1ae6b08f0d9d95d916ae
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.4] - 2024-10-04
11
+
12
+ ## Added
13
+
14
+ - PORO model plugin ([@okuramasafumi])
15
+ - Auto model plugin ([@skryukov])
16
+
10
17
  ## [0.1.3] - 2024-09-27
11
18
 
12
19
  ## Added
@@ -48,7 +55,8 @@ and this project adheres to [Semantic Versioning].
48
55
  [@okuramasafumi]: https://github.com/@okuramasafumi
49
56
  [@skryukov]: https://github.com/skryukov
50
57
 
51
- [Unreleased]: https://github.com/skryukov/typelizer/compare/v0.1.3...HEAD
58
+ [Unreleased]: https://github.com/skryukov/typelizer/compare/v0.1.4...HEAD
59
+ [0.1.4]: https://github.com/skryukov/typelizer/compare/v0.1.3...v0.1.4
52
60
  [0.1.3]: https://github.com/skryukov/typelizer/compare/v0.1.2...v0.1.3
53
61
  [0.1.2]: https://github.com/skryukov/typelizer/compare/v0.1.1...v0.1.2
54
62
  [0.1.1]: https://github.com/skryukov/typelizer/compare/v0.1.0...v0.1.1
data/README.md CHANGED
@@ -202,8 +202,8 @@ Typelizer.configure do |config|
202
202
  # Custom transformation for generated properties
203
203
  config.properties_transformer = ->(properties) { ... }
204
204
 
205
- # Plugin for model type inference (default: ModelPlugins::ActiveRecord)
206
- config.model_plugin = Typelizer::ModelPlugins::ActiveRecord
205
+ # Plugin for model type inference (default: ModelPlugins::Auto)
206
+ config.model_plugin = Typelizer::ModelPlugins::Auto
207
207
 
208
208
  # Plugin for serializer parsing (default: SerializerPlugins::Auto)
209
209
  config.serializer_plugin = Typelizer::SerializerPlugins::Auto
@@ -39,7 +39,7 @@ module Typelizer
39
39
  Object.const_get(base_class) if Object.const_defined?(base_class)
40
40
  end,
41
41
 
42
- model_plugin: ModelPlugins::ActiveRecord,
42
+ model_plugin: ModelPlugins::Auto,
43
43
  serializer_plugin: SerializerPlugins::Auto,
44
44
  plugin_configs: {},
45
45
 
@@ -0,0 +1,19 @@
1
+ module Typelizer
2
+ module ModelPlugins
3
+ module Auto
4
+ class << self
5
+ def new(model_class:, config:)
6
+ plugin(model_class).new(model_class: model_class, config: config)
7
+ end
8
+
9
+ def plugin(model_class)
10
+ if model_class && model_class < ::ActiveRecord::Base
11
+ ActiveRecord
12
+ else
13
+ Poro
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module Typelizer
2
+ module ModelPlugins
3
+ class Poro
4
+ # We don't care about intialization
5
+ def initialize(...)
6
+ end
7
+
8
+ def infer_types(prop)
9
+ prop
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Typelizer
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/typelizer.rb CHANGED
@@ -16,6 +16,8 @@ require_relative "typelizer/serializer_plugins/alba"
16
16
  require_relative "typelizer/serializer_plugins/ams"
17
17
 
18
18
  require_relative "typelizer/model_plugins/active_record"
19
+ require_relative "typelizer/model_plugins/poro"
20
+ require_relative "typelizer/model_plugins/auto"
19
21
 
20
22
  require_relative "typelizer/railtie" if defined?(Rails)
21
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -41,6 +41,8 @@ files:
41
41
  - lib/typelizer/interface.rb
42
42
  - lib/typelizer/listen.rb
43
43
  - lib/typelizer/model_plugins/active_record.rb
44
+ - lib/typelizer/model_plugins/auto.rb
45
+ - lib/typelizer/model_plugins/poro.rb
44
46
  - lib/typelizer/property.rb
45
47
  - lib/typelizer/railtie.rb
46
48
  - lib/typelizer/renderer.rb