Module: FieldTest
- Defined in:
- lib/field_test.rb,
lib/field_test/engine.rb,
lib/field_test/mailer.rb,
lib/field_test/helpers.rb,
lib/field_test/version.rb,
lib/field_test/controller.rb,
lib/field_test/experiment.rb,
lib/field_test/participant.rb,
app/models/field_test/event.rb,
app/models/field_test/membership.rb,
app/helpers/field_test/base_helper.rb,
app/controllers/field_test/base_controller.rb,
lib/generators/field_test/events_generator.rb,
lib/generators/field_test/install_generator.rb,
app/controllers/field_test/experiments_controller.rb,
app/controllers/field_test/memberships_controller.rb,
app/controllers/field_test/participants_controller.rb
Defined Under Namespace
Modules: BaseHelper, Controller, Generators, Helpers, Mailer
Classes: BaseController, Engine, Error, Event, Experiment, ExperimentNotFound, ExperimentsController, Membership, MembershipsController, Participant, ParticipantsController, UnknownParticipant
Constant Summary
collapse
- UUID_NAMESPACE =
"a82ae811-5011-45ab-a728-569df7499c5f"
- VERSION =
"0.7.0"
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
43
44
45
|
# File 'lib/field_test.rb', line 43
def self.cache
config["cache"]
end
|
.config ⇒ Object
31
32
33
|
# File 'lib/field_test.rb', line 31
def self.config
@config ||= YAML.safe_load(ERB.new(File.read(config_path)).result, permitted_classes: [Date, Time], aliases: true)
end
|
.config_path ⇒ Object
26
27
28
29
|
# File 'lib/field_test.rb', line 26
def self.config_path
path = defined?(Rails) ? Rails.root : File
path.join("config", "field_test.yml")
end
|
.cookies ⇒ Object
47
48
49
|
# File 'lib/field_test.rb', line 47
def self.cookies
config.key?("cookies") ? config["cookies"] : true
end
|
.events_supported? ⇒ Boolean
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/field_test.rb', line 59
def self.events_supported?
unless defined?(@events_supported)
table_name = "field_test_events"
@events_supported =
FieldTest::Membership.connection_pool.with_connection do |connection|
if connection.respond_to?(:data_source_exists?)
connection.data_source_exists?(table_name)
else
connection.table_exists?(table_name)
end
end
end
@events_supported
end
|
.exclude_bots? ⇒ Boolean
39
40
41
|
# File 'lib/field_test.rb', line 39
def self.exclude_bots?
config["exclude"] && config["exclude"]["bots"]
end
|
.excluded_ips ⇒ Object
35
36
37
|
# File 'lib/field_test.rb', line 35
def self.excluded_ips
@excluded_ips ||= Array(config["exclude"] && config["exclude"]["ips"]).map { |ip| IPAddr.new(ip) }
end
|
.legacy_participants ⇒ Object
51
52
53
|
# File 'lib/field_test.rb', line 51
def self.legacy_participants
config["legacy_participants"]
end
|
.mask_ip(ip) ⇒ Object
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/field_test.rb', line 74
def self.mask_ip(ip)
addr = IPAddr.new(ip)
if addr.ipv4?
addr.mask(24).to_s
else
addr.mask(48).to_s
end
end
|
.precision ⇒ Object
55
56
57
|
# File 'lib/field_test.rb', line 55
def self.precision
config["precision"] || 0
end
|