Class: AssetS3::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_s3.rb

Direct Known Subclasses

S3

Constant Summary collapse

DEFAULT_ASSET_PATHS =
["favicon.ico", "images", "javascripts", "stylesheets"]
@@asset_paths =
DEFAULT_ASSET_PATHS

Class Method Summary collapse

Class Method Details

.absolute_path(path) ⇒ Object



22
23
24
# File 'lib/asset_s3.rb', line 22

def self.absolute_path(path)
  File.join(path_prefix, path)
end

.asset_pathsObject



18
19
20
# File 'lib/asset_s3.rb', line 18

def self.asset_paths
  @@asset_paths
end

.asset_paths=(paths) ⇒ Object



14
15
16
# File 'lib/asset_s3.rb', line 14

def self.asset_paths=(paths)
  @@asset_paths = paths
end

.assetsObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/asset_s3.rb', line 26

def self.assets
  asset_paths.inject([]) do |assets, path|
    path = absolute_path(path)
    assets << path if File.exists?(path) && !File.directory?(path)
    assets += Dir.glob("#{path}/**/*").inject([]) do |m, file| 
      m << file unless File.directory?(file)
      m
    end
  end
end

.fingerprint(path) ⇒ Object



37
38
39
# File 'lib/asset_s3.rb', line 37

def self.fingerprint(path)
  path.gsub(path_prefix, "")
end

.path_prefixObject



10
11
12
# File 'lib/asset_s3.rb', line 10

def self.path_prefix
  File.join(Rails.root, "public")
end