Class: Fingerjam::Base
- Inherits:
-
Object
- Object
- Fingerjam::Base
- Defined in:
- lib/fingerjam/base.rb
Class Method Summary collapse
- .cached?(relative_path) ⇒ Boolean
- .cached_url(relative_path) ⇒ Object
- .configure(options = {}) ⇒ Object
- .enabled? ⇒ Boolean
- .package_and_lock! ⇒ Object
- .save_cached_url_from_path(relative_path, absolute_path) ⇒ Object
Class Method Details
.cached?(relative_path) ⇒ Boolean
55 56 57 |
# File 'lib/fingerjam/base.rb', line 55 def cached?(relative_path) self.cached_urls.include?(relative_path) end |
.cached_url(relative_path) ⇒ Object
59 60 61 |
# File 'lib/fingerjam/base.rb', line 59 def cached_url(relative_path) self.cached_urls[relative_path] end |
.configure(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fingerjam/base.rb', line 22 def configure( = {}) self.protocol = .delete(:protocol) || "https" self.host = .delete(:host) || "www.example.com" self.cache_prefix = .delete(:cache_prefix) || "/cache/" self.root_path = .delete(:root_path) || Rails.root self.assets_yml_path = .delete(:assets_yml_path) || File.join(root_path, "config", "assets.yml") self.lock_yml_path = .delete(:lock_yml_path) || File.join(root_path, "config", "assets.lock.yml") self.public_path = .delete(:public_path) || File.join(root_path, "public") self.packages_path = .delete(:packages_path) || File.join(public_path, "packages") self.cache_path = .delete(:cache_path) || File.join(public_path, cache_prefix) self.cached_paths = {} begin self.cached_urls = YAML.load_file(lock_yml_path) rescue self.cached_urls = {} end self.enabled = !cached_urls.empty? && Rails.env.production? silence_warnings do Jammit.const_set("ASSET_ROOT", root_path) Jammit.const_set("PUBLIC_ROOT", public_path) Jammit.const_set("DEFAULT_CONFIG_PATH", assets_yml_path) end end |
.enabled? ⇒ Boolean
51 52 53 |
# File 'lib/fingerjam/base.rb', line 51 def enabled? enabled end |
.package_and_lock! ⇒ Object
68 69 70 71 72 73 |
# File 'lib/fingerjam/base.rb', line 68 def package_and_lock! package scan_public symlink write_lockfile end |
.save_cached_url_from_path(relative_path, absolute_path) ⇒ Object
63 64 65 66 |
# File 'lib/fingerjam/base.rb', line 63 def save_cached_url_from_path(relative_path, absolute_path) save_cached_path_from_path(relative_path, absolute_path) generate_cached_url(relative_path) end |