Sha256: d44c77a96e2cc733512ab2768054ee88f31a2b1a95c88bc344f76e1fc9457f9b
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require 'active_support/core_ext/string/inflections.rb' module VersionCake class ExtractionStrategy def extract(request) version = execute(request) if version.is_a?(Fixnum) version elsif version.is_a?(String) && /[0-9]+/.match(version) version.to_i else nil end end def version_key VersionCake::Railtie.config.versioncake.version_key end def execute(request) raise Exception, "ExtractionStrategy requires execute to be implemented" end def self.lookup(strategy) case strategy when String, Symbol strategy_name = "#{strategy}_strategy".camelize begin VersionCake.const_get(strategy_name).new rescue raise Exception, "Unknown VersionCake extraction strategy #{strategy_name}" end when Proc if strategy.arity == 1 VersionCake::CustomStrategy.new(strategy) else raise Exception, "Custom proc extraction strategy requires a single parameter" end when Object if !strategy.methods.include?(:execute) raise Exception, "Custom extraction strategy requires an execute method" elsif strategy.method(:execute).arity != 1 raise Exception, "Custom extraction strategy requires an execute method with a single parameter" else strategy end else raise Exception, "Invalid extration strategy" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
versioncake-2.3.0 | lib/versioncake/strategies/extraction_strategy.rb |