eventy 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbecb855729ed71d610ed6008917ff66e48f149d
4
- data.tar.gz: fbe7ff286d9dd15cae0dfaf74bac476fadbd01c9
3
+ metadata.gz: 24bee34870e8b88e3d749d1f01f542fb46fe6332
4
+ data.tar.gz: 0ac34b2a49c5a5f994f873d077ff059a942965d7
5
5
  SHA512:
6
- metadata.gz: f78694465489b75c85357632f5114020d1ea2e2a610fe300c0e796839062694f9d89c5c340084d9dbbcc8bbeb0522160c3b8a29d0e29da1bab74865ad4ddcb08
7
- data.tar.gz: 519fd8a37f1ff8fe8754cf8f6f6a47d7c2a30f420ec7fffa9b6bd63fea0f6865e41186ee12a89ed8eaf649dc60e7cf83d2a51af57833955ef8e6392433d9351c
6
+ metadata.gz: 8a7024380bec5f673db8f8113b0818c0010339dfc3c3c65a8fc026fce0da694a352a6b473fb25b2a2eb9006104d0ee4f527911c2c646d642338eef6a0bca71ca
7
+ data.tar.gz: 7ca796841268780e8832ae0656ced444b655817780c13a3c6f36c6be8e2553f43acd9a0e455e7f06dbc0a06a63059cf03b4abc0ff944f150f90b53240c5897c5
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Eventy
2
2
 
3
- TODO: Write a gem description
3
+ Super simple event tracking in Rails. Record arbitrary events, associate them with a user or account, and record any associated properties.
4
+
5
+ Currently, Eventy ships with two backends: `active_record`, and `active_record_hstore`.
4
6
 
5
7
  ## Installation
6
8
 
@@ -12,13 +14,28 @@ And then execute:
12
14
 
13
15
  $ bundle
14
16
 
15
- Or install it yourself as:
17
+ Next, run the Rails generator to create a migration for your desired backend (either `active_record` or `active_record_hstore`):
18
+
19
+ $ bundle exec rails generate eventy:active_record
20
+
21
+ You may need to modify this migration. Then run the migration:
22
+
23
+ $ bundle exec rake db:migrate
16
24
 
17
- $ gem install eventy
25
+ Finally, configure eventy to use your preferred backend:
26
+
27
+ # config/initializers/eventy.rb
28
+ Eventy.configure(backend: :active_record)
18
29
 
19
30
  ## Usage
20
31
 
21
- TODO: Write usage instructions here
32
+ Record events by calling `Eventy.record(event_name, unique_identifier, attributes)`:
33
+
34
+ Eventy.record('account:signup', session[:unique_id], { referrer: 'Facebook' })
35
+ Eventy.record('response:create', current_account.unique_id)
36
+ Eventy.record('response:create', current_account.unique_id)
37
+
38
+ You can name your events however you like, associate them with whatever unique identifier you like, and assign them arbitrary properties. Simple.
22
39
 
23
40
  ## Contributing
24
41
 
@@ -6,6 +6,8 @@ module Eventy
6
6
  case options[:backend].to_sym
7
7
  when :active_record
8
8
  require "eventy/backends/active_record"
9
+ when :active_record_hstore
10
+ require "eventy/backends/active_record_hstore"
9
11
  end
10
12
  end
11
13
 
@@ -0,0 +1,11 @@
1
+ module Eventy
2
+ class Event < ::ActiveRecord::Base
3
+ include AbstractEvent
4
+
5
+ store_accessor :properties
6
+
7
+ def self.record(event_name, identity, properties = {})
8
+ create(name: event_name, identity: identity, properties: properties)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Eventy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class Eventy::ActiveRecordHstoreGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def self.next_migration_number(path)
9
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
10
+ end
11
+
12
+ def copy_migrations
13
+ migration_template 'setup_eventy_hstore.rb', "db/migrate/setup_eventy.rb"
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # Creates the database table plus indexes you'll need to use Eventy
2
+ class SetupEventy < ActiveRecord::Migration
3
+ def self.up
4
+ execute "CREATE EXTENSION hstore"
5
+
6
+ create_table :events, force: true do |t|
7
+ t.string :name
8
+ t.string :identity
9
+ t.hstore :properties
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :events, :name
14
+ add_index :events, [:identity, :name]
15
+ add_index :events, :properties, using: :gin
16
+ end
17
+
18
+ def self.down
19
+ drop_table :events
20
+
21
+ execute "DROP EXTENSION hstore"
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Firth-McCoy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-28 00:00:00.000000000 Z
11
+ date: 2013-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,9 +55,12 @@ files:
55
55
  - lib/eventy.rb
56
56
  - lib/eventy/abstract_event.rb
57
57
  - lib/eventy/backends/active_record.rb
58
+ - lib/eventy/backends/active_record_hstore.rb
58
59
  - lib/eventy/version.rb
59
60
  - lib/generators/eventy/active_record_generator.rb
61
+ - lib/generators/eventy/active_record_hstore_generator.rb
60
62
  - lib/generators/eventy/templates/setup_eventy.rb
63
+ - lib/generators/eventy/templates/setup_eventy_hstore.rb
61
64
  homepage: https://github.com/nfm/eventy
62
65
  licenses:
63
66
  - MIT