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_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
- #bankrupt? ⇒ Boolean
- #changed_asset_contents ⇒ Object
-
#initialize(since:, path: ::Rails.root.join("app/assets")) ⇒ 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")) ⇒ AssetChangeSet
initialize with a path and time to find files which changed since that time
14 15 16 17 18 19 20 |
# File 'lib/hot_loader/asset_change_set.rb', line 14 def initialize(since:, path: ::Rails.root.join("app/assets")) @since = since @path = path.to_s asset_glob = File.join(path, AssetChangeSet.asset_glob) @changed_files = Dir.glob(asset_glob).select { |f| File.mtime(f) >= since }.uniq @changed_file_names = changed_files.map { |f| File.basename(f) } end |
Instance Attribute Details
#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
26 27 28 |
# File 'lib/hot_loader/asset_change_set.rb', line 26 def any? changed_files.any? end |
#as_json(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/hot_loader/asset_change_set.rb', line 30 def as_json(={}) { since: since, path: path, changed_file_names: changed_file_names, changed_asset_contents: changed_asset_contents, } end |
#bankrupt? ⇒ Boolean
22 23 24 |
# File 'lib/hot_loader/asset_change_set.rb', line 22 def bankrupt? changed_files.length >= self.class.bankruptcy_count end |
#changed_asset_contents ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/hot_loader/asset_change_set.rb', line 39 def changed_asset_contents @changed_asset_contents ||= changed_files.map do |f| logical_path = to_logical_path(f) asset = ::Rails.application.assets[logical_path] asset.to_s end end |