event_store 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EventStore
2
2
 
3
- A Very Fast Ruby implementation of an EventStore (A+ES).
3
+ A fast, production ready Ruby implementation of an EventStore (A+ES).
4
4
  For more detail on what an EventStore is checkout what Gregg Young has to stay about it:
5
5
  http://codebetter.com/gregyoung/2010/02/20/why-use-event-sourcing/
6
6
 
@@ -15,9 +15,12 @@ EventStore.postgres #test
15
15
 
16
16
  EventStore.vertica(:development)
17
17
  EventStore.vertica #test
18
+ ```
18
19
 
19
- #Production
20
- EventStore.connect_db(redis_config, database_config) #The redis and database configs are the standard hashes expected by the databases -- we just pass them directly in
20
+ ### Connecting in Production
21
+ ```ruby
22
+ EventStore.connect_db(redis_config, database_config)
23
+ #The redis and database configs are the standard hashes expected by the databases -- we just pass them directly in
21
24
  ```
22
25
 
23
26
  ### Notes on Connecting
@@ -64,4 +67,4 @@ client.version
64
67
 
65
68
  # Drop all the events associated with an aggregate, including its snapshot
66
69
  client.destroy!
67
- ```
70
+ ```
data/event_store.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = ["A Ruby implementation of an EventSource (A+ES) tuned for Vertica or Postgres"]
11
11
  spec.email = ["classicist@gmail.com"]
12
12
  spec.summary = %q{Ruby implementation of an EventSource (A+ES) for the Nexia Ecosystem}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/nexiahome/event_store"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1,3 +1,3 @@
1
1
  module EventStore
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/event_store.rb CHANGED
@@ -15,8 +15,8 @@ module EventStore
15
15
  SerializedEvent = Struct.new(:fully_qualified_name, :serialized_event, :version, :occurred_at)
16
16
  SNAPSHOT_DELIMITER = "__NexEvStDelim__"
17
17
 
18
- def self.db_config(env, adapter)
19
- raw_db_config[env.to_s][adapter.to_s]
18
+ def self.db_config
19
+ raw_db_config[@environment.to_s][@adapter.to_s]
20
20
  end
21
21
 
22
22
  def self.raw_db_config
@@ -50,7 +50,7 @@ module EventStore
50
50
  end
51
51
 
52
52
  def self.schema
53
- @schema ||= raw_db_config[@environment][@database]['schema']
53
+ @schema ||= raw_db_config[@environment][@adapter]['schema']
54
54
  end
55
55
 
56
56
  def self.table_name
@@ -66,48 +66,49 @@ module EventStore
66
66
  EventStore.redis.flushdb
67
67
  end
68
68
 
69
- def self.postgres(db_env = :test)
70
- @database = 'postgres'
71
- @environment = db_env.to_s
69
+ def self.postgres(environment = 'test')
72
70
  local_redis_connect
73
- create_db( @database, @environment)
71
+ @adapter = 'postgres'
72
+ @environment = environment.to_s
73
+ @db_config ||= self.db_config
74
+ create_db
75
+ end
76
+
77
+ #To find the ip address of vertica on your local box (running in a vm)
78
+ #1. open Settings -> Network and select Wi-Fi
79
+ #2. open a terminal in the VM
80
+ #3. do /sbin/ifconfig (ifconfig is not in $PATH)
81
+ #4. the inet address for en0 is what you want
82
+ #Hint: if it just hangs, you have have the wrong IP
83
+ def self.vertica(environment = 'test')
84
+ local_redis_connect
85
+ @adapter = 'vertica'
86
+ @environment = environment.to_s
87
+ @db_config ||= self.db_config
88
+ @db_config['host'] ||= ENV['VERTICA_HOST'] || vertica_host
89
+ create_db
74
90
  end
75
91
 
76
- def self.vertica(db_env = :test)
77
- @database = 'vertica'
78
- @environment = db_env.to_s
79
- local_redis_connect
80
- create_db(@database, @environment)
81
- end
82
-
83
- def self.production(database_config, redis_config)
84
- self.redis_connect redis_config
85
- self.connect database_config
86
- end
87
-
88
- def self.create_db(type, db_env, db_config = nil)
89
- @db_type = type
90
- db_config ||= self.db_config(db_env, type)
91
- if type == 'vertica'
92
- #To find the ip address of vertica on your local box (running in a vm)
93
- #1. open Settings -> Network and select Wi-Fi
94
- #2. open a terminal in the VM
95
- #3. do /sbin/ifconfig (ifconfig is not in $PATH)
96
- #4. the inet address for en0 is what you want
97
- #Hint: if it just hangs, you have have the wrong IP
98
- db_config['host'] = ENV['VERTICA_HOST'] || vertica_host
99
- @migrations_dir = 'db/migrations'
100
- else
101
- @migrations_dir = 'db/pg_migrations'
102
- end
92
+ def self.custom_config(database_config, redis_config, envrionment = 'production')
93
+ self.redis_connect(redis_config)
94
+ @adapter = database_config['adapter'].to_s
95
+ @environment = envrionment
96
+ @db_config = database_config
97
+ create_db
98
+ end
99
+
100
+ def self.migrations_dir
101
+ @adapter == 'vertica' ? 'migrations' : 'pg_migrations'
102
+ end
103
103
 
104
- EventStore.connect db_config
104
+ def self.create_db
105
+ self.connect(@db_config)
105
106
  schema_exits = @db.table_exists?("#{schema}__schema_info".to_sym)
106
107
  @db.run "CREATE SCHEMA #{EventStore.schema};" unless schema_exits
107
- Sequel::Migrator.run(@db, @migrations_dir, :table=> "#{schema}__schema_info".to_sym)
108
+ Sequel::Migrator.run(@db, File.expand_path(File.join('..','..','db', self.migrations_dir), __FILE__), :table=> "#{schema}__schema_info".to_sym)
108
109
  end
109
110
 
110
111
  def self.vertica_host
111
- File.read File.expand_path("../../db/vertica_host_address.txt", __FILE__)
112
+ File.read File.expand_path(File.join('..','..','db', 'vertica_host_address.txt'), __FILE__)
112
113
  end
113
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-14 00:00:00.000000000 Z
13
+ date: 2014-02-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -240,7 +240,7 @@ files:
240
240
  - spec/event_store/snapshot_spec.rb
241
241
  - spec/event_store/vertica guy notes.txt
242
242
  - spec/spec_helper.rb
243
- homepage: ''
243
+ homepage: https://github.com/nexiahome/event_store
244
244
  licenses:
245
245
  - MIT
246
246
  post_install_message: