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

Included in:
RailsAssist::Artifact::Asset, RailsAssist::Artifact::Asset
Defined in:
lib/rails_artifactor/artifact/file_name/asset.rb

Defined Under Namespace

Modules: Helper

Constant Summary collapse

DIR =
RailsAssist::Artifact::Directory

Instance Method Summary collapse

Instance Method Details

#asset_file_name(*args) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 45

def asset_file_name *args
  folder, name, type = get_asset_args(args)
  options = last_option args
  root_path = options[:root_path]
  assets_path = options[:assets_path]
  assets_path ||= File.join(root_path, 'app/assets') if root_path
  File.expand_path File.join(assets_path || DIR.asset_dirpath, folder.to_s, "#{name}.#{type}")
end

#get_asset_args(*args) ⇒ Object

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
62
63
# File 'lib/rails_artifactor/artifact/file_name/asset.rb', line 54

def get_asset_args *args
  args = args.flatten
  raise ArgumentError, "asset_file_name must be called with one or more arguments to return a asset file" if args.size == 0
  case args.size
  when 1
    SingleArg.get_asset_args *args
  else
    TwoArgs.get_asset_args *args
  end
end