fluidfeatures-rails 0.3.2 → 0.4.0
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/LICENSE +46 -0
- data/fluidfeatures-rails.gemspec +1 -1
- data/lib/fluidfeatures/rails/version.rb +1 -1
- data/lib/fluidfeatures/rails.rb +25 -28
- metadata +8 -7
data/LICENSE
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
All components of this product are
|
3
|
+
Copyright (c) 2012 FluidFeatures Software Inc. All rights reserved.
|
4
|
+
|
5
|
+
FluidFeatures Software License
|
6
|
+
|
7
|
+
This Software and all content and other materials in the Software or associated
|
8
|
+
with the Software, including, without limitation, all logos, and all designs,
|
9
|
+
text, graphics, pictures, reviews, information, data, software, sound files,
|
10
|
+
other files and the selection and arrangement thereof (collectively, the
|
11
|
+
"Software Materials") are the proprietary property of FluidFeatures Software
|
12
|
+
Inc., or its licensors or users, and are protected by Canada, U.S. and
|
13
|
+
international copyright laws.
|
14
|
+
|
15
|
+
You are granted a limited, non-sublicensable license to access and use the
|
16
|
+
Software, for your commercial use by you and your website users only. The
|
17
|
+
license does not include or authorize: (a) any resale of the Software or the
|
18
|
+
Software Materials therein; (b) modifying or otherwise making any derivative
|
19
|
+
uses of the Software and the Software Materials, or any portion thereof, except
|
20
|
+
where such modification or derivative use is made in connection with your use of
|
21
|
+
the FluidFeatures online service; or (c) any use of the Software or the Software
|
22
|
+
Materials other than for its intended purpose. Any use of the Software or the
|
23
|
+
Software Materials other than as specifically authorized in these license,
|
24
|
+
without the prior written permission of FluidFeatures Software Inc, is strictly
|
25
|
+
prohibited and will terminate the license granted here. Such unauthorized use
|
26
|
+
may also violate applicable laws including without limitation copyright and
|
27
|
+
trademark laws and applicable communications regulations and statutes. Unless
|
28
|
+
explicitly stated herein, nothing in this license shall be construed as
|
29
|
+
conferring any license to intellectual property rights, whether by estoppel,
|
30
|
+
implication or otherwise. This license is revocable at any time for any reason.
|
31
|
+
|
32
|
+
THE SOFTWARE AND THE SOFTWARE MATERIALS (INCLUDING ANY INFORMATION) ARE PROVIDED
|
33
|
+
ON AN "AS IS" AND "AS AVAILABLE" BASIS WITHOUT WARRANTIES OF ANY KIND, EITHER
|
34
|
+
EXPRESS OR IMPLIED, AND INCLUDING WITHOUT LIMITATION IMPLIED REPRESENTATIONS,
|
35
|
+
WARRANTIES OR CONDITIONS OF OR RELATING TO ACCURACY, ACCESSIBILITY,
|
36
|
+
AVAILABILITY, COMPLETENESS, ERRORS, FITNESS FOR A PARTICULAR PURPOSE,
|
37
|
+
MERCHANTABILITY, NON-INFRINGEMENT, PERFORMANCE, QUALITY, RESULTS, SECURITY,
|
38
|
+
SEQUENCE, OR TIMELINESS, ALL OF WHICH ARE HEREBY DISCLAIMED BY FLUIDFEATURES
|
39
|
+
SOFTWARE INC TO THE FULLEST EXTENT PERMITTED BY LAW.
|
40
|
+
|
41
|
+
THE AGGREGATE LIABILITY OF FLUID FEATURES SOFTWARE INC. TO YOU, WHETHER IN
|
42
|
+
CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE, WHETHER ACTIVE, PASSIVE OR
|
43
|
+
IMPUTED), PRODUCT LIABILITY, STRICT LIABILITY OR OTHER THEORY OF LIABILITY,
|
44
|
+
SHALL NOT EXCEED ANY COMPENSATION YOU PAY, IF ANY, FOR ACCESS TO OR USE OF THE
|
45
|
+
SOFTWARE.
|
46
|
+
|
data/fluidfeatures-rails.gemspec
CHANGED
@@ -15,5 +15,5 @@ Gem::Specification.new do |s|
|
|
15
15
|
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
#s.add_dependency "rails", "~>3.0"
|
18
|
-
s.add_dependency "fluidfeatures" unless ENV["FF_DEV"]
|
18
|
+
s.add_dependency "fluidfeatures", "~>0.4.0" unless ENV["FF_DEV"]
|
19
19
|
end
|
data/lib/fluidfeatures/rails.rb
CHANGED
@@ -58,6 +58,8 @@ end
|
|
58
58
|
module ActionController
|
59
59
|
class Base
|
60
60
|
|
61
|
+
attr_accessor :ff_transaction
|
62
|
+
|
61
63
|
# allow fluidfeature to be called from templates
|
62
64
|
helper_method :fluidfeature
|
63
65
|
|
@@ -81,14 +83,17 @@ module ActionController
|
|
81
83
|
raise "fluidfeatures_current_user returned invalid user (Hash expected) : #{user}"
|
82
84
|
end
|
83
85
|
|
84
|
-
# default to anonymous is
|
86
|
+
# default to anonymous is no user id given
|
85
87
|
user[:anonymous] = false unless user[:id]
|
86
88
|
|
87
89
|
# if no user id given, then attempt to get the unique id of this visitor from the cookie
|
88
90
|
user[:id] ||= cookies[:fluidfeatures_anonymous]
|
89
91
|
|
90
|
-
|
92
|
+
url = "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
|
93
|
+
|
94
|
+
transaction = ::FluidFeatures::Rails.ff_app.user_transaction(
|
91
95
|
user[:id],
|
96
|
+
url,
|
92
97
|
user[:name],
|
93
98
|
!!user[:anonymous],
|
94
99
|
user[:uniques],
|
@@ -96,9 +101,9 @@ module ActionController
|
|
96
101
|
)
|
97
102
|
|
98
103
|
# Set/delete cookies for anonymous users
|
99
|
-
if
|
104
|
+
if transaction.user.anonymous
|
100
105
|
# update the cookie, with the unique id of this user
|
101
|
-
cookies[:fluidfeatures_anonymous] =
|
106
|
+
cookies[:fluidfeatures_anonymous] = transaction.user.unique_id
|
102
107
|
else
|
103
108
|
# We are no longer an anoymous user. Delete the cookie
|
104
109
|
if cookies.has_key? :fluidfeatures_anonymous
|
@@ -106,11 +111,14 @@ module ActionController
|
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
109
|
-
|
114
|
+
transaction
|
110
115
|
end
|
111
116
|
|
112
|
-
|
113
|
-
|
117
|
+
#
|
118
|
+
# Initialize the FluidFeatures state for this request.
|
119
|
+
#
|
120
|
+
def fluidfeatures_request_before
|
121
|
+
@ff_transaction = fluidfeatures_initialize_user
|
114
122
|
end
|
115
123
|
|
116
124
|
#
|
@@ -120,38 +128,36 @@ module ActionController
|
|
120
128
|
# We call user_id to get the current user's unique id.
|
121
129
|
#
|
122
130
|
def fluidfeature(feature_name, version_name=nil, default_enabled=nil)
|
131
|
+
|
132
|
+
# also support: fluidfeature(feature_name, default_enabled)
|
123
133
|
if default_enabled == nil and (version_name.is_a? FalseClass or version_name.is_a? TrueClass)
|
124
134
|
default_enabled = version_name
|
125
135
|
version_name = nil
|
126
136
|
end
|
137
|
+
|
127
138
|
unless default_enabled.is_a? FalseClass or default_enabled.is_a? TrueClass
|
128
139
|
default_enabled = fluidfeatures_default_enabled
|
129
140
|
end
|
141
|
+
|
130
142
|
unless ::FluidFeatures::Rails.enabled
|
131
143
|
return default_enabled || false
|
132
144
|
end
|
133
|
-
|
145
|
+
|
146
|
+
ff_transaction.feature_enabled?(feature_name, version_name, default_enabled)
|
134
147
|
end
|
135
148
|
|
136
149
|
def fluidgoal(goal_name, goal_version_name=nil)
|
137
150
|
unless ::FluidFeatures::Rails.enabled
|
138
151
|
return default_enabled || false
|
139
152
|
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
#
|
144
|
-
# Initialize the FluidFeatures state for this request.
|
145
|
-
#
|
146
|
-
def fluidfeatures_request_before
|
147
|
-
@ff_request_start_time = Time.now
|
153
|
+
ff_transaction.goal_hit(goal_name, goal_version_name)
|
148
154
|
end
|
149
155
|
|
150
156
|
#
|
151
157
|
# Returns the features enabled for this request's user.
|
152
158
|
#
|
153
159
|
def fluidfeatures_retrieve_user_features
|
154
|
-
|
160
|
+
ff_transaction.features
|
155
161
|
end
|
156
162
|
|
157
163
|
#
|
@@ -162,21 +168,12 @@ module ActionController
|
|
162
168
|
# without requiring the developer to do it manually.
|
163
169
|
#
|
164
170
|
def fluidfeatures_request_after
|
165
|
-
|
166
|
-
url = "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
|
167
|
-
fluidfeatures_user.end_transaction(
|
168
|
-
url,
|
169
|
-
# stats
|
170
|
-
{
|
171
|
-
:request => {
|
172
|
-
:duration => request_duration
|
173
|
-
}
|
174
|
-
}
|
175
|
-
)
|
171
|
+
ff_transaction.end_transaction
|
176
172
|
end
|
177
173
|
|
178
174
|
def fluidfeatures_default_enabled
|
179
175
|
# By default unknown features are disabled.
|
176
|
+
# Override and return "true" to have features enabled by default.
|
180
177
|
false
|
181
178
|
end
|
182
179
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluidfeatures-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluidfeatures
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.4.0
|
30
30
|
description: Ruby on Rails client for the FluidFeatures service.
|
31
31
|
email:
|
32
32
|
- phil@fluidfeatures.com
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- .gitignore
|
38
38
|
- .travis.yml
|
39
39
|
- Gemfile
|
40
|
+
- LICENSE
|
40
41
|
- README.md
|
41
42
|
- Rakefile
|
42
43
|
- fluidfeatures-rails.gemspec
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
version: '0'
|
81
82
|
requirements: []
|
82
83
|
rubyforge_project: fluidfeatures-rails
|
83
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.23
|
84
85
|
signing_key:
|
85
86
|
specification_version: 3
|
86
87
|
summary: Ruby on Rails client for the FluidFeatures service.
|