Giter Club home page Giter Club logo

Comments (13)

awead avatar awead commented on June 28, 2024

@flyingzumwalt seems like the solution should be that hydra-derivatives accepts parameters for these. Is the gem currently making too many assumptions about the model?

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

@awead one solution would be to use .send instead of .attached_files, but I bet there is a reason that it didn't already do that?

Example

def source_file
    object.send(source_name.to_sym)
end

instead of

def source_file
    object.attached_files[source_name.to_s]
end

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

or maybe rely on a retrieve_attached_file method

def retrieve_attached_file(object, attachment_ref)
    object.send(attachment_ref.to_sym)
end

def source_file
    retrieve_attached_file(object, source_name)
end

def output_file(path)
        # first, check for a defined file
        output_file = if retrieve_attached_file(object, path)
          object.attached_files[path]
        else
          ActiveFedora::File.new("#{object.uri}/#{path}").tap do |file|
            object.attach_file(file, path)
          end
        end
      end

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

I would love it if hydra-derivatives didn't assume that you were using fedora at all. Let the object know how persistence happens, and let the calls to transform_file tell hydra-derivatives which methods to call on that object in order to retrieve the source and return the output.

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

Then hydra-derivatives would become the first hydra gem that's truly useful outside of the hydra/fedora sphere.

from hydra-derivatives.

awead avatar awead commented on June 28, 2024

👍 to that.

from hydra-derivatives.

awead avatar awead commented on June 28, 2024

@flyingzumwalt specify a default retrieve_attached_file method that is the current process using attached_files, but the implementor overrides that? Or make it explicit:

class Hydra::Derivatives::Processor::Base

  def retrieve_attached_file
    raise NotImplementedError, "You must specify a method for retrieving the file's content"
  end

end

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

That doesn't work. That would mean all of your Processors have to choose
which attached_file strategy to assume. I should be able to use the Image
processor, etc. regardless of how files are attached to my object.

from hydra-derivatives.

awead avatar awead commented on June 28, 2024

fair enough!

from hydra-derivatives.

cjcolvar avatar cjcolvar commented on June 28, 2024

👍 to this work, hydra-derivatives assumptions about the model keep us from adopting it.

from hydra-derivatives.

flyingzumwalt avatar flyingzumwalt commented on June 28, 2024

Solving this by refactoring Processors to use a RetrieveSourceFile service for retrieving source file and a PersistOutputFile service for persisting output file. These services can be configured in the initializer and/or in your calls to transform_file.

from hydra-derivatives.

kevinreiss avatar kevinreiss commented on June 28, 2024

See f48c2e5, 946f581.

from hydra-derivatives.

tampakis avatar tampakis commented on June 28, 2024

Fixed in #61. Test coverage in #66.

from hydra-derivatives.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.