end
def one_time_only?
- @meta['One-time-only'] && @meta['One-time-only'] == 'true'
+ @meta['One-time-only'] == 'true'
end
def self.create(src, pass, meta)
break
end
end until line.empty?
- end
+ end if File.exists?(links_path)
end
dst
end
end
end
- DEFAULT_SETTINGS = { :default_expire => 60,
- :gone_period => 10080,
- :filename_length => 20,
- :random_pass_length => 16,
- }
-
# Like RFC 4648 (Base32)
FILENAME_CHARS = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z 2 3 4 5 6 7)
class << self
-
- def setup(settings)
- @settings = DEFAULT_SETTINGS.merge(settings)
- @settings.each_key do |k|
- @settings.class.send(:define_method, k) { self[k] }
- end
- @depot = nil
- @settings
- end
-
- def settings
- @settings ||= setup({})
- end
-
- def depot
- @depot ||= Depot.new(settings.depot_path)
- end
-
def gen_random_base32(length)
name = ''
OpenSSL::Random::random_bytes(length).each_byte do |i|
FILENAME_CHARS.each { |c| map[c] = c; map[c.upcase] = c }
map.merge!({ '1' => 'l', '0' => 'o' })
result = ''
- str.each_char { |c| result << map[c] }
+ str.each_char { |c| result << map[c] if map[c] }
result
end
end