lib/provideal_plugin_utils.rb in provideal-plugin-utils-0.1.0 vs lib/provideal_plugin_utils.rb in provideal-plugin-utils-0.1.1
- old
+ new
@@ -17,29 +17,29 @@
#
# <%= javascript_include_tag 'foo.js', :plugin => 'your_plugin' %>
#
# This will create a proper link to '/plugins/your_plugin/javascripts/foo.js'.
#
- def install_assets(plugin_name, target_path)
+ def install_assets(plugin_name, source_path)
# Precheck conditions
raise "Plugin name required" unless plugin_name
- raise "Target path required" unless target_path
- raise "Taget does't exists" unless File.exists?(target_path)
+ raise "Source path required" unless source_path
+ raise "Source path does't exists" unless File.exists?(source_path)
- # Create the plugins base path inside the hosts public folder
- plugins_public_base_path = "#{RAILS_ROOT}/public/plugins"
- FileUtils.mkdir_p(plugins_public_base_path)
+ # Target path
+ target_base_path = "#{RAILS_ROOT}/public/plugins"
+ FileUtils.mkdir_p(target_base_path) unless File.exists?(target_base_path)
+ target_path = "#{target_base_path}/#{plugin_name}"
- # The source path
- source_path = "#{plugins_public_base_path}/#{plugin_name}"
-
- # Create the symlink if the source_path is not present
- # This allows for manual overrides
- unless File.exists?(source_path)
- system "ln -s #{target_path} #{source_path}"
+ # Only install if the target path does not
+ # exists
+ unless File.exists?(target_path)
+ File.symlink(source_path, target_path)
+ else
+ puts "Info: Assets for plugin #{plugin_name} exists. Skipping installation."
end
end
-
+
#
# Enables Rails extensions
#
def enable #:nodoc:
# enable our overriden asset helper