Skip to content

Commit d6f6617

Browse files
committed
initial commit
0 parents  commit d6f6617

24 files changed

+812
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
# rspec failure tracking
11+
.rspec_status

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sudo: false
3+
language: ruby
4+
cache: bundler
5+
rvm:
6+
- 2.5.1
7+
before_install: gem install bundler -v 2.0.1

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "https://rubygems.org"
2+
3+
# Specify your gem's dependencies in event_source.gemspec
4+
gemspec

Gemfile.lock

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
PATH
2+
remote: .
3+
specs:
4+
event_source (0.1.0)
5+
activesupport (>= 5.0)
6+
dry-monads (~> 1.2)
7+
globalid (~> 0.4)
8+
mongoid (~> 7.0)
9+
10+
GEM
11+
remote: https://rubygems.org/
12+
specs:
13+
actionpack (5.2.3)
14+
actionview (= 5.2.3)
15+
activesupport (= 5.2.3)
16+
rack (~> 2.0)
17+
rack-test (>= 0.6.3)
18+
rails-dom-testing (~> 2.0)
19+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
20+
actionview (5.2.3)
21+
activesupport (= 5.2.3)
22+
builder (~> 3.1)
23+
erubi (~> 1.4)
24+
rails-dom-testing (~> 2.0)
25+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
26+
activemodel (5.2.3)
27+
activesupport (= 5.2.3)
28+
activesupport (5.2.3)
29+
concurrent-ruby (~> 1.0, >= 1.0.2)
30+
i18n (>= 0.7, < 2)
31+
minitest (~> 5.1)
32+
tzinfo (~> 1.1)
33+
bson (4.5.0)
34+
builder (3.2.3)
35+
byebug (11.0.1)
36+
coderay (1.1.2)
37+
concurrent-ruby (1.1.5)
38+
crass (1.0.4)
39+
diff-lcs (1.3)
40+
dry-core (0.4.7)
41+
concurrent-ruby (~> 1.0)
42+
dry-equalizer (0.2.2)
43+
dry-monads (1.2.0)
44+
concurrent-ruby (~> 1.0)
45+
dry-core (~> 0.4, >= 0.4.4)
46+
dry-equalizer
47+
erubi (1.8.0)
48+
globalid (0.4.2)
49+
activesupport (>= 4.2.0)
50+
i18n (1.6.0)
51+
concurrent-ruby (~> 1.0)
52+
loofah (2.2.3)
53+
crass (~> 1.0.2)
54+
nokogiri (>= 1.5.9)
55+
method_source (0.9.2)
56+
mini_portile2 (2.4.0)
57+
minitest (5.11.3)
58+
mongo (2.8.0)
59+
bson (>= 4.4.2, < 5.0.0)
60+
mongoid (7.0.3)
61+
activemodel (>= 5.1, < 6.0.0)
62+
mongo (>= 2.5.1, < 3.0.0)
63+
nokogiri (1.10.3)
64+
mini_portile2 (~> 2.4.0)
65+
pry (0.12.2)
66+
coderay (~> 1.1.0)
67+
method_source (~> 0.9.0)
68+
pry-byebug (3.7.0)
69+
byebug (~> 11.0)
70+
pry (~> 0.10)
71+
rack (2.0.7)
72+
rack-test (1.1.0)
73+
rack (>= 1.0, < 3)
74+
rails-dom-testing (2.0.3)
75+
activesupport (>= 4.2.0)
76+
nokogiri (>= 1.6)
77+
rails-html-sanitizer (1.0.4)
78+
loofah (~> 2.2, >= 2.2.2)
79+
railties (5.2.3)
80+
actionpack (= 5.2.3)
81+
activesupport (= 5.2.3)
82+
method_source
83+
rake (>= 0.8.7)
84+
thor (>= 0.19.0, < 2.0)
85+
rake (12.3.2)
86+
rspec (3.8.0)
87+
rspec-core (~> 3.8.0)
88+
rspec-expectations (~> 3.8.0)
89+
rspec-mocks (~> 3.8.0)
90+
rspec-core (3.8.0)
91+
rspec-support (~> 3.8.0)
92+
rspec-expectations (3.8.4)
93+
diff-lcs (>= 1.2.0, < 2.0)
94+
rspec-support (~> 3.8.0)
95+
rspec-mocks (3.8.0)
96+
diff-lcs (>= 1.2.0, < 2.0)
97+
rspec-support (~> 3.8.0)
98+
rspec-rails (3.8.2)
99+
actionpack (>= 3.0)
100+
activesupport (>= 3.0)
101+
railties (>= 3.0)
102+
rspec-core (~> 3.8.0)
103+
rspec-expectations (~> 3.8.0)
104+
rspec-mocks (~> 3.8.0)
105+
rspec-support (~> 3.8.0)
106+
rspec-support (3.8.2)
107+
thor (0.20.3)
108+
thread_safe (0.3.6)
109+
tzinfo (1.2.5)
110+
thread_safe (~> 0.1)
111+
112+
PLATFORMS
113+
ruby
114+
115+
DEPENDENCIES
116+
bundler (~> 2.0)
117+
event_source!
118+
mongoid (~> 7.0)
119+
pry-byebug (~> 3.0)
120+
rake (~> 12.0)
121+
rspec (~> 3.0)
122+
rspec-rails (~> 3.0)
123+
124+
BUNDLED WITH
125+
2.0.1

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Dan Thomas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# EventSource
2+
3+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/event_source`. To experiment with that code, run `bin/console` for an interactive prompt.
4+
5+
TODO: Delete this and the text above, and describe your gem
6+
7+
## Installation
8+
9+
Add this line to your application's Gemfile:
10+
11+
```ruby
12+
gem 'event_source'
13+
```
14+
15+
And then execute:
16+
17+
$ bundle
18+
19+
Or install it yourself as:
20+
21+
$ gem install event_source
22+
23+
## Usage
24+
25+
TODO: Write usage instructions here
26+
27+
## Development
28+
29+
After 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.
30+
31+
To 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).
32+
33+
## Contributing
34+
35+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/event_source.
36+
37+
## License
38+
39+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require "bundler/gem_tasks"
2+
require "rspec/core/rake_task"
3+
4+
RSpec::Core::RakeTask.new(:spec)
5+
6+
task :default => :spec

bin/console

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
require "bundler/setup"
4+
require "event_source"
5+
6+
# You can add fixtures and/or initialization code here to make experimenting
7+
# with your gem easier. You can also use a different console, if you like.
8+
9+
# (If you use this, don't forget to add pry to your Gemfile!)
10+
# require "pry"
11+
# Pry.start
12+
13+
require "irb"
14+
IRB.start(__FILE__)

bin/setup

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
set -vx
5+
6+
bundle install
7+
8+
# Do any other automated setup that you need to do here

event_source.gemspec

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
lib = File.expand_path("../lib", __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require "event_source/version"
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "event_source"
8+
spec.version = EventSource::VERSION
9+
spec.authors = ["Dan Thomas"]
10+
spec.email = ["[email protected]"]
11+
12+
spec.summary = %q{Record changes to application state by storing updates as a sequence of events}
13+
spec.description = %q{This service uses Mogoid/MongoDB to create an event object to record a state change and
14+
then processes it to update values in the underlying model. It's an implementation of
15+
Martin Fowler's Event Sourcing design pattern and adapted from code developed by
16+
Philippe Creux}
17+
spec.homepage = "https://github.com/ideacrew/event_source"
18+
spec.license = "MIT"
19+
20+
# Specify which files should be added to the gem when it is released.
21+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24+
end
25+
26+
27+
spec.bindir = "exe"
28+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29+
spec.require_paths = ["lib"]
30+
31+
spec.add_dependency 'activesupport', '>= 5.0'
32+
spec.add_dependency 'mongoid', '~> 7.0'
33+
spec.add_dependency 'globalid', '~> 0.4'
34+
spec.add_dependency 'dry-monads', '~> 1.2'
35+
36+
spec.add_development_dependency 'bundler', '~> 2.0'
37+
spec.add_development_dependency 'rake', '~> 12.0'
38+
spec.add_development_dependency 'rspec', '~> 3.0'
39+
spec.add_development_dependency 'rspec-rails', '~> 3.0'
40+
spec.add_development_dependency 'pry-byebug', '~> 3.0'
41+
spec.add_development_dependency 'mongoid', '~> 7.0'
42+
end

lib/event_source.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'dry/monads/result'
2+
3+
require "active_support"
4+
require "active_support/core_ext/module/introspection"
5+
require "mongoid"
6+
require "event_source/version"
7+
require "event_source/command"
8+
require "event_source/dispatcher"
9+
require "event_source/event_stream"
10+
11+
module EventSource
12+
class Error < StandardError; end
13+
# Your code goes here...
14+
end

0 commit comments

Comments
 (0)