Class: FrontendGenerators::AssetCopier
- Inherits:
-
Object
- Object
- FrontendGenerators::AssetCopier
- Defined in:
- lib/frontend_generators/asset_copier.rb
Instance Attribute Summary collapse
-
#asset_path ⇒ Object
readonly
Returns the value of attribute asset_path.
-
#asset_root_dirname ⇒ Object
readonly
Returns the value of attribute asset_root_dirname.
Instance Method Summary collapse
- #copy_asset ⇒ Object
- #destination_dirname ⇒ Object
- #destination_partial_path ⇒ Object
- #full_copy ⇒ Object
-
#initialize(asset_path, asset_root_dirname) ⇒ AssetCopier
constructor
A new instance of AssetCopier.
- #message ⇒ Object
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_path ⇒ Object (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_dirname ⇒ Object (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_asset ⇒ Object
16 17 18 |
# File 'lib/frontend_generators/asset_copier.rb', line 16 def copy_asset FileUtils.cp(asset_path, destination_dirname) end |
#destination_dirname ⇒ Object
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_path ⇒ Object
31 32 33 |
# File 'lib/frontend_generators/asset_copier.rb', line 31 def destination_partial_path asset_path.gsub(asset_root_dirname, "") end |
#full_copy ⇒ Object
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 end |
#message ⇒ Object
20 21 22 |
# File 'lib/frontend_generators/asset_copier.rb', line 20 def "#{Rainbow("create").green} #{destination_partial_path}" end |