Class: AssetsPrecompilerService
- Inherits:
-
Object
- Object
- AssetsPrecompilerService
- Defined in:
- app/services/assets_precompiler_service.rb
Constant Summary collapse
- PUBLIC_PRECOMPILED_ASSET_PATH =
File.join('public', 'assets', 'vinsol_spree_theme')
- PUBLIC_PRECOMPILED_ASSET_PATH_FOR_PREVIEW =
File.join('public', 'assets', 'preview_vinsol_spree_theme')
- THEME_PATH =
File.join('public', 'vinsol_spree_themes')
- CURRENT_THEME_PATH =
File.join(THEME_PATH, 'current')
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #copy_assets ⇒ Object
- #copy_preview_assets ⇒ Object
-
#initialize(theme) ⇒ AssetsPrecompilerService
constructor
A new instance of AssetsPrecompilerService.
- #minify(options = {}) ⇒ Object
Constructor Details
#initialize(theme) ⇒ AssetsPrecompilerService
Returns a new instance of AssetsPrecompilerService.
10 11 12 |
# File 'app/services/assets_precompiler_service.rb', line 10 def initialize(theme) @theme = theme end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
3 4 5 |
# File 'app/services/assets_precompiler_service.rb', line 3 def env @env end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
3 4 5 |
# File 'app/services/assets_precompiler_service.rb', line 3 def manifest @manifest end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
3 4 5 |
# File 'app/services/assets_precompiler_service.rb', line 3 def theme @theme end |
Instance Method Details
#copy_assets ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/services/assets_precompiler_service.rb', line 21 def copy_assets source_path = File.join(CURRENT_THEME_PATH, 'precompiled_assets', '.') FileUtils.rm_r(PUBLIC_PRECOMPILED_ASSET_PATH) if File.exists?(PUBLIC_PRECOMPILED_ASSET_PATH) FileUtils.mkdir_p(PUBLIC_PRECOMPILED_ASSET_PATH) FileUtils.cp_r(source_path, PUBLIC_PRECOMPILED_ASSET_PATH) end |
#copy_preview_assets ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/services/assets_precompiler_service.rb', line 29 def copy_preview_assets source_path = File.join(theme_path, 'precompiled_assets', '.') FileUtils.rm_r(PUBLIC_PRECOMPILED_ASSET_PATH_FOR_PREVIEW) if File.exists?(PUBLIC_PRECOMPILED_ASSET_PATH_FOR_PREVIEW) FileUtils.mkdir_p(PUBLIC_PRECOMPILED_ASSET_PATH_FOR_PREVIEW) FileUtils.cp_r(source_path, PUBLIC_PRECOMPILED_ASSET_PATH_FOR_PREVIEW) end |
#minify(options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'app/services/assets_precompiler_service.rb', line 14 def minify(= {}) .merge!({ precompile: true }) unless .key?(:precompile) build_environment build_manifest [:precompile] ? assets_precompile : manifest end |