Sha256: 1debd3eddfe2b094bde3c8396b76be6f4a9ed6a5f293c9edd7efffb9d850732a

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

class PapermillException < Exception; end

module PapermillHashExtensions
  def deep_merge(hash)
    target = dup
    hash.keys.each do |key|
      if hash[key].is_a? Hash and self[key].is_a? Hash
        target[key] = target[key].deep_merge(hash[key])
        next
      end
      target[key] = hash[key]
    end
    target
  end
end

module PapermillObjectExtensions
  # Nil if empty.
  def nie
    self.blank? ? nil : self
  end
end

module PapermillFileExtensions
  def get_content_type
    begin
      MIME::Types.type_for(self.original_filename).to_s
    rescue NameError
      `file --mime -br #{self.path}`.strip.split(";").first
    end
  end
end

module PapermillFormtasticExtensions
  def image_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:image_upload, method, options)
  end
  def images_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:images_upload, method, options)
  end
  def asset_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:asset_upload, method, options)
  end
  def assets_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:assets_upload, method, options)
  end
end


module StringToUrlNotFound
  def to_url
    gsub(/[^a-zA-Z0-9]/, "-").gsub(/-+/, "-").gsub(/^-|-$/, "").downcase
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
papermill-1.1.6 lib/extensions.rb
papermill-1.1.5 lib/extensions.rb
papermill-1.1.4 lib/extensions.rb
papermill-1.1.3 lib/extensions.rb
papermill-1.1.2 lib/extensions.rb
papermill-1.1.1 lib/extensions.rb
papermill-1.1.0 lib/extensions.rb
papermill-1.0.7 lib/extensions.rb
papermill-1.0.6 lib/extensions.rb
papermill-1.0.5 lib/extensions.rb
papermill-1.0.4 lib/extensions.rb
papermill-1.0.3 lib/extensions.rb
papermill-1.0.2 lib/extensions.rb
papermill-1.0.1 lib/extensions.rb