bullet_train-super_scaffolding 1.0.0 → 1.0.1

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: ff4575c2ac8fe4254a40902558258c4b6987ced04ee50bc7506a829c43c0150a
4
- data.tar.gz: b64e648b62b67455633ea076b597c1cf9689d8a044755f1c28114622ea48dbe3
3
+ metadata.gz: 70a403bf2e245f8843548f1f20f0cccaa3195b4d2f26aa9e3977a7b134bbfbdc
4
+ data.tar.gz: f0afe6854f9f764a8c100f3022ec013d11fd51a3011c8b1ebe4831049fa5b710
5
5
  SHA512:
6
- metadata.gz: c9ca623c19afc3d40a8d235f976c47c4d84eb91e230430c88c0f020109a77dee26f1a82f8b81932a79472947d42c3bec24e14c049227c0253e89c76557a1f9cb
7
- data.tar.gz: 6aa2b5a0b6792eb701fb81926280eda270787773a11c053e433edb1a58e61c4f4c7eb7a1c0d474b0766832c5679607cbcc10e5dc6f4f32f852bdcc54a0ba17b6
6
+ metadata.gz: b935a5defa4a2417f61f4772f9e7539dd724196a6cafcce299a035c827d7675e45523b551b80479d6041191adce72a15c1ba999977d56695bb77de4b602e8225
7
+ data.tar.gz: a045389719135c5d40416b2afcf59240b5db456c7b415e7adfcf6bd8f0aaeb3b893269bbcd741d279e16289d853a806c7a23735cd0146a00b5bb8602eff6d48c
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -2,8 +2,13 @@ require "active_support/inflector"
2
2
  require "fileutils"
3
3
  require "pry"
4
4
  require "colorize"
5
+ require "scaffolding"
6
+ require "#{APP_ROOT}/config/initializers/inflections"
5
7
 
6
- require_relative "#{APP_ROOT}/config/initializers/inflections"
8
+ # TODO This is a hack to allow Super Scaffolding modules to register their path. We'll do this differently once we've
9
+ # properly migrated all the code into the Rails engine structure and Rails is being initialized as part of
10
+ # `bin/super-scaffold`.
11
+ $super_scaffolding_template_paths ||= []
7
12
 
8
13
  # TODO these methods were removed from the global scope in super scaffolding and moved to `Scaffolding::Transformer`,
9
14
  # but oauth provider scaffolding hasn't been updated yet.
@@ -106,6 +106,17 @@ class Scaffolding::Transformer
106
106
  decode_double_replacement_fix(string)
107
107
  end
108
108
 
109
+ def resolve_template_path(file)
110
+ # Figure out the actual location of the file.
111
+ # Originally all the potential source files were in the repository alongside the application.
112
+ # Now the files could be provided by an included Ruby gem, so we allow those Ruby gems to register their base
113
+ # path and then we check them in order to see which template we should use.
114
+ $super_scaffolding_template_paths.reverse.map do |base_path|
115
+ resolved_path = base_path.join(file).to_s
116
+ File.exists?(resolved_path) ? resolved_path : file
117
+ end.compact.first
118
+ end
119
+
109
120
  def get_transformed_file_content(file)
110
121
  transformed_file_content = []
111
122
 
@@ -115,7 +126,7 @@ class Scaffolding::Transformer
115
126
  parents_to_repeat_for = []
116
127
  gathered_lines_for_repeating = nil
117
128
 
118
- File.open(file).each_line do |line|
129
+ File.open(resolve_template_path(file)).each_line do |line|
119
130
  if line.include?("# 🚅 skip when scaffolding.")
120
131
  next
121
132
  end
@@ -213,9 +224,9 @@ class Scaffolding::Transformer
213
224
  puts "Proceeding to generate '#{transformed_directory_name}'."
214
225
  end
215
226
 
216
- Dir.foreach(directory) do |file|
227
+ Dir.foreach(resolve_template_path(directory)) do |file|
217
228
  file = "#{directory}/#{file}"
218
- unless File.directory?(file)
229
+ unless File.directory?(resolve_template_path(file))
219
230
  scaffold_file(file)
220
231
  end
221
232
  end
@@ -1175,7 +1186,7 @@ class Scaffolding::Transformer
1175
1186
  end
1176
1187
 
1177
1188
  files.each do |name|
1178
- if File.directory?(name)
1189
+ if File.directory?(resolve_template_path(name))
1179
1190
  scaffold_directory(name)
1180
1191
  else
1181
1192
  scaffold_file(name)
data/lib/scaffolding.rb CHANGED
@@ -5,4 +5,3 @@ require_relative "scaffolding/oauth_providers"
5
5
  require_relative "scaffolding/transformer"
6
6
  require_relative "scaffolding/class_names_transformer"
7
7
  require_relative "scaffolding/routes_file_manipulator"
8
- require_relative "scaffolding/runner"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails