Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix override task

  • Loading branch information...
commit 4ab0baf0dbffa57c91ca83b60628beb243cdf7a1 1 parent 0848b3f
@parndt parndt authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 bin/refinery-override
View
14 bin/refinery-override
@@ -11,7 +11,7 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
rails_root = Pathname.new(app_path)
end
- if rails_root.exists?
+ if rails_root.exist?
# figure out what to override
override_parts = override_path.downcase.split('/').compact.collect {|part| part if part.length > 0 }.compact
admin = ""
@@ -27,15 +27,15 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
# controller is what's left.
controller = override_parts.first
- controller_with_admin = [admin,override_parts].flatten.compact.join('/')
+ controller_with_admin = [admin,override_parts].flatten.compact.join('/').gsub(/^\//, '')
# copy the controller
unless controller_with_admin =~ /\*(\*)?/ and !action.nil?
- refinery_controllers = Dir[refinery_root.join("vendor", "plugins", "**", "app", "controllers", "#{controller_with_admin}_controller.rb")]
- if refinery_controllers.compact.any? # the controllers may not exist.
+ refinery_controllers = Dir[refinery_root.join("vendor", "plugins", "**", "app", "controllers", "#{controller_with_admin}_controller.rb")].compact
+ if refinery_controllers.any? # the controllers may not exist.
refinery_controllers.each do |refinery_controller|
# make the directories
- FileUtils.mkdir_p(copy_to = rails_root.join("app" "controllers", admin))
+ FileUtils.mkdir_p(copy_to = rails_root.join("app", "controllers", admin).to_s)
FileUtils.cp(refinery_controller, copy_to)
end
else
@@ -46,7 +46,7 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
# copy the action, if it exists
unless action.nil? or action.length == 0
# get all the matching files
- looking_for = refinery_root.join("vendor", "plugins", "**", "app", "views", controller_with_admin.split('/'), "#{action}*.erb")
+ looking_for = refinery_root.join("vendor", "plugins", "**", "app", "views", controller_with_admin.split("/").join(File::SEPARATOR), "#{action}*.erb")
action_files = Dir[looking_for]
# copy in the action template
@@ -55,7 +55,7 @@ unless (override_path = ARGV.shift).nil? or (override_path.length == 0)
action_file_dir = action_file_path.split('/')
action_file_dir.pop # get rid of the file.
- FileUtils.mkdir_p(rails_root.join("app", "views", action_file_dir))
+ FileUtils.mkdir_p(rails_root.join("app", "views", action_file_dir.join(File::SEPARATOR)))
FileUtils.cp action_file, rails_root.join("app", "views", action_file_path)
end
else
Please sign in to comment.
Something went wrong with that request. Please try again.