Giter Club home page Giter Club logo

Comments (7)

hedgesky avatar hedgesky commented on July 2, 2024 1

Just to note, I suggested .set_color_scheme method name as it (for my taste, at least) is a bit more aligned with . add_extra_differ_class and other already used configuration methods.

Regarding passing hashes and encouraging users to merge values into them: it's nice and simple solution. A downside: users could rely on the fact that it's a hash, making major changes to color scheme functionalities more difficult.

from super_diff.

mcmire avatar mcmire commented on July 2, 2024

Not sure why I got confused here. It already works like I thought it did.

from super_diff.

mcmire avatar mcmire commented on July 2, 2024

Reopening this. It feels like more often than not, the actual value is more important than the expected value, so it should jump out more when looking at the output. This will cause the diff to look weird, though, so maybe not?

from super_diff.

mcmire avatar mcmire commented on July 2, 2024

This is what Jest does, for reference:

Screen Shot 2019-12-09 at 9 33 11 PM

from super_diff.

mcmire avatar mcmire commented on July 2, 2024

Maybe worth looking at Ava too: https://github.com/avajs/ava#magic-assert

from super_diff.

hedgesky avatar hedgesky commented on July 2, 2024

Would it make sense to make this configurable? Thus, the cost of the decision for the question in the title wouldn't be that high, because end users would be able to adjust color scheme to their preference if they'd like to.

For example, something like this:

SuperDiff.configure do |config|
  config.set_color_scheme(SuperDiff::ColorSchemes::RedGreen) 
  # or MagentaYellow, or YellowMagenta
end

With schemes defined either similar to as they do now:

module MagentaYellow
  COLORS = {
    alpha: :magenta,
    beta: :yellow,
    border: :blue,
    header: :white,
  }.freeze
end

or without relying on hashes:

module MagentaYellow
  def self.alpha
    :magenta
  end

  def self.beta
    :yellow
  end

  def self.border
    :blue
  end

  def self.header
    :white
  end
end

As another option, set_color_scheme could accept symbol instead of a module as an argument. That approach would be less verbose, but less extensible.

from super_diff.

mcmire avatar mcmire commented on July 2, 2024

Yeah, that's a good point, perhaps the user is the best judge here. I like the idea of passing a module. Or perhaps just a hash?

SuperDiff.configure do |config|
  config.color_scheme = SuperDiff::ColorSchemes.red_green
  # or magenta_yellow, or yellow_magenta... or supply your own
end

or if you wanted to change a couple of settings on the fly, you could even do:

SuperDiff.configure do |config|
  # color_scheme is set to red_green by default
  config.color_scheme.merge!(alpha: :magenta, beta: :yellow)
end

from super_diff.

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.