Module: RailsAssist::Artifact::Asset::FileName::Helper

Included in:
SingleArg::HashArg, SingleArg::HashArgs, SingleArg::StringArg, TwoArgs::NameAndHash, TwoArgs::TwoLabels
Defined in:
lib/rails_artifactor/artifact/file_name/asset.rb

Instance Method Summary collapse

Instance Method Details

#filename_name(str) ⇒ Object



40
41
42
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 40

def filename_name str
  str.gsub /\.(.*)/, ''
end

#filename_type(str) ⇒ Object



36
37
38
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 36

def filename_type str
  str.split('.')[1..-1].join('.')
end

#get_asset_type(type) ⇒ Object



31
32
33
34
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 31

def get_asset_type type
  raise "No type defined" if !type || type.empty?
  get_type(type)
end

#get_type(type) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 18

def get_type type
  case type.to_s
  when 'coffee'
    'js.coffee'
  when 'scss'
    'css.scss'
  when 'sass'
    'css.sass'
  else
    type_from type
  end
end

#type_from(folder) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 7

def type_from folder
  case folder.to_s
  when /javascript/
    :js
  when /style/
    :css
  else
    folder.to_s # raise ArgumentError, "Asset type could not be determined from #{folder}"
  end
end