lib/flyyer.rb in flyyer-2.1.1 vs lib/flyyer.rb in flyyer-2.1.2
- old
+ new
@@ -5,18 +5,19 @@
module Flyyer
class Error < StandardError; end
class Flyyer
- attr_accessor :project, :path, :variables, :meta, :secret, :strategy
+ attr_accessor :project, :default, :path, :variables, :meta, :secret, :strategy
def self.create(&block)
self.new(&block)
end
- def initialize(project = nil, path = nil, variables = {}, meta = {}, secret = nil, strategy = nil)
+ def initialize(project = nil, default = nil, path = nil, variables = {}, meta = {}, secret = nil, strategy = nil)
@project = project
+ @default = default
@path = path || "/"
@variables = variables
@meta = meta
@secret = secret
@strategy = strategy
@@ -26,19 +27,33 @@
def path_safe
@path.start_with?("/") ? @path : "/#{@path}"
end
def params_hash(ignoreV)
- defaults = {
- __v: @meta[:v] || Time.now.to_i, # This forces crawlers to refresh the image
- __id: @meta[:id] || nil,
- _w: @meta[:width] || nil,
- _h: @meta[:height] || nil,
- _res: @meta[:resolution] || nil,
- _ua: @meta[:agent] || nil
- }
- defaults.delete(:__v) if ignoreV
- @variables.nil? ? defaults : defaults.merge(@variables)
+ if @strategy and @strategy.downcase == "jwt" then
+ jwt_defaults = {
+ i: @meta[:id] || nil,
+ w: @meta[:width] || nil,
+ h: @meta[:height] || nil,
+ r: @meta[:resolution] || nil,
+ u: @meta[:agent] || nil,
+ var: @variables,
+ def: @default || nil,
+ }
+ jwt_defaults
+ else
+ defaults = {
+ __v: @meta[:v] || Time.now.to_i, # This forces crawlers to refresh the image
+ __id: @meta[:id] || nil,
+ _w: @meta[:width] || nil,
+ _h: @meta[:height] || nil,
+ _res: @meta[:resolution] || nil,
+ _ua: @meta[:agent] || nil,
+ _def: @default || nil,
+ }
+ defaults.delete(:__v) if ignoreV
+ @variables.nil? ? defaults : defaults.merge(@variables)
+ end
end
def querystring(ignoreV = false)
# Allow accesing the keys of @meta with symbols and strings
# https://stackoverflow.com/a/10786575