ahoy_matey 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -0
- data/app/controllers/ahoy/events_controller.rb +13 -1
- data/lib/ahoy.rb +0 -6
- data/lib/ahoy/stores/active_record_token_store.rb +9 -5
- data/lib/ahoy/stores/base_store.rb +1 -1
- data/lib/ahoy/stores/mongoid_store.rb +8 -1
- data/lib/ahoy/version.rb +1 -1
- data/lib/generators/ahoy/stores/mongoid_visits_generator.rb +8 -0
- data/lib/generators/ahoy/stores/templates/mongoid_visit_model.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2650b75c743530def251ca5e74c48c5a0a6654cc
|
4
|
+
data.tar.gz: 2dae4a806be1b4bd07d11f355440dedb2af33d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04ffd75191af402b3d371f3f641feda3b56482658163b6f4c00838da8c31debd812747199f707a7b87885291cab37855457d76b67a060dd07698bc298993d047
|
7
|
+
data.tar.gz: 28b522d37a313db0a4987bef9b7521642e0f5c6c44f01e71f3332df4095804d03b2ac68e20ebf106b7ebb6020a84c3a5c189910d0fe0d7cd7d2f3435c89be329
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,11 +27,15 @@ And add the javascript file in `app/assets/javascripts/application.js` after jQu
|
|
27
27
|
|
28
28
|
### PostgreSQL
|
29
29
|
|
30
|
+
For Rails 4 and PostgreSQL 9.2 or greater, use:
|
31
|
+
|
30
32
|
```sh
|
31
33
|
rails generate ahoy:stores:active_record -d postgresql
|
32
34
|
rake db:migrate
|
33
35
|
```
|
34
36
|
|
37
|
+
Otherwise, follow the instructions for MySQL.
|
38
|
+
|
35
39
|
### MySQL or SQLite
|
36
40
|
|
37
41
|
Add [activeuuid](https://github.com/jashmenn/activeuuid) to your Gemfile.
|
@@ -2,7 +2,19 @@ module Ahoy
|
|
2
2
|
class EventsController < Ahoy::BaseController
|
3
3
|
|
4
4
|
def create
|
5
|
-
events =
|
5
|
+
events =
|
6
|
+
if params[:name]
|
7
|
+
# legacy API
|
8
|
+
[params]
|
9
|
+
else
|
10
|
+
begin
|
11
|
+
ActiveSupport::JSON.decode(request.body.read)
|
12
|
+
rescue ActiveSupport::JSON.parse_error
|
13
|
+
# do nothing
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
events.each do |event|
|
7
19
|
time = Time.zone.parse(event["time"]) rescue nil
|
8
20
|
|
data/lib/ahoy.rb
CHANGED
@@ -56,14 +56,8 @@ module Ahoy
|
|
56
56
|
# deprecated
|
57
57
|
|
58
58
|
mattr_accessor :domain
|
59
|
-
|
60
59
|
mattr_accessor :visit_model
|
61
|
-
|
62
60
|
mattr_accessor :user_method
|
63
|
-
self.user_method = proc do |controller|
|
64
|
-
(controller.respond_to?(:current_user) && controller.current_user) || (controller.respond_to?(:current_resource_owner, true) && controller.send(:current_resource_owner)) || nil
|
65
|
-
end
|
66
|
-
|
67
61
|
mattr_accessor :exclude_method
|
68
62
|
|
69
63
|
mattr_accessor :subscribers
|
@@ -77,11 +77,15 @@ module Ahoy
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def user
|
80
|
-
|
81
|
-
|
82
|
-
user_method.call
|
83
|
-
|
84
|
-
|
80
|
+
@user ||= begin
|
81
|
+
user_method = Ahoy.user_method
|
82
|
+
if user_method.respond_to?(:call)
|
83
|
+
user_method.call(controller)
|
84
|
+
elsif user_method
|
85
|
+
controller.send(user_method)
|
86
|
+
else
|
87
|
+
super
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -27,7 +27,7 @@ module Ahoy
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def user
|
30
|
-
@user ||= controller.current_user
|
30
|
+
@user ||= (controller.respond_to?(:current_user) && controller.current_user) || (controller.respond_to?(:current_resource_owner, true) && controller.send(:current_resource_owner)) || nil
|
31
31
|
end
|
32
32
|
|
33
33
|
def exclude?
|
@@ -51,7 +51,14 @@ module Ahoy
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def binary(token)
|
54
|
-
|
54
|
+
token = token.delete("-")
|
55
|
+
if defined?(::BSON)
|
56
|
+
::BSON::Binary.new(token, :uuid)
|
57
|
+
elsif defined?(::Moped::BSON)
|
58
|
+
::Moped::BSON::Binary.new(:uuid, token)
|
59
|
+
else
|
60
|
+
token
|
61
|
+
end
|
55
62
|
end
|
56
63
|
|
57
64
|
end
|
data/lib/ahoy/version.rb
CHANGED
@@ -7,6 +7,14 @@ module Ahoy
|
|
7
7
|
source_root File.expand_path("../templates", __FILE__)
|
8
8
|
|
9
9
|
def generate_model
|
10
|
+
@visitor_id_type =
|
11
|
+
if defined?(::BSON)
|
12
|
+
"BSON::Binary"
|
13
|
+
elsif defined?(::Moped::BSON)
|
14
|
+
"Moped::BSON::Binary"
|
15
|
+
else
|
16
|
+
"String"
|
17
|
+
end
|
10
18
|
template "mongoid_visit_model.rb", "app/models/visit.rb"
|
11
19
|
end
|
12
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_matey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|