Sha256: cf0c4d74971b81068a52a30bde4d3201e17183427652584c1049e2349b899218

Contents?: true

Size: 507 Bytes

Versions: 4

Compression:

Stored size: 507 Bytes

Contents

# encoding: utf-8

require 'digest/sha1'
require 'pathname'
require 'securerandom'

module TBird
  class Namer
    attr_reader :ext, :identifier, :token
    def initialize(original_filename, identifier = nil, token = nil)
      @ext = Pathname.new(original_filename).extname
      @identifier = identifier || Digest::SHA1.hexdigest(original_filename)
      @token = token || SecureRandom.uuid
    end

    def new_name(version = 'original')
      "#{identifier}/#{token}_#{version}#{ext}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
t_bird-0.0.5 lib/t_bird/namer.rb
t_bird-0.0.4 lib/t_bird/namer.rb
t_bird-0.0.3 lib/t_bird/namer.rb
t_bird-0.0.2 lib/t_bird/namer.rb