ahoy_matey 1.0.1 → 1.0.2

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: 3e588efc9bc71536e8077c79e1b874db35333d92
4
- data.tar.gz: 1c97d1fc30240204a78519d8a3866e68351d40b9
3
+ metadata.gz: 2650b75c743530def251ca5e74c48c5a0a6654cc
4
+ data.tar.gz: 2dae4a806be1b4bd07d11f355440dedb2af33d85
5
5
  SHA512:
6
- metadata.gz: e448cfa2434da5e946fc7be76dcb0b626f70301828c2fa21fb19ea94e7d2e0d0faeb6d1b140159e9ee4e0de8a805322650d78fe41bf456d3698adc13ccc3e117
7
- data.tar.gz: 795e1ecfb5d87235bd9e3fd66e0714afbda91b9e8ace354509345b12aa62e98e88379874263348b3f96464d18620d8c5db137542716e36e37345df0cfa168aa2
6
+ metadata.gz: 04ffd75191af402b3d371f3f641feda3b56482658163b6f4c00838da8c31debd812747199f707a7b87885291cab37855457d76b67a060dd07698bc298993d047
7
+ data.tar.gz: 28b522d37a313db0a4987bef9b7521642e0f5c6c44f01e71f3332df4095804d03b2ac68e20ebf106b7ebb6020a84c3a5c189910d0fe0d7cd7d2f3435c89be329
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.2
2
+
3
+ - Fixed BSON for Mongoid 3
4
+ - Fixed Doorkeeper integration
5
+ - Fixed user tracking in overridden authenticate method
6
+
1
7
  ## 1.0.1
2
8
 
3
9
  - Fixed `visitable` outside of requests
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 = params[:name] ? [params] : ActiveSupport::JSON.decode(request.body.read)
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
- user_method = Ahoy.user_method
81
- if user_method.respond_to?(:call)
82
- user_method.call(controller)
83
- else
84
- controller.send(user_method)
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
- ::BSON::Binary.new(token.delete("-"), :uuid)
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
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -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
 
@@ -5,7 +5,7 @@ class Visit
5
5
  belongs_to :user
6
6
 
7
7
  # required
8
- field :visitor_id, type: BSON::Binary
8
+ field :visitor_id, type: <%= @visitor_id_type %>
9
9
 
10
10
  # the rest are recommended but optional
11
11
  # simply remove the columns you don't want
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.1
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-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable