camping-abingo 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,10 @@
4
4
  # You can use this as a starting point to follow along the instructions to add
5
5
  # ABingo support based on the blog post series: http://blog.monnet-usa.com/?p=322
6
6
  #
7
- gem 'camping' , '>= 2.0'
8
- gem 'filtering_camping' , '>= 1.0'
7
+ gem 'camping' , '~> 2.0'
8
+ gem 'filtering_camping' , '~> 1.0'
9
9
 
10
- %w(rubygems active_record erb fileutils json markaby md5 redcloth
10
+ %w(rubygems active_record active_support erb fileutils json markaby md5
11
11
  camping camping/session filtering_camping
12
12
  ).each { |lib| require lib }
13
13
 
@@ -17,13 +17,20 @@ module CampingABingoTest
17
17
  include Camping::Session
18
18
  include CampingFilters
19
19
 
20
- app_logger = Logger.new(File.dirname(__FILE__) + '/camping-abingo-test.log')
21
- app_logger.level = Logger::DEBUG
20
+ is_under_camping_server = (Camping.const_defined? :Server)
21
+ if is_under_camping_server
22
+ app_logger = Logger.new(File.dirname(__FILE__) + '/camping-abingo-test.log')
23
+ app_logger.level = Logger::DEBUG
24
+ else
25
+ app_logger = Logger.new($STDERR)
26
+ app_logger.level = Logger::ERROR
27
+ end
22
28
  Camping::Models::Base.logger = app_logger
23
29
 
24
30
  def CampingABingoTest.create
25
31
  dbconfig = YAML.load(File.read('config/database.yml'))
26
- Camping::Models::Base.establish_connection dbconfig['development']
32
+ environment = ENV['DATABASE_URL'] ? 'production' : 'development'
33
+ Camping::Models::Base.establish_connection dbconfig[environment]
27
34
 
28
35
  CampingABingoTest::Models.create_schema :assume => (CampingABingoTest::Models::User.table_exists? ? 1.1 : 0.0)
29
36
  end
@@ -35,7 +42,7 @@ module CampingABingoTest::Models
35
42
 
36
43
  class CreateUserSchema < V 1.0
37
44
  def self.up
38
- create_table :CampingABingoTest_users, :force => true do |t|
45
+ create_table :campingabingotest_users, :force => true do |t|
39
46
  t.integer :id, :null => false
40
47
  t.string :username
41
48
  t.string :password
@@ -45,7 +52,7 @@ module CampingABingoTest::Models
45
52
  end
46
53
 
47
54
  def self.down
48
- drop_table :CampingABingoTest_users
55
+ drop_table :campingabingotest_users
49
56
  end
50
57
  end
51
58
 
@@ -1,8 +1,8 @@
1
- gem 'camping' , '>= 2.0'
2
- gem 'filtering_camping' , '>= 1.0'
1
+ gem 'camping' , '~> 2.0'
2
+ gem 'filtering_camping' , '~> 1.0'
3
3
  gem 'camping-abingo'
4
4
 
5
- %w(rubygems active_record erb fileutils json markaby md5 redcloth
5
+ %w(rubygems active_record active_support erb fileutils json markaby md5
6
6
  camping camping/session filtering_camping camping-abingo
7
7
  ).each { |lib| require lib }
8
8
 
@@ -23,14 +23,22 @@ module CampingABingoTest
23
23
  extend ABingoCampingPlugin
24
24
  include ABingoCampingPlugin::Filters
25
25
 
26
- app_logger = Logger.new(File.dirname(__FILE__) + '/camping-abingo-test.log')
27
- app_logger.level = Logger::DEBUG
26
+ is_under_camping_server = (Camping.const_defined? :Server)
27
+ if is_under_camping_server
28
+ app_logger = Logger.new(File.dirname(__FILE__) + '/camping-abingo-test.log')
29
+ app_logger.level = Logger::DEBUG
30
+ else
31
+ app_logger = Logger.new($STDERR)
32
+ app_logger.level = Logger::ERROR
33
+ end
34
+
28
35
  Camping::Models::Base.logger = app_logger
29
36
  ABingoCampingPlugin.logger = app_logger
30
37
 
31
38
  def CampingABingoTest.create
32
39
  dbconfig = YAML.load(File.read('config/database.yml'))
33
- Camping::Models::Base.establish_connection dbconfig['development']
40
+ environment = ENV['DATABASE_URL'] ? 'production' : 'development'
41
+ Camping::Models::Base.establish_connection dbconfig[environment]
34
42
 
35
43
  ABingoCampingPlugin.create
36
44
  Abingo.cache.logger = Camping::Models::Base.logger
@@ -47,7 +55,7 @@ module CampingABingoTest::Models
47
55
 
48
56
  class CreateUserSchema < V 1.1
49
57
  def self.up
50
- create_table :CampingABingoTest_users, :force => true do |t|
58
+ create_table :campingabingotest_users, :force => true do |t|
51
59
  t.integer :id, :null => false
52
60
  t.string :username
53
61
  t.string :password
@@ -60,7 +68,7 @@ module CampingABingoTest::Models
60
68
 
61
69
  def self.down
62
70
  ABingoCampingPlugin::Models.down
63
- drop_table :CampingABingoTest_users
71
+ drop_table :campingabingotest_users
64
72
  end
65
73
  end
66
74
 
@@ -63,16 +63,7 @@ Ok, at this point we have a minimally configured application module. Our next st
63
63
 
64
64
  ===Plugging in the ABingo models
65
65
 
66
- First, we'll include the include ABingoCampingPlugin::Models module so we can get all the ABingo-specific models. Then we'll define a User model. The User will need to keep track of the applications it provided access to. It will also manage the tokens associated with these applications. Our model will look like this:
67
-
68
- class User < Base;
69
- has_many :client_applications
70
- has_many :tokens,
71
- :class_name=>"OauthToken",
72
- :order=>"authorized_at desc",
73
- :include=>[:client_application]
74
-
75
- end
66
+ First, we'll include the include ABingoCampingPlugin::Models module so we can get all the ABingo-specific models.
76
67
 
77
68
  Now we need a CreateUserSchema migration class to define our database tables for User, and ABingo models. In the up and down methods we will plugin a call to the corresponding method from the ABingoCampingPlugin::Models module to create the tables for the Experiment and Alternative models.
78
69
 
@@ -706,14 +697,14 @@ module ABingoCampingPlugin::Helpers
706
697
 
707
698
  end #ABingoCampingPlugin::Helpers
708
699
 
709
- # Filters module for OAuth Camping Plugin.
700
+ # Filters module for ABingo Camping Plugin.
710
701
  # The module will be plugged in to the main app Helpers module.
711
702
  # Example:
712
703
  # module CampingOAuthProvider
713
704
  # include Camping::Session
714
705
  # include CampingFilters
715
- # extend OAuthCampingPlugin
716
- # include OAuthCampingPlugin::Filters
706
+ # extend ABingoCampingPlugin
707
+ # include ABingoCampingPlugin::Filters
717
708
  #
718
709
  # # ...
719
710
  # end
@@ -755,11 +746,6 @@ end
755
746
  # module CampingABingoTest::Models
756
747
  # include ABingoCampingPlugin::Models
757
748
  #
758
- # class User < Base;
759
- # has_many :client_applications
760
- # has_many :tokens, :class_name=>"OauthToken",:order=>"authorized_at desc",:include=>[:client_application]
761
- #
762
- # end
763
749
  # # ...
764
750
  # end
765
751
  #
@@ -1155,7 +1141,7 @@ module ABingoCampingPlugin::Views
1155
1141
  }
1156
1142
 
1157
1143
  experiment.alternatives.each do | alternative |
1158
- tr.abingo_alternative_row { td { h(alternative.content) };
1144
+ tr.abingo_alternative_row { td { ERB::Util.h(alternative.content) };
1159
1145
  td { alternative.participants.to_s };
1160
1146
  td { alternative.conversions.to_s + '(' + alternative.pretty_conversion_rate + ')' };
1161
1147
  td {
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 5
9
- version: 1.0.5
8
+ - 6
9
+ version: 1.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick McKenzie
@@ -15,7 +15,7 @@ autorequire: camping-abingo
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-04 00:00:00 -07:00
18
+ date: 2010-12-07 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency