eventosaurus 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a8ef4f20b8d48c0c0e035f514ba4088578e9068
4
- data.tar.gz: 9038157130f2b42586d4fee746a3ebd394d3d0c2
3
+ metadata.gz: 599ff59a55cf9f34dc2c1fce3b3ef8e605bc2aee
4
+ data.tar.gz: 832ae4467408a064116a2335ba9e41fefc923c30
5
5
  SHA512:
6
- metadata.gz: 90643659fb8232e9f6d713d946adbd8f984d49038d00a9095bd30a79df287796603ffcb449104ea79829f8f4944dd0906d5a204742d72a66579739d8888116a9
7
- data.tar.gz: 158959e5a2f144a853cf7fa300301dde2d08dc742143b98ab826984ee081d79981d9a40a73df7bce2b38d28602e10e94cfcfd076fc6000c504c1bc171b50cb02
6
+ metadata.gz: 393946457e9f53cc08e65c1b9e42284840280039aac1c0777298bec8210b07047761d25c56cd986b11cd682151277632771023c30c387eb296839877fb74d7cf
7
+ data.tar.gz: 2f6234c2b220187f760d3d03d5cc5ab0f26299b3927d6846980e4a1038b22353889368f34787c5535b7297d4bd6d1b49aacfb54688b43c437ab6be85b332c5e7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.1
2
+
3
+ * updates test_mode methods to accept any number of arguments
4
+
1
5
  # 1.0.0
2
6
 
3
7
  * changes name to 'eventosaurus'
data/README.md CHANGED
@@ -127,7 +127,7 @@ There are some built-in attributes for your events:
127
127
 
128
128
  ## Building the Tables
129
129
 
130
- DynamoDB must have the tables needed to run your events. Once you've written your event classes you must run a rake task to create the tables. The tables are namespaced by your environment, as defined in the environment_prefix variable mentioned above. So if you build locally, the table name might be `localhost_core_customer_audit`. This will allow us to quickly get up and running on new environments. For the time being, the rake task expects your event definitions to be in `app/models/events`. **Be sure to put them there!**. Rake tasks are scoped to only work with tables that begin with your environment_prefix. This means even if staging and production point to the same dynamodb account, the `drop_tables` task will only drop tables from the environment specified.
130
+ DynamoDB must have the tables needed to run your events. Once you've written your event classes you must run a rake task to create the tables. The tables are namespaced by your environment, as defined in the environment_prefix variable mentioned above. So if you build locally, the table name might be `localhost_phone_call`. This will allow us to quickly get up and running on new environments. For the time being, the rake task expects your event definitions to be in `app/models/events`. **Be sure to put them there!**. Rake tasks are scoped to only work with tables that begin with your environment_prefix. This means even if staging and production point to the same dynamodb account, the `drop_tables` task will only drop tables from the environment specified.
131
131
 
132
132
  ```
133
133
  rake eventosaurus:create_tables
@@ -159,15 +159,12 @@ To store data use the `.store` class method on your event class. Use the same si
159
159
 
160
160
  ```ruby
161
161
  # Somewhere in your app:
162
- def check_for_audit(row)
163
- if audit_time?
164
- Events::CoreCustomerAudit.store(
165
- updated_row: row,
166
- updated_attribute: 'first_name',
167
- updated_by_user_id: 35,
168
- audit_occurred_at: UTC.now
162
+ def check_for_phonecall(row)
163
+ Events::PhoneCall.store(
164
+ person_id: row[:person_id],
165
+ phone_number: row[:phone_number],
166
+ last_called: row[:last_called]
169
167
  )
170
- end
171
168
  end
172
169
  ```
173
170
 
@@ -176,17 +173,17 @@ To store data use the `.store` class method on your event class. Use the same si
176
173
  The gem gives you some dynamic methods to query your data based on your table definition. It's important to keep in mind that you are working with DynamoDB. It is not meant to be a data store that is accessed generically. It expects you to know the queries you want to run upfront. Good for us, we are storing each event type in its own table, so we can make good guesses about this. To this end, eventosaurus creates getters for the attributes you listed in your table definition:
177
174
 
178
175
  ```ruby
179
- Events::CoreCustomerAudit.by_customer_id(5)
180
- Events::CoreCustomerAudit.by_customer_id(5).by_table_name('users').count
176
+ Events::PhoneCall.by_person_id(5)
177
+ Events::PhoneCall.by_person_id(5).by_table_name('users').count
181
178
 
182
179
  # event_uuid & created_at included for free :)
183
- Events::CoreCustomerAudit.by_created_at('2015-01-04', 'GT')
180
+ Events::PhoneCall.by_created_at('2015-01-04', 'GT')
184
181
  ```
185
182
 
186
183
  The queries above return eventosaurus Query objects. To actually execute the query, use the `run` method:
187
184
 
188
185
  ```ruby
189
- Events::CoreCustomerAudit.by_customer_id(5).count.run
186
+ Events::PhoneCall.by_person_id(5).count.run
190
187
  ```
191
188
 
192
189
  Note:
@@ -197,7 +194,7 @@ Note:
197
194
 
198
195
  ```
199
196
  # too many secondary predicates. after one secondary index is used, the rest will be full scans on whatever comes back after the first local index.
200
- Events::CoreCustomerAudit.by_created_at('2015-01-04', 'GT').by_table_name('users')
197
+ Events::PhoneCall.by_created_at('2015-01-04', 'GT').by_table_name('users')
201
198
  ```
202
199
 
203
200
  **To sum it up: for speed, you are allowed 0||1 partition key condition and 0||1 secondary condition. No more than that.**
data/lib/eventosaurus.rb CHANGED
@@ -6,5 +6,6 @@ require 'eventosaurus/configuration'
6
6
  require 'eventosaurus/storable'
7
7
  require 'eventosaurus/query_builder'
8
8
  require 'eventosaurus/services/table_manager_service'
9
+ require 'eventosaurus/lib/test_mode'
9
10
  require 'eventosaurus/models/table.rb'
10
11
  require 'eventosaurus/models/query.rb'
@@ -16,13 +16,11 @@ module Eventosaurus
16
16
  end
17
17
 
18
18
  def enable_test_mode
19
- Storable::ClassMethods.redefine_method(:store) do
20
- true
21
- end
19
+ store = TestMode.instance_method(:store)
20
+ run = TestMode.instance_method(:run)
22
21
 
23
- Models::Query.redefine_method(:run) do
24
- true
25
- end
22
+ Storable::ClassMethods.send(:define_method, :store, store)
23
+ Models::Query.send(:define_method, :run, run)
26
24
  end
27
25
  end
28
26
 
@@ -0,0 +1,11 @@
1
+ module Eventosaurus
2
+ module TestMode
3
+ def store(*_)
4
+ true
5
+ end
6
+
7
+ def run(*_)
8
+ true
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  module Eventosaurus
2
2
  MAJOR = '1'.freeze
3
3
  MINOR = '0'.freeze
4
- PATCH = '0'.freeze
4
+ PATCH = '1'.freeze
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventosaurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blue Apron Engineering
@@ -175,6 +175,7 @@ files:
175
175
  - eventosaurus.gemspec
176
176
  - lib/eventosaurus.rb
177
177
  - lib/eventosaurus/configuration.rb
178
+ - lib/eventosaurus/lib/test_mode.rb
178
179
  - lib/eventosaurus/models/query.rb
179
180
  - lib/eventosaurus/models/table.rb
180
181
  - lib/eventosaurus/persistors/sidekiq.rb
@@ -211,4 +212,3 @@ signing_key:
211
212
  specification_version: 4
212
213
  summary: Enables easy reporting of events to an event store.
213
214
  test_files: []
214
- has_rdoc: