diff --git a/Rakefile b/Rakefile index b7e9ed5..93cb943 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) diff --git a/event_sourcery-postgres.gemspec b/event_sourcery-postgres.gemspec index 2f168cd..4ad5267 100644 --- a/event_sourcery-postgres.gemspec +++ b/event_sourcery-postgres.gemspec @@ -4,37 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'event_sourcery/postgres/version' Gem::Specification.new do |spec| - spec.name = "event_sourcery-postgres" + spec.name = 'event_sourcery-postgres' spec.version = EventSourcery::Postgres::VERSION # TODO: update authors - spec.authors = ["Steve Hodgkiss"] - spec.email = ["steve@hodgkiss.me"] + spec.authors = ['Steve Hodgkiss'] + spec.email = ['steve@hodgkiss.me'] - spec.summary = %q{Postgres event store for use with EventSourcery} - spec.homepage = "https://github.com/envato/event_sourcery-postgres" + spec.summary = 'Postgres event store for use with EventSourcery' + spec.homepage = 'https://github.com/envato/event_sourcery-postgres' # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. if spec.respond_to?(:metadata) spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." + raise 'RubyGems 2.0 or newer is required to protect against ' \ + 'public gem pushes.' end spec.files = `git ls-files -z`.split("\x0").reject do |f| f.match(%r{^(test|spec|features)/}) end - spec.bindir = "exe" + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] spec.add_dependency 'sequel', '~> 4.38' spec.add_dependency 'pg' spec.add_dependency 'event_sourcery', '>= 0.10.0' - spec.add_development_dependency "bundler", "~> 1.10" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "pry" - spec.add_development_dependency "benchmark-ips" + spec.add_development_dependency 'bundler', '~> 1.10' + spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_development_dependency 'pry' + spec.add_development_dependency 'benchmark-ips' end diff --git a/lib/event_sourcery/postgres/table_owner.rb b/lib/event_sourcery/postgres/table_owner.rb index 13919d4..4735ff2 100644 --- a/lib/event_sourcery/postgres/table_owner.rb +++ b/lib/event_sourcery/postgres/table_owner.rb @@ -67,7 +67,7 @@ def table(name = nil) end def table_name_prefixed(name) - [table_prefix, name].compact.join("_").to_sym + [table_prefix, name].compact.join('_').to_sym end end end diff --git a/lib/event_sourcery/postgres/tracker.rb b/lib/event_sourcery/postgres/tracker.rb index 0098d9b..d487b8b 100644 --- a/lib/event_sourcery/postgres/tracker.rb +++ b/lib/event_sourcery/postgres/tracker.rb @@ -13,7 +13,7 @@ def setup(processor_name = nil) create_table_if_not_exists if EventSourcery::Postgres.config.auto_create_projector_tracker unless tracker_table_exists? - raise UnableToLockProcessorError, "Projector tracker table does not exist" + raise UnableToLockProcessorError, 'Projector tracker table does not exist' end if processor_name diff --git a/lib/event_sourcery/postgres/version.rb b/lib/event_sourcery/postgres/version.rb index 47554e8..54ccb99 100644 --- a/lib/event_sourcery/postgres/version.rb +++ b/lib/event_sourcery/postgres/version.rb @@ -1,5 +1,5 @@ module EventSourcery module Postgres - VERSION = "0.2.0" + VERSION = '0.2.0' end end diff --git a/script/bench_writing_events.rb b/script/bench_writing_events.rb index 72adc3d..25f5e82 100644 --- a/script/bench_writing_events.rb +++ b/script/bench_writing_events.rb @@ -41,7 +41,7 @@ def new_event end Benchmark.ips do |b| - b.report("event_store.sink") do + b.report('event_store.sink') do event_store.sink(new_event) end end diff --git a/spec/event_sourcery/postgres/optimised_event_poll_waiter_spec.rb b/spec/event_sourcery/postgres/optimised_event_poll_waiter_spec.rb index da54d15..e0bbde7 100644 --- a/spec/event_sourcery/postgres/optimised_event_poll_waiter_spec.rb +++ b/spec/event_sourcery/postgres/optimised_event_poll_waiter_spec.rb @@ -52,13 +52,13 @@ def notify_event_ids(*ids) end end - context "when an error is raised" do + context 'when an error is raised' do let(:thread) { double } before { allow(Thread).to receive(:new).and_return(thread) } - context "when the listening thread is alive" do - it "kills the listening thread" do + context 'when the listening thread is alive' do + it 'kills the listening thread' do allow(thread).to receive(:alive?).and_return(true) expect(thread).to receive(:kill) @@ -69,8 +69,8 @@ def notify_event_ids(*ids) end end - context "when the listening thread is not alive" do - it "does not try to kill any listening threads" do + context 'when the listening thread is not alive' do + it 'does not try to kill any listening threads' do allow(thread).to receive(:alive?).and_return(false) expect(thread).to_not receive(:kill) diff --git a/spec/event_sourcery/postgres/projector_spec.rb b/spec/event_sourcery/postgres/projector_spec.rb index 0bcf6f9..d6ae348 100644 --- a/spec/event_sourcery/postgres/projector_spec.rb +++ b/spec/event_sourcery/postgres/projector_spec.rb @@ -82,7 +82,7 @@ def new_projector(&block) describe '#project' do let(:event) { new_event(type: :terms_accepted) } - it "processes events via project method" do + it 'processes events via project method' do projector = new_projector do def project(event) @processed_event = event @@ -170,7 +170,7 @@ def process(event) context 'when an error occurs processing the event' do - it "rolls back the projected changes" do + it 'rolls back the projected changes' do projector.raise_error = true projector.subscribe_to(event_store, subscription_master: subscription_master) rescue nil expect(connection[:profiles].count).to eq 0 @@ -183,7 +183,7 @@ def process(event) allow(tracker).to receive(:processed_event).and_raise(StandardError) end - it "rolls back the projected changes" do + it 'rolls back the projected changes' do projector.subscribe_to(event_store, subscription_master: subscription_master) rescue nil expect(connection[:profiles].count).to eq 0 end diff --git a/spec/event_sourcery/postgres/reactor_spec.rb b/spec/event_sourcery/postgres/reactor_spec.rb index 17d5f3e..3d6d633 100644 --- a/spec/event_sourcery/postgres/reactor_spec.rb +++ b/spec/event_sourcery/postgres/reactor_spec.rb @@ -190,7 +190,7 @@ def process(event) before do reactor.setup - stub_const("TestActioner", action_stub_class) + stub_const('TestActioner', action_stub_class) end def event_count @@ -263,12 +263,12 @@ def process(event) it 'can manupulate the event body as part of the action' do reactor.process(event_1) - expect(latest_events(1).first.body["token"]).to eq 'secret-identifier' + expect(latest_events(1).first.body['token']).to eq 'secret-identifier' end it 'stores the driven by event id in the body' do reactor.process(event_1) - expect(latest_events(1).first.body["_driven_by_event_id"]).to eq event_1.id + expect(latest_events(1).first.body['_driven_by_event_id']).to eq event_1.id end end end diff --git a/spec/event_sourcery/postgres/tracker_spec.rb b/spec/event_sourcery/postgres/tracker_spec.rb index 159f9d2..4aa6b0d 100644 --- a/spec/event_sourcery/postgres/tracker_spec.rb +++ b/spec/event_sourcery/postgres/tracker_spec.rb @@ -84,7 +84,7 @@ def setup_table context 'unable to lock tracker row' do let(:db) { new_connection } - it "raises an error" do + it 'raises an error' do expect { tracker = described_class.new(db, table_name: table_name) tracker.setup(processor_name) diff --git a/spec/event_sourcery/postgres_spec.rb b/spec/event_sourcery/postgres_spec.rb index 1ff57d2..e5d63cd 100644 --- a/spec/event_sourcery/postgres_spec.rb +++ b/spec/event_sourcery/postgres_spec.rb @@ -1,7 +1,7 @@ -require "spec_helper" +require 'spec_helper' RSpec.describe EventSourcery::Postgres do - it "has a version number" do + it 'has a version number' do expect(EventSourcery::Postgres::VERSION).not_to be nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab5062a..58a55f5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ -require "bundler/setup" -require "event_sourcery/postgres" +require 'bundler/setup' +require 'event_sourcery/postgres' require 'event_sourcery/rspec/event_store_shared_examples' require 'timeout' @@ -7,7 +7,7 @@ RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' config.expect_with :rspec do |c| c.syntax = :expect diff --git a/spec/support/db_helpers.rb b/spec/support/db_helpers.rb index 454615d..79ab576 100644 --- a/spec/support/db_helpers.rb +++ b/spec/support/db_helpers.rb @@ -37,15 +37,15 @@ def reset_database end def recreate_database - pg_connection.execute("drop table if exists events") - pg_connection.execute("drop table if exists aggregates") - pg_connection.execute("drop table if exists projector_tracker") + pg_connection.execute('drop table if exists events') + pg_connection.execute('drop table if exists aggregates') + pg_connection.execute('drop table if exists projector_tracker') EventSourcery::Postgres::Schema.create_event_store(db: pg_connection) EventSourcery::Postgres::Schema.create_projector_tracker(db: pg_connection) end def release_advisory_locks(connection=pg_connection) - connection.fetch("SELECT pg_advisory_unlock_all();").to_a + connection.fetch('SELECT pg_advisory_unlock_all();').to_a end end