bp3-string 0.1.1 → 0.1.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 +4 -4
- data/.rubocop.yml +0 -2
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +73 -78
- data/Rakefile +4 -3
- data/bp3-string.gemspec +8 -8
- data/lib/bp3/string/controllerize.rb +1 -1
- data/lib/bp3/string/mapper_base.rb +41 -0
- data/lib/bp3/string/table_controller_map.rb +33 -15
- data/lib/bp3/string/table_model_map.rb +6 -24
- data/lib/bp3/string/version.rb +1 -1
- data/lib/bp3/string.rb +1 -0
- metadata +22 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ea07615a38dda2b4c9cb905a88a0fd402082bd288677f3ffbeb42cfe49a0ded
|
|
4
|
+
data.tar.gz: '096cb470454f2f9bcfff18d0890de7df69274301bea6fcf9a6e81e08de96dae4'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff5def22f298e31fb666b044ea126b065e83d00538fc3c094dbaa14d49685e98a10b91daf0c19377a35ccc008eec7b25908b7fab910ef6a8c94adaa2f851fd98
|
|
7
|
+
data.tar.gz: b2615c56ee6801534215e336db7399af669e979873a2e697c33f9f5ed754fe9c44226bc22b6d4a1c7c3a1f28b3b7f5dc37393d676fe023f68a2c80a1988e4d0f
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
## [0.1.
|
|
3
|
+
## [0.1.3] - 2024-11-18
|
|
4
|
+
|
|
5
|
+
- Relax gem constraints
|
|
6
|
+
|
|
7
|
+
## [0.1.2] - 2024-08-19
|
|
8
|
+
|
|
9
|
+
- Use all ActionController descendents to populate the `TableControllerMap` hash.
|
|
10
|
+
- Pluralize default controller class
|
|
11
|
+
- Refactoring
|
|
12
|
+
|
|
13
|
+
## [0.1.1] - 2024-06-03
|
|
4
14
|
|
|
5
15
|
- Tweaks and documentation
|
|
6
16
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,87 +1,90 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bp3-string (0.1.
|
|
5
|
-
activerecord (
|
|
6
|
-
activesupport (>= 7.1.2
|
|
7
|
-
railties (
|
|
4
|
+
bp3-string (0.1.3)
|
|
5
|
+
activerecord (>= 7.1.2)
|
|
6
|
+
activesupport (>= 7.1.2)
|
|
7
|
+
railties (>= 7.1.2)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
actionpack (
|
|
13
|
-
actionview (=
|
|
14
|
-
activesupport (=
|
|
12
|
+
actionpack (8.0.0)
|
|
13
|
+
actionview (= 8.0.0)
|
|
14
|
+
activesupport (= 8.0.0)
|
|
15
15
|
nokogiri (>= 1.8.5)
|
|
16
|
-
racc
|
|
17
16
|
rack (>= 2.2.4)
|
|
18
17
|
rack-session (>= 1.0.1)
|
|
19
18
|
rack-test (>= 0.6.3)
|
|
20
19
|
rails-dom-testing (~> 2.2)
|
|
21
20
|
rails-html-sanitizer (~> 1.6)
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
useragent (~> 0.16)
|
|
22
|
+
actionview (8.0.0)
|
|
23
|
+
activesupport (= 8.0.0)
|
|
24
24
|
builder (~> 3.1)
|
|
25
25
|
erubi (~> 1.11)
|
|
26
26
|
rails-dom-testing (~> 2.2)
|
|
27
27
|
rails-html-sanitizer (~> 1.6)
|
|
28
|
-
activemodel (
|
|
29
|
-
activesupport (=
|
|
30
|
-
activerecord (
|
|
31
|
-
activemodel (=
|
|
32
|
-
activesupport (=
|
|
28
|
+
activemodel (8.0.0)
|
|
29
|
+
activesupport (= 8.0.0)
|
|
30
|
+
activerecord (8.0.0)
|
|
31
|
+
activemodel (= 8.0.0)
|
|
32
|
+
activesupport (= 8.0.0)
|
|
33
33
|
timeout (>= 0.4.0)
|
|
34
|
-
activesupport (
|
|
34
|
+
activesupport (8.0.0)
|
|
35
35
|
base64
|
|
36
|
+
benchmark (>= 0.3)
|
|
36
37
|
bigdecimal
|
|
37
|
-
concurrent-ruby (~> 1.0, >= 1.
|
|
38
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
38
39
|
connection_pool (>= 2.2.5)
|
|
39
40
|
drb
|
|
40
41
|
i18n (>= 1.6, < 2)
|
|
42
|
+
logger (>= 1.4.2)
|
|
41
43
|
minitest (>= 5.1)
|
|
42
|
-
|
|
43
|
-
tzinfo (~> 2.0)
|
|
44
|
+
securerandom (>= 0.3)
|
|
45
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
46
|
+
uri (>= 0.13.1)
|
|
44
47
|
ast (2.4.2)
|
|
45
48
|
base64 (0.2.0)
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
benchmark (0.4.0)
|
|
50
|
+
bigdecimal (3.1.8)
|
|
51
|
+
builder (3.3.0)
|
|
48
52
|
byebug (11.1.3)
|
|
49
|
-
concurrent-ruby (1.
|
|
53
|
+
concurrent-ruby (1.3.4)
|
|
50
54
|
connection_pool (2.4.1)
|
|
51
55
|
crass (1.0.6)
|
|
52
56
|
diff-lcs (1.5.1)
|
|
53
57
|
drb (2.2.1)
|
|
54
|
-
erubi (1.
|
|
55
|
-
i18n (1.14.
|
|
58
|
+
erubi (1.13.0)
|
|
59
|
+
i18n (1.14.6)
|
|
56
60
|
concurrent-ruby (~> 1.0)
|
|
57
61
|
io-console (0.7.2)
|
|
58
|
-
irb (1.
|
|
59
|
-
rdoc
|
|
62
|
+
irb (1.14.1)
|
|
63
|
+
rdoc (>= 4.0.0)
|
|
60
64
|
reline (>= 0.4.2)
|
|
61
|
-
json (2.
|
|
65
|
+
json (2.8.2)
|
|
62
66
|
language_server-protocol (3.17.0.3)
|
|
63
|
-
|
|
67
|
+
logger (1.6.1)
|
|
68
|
+
loofah (2.23.1)
|
|
64
69
|
crass (~> 1.0.2)
|
|
65
70
|
nokogiri (>= 1.12.0)
|
|
66
|
-
minitest (5.
|
|
67
|
-
|
|
68
|
-
nokogiri (1.16.3-x86_64-darwin)
|
|
71
|
+
minitest (5.25.1)
|
|
72
|
+
nokogiri (1.16.7-x86_64-darwin)
|
|
69
73
|
racc (~> 1.4)
|
|
70
|
-
parallel (1.
|
|
71
|
-
parser (3.3.0
|
|
74
|
+
parallel (1.26.3)
|
|
75
|
+
parser (3.3.6.0)
|
|
72
76
|
ast (~> 2.4.1)
|
|
73
77
|
racc
|
|
74
|
-
psych (5.
|
|
78
|
+
psych (5.2.0)
|
|
75
79
|
stringio
|
|
76
|
-
racc (1.
|
|
77
|
-
rack (3.
|
|
80
|
+
racc (1.8.1)
|
|
81
|
+
rack (3.1.8)
|
|
78
82
|
rack-session (2.0.0)
|
|
79
83
|
rack (>= 3.0.0)
|
|
80
84
|
rack-test (2.1.0)
|
|
81
85
|
rack (>= 1.3)
|
|
82
|
-
rackup (2.1
|
|
86
|
+
rackup (2.2.1)
|
|
83
87
|
rack (>= 3)
|
|
84
|
-
webrick (~> 1.8)
|
|
85
88
|
rails-dom-testing (2.2.0)
|
|
86
89
|
activesupport (>= 5.0.0)
|
|
87
90
|
minitest
|
|
@@ -89,82 +92,74 @@ GEM
|
|
|
89
92
|
rails-html-sanitizer (1.6.0)
|
|
90
93
|
loofah (~> 2.21)
|
|
91
94
|
nokogiri (~> 1.14)
|
|
92
|
-
railties (
|
|
93
|
-
actionpack (=
|
|
94
|
-
activesupport (=
|
|
95
|
-
irb
|
|
95
|
+
railties (8.0.0)
|
|
96
|
+
actionpack (= 8.0.0)
|
|
97
|
+
activesupport (= 8.0.0)
|
|
98
|
+
irb (~> 1.13)
|
|
96
99
|
rackup (>= 1.0.0)
|
|
97
100
|
rake (>= 12.2)
|
|
98
101
|
thor (~> 1.0, >= 1.2.2)
|
|
99
102
|
zeitwerk (~> 2.6)
|
|
100
103
|
rainbow (3.1.1)
|
|
101
104
|
rake (13.2.1)
|
|
102
|
-
rdoc (6.
|
|
105
|
+
rdoc (6.7.0)
|
|
103
106
|
psych (>= 4.0.0)
|
|
104
|
-
regexp_parser (2.9.
|
|
105
|
-
reline (0.5.
|
|
107
|
+
regexp_parser (2.9.2)
|
|
108
|
+
reline (0.5.11)
|
|
106
109
|
io-console (~> 0.5)
|
|
107
|
-
rexml (3.2.6)
|
|
108
110
|
rspec (3.13.0)
|
|
109
111
|
rspec-core (~> 3.13.0)
|
|
110
112
|
rspec-expectations (~> 3.13.0)
|
|
111
113
|
rspec-mocks (~> 3.13.0)
|
|
112
|
-
rspec-core (3.13.
|
|
114
|
+
rspec-core (3.13.2)
|
|
113
115
|
rspec-support (~> 3.13.0)
|
|
114
|
-
rspec-expectations (3.13.
|
|
116
|
+
rspec-expectations (3.13.3)
|
|
115
117
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
116
118
|
rspec-support (~> 3.13.0)
|
|
117
|
-
rspec-mocks (3.13.
|
|
119
|
+
rspec-mocks (3.13.2)
|
|
118
120
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
119
121
|
rspec-support (~> 3.13.0)
|
|
120
122
|
rspec-support (3.13.1)
|
|
121
|
-
rubocop (1.
|
|
123
|
+
rubocop (1.68.0)
|
|
122
124
|
json (~> 2.3)
|
|
123
125
|
language_server-protocol (>= 3.17.0)
|
|
124
126
|
parallel (~> 1.10)
|
|
125
127
|
parser (>= 3.3.0.2)
|
|
126
128
|
rainbow (>= 2.2.2, < 4.0)
|
|
127
|
-
regexp_parser (>=
|
|
128
|
-
|
|
129
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
129
|
+
regexp_parser (>= 2.4, < 3.0)
|
|
130
|
+
rubocop-ast (>= 1.32.2, < 2.0)
|
|
130
131
|
ruby-progressbar (~> 1.7)
|
|
131
132
|
unicode-display_width (>= 2.4.0, < 3.0)
|
|
132
|
-
rubocop-ast (1.
|
|
133
|
-
parser (>= 3.3.0
|
|
134
|
-
rubocop-capybara (2.20.0)
|
|
135
|
-
rubocop (~> 1.41)
|
|
136
|
-
rubocop-factory_bot (2.25.1)
|
|
137
|
-
rubocop (~> 1.41)
|
|
133
|
+
rubocop-ast (1.36.1)
|
|
134
|
+
parser (>= 3.3.1.0)
|
|
138
135
|
rubocop-rake (0.6.0)
|
|
139
136
|
rubocop (~> 1.0)
|
|
140
|
-
rubocop-rspec (2.
|
|
141
|
-
rubocop (~> 1.
|
|
142
|
-
rubocop-capybara (~> 2.17)
|
|
143
|
-
rubocop-factory_bot (~> 2.22)
|
|
144
|
-
rubocop-rspec_rails (~> 2.28)
|
|
145
|
-
rubocop-rspec_rails (2.28.2)
|
|
146
|
-
rubocop (~> 1.40)
|
|
137
|
+
rubocop-rspec (3.2.0)
|
|
138
|
+
rubocop (~> 1.61)
|
|
147
139
|
ruby-progressbar (1.13.0)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
securerandom (0.3.2)
|
|
141
|
+
stringio (3.1.2)
|
|
142
|
+
thor (1.3.2)
|
|
143
|
+
timeout (0.4.2)
|
|
151
144
|
tzinfo (2.0.6)
|
|
152
145
|
concurrent-ruby (~> 1.0)
|
|
153
|
-
unicode-display_width (2.
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
unicode-display_width (2.6.0)
|
|
147
|
+
uri (1.0.2)
|
|
148
|
+
useragent (0.16.10)
|
|
149
|
+
zeitwerk (2.7.1)
|
|
156
150
|
|
|
157
151
|
PLATFORMS
|
|
158
152
|
x86_64-darwin-22
|
|
153
|
+
x86_64-darwin-23
|
|
159
154
|
|
|
160
155
|
DEPENDENCIES
|
|
161
156
|
bp3-string!
|
|
162
157
|
byebug
|
|
163
|
-
rake (
|
|
164
|
-
rspec (
|
|
165
|
-
rubocop (
|
|
166
|
-
rubocop-rake (
|
|
167
|
-
rubocop-rspec (
|
|
158
|
+
rake (>= 13.0)
|
|
159
|
+
rspec (>= 3.0)
|
|
160
|
+
rubocop (>= 1.21)
|
|
161
|
+
rubocop-rake (>= 0.6)
|
|
162
|
+
rubocop-rspec (>= 2.25)
|
|
168
163
|
|
|
169
164
|
BUNDLED WITH
|
|
170
|
-
2.5.
|
|
165
|
+
2.5.23
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'bundler/setup'
|
|
3
4
|
require 'bundler/gem_tasks'
|
|
4
5
|
require 'rspec/core/rake_task'
|
|
5
|
-
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
-
|
|
8
6
|
require 'rubocop/rake_task'
|
|
9
7
|
|
|
8
|
+
Dir.glob('lib/tasks/**/*.rake').each { |file| load file }
|
|
9
|
+
|
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
10
11
|
RuboCop::RakeTask.new
|
|
11
12
|
|
|
12
13
|
task default: %i[spec rubocop]
|
data/bp3-string.gemspec
CHANGED
|
@@ -31,16 +31,16 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
32
|
spec.require_paths = ['lib']
|
|
33
33
|
|
|
34
|
-
spec.add_dependency 'activerecord', '
|
|
35
|
-
spec.add_dependency 'activesupport',
|
|
36
|
-
spec.add_dependency 'railties', '
|
|
34
|
+
spec.add_dependency 'activerecord', '>= 7.1.2'
|
|
35
|
+
spec.add_dependency 'activesupport', '>= 7.1.2'
|
|
36
|
+
spec.add_dependency 'railties', '>= 7.1.2'
|
|
37
37
|
|
|
38
38
|
spec.add_development_dependency 'byebug'
|
|
39
|
-
spec.add_development_dependency 'rake', '
|
|
40
|
-
spec.add_development_dependency 'rspec', '
|
|
41
|
-
spec.add_development_dependency 'rubocop', '
|
|
42
|
-
spec.add_development_dependency 'rubocop-rake', '
|
|
43
|
-
spec.add_development_dependency 'rubocop-rspec', '
|
|
39
|
+
spec.add_development_dependency 'rake', '>= 13.0'
|
|
40
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
|
41
|
+
spec.add_development_dependency 'rubocop', '>= 1.21'
|
|
42
|
+
spec.add_development_dependency 'rubocop-rake', '>= 0.6'
|
|
43
|
+
spec.add_development_dependency 'rubocop-rspec', '>= 2.25'
|
|
44
44
|
|
|
45
45
|
# For more information and examples about making a new gem, check out our
|
|
46
46
|
# guide at: https://bundler.io/guides/creating_gem.html
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bp3
|
|
4
|
+
module String
|
|
5
|
+
# MapperBase provides the base class for controller and model mappings
|
|
6
|
+
class MapperBase
|
|
7
|
+
include Subclassable
|
|
8
|
+
|
|
9
|
+
# override in testing if needed
|
|
10
|
+
def self.testing?
|
|
11
|
+
false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.reset_cached_hash
|
|
15
|
+
@cached_hash = nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.build_hash
|
|
19
|
+
new.build_hash
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.hash
|
|
23
|
+
cached_hash
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def hash
|
|
27
|
+
self.class.hash
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def sti_subclass?(model)
|
|
33
|
+
self.class.sti_subclass?(model)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def subclassed?(model)
|
|
37
|
+
self.class.subclassed?(model)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Bp3
|
|
4
4
|
module String
|
|
5
|
-
# TableControllerMap provides for mappings between
|
|
6
|
-
class TableControllerMap
|
|
7
|
-
include Subclassable
|
|
8
|
-
|
|
5
|
+
# TableControllerMap provides for mappings between table-like strings and controller class names
|
|
6
|
+
class TableControllerMap < MapperBase
|
|
9
7
|
@cached_hash = nil
|
|
10
8
|
CACHED_HASH_MUTEX = Mutex.new
|
|
11
9
|
|
|
12
|
-
def self.testing?
|
|
13
|
-
Rails.env.test?
|
|
14
|
-
end
|
|
15
|
-
|
|
16
10
|
def self.cached_hash
|
|
17
11
|
return build_hash if testing?
|
|
18
12
|
return @cached_hash if @cached_hash.present?
|
|
@@ -24,11 +18,18 @@ module Bp3
|
|
|
24
18
|
end
|
|
25
19
|
end
|
|
26
20
|
|
|
27
|
-
def
|
|
28
|
-
@
|
|
21
|
+
def build_hash
|
|
22
|
+
@encoding = 'string'.encoding # TODO: not sure why encoding sometimes doesn't match
|
|
23
|
+
@ar_hash = build_hash_from_active_record
|
|
24
|
+
@ac_hash = build_hash_from_action_controller
|
|
25
|
+
@ar_hash.merge(@ac_hash)
|
|
29
26
|
end
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_reader :ar_hash, :ac_hash, :encoding
|
|
31
|
+
|
|
32
|
+
def build_hash_from_active_record
|
|
32
33
|
hash = {}
|
|
33
34
|
ActiveRecord::Base.descendants.each do |model|
|
|
34
35
|
table_name = model.table_name
|
|
@@ -42,12 +43,29 @@ module Bp3
|
|
|
42
43
|
hash
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
def
|
|
46
|
-
|
|
46
|
+
def build_hash_from_action_controller
|
|
47
|
+
hash = {}
|
|
48
|
+
ActionController::Base.descendants.each do |controller|
|
|
49
|
+
hash.merge!(build_hash_from_controller(controller))
|
|
50
|
+
end
|
|
51
|
+
hash
|
|
47
52
|
end
|
|
48
53
|
|
|
49
|
-
def
|
|
50
|
-
|
|
54
|
+
def build_hash_from_controller(controller)
|
|
55
|
+
hash = {}
|
|
56
|
+
if controller.descendants.empty?
|
|
57
|
+
if controller.name.present?
|
|
58
|
+
controller_name = controller.name.encode(encoding)
|
|
59
|
+
tableish_name = controller_name.gsub(/Controller\z/, '').underscore.tr('/', '_').pluralize
|
|
60
|
+
hash[tableish_name] = controller_name unless @ar_hash.key?(tableish_name)
|
|
61
|
+
hash[tableish_name.singularize] = controller_name unless @ar_hash.key?(tableish_name.singularize)
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
controller.descendants.each do |ctrlr|
|
|
65
|
+
hash.merge!(build_hash_from_controller(ctrlr))
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
hash
|
|
51
69
|
end
|
|
52
70
|
end
|
|
53
71
|
end
|
|
@@ -4,17 +4,11 @@ require 'active_record'
|
|
|
4
4
|
|
|
5
5
|
module Bp3
|
|
6
6
|
module String
|
|
7
|
-
# TableModelMap provides for mappings between tables and
|
|
8
|
-
class TableModelMap
|
|
9
|
-
include Subclassable
|
|
10
|
-
|
|
7
|
+
# TableModelMap provides for mappings between tables and model class names
|
|
8
|
+
class TableModelMap < MapperBase
|
|
11
9
|
@cached_hash = nil
|
|
12
10
|
CACHED_HASH_MUTEX = Mutex.new
|
|
13
11
|
|
|
14
|
-
def self.testing?
|
|
15
|
-
Rails.env.test?
|
|
16
|
-
end
|
|
17
|
-
|
|
18
12
|
def self.cached_hash
|
|
19
13
|
return build_hash if testing?
|
|
20
14
|
return @cached_hash if @cached_hash.present?
|
|
@@ -26,39 +20,27 @@ module Bp3
|
|
|
26
20
|
end
|
|
27
21
|
end
|
|
28
22
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.build_hash
|
|
34
|
-
enc = 'string'.encoding # TODO: not sure why encoding sometimes doesn't match
|
|
23
|
+
def build_hash
|
|
24
|
+
encoding = 'string'.encoding # TODO: not sure why encoding sometimes doesn't match
|
|
35
25
|
hash = {}
|
|
36
26
|
ActiveRecord::Base.descendants.each do |model|
|
|
37
27
|
table_name = model.table_name
|
|
38
28
|
next if table_name.blank?
|
|
39
29
|
|
|
40
30
|
table_name = table_name.split('.').last # remove the schema
|
|
41
|
-
model_name = determine_model_name(model).encode(
|
|
31
|
+
model_name = determine_model_name(model).encode(encoding)
|
|
42
32
|
hash[table_name] = model_name
|
|
43
33
|
hash[table_name.singularize] = model_name
|
|
44
34
|
end
|
|
45
35
|
hash
|
|
46
36
|
end
|
|
47
37
|
|
|
48
|
-
def
|
|
38
|
+
def determine_model_name(model)
|
|
49
39
|
return determine_model_name(model.superclass) if sti_subclass?(model)
|
|
50
40
|
return determine_model_name(model.descendants.first) if subclassed?(model)
|
|
51
41
|
|
|
52
42
|
model.name
|
|
53
43
|
end
|
|
54
|
-
|
|
55
|
-
def self.hash
|
|
56
|
-
cached_hash
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def hash
|
|
60
|
-
self.class.hash
|
|
61
|
-
end
|
|
62
44
|
end
|
|
63
45
|
end
|
|
64
46
|
end
|
data/lib/bp3/string/version.rb
CHANGED
data/lib/bp3/string.rb
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bp3-string
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wim den Braven
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 7.1.2
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 7.1.2
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -31,9 +31,6 @@ dependencies:
|
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: 7.1.2
|
|
34
|
-
- - "<"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '8'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -41,23 +38,20 @@ dependencies:
|
|
|
41
38
|
- - ">="
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
40
|
version: 7.1.2
|
|
44
|
-
- - "<"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '8'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
42
|
name: railties
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
|
-
- - "
|
|
45
|
+
- - ">="
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
47
|
+
version: 7.1.2
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
51
|
requirements:
|
|
58
|
-
- - "
|
|
52
|
+
- - ">="
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
54
|
+
version: 7.1.2
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
56
|
name: byebug
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -76,70 +70,70 @@ dependencies:
|
|
|
76
70
|
name: rake
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
|
-
- - "
|
|
73
|
+
- - ">="
|
|
80
74
|
- !ruby/object:Gem::Version
|
|
81
75
|
version: '13.0'
|
|
82
76
|
type: :development
|
|
83
77
|
prerelease: false
|
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
79
|
requirements:
|
|
86
|
-
- - "
|
|
80
|
+
- - ">="
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
82
|
version: '13.0'
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
84
|
name: rspec
|
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
|
92
86
|
requirements:
|
|
93
|
-
- - "
|
|
87
|
+
- - ">="
|
|
94
88
|
- !ruby/object:Gem::Version
|
|
95
89
|
version: '3.0'
|
|
96
90
|
type: :development
|
|
97
91
|
prerelease: false
|
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
93
|
requirements:
|
|
100
|
-
- - "
|
|
94
|
+
- - ">="
|
|
101
95
|
- !ruby/object:Gem::Version
|
|
102
96
|
version: '3.0'
|
|
103
97
|
- !ruby/object:Gem::Dependency
|
|
104
98
|
name: rubocop
|
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
|
106
100
|
requirements:
|
|
107
|
-
- - "
|
|
101
|
+
- - ">="
|
|
108
102
|
- !ruby/object:Gem::Version
|
|
109
103
|
version: '1.21'
|
|
110
104
|
type: :development
|
|
111
105
|
prerelease: false
|
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
107
|
requirements:
|
|
114
|
-
- - "
|
|
108
|
+
- - ">="
|
|
115
109
|
- !ruby/object:Gem::Version
|
|
116
110
|
version: '1.21'
|
|
117
111
|
- !ruby/object:Gem::Dependency
|
|
118
112
|
name: rubocop-rake
|
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
|
120
114
|
requirements:
|
|
121
|
-
- - "
|
|
115
|
+
- - ">="
|
|
122
116
|
- !ruby/object:Gem::Version
|
|
123
117
|
version: '0.6'
|
|
124
118
|
type: :development
|
|
125
119
|
prerelease: false
|
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
121
|
requirements:
|
|
128
|
-
- - "
|
|
122
|
+
- - ">="
|
|
129
123
|
- !ruby/object:Gem::Version
|
|
130
124
|
version: '0.6'
|
|
131
125
|
- !ruby/object:Gem::Dependency
|
|
132
126
|
name: rubocop-rspec
|
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
|
134
128
|
requirements:
|
|
135
|
-
- - "
|
|
129
|
+
- - ">="
|
|
136
130
|
- !ruby/object:Gem::Version
|
|
137
131
|
version: '2.25'
|
|
138
132
|
type: :development
|
|
139
133
|
prerelease: false
|
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
135
|
requirements:
|
|
142
|
-
- - "
|
|
136
|
+
- - ">="
|
|
143
137
|
- !ruby/object:Gem::Version
|
|
144
138
|
version: '2.25'
|
|
145
139
|
description:
|
|
@@ -162,6 +156,7 @@ files:
|
|
|
162
156
|
- lib/bp3-string.rb
|
|
163
157
|
- lib/bp3/string.rb
|
|
164
158
|
- lib/bp3/string/controllerize.rb
|
|
159
|
+
- lib/bp3/string/mapper_base.rb
|
|
165
160
|
- lib/bp3/string/modelize.rb
|
|
166
161
|
- lib/bp3/string/railtie.rb
|
|
167
162
|
- lib/bp3/string/subclassable.rb
|
|
@@ -194,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
194
189
|
- !ruby/object:Gem::Version
|
|
195
190
|
version: '0'
|
|
196
191
|
requirements: []
|
|
197
|
-
rubygems_version: 3.5.
|
|
192
|
+
rubygems_version: 3.5.23
|
|
198
193
|
signing_key:
|
|
199
194
|
specification_version: 4
|
|
200
195
|
summary: bp3-string adapts the String class for BP3 (persuavis/black_phoebe_3).
|