schema_doc 0.0.3 → 0.0.4

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: de7315ab4e254938328c0acfdce54a58f9169c329d5c473ffaad3b81aca91675
4
- data.tar.gz: 5a6b26ed9c8b57a03ae054f0e68b66885951d5cda75fe187b7cfeb441b95881c
3
+ metadata.gz: eadb829eb9f3581debcd1a1916db1f39ef23782a3f10257394453ba9e28d82d9
4
+ data.tar.gz: 0ac48d9c7a82bac4d46435065bd1064fd1bea25b5c25f7d3a351131d54b2c6ed
5
5
  SHA512:
6
- metadata.gz: d8bd9c1154c5be36875336f29a90f0ffc85e1b1c43a1d3664f05b0b2d18b0498022d1e6e85e0f101c483829d1983cfcd9cb9a0b99a5970ab2ae04abb5def625e
7
- data.tar.gz: b331c3d7ec6e178460dab62eb9f1a2c80383cbf7949b46178be2e280984517b878dbac406485a149a3ec6d10e2dc62820eb07d76fc61a43c5defdadc08f6db61
6
+ metadata.gz: cf247b70e5250c9504f19e7c48bcd7ac15846e099fbcd3e10d4241b5c235c57e1619f381302d6ac1d165f6a91e64fda1a0f222f97b7d3491ccdb08f24ba02e8a
7
+ data.tar.gz: ff8843e7a210fece539ec0aab79dc363f47c1a0e3e2bf5a0f81f457e6108d9beaeccbcba79e244fba9fe65bbf9d2a1d1ae75393cc377761e025be373388fcaa9
data/README.md CHANGED
@@ -38,6 +38,16 @@ end
38
38
 
39
39
  SchemaDoc will output [THIS](https://github.com/mizoR/schema_doc/tree/master/example/sample_output.md).
40
40
 
41
+ ## Optional Configuration
42
+
43
+ If you want to customize the models that are listed, you can create a `config/initializers/schema_doc.rb` as shown in the example below:
44
+
45
+ ```ruby
46
+ SchemaDoc.configure do |config|
47
+ config.model_classes = Proc.new { ApplicationRecord.descendants.select{ |klass| klass.superclass.name == ApplicationRecord.name } }
48
+ end
49
+ ```
50
+
41
51
  ## Contributing
42
52
 
43
53
  1. Fork it
@@ -1,8 +1,25 @@
1
+ require "schema_doc/configuration"
1
2
  require "schema_doc/version"
2
3
  require "schema_doc/document"
3
4
  require "schema_doc/railtie" if defined?(Rails)
4
5
 
5
6
  module SchemaDoc
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.reset
16
+ @configuration = Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
22
+
6
23
  def self.root
7
24
  File.expand_path('../..', __FILE__)
8
25
  end
@@ -0,0 +1,9 @@
1
+ module SchemaDoc
2
+ class Configuration
3
+ attr_accessor :model_classes
4
+
5
+ def initialize
6
+ @model_classes = Proc.new { ActiveRecord::Base.descendants }
7
+ end
8
+ end
9
+ end
@@ -29,7 +29,7 @@ module SchemaDoc
29
29
  end
30
30
 
31
31
  def model_classes
32
- ActiveRecord::Base.descendants
32
+ SchemaDoc.configuration.model_classes.try(:call)
33
33
  end
34
34
 
35
35
  def model_classes_group_by_table_name
@@ -1,3 +1,3 @@
1
1
  module SchemaDoc
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mizokami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - example/sample_output.md
98
98
  - lib/schema_doc.rb
99
+ - lib/schema_doc/configuration.rb
99
100
  - lib/schema_doc/document.rb
100
101
  - lib/schema_doc/railtie.rb
101
102
  - lib/schema_doc/tasks.rake