Class: Observ::AssetSyncer
- Inherits:
-
Object
- Object
- Observ::AssetSyncer
- Defined in:
- lib/observ/asset_syncer.rb
Overview
Service class for syncing assets from the gem to the host application
Instance Attribute Summary collapse
-
#app_root ⇒ Object
readonly
Returns the value of attribute app_root.
-
#gem_root ⇒ Object
readonly
Returns the value of attribute gem_root.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(gem_root:, app_root:, logger: $stdout) ⇒ AssetSyncer
constructor
A new instance of AssetSyncer.
-
#sync_javascript_controllers(dest_path) ⇒ Hash
Sync JavaScript controllers to the destination path.
-
#sync_stylesheets(dest_path) ⇒ Hash
Sync stylesheets to the destination path.
Constructor Details
#initialize(gem_root:, app_root:, logger: $stdout) ⇒ AssetSyncer
Returns a new instance of AssetSyncer.
11 12 13 14 15 |
# File 'lib/observ/asset_syncer.rb', line 11 def initialize(gem_root:, app_root:, logger: $stdout) @gem_root = Pathname.new(gem_root) @app_root = Pathname.new(app_root) @logger = logger end |
Instance Attribute Details
#app_root ⇒ Object (readonly)
Returns the value of attribute app_root.
6 7 8 |
# File 'lib/observ/asset_syncer.rb', line 6 def app_root @app_root end |
#gem_root ⇒ Object (readonly)
Returns the value of attribute gem_root.
6 7 8 |
# File 'lib/observ/asset_syncer.rb', line 6 def gem_root @gem_root end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/observ/asset_syncer.rb', line 6 def logger @logger end |
Instance Method Details
#sync_javascript_controllers(dest_path) ⇒ Hash
Sync JavaScript controllers to the destination path
33 34 35 36 37 38 39 40 41 |
# File 'lib/observ/asset_syncer.rb', line 33 def sync_javascript_controllers(dest_path) source_path = gem_root.join("app", "assets", "javascripts", "observ", "controllers") sync_files( source_path: source_path, dest_path: Pathname.new(dest_path), pattern: "*.js", label: "JavaScript controllers" ) end |
#sync_stylesheets(dest_path) ⇒ Hash
Sync stylesheets to the destination path
20 21 22 23 24 25 26 27 28 |
# File 'lib/observ/asset_syncer.rb', line 20 def sync_stylesheets(dest_path) source_path = gem_root.join("app", "assets", "stylesheets", "observ") sync_files( source_path: source_path, dest_path: Pathname.new(dest_path), pattern: "*.scss", label: "stylesheets" ) end |