Module: Audioproxy
- Defined in:
- lib/audioproxy.rb,
lib/audioproxy/rails.rb,
lib/audioproxy/config.rb,
lib/audioproxy/expiry.rb,
lib/audioproxy/signer.rb,
lib/audioproxy/options.rb,
lib/audioproxy/version.rb,
lib/audioproxy/url_builder.rb,
lib/audioproxy/rails/helpers.rb,
lib/audioproxy/rails/railtie.rb,
lib/audioproxy/rails/blob_resolver.rb
Overview
Nothing in this namespace may reference Rails constants; ActiveSupport is fair game except inside Audioproxy::Signer, which stays liftable. See D1.
Defined Under Namespace
Modules: Expiry, Options, Rails Classes: Config, ConfigurationError, Signer, UnattachedError, UnsupportedServiceError, UrlBuilder
Constant Summary collapse
- VERSION =
"0.3.0"
Class Attribute Summary collapse
- .config ⇒ Object
-
.source_resolver ⇒ Object
readonly
Anything that is not already a source String is handed to this resolver.
Class Method Summary collapse
- .configure {|config| ... } ⇒ Object
-
.info_url(source, **options) ⇒ Object
Probe metadata as JSON.
-
.peaks_url(source, **options) ⇒ Object
Waveform peaks: f:peaks fixed, and only the options peaks read.
- .register_source_resolver(resolver = nil, &block) ⇒ Object
- .reset_source_resolver ⇒ Object
-
.url_for(source, **options) ⇒ Object
Usable from jobs, mailers and serializers of any Ruby program, Rails or not, as are the two below.
Class Attribute Details
.config ⇒ Object
13 14 15 |
# File 'lib/audioproxy.rb', line 13 def config @config ||= Config.new end |
.source_resolver ⇒ Object (readonly)
Anything that is not already a source String is handed to this resolver.
The Rails layer registers one for ActiveStorage objects; the core stays
ignorant of what a blob is, which is what keeps url_for usable with no
Rails loaded at all (D5).
43 44 45 |
# File 'lib/audioproxy.rb', line 43 def source_resolver @source_resolver end |
Class Method Details
.configure {|config| ... } ⇒ Object
17 18 19 20 |
# File 'lib/audioproxy.rb', line 17 def configure yield config config end |
.info_url(source, **options) ⇒ Object
Probe metadata as JSON. Takes no proxy options and ignores the configured defaults and expiry, because /info can carry neither.
30 31 32 |
# File 'lib/audioproxy.rb', line 30 def info_url(source, **) UrlBuilder.new(config).info_url(source, **) end |
.peaks_url(source, **options) ⇒ Object
Waveform peaks: f:peaks fixed, and only the options peaks read.
35 36 37 |
# File 'lib/audioproxy.rb', line 35 def peaks_url(source, **) UrlBuilder.new(config).peaks_url(source, **) end |
.register_source_resolver(resolver = nil, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/audioproxy.rb', line 45 def register_source_resolver(resolver = nil, &block) resolver ||= block unless resolver.respond_to?(:call) raise ArgumentError, "an Audioproxy source resolver must respond to #call, got #{resolver.class}" end @source_resolver = resolver end |
.reset_source_resolver ⇒ Object
55 56 57 |
# File 'lib/audioproxy.rb', line 55 def reset_source_resolver @source_resolver = nil end |
.url_for(source, **options) ⇒ Object
Usable from jobs, mailers and serializers of any Ruby program, Rails or not, as are the two below.
24 25 26 |
# File 'lib/audioproxy.rb', line 24 def url_for(source, **) UrlBuilder.new(config).url_for(source, **) end |