Class: Devformance::FileResult

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/devformance/file_result.rb

Class Method Summary collapse

Class Method Details

.file_key_for(file_path) ⇒ Object



12
13
14
15
16
17
18
# File 'app/models/devformance/file_result.rb', line 12

def self.file_key_for(file_path)
  relative_path = Pathname.new(file_path).relative_path_from(Rails.root).to_s

  relative_path.gsub(/[^a-z0-9_]+/i, "_").downcase.sub(/_rb\z/, "")
rescue ArgumentError
  file_path.to_s.gsub(/[^a-z0-9_]+/i, "_").downcase.sub(/_rb\z/, "")
end