Class: FrontendGenerators::AssetCopier

Inherits:
Object
  • Object
show all
Defined in:
lib/frontend_generators/asset_copier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset_path, asset_root_dirname) ⇒ AssetCopier

Returns a new instance of AssetCopier.



5
6
7
8
# File 'lib/frontend_generators/asset_copier.rb', line 5

def initialize(asset_path, asset_root_dirname)
  @asset_path = asset_path
  @asset_root_dirname = asset_root_dirname
end

Instance Attribute Details

#asset_pathObject (readonly)

Returns the value of attribute asset_path.



3
4
5
# File 'lib/frontend_generators/asset_copier.rb', line 3

def asset_path
  @asset_path
end

#asset_root_dirnameObject (readonly)

Returns the value of attribute asset_root_dirname.



3
4
5
# File 'lib/frontend_generators/asset_copier.rb', line 3

def asset_root_dirname
  @asset_root_dirname
end

Instance Method Details

#copy_assetObject



16
17
18
# File 'lib/frontend_generators/asset_copier.rb', line 16

def copy_asset
  FileUtils.cp(asset_path, destination_dirname)
end

#destination_dirnameObject



24
25
26
27
28
29
# File 'lib/frontend_generators/asset_copier.rb', line 24

def destination_dirname
  p = asset_path.gsub(asset_root_dirname, Turf.find(:destination_root).to_s)
  dirname = File.dirname(p)
  FileUtils.mkdir_p(dirname)
  dirname
end

#destination_partial_pathObject



31
32
33
# File 'lib/frontend_generators/asset_copier.rb', line 31

def destination_partial_path
  asset_path.gsub(asset_root_dirname, "")
end

#full_copyObject



10
11
12
13
14
# File 'lib/frontend_generators/asset_copier.rb', line 10

def full_copy
  FileUtils.mkdir_p(destination_dirname)
  copy_asset
  puts message
end

#messageObject



20
21
22
# File 'lib/frontend_generators/asset_copier.rb', line 20

def message
  "#{Rainbow("create").green}    #{destination_partial_path}"
end