Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def copy_routes

def copy_controllers
in_root do
if File.exists? "app/controllers/#{module_name_for_path(old_module_name)}"
if File.exist? "app/controllers/#{module_name_for_path(old_module_name)}"
log "Copying all files from app/controllers/#{module_name_for_path(old_module_name)} to app/controllers/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "app/controllers/#{module_name_for_path(old_module_name)}", "app/controllers/#{module_name_for_path(new_module_name)}"
Dir.glob("app/controllers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -56,7 +56,7 @@ def copy_controller_tests
in_root do
case Versionist.configuration.configured_test_framework
when :test_unit
if File.exists? "#{Versionist.test_path}/#{module_name_for_path(old_module_name)}"
if File.exist? "#{Versionist.test_path}/#{module_name_for_path(old_module_name)}"
log "Copying all files from #{Versionist.test_path}/#{module_name_for_path(old_module_name)} to #{Versionist.test_path}/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "#{Versionist.test_path}/#{module_name_for_path(old_module_name)}", "#{Versionist.test_path}/#{module_name_for_path(new_module_name)}"
Dir.glob("#{Versionist.test_path}/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -68,7 +68,7 @@ def copy_controller_tests
end

if Versionist.older_than_rails_5?
if File.exists? "test/integration/#{module_name_for_path(old_module_name)}"
if File.exist? "test/integration/#{module_name_for_path(old_module_name)}"
log "Copying all files from test/integration/#{module_name_for_path(old_module_name)} to test/integration/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "test/integration/#{module_name_for_path(old_module_name)}", "test/integration/#{module_name_for_path(new_module_name)}"
Dir.glob("test/integration/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -80,7 +80,7 @@ def copy_controller_tests
end
end
when :rspec
if File.exists? "spec/controllers/#{module_name_for_path(old_module_name)}"
if File.exist? "spec/controllers/#{module_name_for_path(old_module_name)}"
log "Copying all files from spec/controllers/#{module_name_for_path(old_module_name)} to spec/controllers/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "spec/controllers/#{module_name_for_path(old_module_name)}", "spec/controllers/#{module_name_for_path(new_module_name)}"
Dir.glob("spec/controllers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -91,7 +91,7 @@ def copy_controller_tests
say "No controller specs found in spec/controllers for #{old_version}"
end

if File.exists? "spec/requests/#{module_name_for_path(old_module_name)}"
if File.exist? "spec/requests/#{module_name_for_path(old_module_name)}"
log "Copying all files from spec/requests/#{module_name_for_path(old_module_name)} to spec/requests/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "spec/requests/#{module_name_for_path(old_module_name)}", "spec/requests/#{module_name_for_path(new_module_name)}"
Dir.glob("spec/requests/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -109,7 +109,7 @@ def copy_controller_tests

def copy_presenters
in_root do
if File.exists? "app/presenters/#{module_name_for_path(old_module_name)}"
if File.exist? "app/presenters/#{module_name_for_path(old_module_name)}"
log "Copying all files from app/presenters/#{module_name_for_path(old_module_name)} to app/presenters/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "app/presenters/#{module_name_for_path(old_module_name)}", "app/presenters/#{module_name_for_path(new_module_name)}"
Dir.glob("app/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -126,7 +126,7 @@ def copy_presenter_tests
in_root do
case Versionist.configuration.configured_test_framework
when :test_unit
if File.exists? "test/presenters/#{module_name_for_path(old_module_name)}"
if File.exist? "test/presenters/#{module_name_for_path(old_module_name)}"
log "Copying all files from test/presenters/#{module_name_for_path(old_module_name)} to test/presenters/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "test/presenters/#{module_name_for_path(old_module_name)}", "test/presenters/#{module_name_for_path(new_module_name)}"
Dir.glob("test/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -137,7 +137,7 @@ def copy_presenter_tests
say "No presenter tests found in test/presenters for #{old_version}"
end
when :rspec
if File.exists? "spec/presenters/#{module_name_for_path(old_module_name)}"
if File.exist? "spec/presenters/#{module_name_for_path(old_module_name)}"
log "Copying all files from spec/presenters/#{module_name_for_path(old_module_name)} to spec/presenters/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "spec/presenters/#{module_name_for_path(old_module_name)}", "spec/presenters/#{module_name_for_path(new_module_name)}"
Dir.glob("spec/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -155,7 +155,7 @@ def copy_presenter_tests

def copy_helpers
in_root do
if File.exists? "app/helpers/#{module_name_for_path(old_module_name)}"
if File.exist? "app/helpers/#{module_name_for_path(old_module_name)}"
log "Copying all files from app/helpers/#{module_name_for_path(old_module_name)} to app/helpers/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "app/helpers/#{module_name_for_path(old_module_name)}", "app/helpers/#{module_name_for_path(new_module_name)}"
Dir.glob("app/helpers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -172,7 +172,7 @@ def copy_helper_tests
in_root do
case Versionist.configuration.configured_test_framework
when :test_unit
if File.exists? "test/helpers/#{module_name_for_path(old_module_name)}"
if File.exist? "test/helpers/#{module_name_for_path(old_module_name)}"
log "Copying all files from test/helpers/#{module_name_for_path(old_module_name)} to test/helpers/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "test/helpers/#{module_name_for_path(old_module_name)}", "test/helpers/#{module_name_for_path(new_module_name)}"
Dir.glob("test/helpers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -183,7 +183,7 @@ def copy_helper_tests
say "No helper tests found in test/helpers for #{old_version}"
end
when :rspec
if File.exists? "spec/helpers/#{module_name_for_path(old_module_name)}"
if File.exist? "spec/helpers/#{module_name_for_path(old_module_name)}"
log "Copying all files from spec/helpers/#{module_name_for_path(old_module_name)} to spec/helpers/#{module_name_for_path(new_module_name)}"
FileUtils.cp_r "spec/helpers/#{module_name_for_path(old_module_name)}", "spec/helpers/#{module_name_for_path(new_module_name)}"
Dir.glob("spec/helpers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
Expand All @@ -201,7 +201,7 @@ def copy_helper_tests

def copy_documentation
in_root do
if File.exists? "public/docs/#{old_version}"
if File.exist? "public/docs/#{old_version}"
log "Copying all files from public/docs/#{old_version} to public/docs/#{new_version}"
FileUtils.cp_r "public/docs/#{old_version}/.", "public/docs/#{new_version}"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NewControllerGenerator < Rails::Generators::NamedBase

def new_controller
in_root do
raise "API module namespace #{module_name} doesn't exist. Please run \'rails generate versionist:new_api_version\' generator first" if !File.exists?("app/controllers/#{module_name_for_path(module_name)}")
raise "API module namespace #{module_name} doesn't exist. Please run \'rails generate versionist:new_api_version\' generator first" if !File.exist?("app/controllers/#{module_name_for_path(module_name)}")
template 'new_controller.rb', File.join("app", "controllers", "#{module_name_for_path(module_name)}", "#{file_name}_controller.rb")

api_version_block = /api_version.*:?module\s*(=>|:)\s*("|')#{module_name_for_route(module_name)}("|')/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NewPresenterGenerator < Rails::Generators::NamedBase

def new_presenter
in_root do
raise "API module namespace #{module_name} doesn't exist. Please run \'rails generate versionist:new_api_version\' generator first" if !File.exists?("app/presenters/#{module_name_for_path(module_name)}")
raise "API module namespace #{module_name} doesn't exist. Please run \'rails generate versionist:new_api_version\' generator first" if !File.exist?("app/presenters/#{module_name_for_path(module_name)}")
template 'new_presenter.rb', File.join("app", "presenters", "#{module_name_for_path(module_name)}", "#{file_name}_presenter.rb")
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/versionist/rspec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module RspecHelper
# Gets the name of the helper file to require in spec files
# Accounting for rspec-rails 2 vs rspec-rails 3
def rspec_helper_filename
if File.exists? "spec/rails_helper.rb"
if File.exist? "spec/rails_helper.rb"
"rails_helper"
else
"spec_helper"
Expand Down