Class: WebSvr::AssetInfo
- Inherits:
-
Object
- Object
- WebSvr::AssetInfo
- Defined in:
- lib/web_svr/asset_info.rb
Constant Summary collapse
- @@index_by_published =
Class Variables
{}
- @@index_by_pn =
{}
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pn ⇒ Object
readonly
Returns the value of attribute pn.
-
#published_name ⇒ Object
readonly
Returns the value of attribute published_name.
-
#published_pn ⇒ Object
readonly
Returns the value of attribute published_pn.
Class Method Summary collapse
-
.find_info_for(pn) ⇒ Object
Find the asset info for the given published name.
-
.find_published_name_for(pn) ⇒ Object
Find the asset info for the given published name.
-
.index(info) ⇒ Object
Index the the given asset info record.
-
.list_all(engine) ⇒ Object
List All assets.
Instance Method Summary collapse
-
#initialize(engine, full_path, name, pn) ⇒ AssetInfo
constructor
Set up an asset information object.
-
#register ⇒ Object
Register the asset with indexes, inflating all needed data elements.
Constructor Details
#initialize(engine, full_path, name, pn) ⇒ AssetInfo
Set up an asset information object.
32 33 34 35 36 37 38 39 |
# File 'lib/web_svr/asset_info.rb', line 32 def initialize( engine, full_path, name, pn ) @engine = engine @log = @engine.log @full_path = full_path @name = name @pn = pn end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
22 23 24 |
# File 'lib/web_svr/asset_info.rb', line 22 def hash @hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/web_svr/asset_info.rb', line 22 def name @name end |
#pn ⇒ Object (readonly)
Returns the value of attribute pn.
22 23 24 |
# File 'lib/web_svr/asset_info.rb', line 22 def pn @pn end |
#published_name ⇒ Object (readonly)
Returns the value of attribute published_name.
22 23 24 |
# File 'lib/web_svr/asset_info.rb', line 22 def published_name @published_name end |
#published_pn ⇒ Object (readonly)
Returns the value of attribute published_pn.
22 23 24 |
# File 'lib/web_svr/asset_info.rb', line 22 def published_pn @published_pn end |
Class Method Details
.find_info_for(pn) ⇒ Object
Find the asset info for the given published name.
93 94 95 |
# File 'lib/web_svr/asset_info.rb', line 93 def self.find_info_for pn return @@index_by_published[ pn ] end |
.find_published_name_for(pn) ⇒ Object
Find the asset info for the given published name.
84 85 86 87 88 |
# File 'lib/web_svr/asset_info.rb', line 84 def self.find_published_name_for pn return nil unless pn return @@index_by_pn[ pn ]&.published_pn end |
.index(info) ⇒ Object
Index the the given asset info record.
74 75 76 77 78 79 |
# File 'lib/web_svr/asset_info.rb', line 74 def self.index info return unless info @@index_by_pn[ info.pn ] = info @@index_by_published[ info.published_pn ] = info end |
.list_all(engine) ⇒ Object
List All assets.
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/web_svr/asset_info.rb', line 100 def self.list_all engine data = [] @@index_by_pn.each do |pn, info| data << [ info.name, info.pn, info.published_pn ] end headers = [ "Name", "Asset Path", "Published" ] puts Gloo::App::Platform::RETURN title = "Assets in Running Web App" engine.platform.table.show headers, data, title puts Gloo::App::Platform::RETURN end |
Instance Method Details
#register ⇒ Object
Register the asset with indexes, inflating all needed data elements.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/web_svr/asset_info.rb', line 49 def register @log.debug "*** REGISTERING ASSET: #{@name}" @log.debug "*** #{@full_path} " @log.debug "*** #PN: #{@pn} name: #{@name}" @hash = Gloo::Objs::FileHandle.hash_for_file( @full_path ) # Build published name ext = File.extname( @pn ) # Gets just the extension n = @name[ 0..-ext.length - 1 ] pn = @pn[ 0..-ext.length - 1 ] @published_name = "#{n}-#{@hash}#{ext}" @published_pn = "#{pn}-#{@hash}#{ext}" @log.debug "*** Published Name: #{@published_name}" @log.debug "*** Published Path: #{@published_pn}" # Add to indexes AssetInfo.index self end |