Module: Rails::Diff
- Defined in:
- lib/rails/diff.rb,
lib/rails/diff/cli.rb,
lib/rails/diff/logger.rb,
lib/rails/diff/version.rb,
lib/rails/diff/rails_repo.rb,
lib/rails/diff/file_tracker.rb,
lib/rails/diff/rails_app_generator.rb
Defined Under Namespace
Modules: Logger
Classes: CLI, FileTracker, RailsAppGenerator, RailsRepo
Constant Summary
collapse
- CACHE_DIR =
File.expand_path("#{ENV["HOME"]}/.rails-diff/cache")
- VERSION =
"0.6.0"
Class Method Summary
collapse
-
.file(*files, no_cache: false, commit: nil, new_app_options: nil) ⇒ Object
-
.generated(generator_name, *args, no_cache: false, skip: [], only: [], commit: nil, new_app_options: nil) ⇒ Object
-
.system!(*cmd, logger:, abort: true) ⇒ Object
Class Method Details
.file(*files, no_cache: false, commit: nil, new_app_options: nil) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/rails/diff.rb', line 19
def file(*files, no_cache: false, commit: nil, new_app_options: nil)
app_generator = RailsAppGenerator.new(commit:, new_app_options:, no_cache:)
app_generator.create_template_app
files
.filter_map { |it| (it, app_generator.template_app_path) }
.join("\n")
end
|
.generated(generator_name, *args, no_cache: false, skip: [], only: [], commit: nil, new_app_options: nil) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/rails/diff.rb', line 28
def generated(generator_name, *args, no_cache: false, skip: [], only: [], commit: nil, new_app_options: nil)
app_generator = RailsAppGenerator.new(commit:, new_app_options:, no_cache:)
app_generator.create_template_app
app_generator.install_app_dependencies
app_generator.run_generator(generator_name, *args, skip, only)
.map { |it| (it, app_generator.template_app_path) }
.join("\n\n")
end
|
.system!(*cmd, logger:, abort: true) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rails/diff.rb', line 38
def system!(*cmd, logger:, abort: true)
_, stderr, status = Open3.capture3(*cmd)
logger.debug(cmd.join(" "))
if status.success?
true
elsif abort
logger.error("Command failed:", cmd.join(" "))
abort stderr
else
false
end
end
|