class R2M::Command
Adds CLI commands convert and migrate
bin/r2m convert
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/r2m/command.rb, line 17 def self.exit_on_failure? true end
Public Instance Methods
convert(*paths)
click to toggle source
# File lib/r2m/command.rb, line 22 def convert(*paths) files(paths.flatten).each { |path| run_convert path } end
migrate(*paths)
click to toggle source
# File lib/r2m/command.rb, line 34 def migrate(*paths) setup_rails_to_run_minitest files(paths.flatten).each do |path| say "Processing #{path}" migrated_path = run_migrate(path) run_convert(migrated_path) end end
Private Instance Methods
files(paths)
click to toggle source
# File lib/r2m/command.rb, line 60 def files(paths) paths = Array(paths) return Dir.glob('spec/**/*_spec.rb') if paths.empty? paths.map do |path| if File.exist?(path) && !File.directory?(path) path elsif Dir.exist?(path) Dir.glob(File.join(path, '**', '*_spec.rb')) else Dir.glob(path) end end.flatten end
run_convert(file)
click to toggle source
# File lib/r2m/command.rb, line 55 def run_convert(file) say "Processing #{file}" SpecConvector.new(self).process(file.to_s) end
run_migrate(path)
click to toggle source
# File lib/r2m/command.rb, line 51 def run_migrate(path) SpecMigration.new(Pathname.pwd).migrate(File.realpath(path)) end
setup_rails_to_run_minitest()
click to toggle source
# File lib/r2m/command.rb, line 46 def setup_rails_to_run_minitest path_to_rails_template = File.expand_path('../../template.rb', __dir__) system("DISABLE_SPRING=1 rails app:template LOCATION=#{path_to_rails_template}") end