Method: Cms.scrub_path
- Defined in:
- lib/cms/init.rb
.scrub_path(path) ⇒ Object
This next ‘hack’ is to allow script/generate browser_cms to work on Windows machines. I’m not sure why this is necessary.
This Generator is adding an absolute file path to the manifest, which is file (like a .js or migration) in the gem directory on the developers’s machine, rather than just a relative path with the rails_generator directory. On windows, this will mean you are basically doing this.
m.file “C:/Ruby/lib/ruby/gems/1.8/gems/browsercms-3.0.0/public/javascripts/jquery-ui.js”, “testing/jquery-ui.js”
When the generator hits this command during playback, it will throw an error like this:
Pattern 'c' matches more than one generator: content_block, controller
The generator then fails and stops copying. Stripping the C: off the front seems to fix this problem. I.e. This command correctly copies the file on Windows XP.
m.file "/Ruby/lib/ruby/gems/1.8/gems/browsercms-3.0.0/public/javascripts/jquery-ui.js", "testing/jquery-ui.js"
74 75 76 77 |
# File 'lib/cms/init.rb', line 74 def scrub_path(path) windows_drive_pattern = /\b[A-Za-z]:\// # Works on drives labeled A-Z: scrubbed_source_file_name = path.gsub(windows_drive_pattern, "/") end |