open_conference_ware 1.0.0.pre2 → 1.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.travis.yml +3 -0
- data/README.md +6 -4
- data/app/assets/javascripts/open_conference_ware/{persona.js → persona.js.erb} +1 -1
- data/app/assets/stylesheets/open_conference_ware/custom.css.scss +14 -18
- data/app/controllers/open_conference_ware/application_controller.rb +2 -2
- data/app/controllers/open_conference_ware/authentications_controller.rb +8 -0
- data/app/controllers/open_conference_ware/manage/events_controller.rb +2 -2
- data/app/controllers/open_conference_ware/proposals_controller.rb +1 -1
- data/app/helpers/open_conference_ware/snippets_helper.rb +1 -1
- data/app/helpers/open_conference_ware/user_favorites_helper.rb +8 -4
- data/app/mixins/open_conference_ware/settings_checkers_mixin.rb +1 -0
- data/app/models/open_conference_ware/event.rb +1 -8
- data/app/models/open_conference_ware/proposal.rb +54 -61
- data/app/models/open_conference_ware/snippet.rb +1 -6
- data/app/observers/open_conference_ware/cache_watcher.rb +3 -3
- data/app/views/layouts/open_conference_ware/_header.html.erb +3 -1
- data/app/views/open_conference_ware/422.html.erb +1 -1
- data/app/views/open_conference_ware/500.html.erb +1 -1
- data/app/views/open_conference_ware/proposals/_form.html.erb +5 -5
- data/app/views/open_conference_ware/proposals/_list.html.erb +4 -4
- data/app/views/open_conference_ware/proposals/_list_concise.html.erb +3 -3
- data/app/views/open_conference_ware/proposals/_sub_list.html.erb +2 -2
- data/app/views/open_conference_ware/proposals/_transition_control.html.erb +2 -2
- data/app/views/open_conference_ware/proposals/show.html.erb +33 -54
- data/db/migrate/20131203235216_create_open_conference_ware_comments.rb +1 -1
- data/db/migrate/20131203235418_create_open_conference_ware_events.rb +1 -2
- data/db/migrate/20131203235524_create_open_conference_ware_proposals.rb +5 -5
- data/db/migrate/20131203235723_create_open_conference_ware_rooms.rb +1 -1
- data/db/migrate/20131203235831_create_open_conference_ware_schedule_items.rb +2 -2
- data/db/migrate/20131203235934_create_open_conference_ware_session_types.rb +1 -1
- data/db/migrate/20131204000008_create_open_conference_ware_snippets.rb +1 -1
- data/db/migrate/20131204000048_create_open_conference_ware_taggings.rb +2 -2
- data/db/migrate/20131204000147_create_open_conference_ware_tracks.rb +1 -1
- data/db/migrate/20131204000355_create_proposals_users_join_table.rb +3 -0
- data/lib/generators/open_conference_ware/install/install_generator.rb +10 -0
- data/lib/generators/open_conference_ware/install/templates/config_initializer.rb +24 -2
- data/lib/generators/open_conference_ware/install/templates/secret_token.rb.erb +13 -0
- data/lib/generators/open_conference_ware/install/templates/secrets.yml.erb +18 -0
- data/lib/open_conference_ware.rb +10 -4
- data/lib/open_conference_ware/dependencies.rb +0 -1
- data/lib/open_conference_ware/version.rb +1 -1
- data/lib/tasks/open_conference_ware_tasks.rake +3 -2
- data/open_conference_ware.gemspec +0 -1
- data/spec/controllers/open_conference_ware/proposals_controller_spec.rb +5 -5
- data/spec/dummy/config/initializers/01_open_conference_ware.rb +24 -2
- data/spec/dummy/config/initializers/02_omniauth.rb +1 -1
- data/spec/dummy/config/initializers/secret_token.rb +2 -1
- data/spec/dummy/config/secrets.yml +18 -0
- data/spec/spec_helper_customizations.rb +2 -1
- data/spec/views/open_conference_ware/proposals/_transition_control.html.erb_spec.rb +2 -1
- data/spec/views/open_conference_ware/rooms/show.html.erb_spec.rb +1 -0
- data/spec/views/open_conference_ware/session_types/show.html.erb_spec.rb +1 -0
- data/spec/views/open_conference_ware/tracks/show.html.erb_spec.rb +1 -0
- data/util/transfer_schedule_items.rb +1 -1
- data/util/user_favorites_contention_report.rb +1 -1
- metadata +7 -22
- metadata.gz.sig +0 -0
- data/app/mixins/open_conference_ware/cache_lookups_mixin.rb +0 -128
- data/spec/integration/open_conference_ware/cache_lookups_mixin_spec.rb +0 -122
@@ -0,0 +1,13 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure your secret_key_base is kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
<%= Rails.application.class.to_s %>.config.secret_key_base = OpenConferenceWare.secret_key_base
|
13
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#===[ Secrets ]=========================================================
|
2
|
+
#
|
3
|
+
# This file is meant for storing secret information that is never
|
4
|
+
# published or committed to a revision control system.
|
5
|
+
#
|
6
|
+
#---[ Values ]----------------------------------------------------------
|
7
|
+
|
8
|
+
# Email address of administrator that will get requests for assistance from users:
|
9
|
+
administrator_email: 'your@email.addr'
|
10
|
+
|
11
|
+
# Secret key for getting an ATOM feed of private comments:
|
12
|
+
comments_secret: <%= SecureRandom.hex(64) %>
|
13
|
+
|
14
|
+
# The Rails secret_key_base
|
15
|
+
# Used by config/initializers/secret_token.rb
|
16
|
+
secret_key_base: <%= SecureRandom.hex(64) %>
|
17
|
+
|
18
|
+
#===[ fin ]=============================================================
|
data/lib/open_conference_ware.rb
CHANGED
@@ -13,7 +13,7 @@ module OpenConferenceWare
|
|
13
13
|
self.mount_point ||= "/"
|
14
14
|
|
15
15
|
def self.mounted_path(path)
|
16
|
-
"#{self.mount_point}/#{path}".gsub("
|
16
|
+
"#{self.mount_point}/#{path}".gsub(/\/\/+/,"/")
|
17
17
|
end
|
18
18
|
|
19
19
|
# Secrets
|
@@ -22,11 +22,12 @@ module OpenConferenceWare
|
|
22
22
|
# Email address of administrator that will get exception notifications
|
23
23
|
# and requests for assistance from users:
|
24
24
|
mattr_accessor :administrator_email
|
25
|
-
self.administrator_email ||= 'your@email.addr'
|
26
25
|
|
27
26
|
# Secret key for getting an ATOM feed of private comments:
|
28
27
|
mattr_accessor :comments_secret
|
29
|
-
|
28
|
+
|
29
|
+
# The secret_key_base, which we'll pass on to Rails
|
30
|
+
mattr_accessor :secret_key_base
|
30
31
|
|
31
32
|
# Email
|
32
33
|
|
@@ -135,7 +136,12 @@ module OpenConferenceWare
|
|
135
136
|
|
136
137
|
# Can users add comments until a toggle is flipped on the event?
|
137
138
|
mattr_accessor :have_event_proposal_comments_after_deadline
|
138
|
-
self.have_event_proposal_comments_after_deadline
|
139
|
+
self.have_event_proposal_comments_after_deadline ||= true
|
140
|
+
|
141
|
+
# Can users note their favorite sessions?
|
142
|
+
mattr_accessor :have_user_favorites
|
143
|
+
self.have_user_favorites ||= true
|
144
|
+
|
139
145
|
|
140
146
|
# What audience experience levels can a proposal be classified as? The list will be displayed on the form in the order defined below. The "slug" is the unique key defining the particular audience level, while the "label" is the human-readable value displayed.
|
141
147
|
mattr_accessor :proposal_audience_levels
|
@@ -4,8 +4,9 @@ namespace :open_conference_ware do
|
|
4
4
|
puts <<-HERE
|
5
5
|
|
6
6
|
TO FINISH SETUP
|
7
|
-
1. See README.
|
8
|
-
2.
|
7
|
+
1. See README.md for information about configuration and customization
|
8
|
+
2. Edit config/initializers/01_open_conference_ware.rb and config/secrets.yml
|
9
|
+
2. Start the server: bin/rails server
|
9
10
|
3. Sign in as an admin in development mode
|
10
11
|
4. Use the web-based admin interface to create and configure an event
|
11
12
|
HERE
|
@@ -41,7 +41,6 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.add_dependency 'vpim', '~> 13.11.11'
|
42
42
|
s.add_dependency 'nokogiri', '~> 1.6.0'
|
43
43
|
s.add_dependency 'prawn', '~> 0.12.0'
|
44
|
-
s.add_dependency 'dalli', '~> 2.6.4'
|
45
44
|
s.add_dependency "dynamic_form", '~> 1.1.4'
|
46
45
|
s.add_dependency 'rinku', '~> 1.7.3'
|
47
46
|
|
@@ -362,7 +362,7 @@ describe OpenConferenceWare::ProposalsController do
|
|
362
362
|
it "should redirect back to proposals list if asked to display a proposal without an event" do
|
363
363
|
proposal = proposals(:quentin_widgets)
|
364
364
|
proposal.stub(event: nil)
|
365
|
-
Proposal.stub(find_by_id: proposal, find: proposal
|
365
|
+
Proposal.stub(find_by_id: proposal, find: proposal)
|
366
366
|
|
367
367
|
get :show, id: proposal.id
|
368
368
|
|
@@ -449,7 +449,7 @@ describe OpenConferenceWare::ProposalsController do
|
|
449
449
|
old_session = stub_model(Proposal, status: 'confirmed', event: old_event)
|
450
450
|
old_session.users << old_session_user
|
451
451
|
|
452
|
-
Proposal.stub(find: old_session, find_by_id: old_session
|
452
|
+
Proposal.stub(find: old_session, find_by_id: old_session)
|
453
453
|
Event.stub(current: current_event)
|
454
454
|
|
455
455
|
get :session_show, id: old_session.id
|
@@ -478,7 +478,7 @@ describe OpenConferenceWare::ProposalsController do
|
|
478
478
|
it "should not notify owners of acceptance if proposal confirmation controls are not visible" do
|
479
479
|
event = @proposal.event
|
480
480
|
event.stub(:show_proposal_confirmation_controls? => false)
|
481
|
-
Proposal.stub(
|
481
|
+
Proposal.stub(find: @proposal)
|
482
482
|
|
483
483
|
login_as(users(:quentin))
|
484
484
|
|
@@ -951,7 +951,7 @@ describe OpenConferenceWare::ProposalsController do
|
|
951
951
|
describe "delete" do
|
952
952
|
before do
|
953
953
|
@proposal = proposals(:quentin_widgets)
|
954
|
-
Proposal.stub(:
|
954
|
+
Proposal.stub(:find).and_return(@proposal)
|
955
955
|
end
|
956
956
|
|
957
957
|
def assert_delete(login=nil, &block)
|
@@ -1238,7 +1238,7 @@ describe OpenConferenceWare::ProposalsController do
|
|
1238
1238
|
|
1239
1239
|
it "should return a status of :invalid_event when a proposal doesn't have a valid event" do
|
1240
1240
|
proposal = stub_model(Proposal, state: "confirmed", event: nil)
|
1241
|
-
Proposal.stub(:
|
1241
|
+
Proposal.stub(:find).and_return(proposal)
|
1242
1242
|
@controller.stub(:params).and_return({ id: 1000 })
|
1243
1243
|
@controller.send(:get_proposal_and_assignment_status).should == [proposal, :invalid_event]
|
1244
1244
|
end
|
@@ -6,6 +6,11 @@ OpenConferenceWare.configure do |config|
|
|
6
6
|
# in some cases with a string like "/open_conference_ware"
|
7
7
|
config.mount_point = '/open_conference_ware'
|
8
8
|
|
9
|
+
# Mailer host
|
10
|
+
# The hostname to use when generating links in emails.
|
11
|
+
# This shoud be the domain where OCW is hosted.
|
12
|
+
config.mailer_host = 'ocw.local'
|
13
|
+
|
9
14
|
# Event name, or organization running events:
|
10
15
|
config.organization = 'Open Source Bridge'
|
11
16
|
|
@@ -22,6 +27,21 @@ OpenConferenceWare.configure do |config|
|
|
22
27
|
# TODO: Setting the current event here is a short-term hack and will be replaced shortly with a Site record that tracks the current event in the database and provides a way to set it through an admin web UI.
|
23
28
|
# config.current_event_slug = '2012'
|
24
29
|
|
30
|
+
##[ Secrets ]##
|
31
|
+
# Some are sensitive and should not be checked in to version control.
|
32
|
+
# These are loaded from config/secrets.yml, which should be privately copied to your
|
33
|
+
# server and linked by your deployment process.
|
34
|
+
|
35
|
+
secrets_file = Rails.root.join('config', 'secrets.yml')
|
36
|
+
if File.exists?(secrets_file)
|
37
|
+
secrets = YAML.load_file(secrets_file)
|
38
|
+
config.administrator_email = secrets["administrator_email"]
|
39
|
+
config.comments_secret = secrets["comments_secret"]
|
40
|
+
config.secret_key_base = secrets["secret_key_base"]
|
41
|
+
else
|
42
|
+
raise "Oops, config/secrets.yml could not be found."
|
43
|
+
end
|
44
|
+
|
25
45
|
##[ OCW Features ]##
|
26
46
|
# Many features of OpenConferenceWare can be toggled via these settings
|
27
47
|
|
@@ -64,13 +84,16 @@ OpenConferenceWare.configure do |config|
|
|
64
84
|
# Can users add comments until a toggle is flipped on the event?
|
65
85
|
config.have_event_proposal_comments_after_deadline = true
|
66
86
|
|
87
|
+
# Can users note their favorite sessions?
|
88
|
+
config.have_user_favorites = true
|
89
|
+
|
67
90
|
# What audience experience levels can a proposal be classified as?
|
68
91
|
# The list will be displayed on the form in the order defined below.
|
69
92
|
# The "slug" is the unique key defining the particular audience level, while
|
70
93
|
# the "label" is the human-readable value displayed.
|
71
94
|
#
|
72
95
|
# Set this to a blank array to disable audience levels
|
73
|
-
config.proposal_audience_levels
|
96
|
+
config.proposal_audience_levels = [
|
74
97
|
{slug: 'a', label: 'Beginner'},
|
75
98
|
{slug: 'b', label: 'Intermediate'},
|
76
99
|
{slug: 'c', label: 'Advanced'}
|
@@ -106,5 +129,4 @@ OpenConferenceWare.configure do |config|
|
|
106
129
|
# NOTE: The current default theme never displays any breadcrumbs, but infrastructure exists to support them.
|
107
130
|
#
|
108
131
|
# config.breadcrumbs = [['Home', 'http://openconferenceware.org']]
|
109
|
-
|
110
132
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
OmniAuth.config.path_prefix = OpenConferenceWare.mounted_path("
|
1
|
+
OmniAuth.config.path_prefix = OpenConferenceWare.mounted_path("auth")
|
2
2
|
|
3
3
|
Rails.application.config.middleware.use OpenConferenceWare::OmniAuthBuilder do
|
4
4
|
provider :developer if %w[development preview].include?(Rails.env)
|
@@ -9,4 +9,5 @@
|
|
9
9
|
|
10
10
|
# Make sure your secret_key_base is kept private
|
11
11
|
# if you're sharing your code publicly.
|
12
|
-
Dummy::Application.config.secret_key_base =
|
12
|
+
Dummy::Application.config.secret_key_base = OpenConferenceWare.secret_key_base
|
13
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#===[ Secrets ]=========================================================
|
2
|
+
#
|
3
|
+
# This file is meant for storing secret information that is never
|
4
|
+
# published or committed to a revision control system.
|
5
|
+
#
|
6
|
+
#---[ Values ]----------------------------------------------------------
|
7
|
+
|
8
|
+
# Email address of administrator that will get requests for assistance from users:
|
9
|
+
administrator_email: 'your@email.addr'
|
10
|
+
|
11
|
+
# Secret key for getting an ATOM feed of private comments:
|
12
|
+
comments_secret: e7ed7cc63ae64f10fcb1dd9c7ba34656242dca9642222dcdaa8bd63a074913d9edbe300b0bef6bdc24e9a4cf7ad3f3177c6a762a8b62ad5ca482570d3969b19b
|
13
|
+
|
14
|
+
# The Rails secret_key_base
|
15
|
+
# Used by config/initializers/secret_token.rb
|
16
|
+
secret_key_base: 1f5085ba0fbf858fa957a9ea1406898266b8685a51da9b2127afcd8d2e54ba454a51cd59d39265e1819144da15594874dcb5a8bbfd2a5f3bcc7d30960619bb94
|
17
|
+
|
18
|
+
#===[ fin ]=============================================================
|
@@ -94,7 +94,7 @@ module OCWHelpers
|
|
94
94
|
assign(:events, events)
|
95
95
|
end
|
96
96
|
|
97
|
-
Event.stub(:
|
97
|
+
Event.stub(:current).and_return do |*args|
|
98
98
|
key = args.pop
|
99
99
|
key ? event : events
|
100
100
|
end
|
@@ -115,6 +115,7 @@ module OCWHelpers
|
|
115
115
|
view.stub(:event_rooms?).and_return(true)
|
116
116
|
view.stub(:proposal_speaking_experience?).and_return(true)
|
117
117
|
view.stub(:schedule_visible?).and_return(true)
|
118
|
+
view.stub(:user_favorites?).and_return(true)
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "open_conference_ware/proposals/_transition_control.html.erb" do
|
4
4
|
it "should render a state changing select menu with valid events and destination label" do
|
5
|
-
|
5
|
+
aasm = double("aasm", events: [:accept, :reject], current_state: :proposed)
|
6
|
+
proposal = stub_model(Proposal, aasm: aasm)
|
6
7
|
assign(:proposal, proposal)
|
7
8
|
render
|
8
9
|
rendered.should have_selector("select[name='proposal[transition]']") do |node|
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "open_conference_ware/rooms/show.html.erb" do
|
4
4
|
include OpenConferenceWare::RoomsHelper
|
5
5
|
before(:each) do
|
6
|
+
stub_settings_accessors_on(view)
|
6
7
|
assign(:room, stub_model(Room))
|
7
8
|
@event = stub_current_event!
|
8
9
|
view.stub(:admin?).and_return(false)
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "open_conference_ware/session_types/show.html.erb" do
|
4
4
|
include OpenConferenceWare::SessionTypesHelper
|
5
5
|
before(:each) do
|
6
|
+
stub_settings_accessors_on(view)
|
6
7
|
assign(:session_type, stub_model(SessionType))
|
7
8
|
view.stub(:admin?).and_return(false)
|
8
9
|
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "open_conference_ware/tracks/show.html.erb" do
|
4
4
|
include OpenConferenceWare::TracksHelper
|
5
5
|
before(:each) do
|
6
|
+
stub_settings_accessors_on(view)
|
6
7
|
@event = stub_current_event!(controller: view)
|
7
8
|
@track = stub_model(Track,
|
8
9
|
title: "value for title",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_conference_ware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,7 +43,7 @@ cert_chain:
|
|
43
43
|
YjFvOVpmLzMrb3VkSjhYM0I3bWgwUzRwYU9rClRSeUprSllTVWtnZG5BRk1J
|
44
44
|
a1k2Ky9OK1RINWdBMFB4dkJzUTJYeFRvbm9XSnJRdEZra2dkRXVZck1RU1dY
|
45
45
|
eWYKMUMzdFdKSjkKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
46
|
-
date: 2013-12-
|
46
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
47
47
|
dependencies:
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rails
|
@@ -269,22 +269,6 @@ dependencies:
|
|
269
269
|
- - ~>
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: 0.12.0
|
272
|
-
- !ruby/object:Gem::Dependency
|
273
|
-
name: dalli
|
274
|
-
requirement: !ruby/object:Gem::Requirement
|
275
|
-
none: false
|
276
|
-
requirements:
|
277
|
-
- - ~>
|
278
|
-
- !ruby/object:Gem::Version
|
279
|
-
version: 2.6.4
|
280
|
-
type: :runtime
|
281
|
-
prerelease: false
|
282
|
-
version_requirements: !ruby/object:Gem::Requirement
|
283
|
-
none: false
|
284
|
-
requirements:
|
285
|
-
- - ~>
|
286
|
-
- !ruby/object:Gem::Version
|
287
|
-
version: 2.6.4
|
288
272
|
- !ruby/object:Gem::Dependency
|
289
273
|
name: dynamic_form
|
290
274
|
requirement: !ruby/object:Gem::Requirement
|
@@ -598,7 +582,7 @@ files:
|
|
598
582
|
- app/assets/javascripts/open_conference_ware/favorites.js
|
599
583
|
- app/assets/javascripts/open_conference_ware/ie.js
|
600
584
|
- app/assets/javascripts/open_conference_ware/menu.js
|
601
|
-
- app/assets/javascripts/open_conference_ware/persona.js
|
585
|
+
- app/assets/javascripts/open_conference_ware/persona.js.erb
|
602
586
|
- app/assets/javascripts/open_conference_ware/proposals.js
|
603
587
|
- app/assets/javascripts/open_conference_ware/schedule.js
|
604
588
|
- app/assets/javascripts/open_conference_ware/spinner.js
|
@@ -640,7 +624,6 @@ files:
|
|
640
624
|
- app/helpers/open_conference_ware/user_favorites_helper.rb
|
641
625
|
- app/mailers/open_conference_ware/speaker_mailer.rb
|
642
626
|
- app/mixins/open_conference_ware/breadcrumbs_mixin.rb
|
643
|
-
- app/mixins/open_conference_ware/cache_lookups_mixin.rb
|
644
627
|
- app/mixins/open_conference_ware/faux_routes_mixin.rb
|
645
628
|
- app/mixins/open_conference_ware/normalize_url_mixin.rb
|
646
629
|
- app/mixins/open_conference_ware/public_attributes_mixin.rb
|
@@ -791,6 +774,8 @@ files:
|
|
791
774
|
- lib/generators/open_conference_ware/install/install_generator.rb
|
792
775
|
- lib/generators/open_conference_ware/install/templates/config_initializer.rb
|
793
776
|
- lib/generators/open_conference_ware/install/templates/omniauth_initializer.rb
|
777
|
+
- lib/generators/open_conference_ware/install/templates/secret_token.rb.erb
|
778
|
+
- lib/generators/open_conference_ware/install/templates/secrets.yml.erb
|
794
779
|
- lib/generators/open_conference_ware/views/views_generator.rb
|
795
780
|
- lib/open_conference_ware.rb
|
796
781
|
- lib/open_conference_ware/dependencies.rb
|
@@ -855,6 +840,7 @@ files:
|
|
855
840
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
856
841
|
- spec/dummy/config/locales/en.yml
|
857
842
|
- spec/dummy/config/routes.rb
|
843
|
+
- spec/dummy/config/secrets.yml
|
858
844
|
- spec/dummy/db/schema.rb
|
859
845
|
- spec/dummy/db/seeds.rb
|
860
846
|
- spec/dummy/lib/assets/.keep
|
@@ -896,7 +882,6 @@ files:
|
|
896
882
|
- spec/helpers/open_conference_ware/time_range_helper_spec.rb
|
897
883
|
- spec/helpers/open_conference_ware/tracks_helper_spec.rb
|
898
884
|
- spec/helpers/open_conference_ware/user_favorites_helper_spec.rb
|
899
|
-
- spec/integration/open_conference_ware/cache_lookups_mixin_spec.rb
|
900
885
|
- spec/mixins/open_conference_ware/normalize_url_mixin_spec.rb
|
901
886
|
- spec/models/open_conference_ware/authentication_spec.rb
|
902
887
|
- spec/models/open_conference_ware/event_spec.rb
|
@@ -1057,6 +1042,7 @@ test_files:
|
|
1057
1042
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
1058
1043
|
- spec/dummy/config/locales/en.yml
|
1059
1044
|
- spec/dummy/config/routes.rb
|
1045
|
+
- spec/dummy/config/secrets.yml
|
1060
1046
|
- spec/dummy/db/schema.rb
|
1061
1047
|
- spec/dummy/db/seeds.rb
|
1062
1048
|
- spec/dummy/lib/assets/.keep
|
@@ -1098,7 +1084,6 @@ test_files:
|
|
1098
1084
|
- spec/helpers/open_conference_ware/time_range_helper_spec.rb
|
1099
1085
|
- spec/helpers/open_conference_ware/tracks_helper_spec.rb
|
1100
1086
|
- spec/helpers/open_conference_ware/user_favorites_helper_spec.rb
|
1101
|
-
- spec/integration/open_conference_ware/cache_lookups_mixin_spec.rb
|
1102
1087
|
- spec/mixins/open_conference_ware/normalize_url_mixin_spec.rb
|
1103
1088
|
- spec/models/open_conference_ware/authentication_spec.rb
|
1104
1089
|
- spec/models/open_conference_ware/event_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,128 +0,0 @@
|
|
1
|
-
module OpenConferenceWare
|
2
|
-
|
3
|
-
# = CacheLookupsMixin
|
4
|
-
#
|
5
|
-
# A mixin that provides simple caching for ActiveRecord models. It's best used
|
6
|
-
# for models that have relatively few records (less than a thousand) and are
|
7
|
-
# updated infrequently (less than once per second).
|
8
|
-
#
|
9
|
-
# == Example of usage
|
10
|
-
#
|
11
|
-
# Setup lookups for Thing:
|
12
|
-
#
|
13
|
-
# class Thing < ActiveRecord::Base
|
14
|
-
# cache_lookups_for :id, order: :created_at
|
15
|
-
# ...
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# Return array of things in the order they were created:
|
19
|
-
# things = Thing.lookup
|
20
|
-
#
|
21
|
-
# Return a particular Thing matching ID 66:
|
22
|
-
# thing = Thing.lookup(66)
|
23
|
-
module CacheLookupsMixin
|
24
|
-
def self.included(mixee)
|
25
|
-
mixee.send(:extend, ClassMethods)
|
26
|
-
mixee.class_eval do
|
27
|
-
# ActiveRecord model's attribute to use when asked to lookup a specific
|
28
|
-
# item. Defaults to :id.
|
29
|
-
cattr_accessor :lookup_key
|
30
|
-
self.lookup_key = :id
|
31
|
-
|
32
|
-
# Hash of options passed to ActiveRecord::Base.find when populating the
|
33
|
-
# cache. This makes it possible to add :order and filter by :condition.
|
34
|
-
cattr_accessor :lookup_opts
|
35
|
-
self.lookup_opts = {}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
module ClassMethods
|
40
|
-
# Should lookups be cached? If the "perform_caching" Rails environment
|
41
|
-
# configuration setting is enabled, default to using cache.
|
42
|
-
#
|
43
|
-
# You can force caching on or off using the CACHELOOKUPS environmental
|
44
|
-
# variable, e.g. activate with:
|
45
|
-
#
|
46
|
-
# CACHELOOKUPS=1 ./script/server
|
47
|
-
def cache_lookups?
|
48
|
-
if Rails.configuration.action_controller.perform_caching
|
49
|
-
return ENV['CACHELOOKUPS'] != '0'
|
50
|
-
else
|
51
|
-
return ENV['CACHELOOKUPS'] == '1'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Setup the lookup caching system.
|
56
|
-
#
|
57
|
-
# Arguments:
|
58
|
-
# * key: The attribute you'll use as a key for doing lookups.
|
59
|
-
# * opts: Options to pass to ActiveRecord::Base.find.
|
60
|
-
def cache_lookups_for(key, opts={})
|
61
|
-
self.lookup_key = key
|
62
|
-
self.lookup_opts = opts
|
63
|
-
end
|
64
|
-
|
65
|
-
# Return silo that this class's values will be stored in.
|
66
|
-
def lookup_silo_name
|
67
|
-
return "#{self.name.gsub('::', '__')}_dict"
|
68
|
-
end
|
69
|
-
|
70
|
-
def query_one(key)
|
71
|
-
return self.where(self.lookup_key => key).first
|
72
|
-
end
|
73
|
-
|
74
|
-
def query_all
|
75
|
-
scope = self
|
76
|
-
scope = scope.order(self.lookup_opts[:order]) if self.lookup_opts[:order]
|
77
|
-
scope = scope.includes(*self.lookup_opts[:include]) if self.lookup_opts[:include]
|
78
|
-
return scope
|
79
|
-
end
|
80
|
-
|
81
|
-
# Return instance from cache matching +key+. If +key+ is undefined, returns
|
82
|
-
# array of all instances.
|
83
|
-
def lookup(key=nil)
|
84
|
-
unless self.cache_lookups?
|
85
|
-
return key ?
|
86
|
-
self.query_one(key) :
|
87
|
-
self.query_all
|
88
|
-
end
|
89
|
-
|
90
|
-
silo = self.lookup_silo_name
|
91
|
-
key_number = key.try(:[], '#'+to_s) if key.present?
|
92
|
-
ActiveRecord::Base.benchmark("Lookup: #{silo}#{key_number}") do
|
93
|
-
dict = self.fetch_object(silo){
|
94
|
-
# FIXME Exceptions within this block are silently swallowed by something. This is bad.
|
95
|
-
dict = Hashery::Dictionary.new
|
96
|
-
for record in self.query_all
|
97
|
-
dict[record.send(self.lookup_key)] = record
|
98
|
-
end
|
99
|
-
dict
|
100
|
-
}
|
101
|
-
return key ? dict[key.kind_of?(Symbol) ? key.to_s : key] : dict.values
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def expire_cache
|
106
|
-
Rails.logger.info("Lookup, expiring: #{self.name}")
|
107
|
-
CacheWatcher.expire(/#{lookup_silo_name}_.+/)
|
108
|
-
end
|
109
|
-
|
110
|
-
def fetch_object(silo, &block)
|
111
|
-
self.revive_associations_for(self)
|
112
|
-
return Rails.cache.fetch(silo, &block)
|
113
|
-
end
|
114
|
-
|
115
|
-
def revive_associations_for(object)
|
116
|
-
if object.kind_of?(ActiveRecord::Base) || object.ancestors.include?(ActiveRecord::Base)
|
117
|
-
object.reflect_on_all_associations.each do |association|
|
118
|
-
name = association.class_name
|
119
|
-
unless object.constants.include?(name)
|
120
|
-
name.constantize # This line forces Rails to load this class
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|