ts_schema 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +160 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +35 -0
  7. data/Rakefile +3 -0
  8. data/bin/test +5 -0
  9. data/lib/generators/install_generator.rb +21 -0
  10. data/lib/generators/templates/ts_schema.rb +30 -0
  11. data/lib/tasks/ts_schema_tasks.rake +24 -0
  12. data/lib/ts_schema/configuration.rb +41 -0
  13. data/lib/ts_schema/conversion_table.yml +18 -0
  14. data/lib/ts_schema/railtie.rb +4 -0
  15. data/lib/ts_schema/schema_generator.rb +110 -0
  16. data/lib/ts_schema/version.rb +3 -0
  17. data/lib/ts_schema.rb +21 -0
  18. data/test/dummy/Rakefile +6 -0
  19. data/test/dummy/app/assets/images/.keep +0 -0
  20. data/test/dummy/app/assets/javascripts/schema.d.ts +71 -0
  21. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  22. data/test/dummy/app/controllers/application_controller.rb +2 -0
  23. data/test/dummy/app/controllers/concerns/.keep +0 -0
  24. data/test/dummy/app/frontend/types/schema.d.ts +71 -0
  25. data/test/dummy/app/helpers/application_helper.rb +2 -0
  26. data/test/dummy/app/jobs/application_job.rb +7 -0
  27. data/test/dummy/app/models/application_record.rb +3 -0
  28. data/test/dummy/app/models/concerns/.keep +0 -0
  29. data/test/dummy/app/models/example.rb +15 -0
  30. data/test/dummy/app/models/five.rb +3 -0
  31. data/test/dummy/app/models/four.rb +4 -0
  32. data/test/dummy/app/models/one.rb +4 -0
  33. data/test/dummy/app/models/three.rb +4 -0
  34. data/test/dummy/app/models/two.rb +3 -0
  35. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  36. data/test/dummy/bin/rails +4 -0
  37. data/test/dummy/bin/rake +4 -0
  38. data/test/dummy/bin/setup +33 -0
  39. data/test/dummy/config/application.rb +41 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +86 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +63 -0
  44. data/test/dummy/config/environments/production.rb +76 -0
  45. data/test/dummy/config/environments/test.rb +53 -0
  46. data/test/dummy/config/initializers/config/initializers/ts_schema.rb +30 -0
  47. data/test/dummy/config/initializers/content_security_policy.rb +26 -0
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  49. data/test/dummy/config/initializers/inflections.rb +16 -0
  50. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  51. data/test/dummy/config/locales/en.yml +33 -0
  52. data/test/dummy/config/puma.rb +43 -0
  53. data/test/dummy/config/routes.rb +6 -0
  54. data/test/dummy/config/storage.yml +34 -0
  55. data/test/dummy/config.ru +6 -0
  56. data/test/dummy/db/migrate/20220401195333_create_examples.rb +23 -0
  57. data/test/dummy/db/migrate/20220402131712_create_ones.rb +9 -0
  58. data/test/dummy/db/migrate/20220402131955_create_twos.rb +9 -0
  59. data/test/dummy/db/migrate/20220402132415_create_threes.rb +7 -0
  60. data/test/dummy/db/migrate/20220402132543_create_fours.rb +10 -0
  61. data/test/dummy/db/migrate/20220402132906_create_fives.rb +12 -0
  62. data/test/dummy/db/schema.rb +81 -0
  63. data/test/dummy/lib/assets/.keep +0 -0
  64. data/test/dummy/log/.keep +0 -0
  65. data/test/dummy/public/404.html +67 -0
  66. data/test/dummy/public/422.html +67 -0
  67. data/test/dummy/public/500.html +66 -0
  68. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  69. data/test/dummy/public/apple-touch-icon.png +0 -0
  70. data/test/dummy/public/favicon.ico +0 -0
  71. data/test/install_generator_test.rb +13 -0
  72. data/test/test_helper.rb +18 -0
  73. data/test/tmp/config/initializers/ts_schema.rb +30 -0
  74. data/test/ts_schema_test.rb +26 -0
  75. data/ts_schema.gemspec +20 -0
  76. metadata +139 -0
@@ -0,0 +1,43 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15
+
16
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
+ #
18
+ port ENV.fetch("PORT") { 3000 }
19
+
20
+ # Specifies the `environment` that Puma will run in.
21
+ #
22
+ environment ENV.fetch("RAILS_ENV") { "development" }
23
+
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
+
27
+ # Specifies the number of `workers` to boot in clustered mode.
28
+ # Workers are forked web server processes. If using threads and workers together
29
+ # the concurrency of the application would be max `threads` * `workers`.
30
+ # Workers do not work on JRuby or Windows (both of which do not support
31
+ # processes).
32
+ #
33
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
+
35
+ # Use the `preload_app!` method when specifying a `workers` number.
36
+ # This directive tells Puma to first boot the application and load code
37
+ # before forking the application. This takes advantage of Copy On Write
38
+ # process behavior so workers use less memory.
39
+ #
40
+ # preload_app!
41
+
42
+ # Allow puma to be restarted by `bin/rails restart` command.
43
+ plugin :tmp_restart
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
+
4
+ # Defines the root path route ("/")
5
+ # root "articles#index"
6
+ end
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket-<%= Rails.env %>
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket-<%= Rails.env %>
23
+
24
+ # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name-<%= Rails.env %>
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,23 @@
1
+ class CreateExamples < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :examples do |t|
4
+ t.string :col_string, null: false
5
+ t.text :col_text, null: false
6
+ t.integer :col_integer, null: false
7
+ t.integer :col_enum, null: false
8
+ t.bigint :col_bigint, null: false
9
+ t.float :col_float, null: false
10
+ t.decimal :col_decimal, null: false
11
+ t.json :col_json
12
+ t.jsonb :col_jsonb
13
+ t.binary :col_binary
14
+ t.boolean :col_boolean
15
+ t.date :col_date
16
+ t.datetime :col_datetime
17
+ t.timestamp :col_timestamp
18
+ t.inet :col_inet
19
+ t.cidr :col_cidr
20
+ t.macaddr :col_macaddr
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ class CreateOnes < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :ones do |t|
4
+ t.references :example, null: false, foreign_key: true
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTwos < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :twos do |t|
4
+ t.references :example, null: false, foreign_key: true
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class CreateThrees < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :threes do |t|
4
+ t.timestamps
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class CreateFours < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :fours do |t|
4
+ t.references :example, null: false, foreign_key: true
5
+ t.references :three, null: false, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ class CreateFives < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :fives do |t|
4
+ t.timestamps
5
+ end
6
+
7
+ create_table :examples_fives, id: false do |t|
8
+ t.belongs_to :example
9
+ t.belongs_to :part
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,81 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[7.0].define(version: 2022_04_02_132906) do
14
+ # These are extensions that must be enabled in order to support this database
15
+ enable_extension "plpgsql"
16
+
17
+ create_table "examples", force: :cascade do |t|
18
+ t.string "col_string", null: false
19
+ t.text "col_text", null: false
20
+ t.integer "col_integer", null: false
21
+ t.integer "col_enum", null: false
22
+ t.bigint "col_bigint", null: false
23
+ t.float "col_float", null: false
24
+ t.decimal "col_decimal", null: false
25
+ t.json "col_json"
26
+ t.jsonb "col_jsonb"
27
+ t.binary "col_binary"
28
+ t.boolean "col_boolean"
29
+ t.date "col_date"
30
+ t.datetime "col_datetime"
31
+ t.datetime "col_timestamp", precision: nil
32
+ t.inet "col_inet"
33
+ t.cidr "col_cidr"
34
+ t.macaddr "col_macaddr"
35
+ end
36
+
37
+ create_table "examples_fives", id: false, force: :cascade do |t|
38
+ t.bigint "example_id"
39
+ t.bigint "part_id"
40
+ t.index ["example_id"], name: "index_examples_fives_on_example_id"
41
+ t.index ["part_id"], name: "index_examples_fives_on_part_id"
42
+ end
43
+
44
+ create_table "fives", force: :cascade do |t|
45
+ t.datetime "created_at", null: false
46
+ t.datetime "updated_at", null: false
47
+ end
48
+
49
+ create_table "fours", force: :cascade do |t|
50
+ t.bigint "example_id", null: false
51
+ t.bigint "three_id", null: false
52
+ t.datetime "created_at", null: false
53
+ t.datetime "updated_at", null: false
54
+ t.index ["example_id"], name: "index_fours_on_example_id"
55
+ t.index ["three_id"], name: "index_fours_on_three_id"
56
+ end
57
+
58
+ create_table "ones", force: :cascade do |t|
59
+ t.bigint "example_id", null: false
60
+ t.datetime "created_at", null: false
61
+ t.datetime "updated_at", null: false
62
+ t.index ["example_id"], name: "index_ones_on_example_id"
63
+ end
64
+
65
+ create_table "threes", force: :cascade do |t|
66
+ t.datetime "created_at", null: false
67
+ t.datetime "updated_at", null: false
68
+ end
69
+
70
+ create_table "twos", force: :cascade do |t|
71
+ t.bigint "example_id", null: false
72
+ t.datetime "created_at", null: false
73
+ t.datetime "updated_at", null: false
74
+ t.index ["example_id"], name: "index_twos_on_example_id"
75
+ end
76
+
77
+ add_foreign_key "fours", "examples"
78
+ add_foreign_key "fours", "threes"
79
+ add_foreign_key "ones", "examples"
80
+ add_foreign_key "twos", "examples"
81
+ end
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class InstallGeneratorTest < Rails::Generators::TestCase
4
+ tests TsSchema::Generators::InstallGenerator
5
+ destination File.expand_path("../tmp", __FILE__)
6
+ setup :prepare_destination
7
+
8
+ test "it creats a file" do
9
+ run_generator
10
+
11
+ assert_file "config/initializers/ts_schema.rb"
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require_relative "../test/dummy/config/environment"
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
6
+ require "rails/test_help"
7
+
8
+ # Load fixtures from the engine
9
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
10
+ ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
11
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
12
+ ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
13
+ ActiveSupport::TestCase.fixtures :all
14
+ end
15
+
16
+ # For generators
17
+ require "rails/generators/test_case"
18
+ require "generators/install_generator"
@@ -0,0 +1,30 @@
1
+ TsSchema.setup do |config|
2
+ # Options: camel|snake|pascal
3
+ # config.case = :camel
4
+
5
+ # Customize output path and file name
6
+ # config.output = Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts')
7
+
8
+ # Whether to generate the schema file on migrations and rollbacks
9
+ # config.auto_generate = true
10
+
11
+ # Add custom type mappings or overrides
12
+ # config.custom_types = {
13
+ #
14
+ # }
15
+
16
+ # Default type for unrecognized types
17
+ # config.default_type = :string
18
+
19
+ # Whether to generate types for associations
20
+ # config.include_associated = true
21
+
22
+ # Namespace
23
+ # config.namespace = :schema
24
+
25
+ # Options: tab|space
26
+ # config.indent = :tab
27
+
28
+ # If indent is spaces, specify how many
29
+ # config.spaces = 2
30
+ end
@@ -0,0 +1,26 @@
1
+ require "test_helper"
2
+
3
+ class TsSchemaTest < ActiveSupport::TestCase
4
+ test "it loads custom config values from initializer" do
5
+ assert TsSchema.configuration.case
6
+ assert TsSchema.configuration.output
7
+ assert TsSchema.configuration.auto_generate
8
+ assert TsSchema.configuration.types
9
+ assert TsSchema.configuration.custom_types
10
+ assert TsSchema.configuration.default_type
11
+ assert TsSchema.configuration.include_associated
12
+ assert TsSchema.configuration.namespace
13
+ end
14
+
15
+ test "it generates a schema file" do
16
+ path = TsSchema.configuration.output
17
+ File.delete(path) if File.exist?(path)
18
+
19
+ TsSchema.generate
20
+ assert File.exist?(path)
21
+ end
22
+
23
+ test "it has a version number" do
24
+ assert TsSchema::VERSION
25
+ end
26
+ end
data/ts_schema.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ require_relative "lib/ts_schema/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "ts_schema"
5
+ spec.version = TsSchema::VERSION
6
+ spec.authors = ["Avram Walden"]
7
+ spec.email = ["aviemet@gmail.com"]
8
+ spec.homepage = "https://github.com/aviemet"
9
+ spec.summary = "Generates typescript definitions from ActiveRecord"
10
+ spec.description = ""
11
+ spec.license = "MIT"
12
+
13
+ spec.metadata["homepage_uri"] = spec.homepage
14
+ spec.metadata["source_code_uri"] = "https://github.com/aviemet/ts_schema"
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency 'rails', '~> 7.0', '>= 7.0.2.3'
20
+ end