{"id":24716706,"url":"https://github.com/baylorrae/fourth_dimensional","last_synced_at":"2025-10-09T13:31:43.449Z","repository":{"id":56847645,"uuid":"172088677","full_name":"BaylorRae/fourth_dimensional","owner":"BaylorRae","description":"An event sourcing library to account for the state of a system in relation to time.","archived":false,"fork":false,"pushed_at":"2019-02-27T17:21:19.000Z","size":2227,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T14:40:18.230Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaylorRae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-22T15:25:58.000Z","updated_at":"2019-02-27T17:18:43.000Z","dependencies_parsed_at":"2022-09-09T06:21:35.746Z","dependency_job_id":null,"html_url":"https://github.com/BaylorRae/fourth_dimensional","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/BaylorRae/fourth_dimensional","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2Ffourth_dimensional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2Ffourth_dimensional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2Ffourth_dimensional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2Ffourth_dimensional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaylorRae","download_url":"https://codeload.github.com/BaylorRae/fourth_dimensional/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2Ffourth_dimensional/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278820733,"owners_count":26051767,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-01-27T09:13:59.617Z","updated_at":"2025-10-09T13:31:43.170Z","avatar_url":"https://github.com/BaylorRae.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fourth Dimensional\n\nFourth Dimensional is an event sourcing library to account for the state of a\nsystem in relation to time.\n\nThis project is a lightweight dsl for commands and events for use with\nActiveRecord. Eventually I'd like it to support Sequel as well.\n\n[RDoc][rdoc_url]\n\n[![Build Status]][travis_status] [![Code Climate Maintainability]][maintainability_status] [![Code Climate Coverage]][coverage_status]\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'fourth_dimensional'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install fourth_dimensional\n\n## Usage\n\nThis API is in flux, but here's the general idea.\n\n```ruby\nclass PostAdded \u003c FourthDimensional::Event\n  def title\n    data.fetch('title')\n  end\n\n  def body\n    data.fetch('body')\n  end\n\n  def published\n    data.fetch('published')\n  end\nend\n\nclass AddPost \u003c FourthDimensional::Command\n  attributes :title, :body, :published\n  validates_presence_of :title, :body\nend\n\nclass PostCommandHandler \u003c FourthDimensional::CommandHandler\n  on AddPost do |command|\n    with_aggregate(PostAggregate, command) do |post|\n      post.add(title: command.title,\n               body: command.body,\n               published: command.published)\n    end\n  end\nend\n\nclass PostAggregate \u003c FourthDimensional::AggregateRoot\n  def add(title:, body:, published:)\n    apply(PostAdded,\n      data: {\n        title: title,\n        body: body,\n        published: published\n      }\n    )\n  end\nend\n\nclass PostProjector \u003c FourthDimensional::RecordProjector\n  self.record_class = 'Post'\n\n  on PostAdded do |event|\n    record.title = event.title\n    record.body = event.body\n    record.published = event.published\n  end\nend\n\ndef main\n  FourthDimensional.configure do |config|\n    config.command_handlers = [\n      PostCommandHandler\n    ]\n\n    config.event_handlers = [\n      PostProjector\n    ]\n  end\n\n  aggregate_id = SecureRandom.uuid\n\n  command = AddPost.new(aggregate_id: aggregate_id,\n                        title: 'post-title',\n                        body: 'post-body',\n                        published: true)\n\n  # persists command and event if successful\n  FourthDimensional.execute_commands(command)\n\n  post = Post.find(aggregate_id)\n  expect(post.title).to eq('post-title')\n  expect(post.body).to eq('post-body')\n  expect(post.published).to be_truthy\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/baylorrae/fourth_dimensional.\n\n[rdoc_url]: https://baylorrae.com/fourth_dimensional\n\n[Build Status]: https://travis-ci.org/BaylorRae/fourth_dimensional.svg?branch=master\n[travis_status]: https://travis-ci.org/BaylorRae/fourth_dimensional\n\n[Code Climate Maintainability]: https://img.shields.io/codeclimate/maintainability/BaylorRae/fourth_dimensional.svg\n[maintainability_status]: https://codeclimate.com/github/BaylorRae/fourth_dimensional/progress/maintainability\n\n[Code Climate Coverage]: https://img.shields.io/codeclimate/coverage/BaylorRae/fourth_dimensional.svg\n[coverage_status]: https://codeclimate.com/github/BaylorRae/fourth_dimensional/progress/coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaylorrae%2Ffourth_dimensional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaylorrae%2Ffourth_dimensional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaylorrae%2Ffourth_dimensional/lists"}