{"id":25040657,"url":"https://github.com/joeldrapper/difftastic-ruby","last_synced_at":"2025-04-05T06:03:31.905Z","repository":{"id":273533579,"uuid":"920051295","full_name":"joeldrapper/difftastic-ruby","owner":"joeldrapper","description":"Ruby interface for Difftastic.","archived":false,"fork":false,"pushed_at":"2025-03-19T22:43:43.000Z","size":127,"stargazers_count":60,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T16:16:44.361Z","etag":null,"topics":["diffing","difftastic","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeldrapper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-DEPENDENCIES.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-21T13:34:19.000Z","updated_at":"2025-03-19T22:43:47.000Z","dependencies_parsed_at":"2025-01-28T17:31:19.915Z","dependency_job_id":null,"html_url":"https://github.com/joeldrapper/difftastic-ruby","commit_stats":null,"previous_names":["joeldrapper/difftastic-ruby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeldrapper%2Fdifftastic-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeldrapper%2Fdifftastic-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeldrapper%2Fdifftastic-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeldrapper%2Fdifftastic-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeldrapper","download_url":"https://codeload.github.com/joeldrapper/difftastic-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294516,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diffing","difftastic","ruby"],"created_at":"2025-02-06T03:03:37.392Z","updated_at":"2025-04-05T06:03:31.879Z","avatar_url":"https://github.com/joeldrapper.png","language":"Ruby","readme":"# Difftastic Ruby\n\nA Ruby interface and wrapper for the wonderful [Difftastic](https://difftastic.wilfred.me.uk) CLI tool.\n\n## Creating a Differ\n\nFirst, create a differ with your configuration:\n\n```ruby\nMY_DIFFER = Difftastic::Differ.new(\n  background: :dark,\n  color: :always,\n  left_label: \"Expected\",\n  right_label: \"Actual\"\n)\n```\n\n## Diffing Objects\n\nYou can diff objects with different configurations:\n\n```ruby\na = { foo: 1, bar: [2, 3, 4] }\nb = { foo: 1, bar: [2, 4, 3] }\n\nputs MY_DIFFER.diff_objects(a, b)\n```\n\n## Diffing Ruby Code\n\nYou can diff Ruby code:\n\n```ruby\na = \u003c\u003c~RUBY\n  def hello\n    puts \"Hello, world!\"\n  end\nRUBY\n\nb = \u003c\u003c~RUBY\n  def hello\n    puts \"Goodbye, world!\"\n  end\nRUBY\n\nputs MY_DIFFER.diff_ruby(a, b)\n```\n\n## Additional File Type Methods\n\nYou can also diff other file types using the following methods:\n\n```ruby\na = \"\u003chtml\u003e\\n\\t\u003cbody\u003e\\n\\t\\t\u003ch1\u003eHello, world!\u003c/h1\u003e\\n\\t\u003c/body\u003e\\n\u003c/html\u003e\"\nb = \"\u003chtml\u003e\\n\\t\u003cbody\u003e\\n\\t\\t\u003ch1\u003eGoodbye, world!\u003c/h1\u003e\\n\\t\u003c/body\u003e\\n\u003c/html\u003e\"\n\nputs MY_DIFFER.diff_html(a, b)\n\na = '{ \"foo\": 1, \"bar\": 2 }'\nb = '{ \"foo\": 1, \"bar\": 3 }'\n\nputs MY_DIFFER.diff_json(a, b)\n\na = \"body { color: red; }\"\nb = \"body { color: blue; }\"\n\nputs MY_DIFFER.diff_css(a, b)\n\na = \"\u003cnote\u003e\u003cto\u003eTove\u003c/to\u003e\u003cfrom\u003eJani\u003c/from\u003e\u003c/note\u003e\"\nb = \"\u003cnote\u003e\u003cto\u003eTove\u003c/to\u003e\u003cfrom\u003eJohn\u003c/from\u003e\u003c/note\u003e\"\n\nputs MY_DIFFER.diff_xml(a, b)\n\na = \"foo: 1\\nbar: 2\"\nb = \"foo: 1\\nbar: 3\"\n\nputs MY_DIFFER.diff_yaml(a, b)\n```\n\n## Configuring Difftastic::Differ\n\nYou can configure the `Difftastic::Differ` instance with various options:\n\n- `background`: Set the background color (`:dark` or `:light`).\n- `color`: Set the color mode (`:always`, `:never`, or `:auto`).\n- `syntax_highlight`: Enable or disable syntax highlighting (`:on` or `:off`).\n- `context`: Set the number of context lines to display.\n- `width`: Use this many columns when calculating line wrapping. If not specified, difftastic will detect the terminal width.\n- `tab_width`: Set the tab width for indentation.\n- `parse_error_limit`: Set the limit for parse errors.\n- `underline_highlights`: Enable or disable underlining highlights (`true` or `false`).\n- `left_label`: Set the label for the left side of the diff.\n- `right_label`: Set the label for the right side of the diff.\n- `display`: Set the display mode (`\"side-by-side-show-both\"`, `\"side-by-side\"`, or `\"inline\"`).\n\n## Pretty Method\n\nThe `Difftastic` module includes a `pretty` method for formatting objects:\n\n```ruby\nobject = { foo: 1, bar: [2, 3, 4] }\nformatted_object = Difftastic.pretty(object)\nputs formatted_object\n```\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeldrapper%2Fdifftastic-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeldrapper%2Fdifftastic-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeldrapper%2Fdifftastic-ruby/lists"}