Class: React::Rails::HotLoader::AssetChangeSet
- Inherits:
-
Object
- Object
- React::Rails::HotLoader::AssetChangeSet
- Defined in:
- lib/hot_loader/asset_change_set.rb
Instance Attribute Summary collapse
-
#changed_asset_contents ⇒ Object
readonly
Returns the value of attribute changed_asset_contents.
-
#changed_file_names ⇒ Object
readonly
Returns the value of attribute changed_file_names.
-
#changed_files ⇒ Object
readonly
Returns the value of attribute changed_files.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#since ⇒ Object
readonly
Returns the value of attribute since.
Instance Method Summary collapse
- #any? ⇒ Boolean
- #as_json(options = {}) ⇒ Object
-
#initialize(since:, path: ::Rails.root.join("app/assets/javascripts")) ⇒ AssetChangeSet
constructor
initialize with a path and time to find files which changed since that time.
Constructor Details
#initialize(since:, path: ::Rails.root.join("app/assets/javascripts")) ⇒ AssetChangeSet
initialize with a path and time to find files which changed since that time
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hot_loader/asset_change_set.rb', line 8 def initialize(since:, path: ::Rails.root.join("app/assets/javascripts")) @since = since @path = path.to_s asset_glob = path.to_s + "/**/*.js*" @changed_files = Dir.glob(asset_glob).select { |f| File.mtime(f) >= since } @changed_file_names = changed_files.map { |f| f.split("/").last } @changed_asset_contents = changed_files.map do |f| logical_path = f.sub(path.to_s, "").sub(/^\//, '') ::Rails.application.assets[logical_path].to_s end end |
Instance Attribute Details
#changed_asset_contents ⇒ Object (readonly)
Returns the value of attribute changed_asset_contents.
5 6 7 |
# File 'lib/hot_loader/asset_change_set.rb', line 5 def changed_asset_contents @changed_asset_contents end |
#changed_file_names ⇒ Object (readonly)
Returns the value of attribute changed_file_names.
5 6 7 |
# File 'lib/hot_loader/asset_change_set.rb', line 5 def changed_file_names @changed_file_names end |
#changed_files ⇒ Object (readonly)
Returns the value of attribute changed_files.
5 6 7 |
# File 'lib/hot_loader/asset_change_set.rb', line 5 def changed_files @changed_files end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/hot_loader/asset_change_set.rb', line 5 def path @path end |
#since ⇒ Object (readonly)
Returns the value of attribute since.
5 6 7 |
# File 'lib/hot_loader/asset_change_set.rb', line 5 def since @since end |
Instance Method Details
#any? ⇒ Boolean
20 21 22 |
# File 'lib/hot_loader/asset_change_set.rb', line 20 def any? changed_files.any? end |
#as_json(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/hot_loader/asset_change_set.rb', line 24 def as_json(={}) { since: since, path: path, changed_file_names: changed_file_names, changed_asset_contents: changed_asset_contents, } end |