ads-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3a718faa5f0d5b92d7817cf378cf902b6a6a95e
4
- data.tar.gz: e2831ca03f42c7dc64653ab7d487613eecb7f864
3
+ metadata.gz: 6e3631ccff398d44be0e1a07e2a3ef55298ecd51
4
+ data.tar.gz: 08fd7244266fc90c3d9cc06562cd2eaa9d607835
5
5
  SHA512:
6
- metadata.gz: 752c3b4eacb0c08e9bf04d37d5cc9717c2d9a0a3eafc331c6283b39711c871c35919dee7d89ff7abba0c6499b81afdd88908155e1876f421e2cad29d95ddddad
7
- data.tar.gz: 992f635fd4ddfe5549b36e6be759ba68b5230091fdd1c9d152adaa52d6424fbd02b4b533c8b8c3190908d343884348fcb46901f22e562add8ef619bbffffc56d
6
+ metadata.gz: f1de5d731c51f67e3fdd8f710e74ebc71dc2a6c08cd1fc1ef328ed3889d90d4f5eec282e52a48ea337468954a1da08bd292b19c592e3f7225b2185a566b68ac0
7
+ data.tar.gz: 9daa6d7394c0ddf2bf817b475bf006985e51fb011b15d5e1b8394651298f51b5b177bb050760f1498682850d9a99a1b3690287886a365dfa14fee0d0b6ec9070
data/README.rdoc CHANGED
@@ -1,12 +1,8 @@
1
- === WARNING: From version 0.0.8 and above we changed the behavior of the renderer to only being use when the environment is not production.
2
-
3
- ---
4
-
5
- {<img src="https://badge.fury.io/rb/ads-rails.png" alt="Gem Version" />}[http://badge.fury.io/rb/ads-rails] {<img src="https://codeclimate.com/github/museways/ads-rails.png" />}[https://codeclimate.com/github/museways/ads-rails] {<img src="https://travis-ci.org/museways/ads-rails.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/ads-rails] {<img src="https://gemnasium.com/museways/ads-rails.png" alt="Dependency Status" />}[https://gemnasium.com/museways/ads-rails]
1
+ {<img src="https://badge.fury.io/rb/ads-rails.png" alt="Gem Version" />}[http://badge.fury.io/rb/ads-rails] {<img src="https://codeclimate.com/github/museways/ads-rails.png" />}[https://codeclimate.com/github/museways/ads-rails] {<img src="https://travis-ci.org/museways/ads-rails.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/ads-rails]
6
2
 
7
3
  = Ads Rails
8
4
 
9
- Adds a simple helper to create the google adsense include tag.
5
+ Adds a simple helper to create the google adsense include tag in rails.
10
6
 
11
7
  = Install
12
8
 
@@ -18,12 +14,32 @@ Then bundle:
18
14
 
19
15
  = Usage
20
16
 
21
- In your view add a line like this wherever you like:
22
- <%= google_adsense_include_tag client: 'client', slot: 'slot', width: 'width', height: 'height' %>
17
+ In your views call the helper like this:
18
+ <%= google_adsense_include_tag client: 'pub-1234', slot: '1234', ... %>
23
19
 
24
- (Will only show the include tag in production)
20
+ All the arguments will be mapped to the the corresponding google_ad variable:
21
+ google_ad_client = 'pub-1234'
22
+ google_ad_slot = '1234'
23
+ .
24
+ .
25
+ .
26
+
27
+ NOTE: If environment is not production, will show a gray rectangle.
25
28
 
26
29
  = Configuration
27
30
 
28
- If you don't like the default color div in development, you can use a custom renderer:
29
- config.ads.renderer = lamda { |options| tag(:img, src: "http://placehold.it/#{options[:width]}x#{options[:height]}&text=Google+AdSense") }
31
+ To change the output when the environment is not production, add a custom renderer in your application.rb:
32
+ config.ads.renderer = lambda { |options|
33
+ tag(
34
+ :img,
35
+ src: "http://placehold.it/#{options[:width]}x#{options[:height]}&text=Adsense"
36
+ )
37
+ }
38
+
39
+ = Credits
40
+
41
+ This gem is maintained and funded by museways[http://museways.com].
42
+
43
+ = License
44
+
45
+ It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
data/lib/ads/rails.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'ads/rails/action_view/base'
2
2
  require 'ads/rails/railtie'
3
- require 'ads/rails/version'
4
3
 
5
4
  module Ads
6
5
  module Rails
@@ -6,18 +6,31 @@ module Ads
6
6
  def google_adsense_include_tag(*args)
7
7
  options = args.extract_options!
8
8
  if ::Rails.env.production?
9
- script = <<-SCRIPT.strip_heredoc
10
- google_ad_client = '#{options[:client]}';
11
- google_ad_slot = '#{options[:slot]}';
12
- google_ad_width = #{options[:width]};
13
- google_ad_height = #{options[:height]};
14
- SCRIPT
15
- content_tag(:script, script.html_safe, type: 'text/javascript') +
16
- content_tag(:script, nil, type: 'text/javascript', src: "#{request.protocol}pagead2.googlesyndication.com/pagead/show_ads.js")
9
+ script = ''.tap do |script|
10
+ options.each do |key, value|
11
+ value = "'#{value}'" if value.is_a? String
12
+ script << "google_ad_#{key} = #{value};\n"
13
+ end
14
+ end
15
+ content_tag(
16
+ :script,
17
+ script.html_safe,
18
+ type: 'text/javascript'
19
+ ) +
20
+ content_tag(
21
+ :script,
22
+ nil,
23
+ type: 'text/javascript',
24
+ src: "#{request.protocol}pagead2.googlesyndication.com/pagead/show_ads.js"
25
+ )
17
26
  elsif ::Rails.application.config.ads.renderer.is_a? Proc
18
27
  instance_exec options, &::Rails.application.config.ads.renderer
19
28
  else
20
- content_tag :div, nil, style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;"
29
+ content_tag(
30
+ :div,
31
+ nil,
32
+ style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;"
33
+ )
21
34
  end
22
35
  end
23
36
 
@@ -1,7 +1,7 @@
1
1
  module Ads
2
2
  module Rails
3
3
 
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
 
6
6
  end
7
7
  end
@@ -20,4 +20,3 @@ module Dummy
20
20
  # config.i18n.default_locale = :de
21
21
  end
22
22
  end
23
-
@@ -1,7 +1,4 @@
1
1
  Dummy::Application.routes.draw do
2
-
3
- root to: 'pages#index'
4
-
5
2
  # The priority is based upon order of creation: first created -> highest priority.
6
3
  # See how all your routes lay out with "rake routes".
7
4
 
@@ -1000,3 +1000,343 @@ Started GET "/" for 127.0.0.1 at 2014-06-08 18:12:29 -0300
1000
1000
  Processing by PagesController#index as HTML
1001
1001
  Completed 200 OK in 1ms (Views: 0.6ms | ActiveRecord: 0.0ms)
1002
1002
   (0.1ms) rollback transaction
1003
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1004
+  (0.1ms) select sqlite_version(*)
1005
+  (0.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1006
+  (0.0ms) SELECT version FROM "schema_migrations"
1007
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1008
+  (0.1ms) begin transaction
1009
+ ------------------------------------------------------------------------------------
1010
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1011
+ ------------------------------------------------------------------------------------
1012
+  (0.0ms) rollback transaction
1013
+  (0.0ms) begin transaction
1014
+ ------------------------------------------------------------------------------------
1015
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1016
+ ------------------------------------------------------------------------------------
1017
+  (0.0ms) rollback transaction
1018
+  (0.0ms) begin transaction
1019
+ ------------------------------------------------------------------------------------------
1020
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1021
+ ------------------------------------------------------------------------------------------
1022
+  (0.0ms) rollback transaction
1023
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1024
+  (0.1ms) select sqlite_version(*)
1025
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1026
+  (0.1ms) SELECT version FROM "schema_migrations"
1027
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1028
+  (0.1ms) begin transaction
1029
+ ------------------------------------------------------------------------------------
1030
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1031
+ ------------------------------------------------------------------------------------
1032
+  (0.1ms) rollback transaction
1033
+  (0.0ms) begin transaction
1034
+ ------------------------------------------------------------------------------------
1035
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1036
+ ------------------------------------------------------------------------------------
1037
+  (0.0ms) rollback transaction
1038
+  (0.0ms) begin transaction
1039
+ ------------------------------------------------------------------------------------------
1040
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1041
+ ------------------------------------------------------------------------------------------
1042
+  (0.0ms) rollback transaction
1043
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1044
+  (0.1ms) select sqlite_version(*)
1045
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1046
+  (0.1ms) SELECT version FROM "schema_migrations"
1047
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1048
+  (0.1ms) begin transaction
1049
+ ------------------------------------------------------------------------------------
1050
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1051
+ ------------------------------------------------------------------------------------
1052
+  (0.0ms) rollback transaction
1053
+  (0.0ms) begin transaction
1054
+ ------------------------------------------------------------------------------------
1055
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1056
+ ------------------------------------------------------------------------------------
1057
+  (0.0ms) rollback transaction
1058
+  (0.0ms) begin transaction
1059
+ ------------------------------------------------------------------------------------------
1060
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1061
+ ------------------------------------------------------------------------------------------
1062
+  (0.1ms) rollback transaction
1063
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1064
+  (0.1ms) select sqlite_version(*)
1065
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1066
+  (0.0ms) SELECT version FROM "schema_migrations"
1067
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1068
+  (0.1ms) begin transaction
1069
+ ------------------------------------------------------------------------------------
1070
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1071
+ ------------------------------------------------------------------------------------
1072
+  (0.2ms) rollback transaction
1073
+  (0.0ms) begin transaction
1074
+ ------------------------------------------------------------------------------------
1075
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1076
+ ------------------------------------------------------------------------------------
1077
+  (0.2ms) rollback transaction
1078
+  (0.1ms) begin transaction
1079
+ ------------------------------------------------------------------------------------------
1080
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1081
+ ------------------------------------------------------------------------------------------
1082
+  (0.2ms) rollback transaction
1083
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1084
+  (0.1ms) select sqlite_version(*)
1085
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1086
+  (0.1ms) SELECT version FROM "schema_migrations"
1087
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1088
+  (0.1ms) begin transaction
1089
+ ------------------------------------------------------------------------------------
1090
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1091
+ ------------------------------------------------------------------------------------
1092
+  (0.1ms) rollback transaction
1093
+  (0.1ms) begin transaction
1094
+ ------------------------------------------------------------------------------------
1095
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1096
+ ------------------------------------------------------------------------------------
1097
+  (0.1ms) rollback transaction
1098
+  (0.1ms) begin transaction
1099
+ ------------------------------------------------------------------------------------------
1100
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1101
+ ------------------------------------------------------------------------------------------
1102
+  (0.2ms) rollback transaction
1103
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1104
+  (0.1ms) select sqlite_version(*)
1105
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1106
+  (0.0ms) SELECT version FROM "schema_migrations"
1107
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1108
+  (0.1ms) begin transaction
1109
+ ------------------------------------------------------------------------------------
1110
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1111
+ ------------------------------------------------------------------------------------
1112
+  (0.2ms) rollback transaction
1113
+  (0.1ms) begin transaction
1114
+ ------------------------------------------------------------------------------------
1115
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1116
+ ------------------------------------------------------------------------------------
1117
+  (0.1ms) rollback transaction
1118
+  (0.1ms) begin transaction
1119
+ ------------------------------------------------------------------------------------------
1120
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1121
+ ------------------------------------------------------------------------------------------
1122
+  (0.1ms) rollback transaction
1123
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1124
+  (0.1ms) select sqlite_version(*)
1125
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1126
+  (0.0ms) SELECT version FROM "schema_migrations"
1127
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1128
+  (0.4ms) begin transaction
1129
+ ------------------------------------------------------------------------------------
1130
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1131
+ ------------------------------------------------------------------------------------
1132
+  (0.1ms) rollback transaction
1133
+  (0.1ms) begin transaction
1134
+ ------------------------------------------------------------------------------------
1135
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1136
+ ------------------------------------------------------------------------------------
1137
+  (0.0ms) rollback transaction
1138
+  (0.0ms) begin transaction
1139
+ ------------------------------------------------------------------------------------------
1140
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1141
+ ------------------------------------------------------------------------------------------
1142
+  (0.2ms) rollback transaction
1143
+  (0.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1144
+  (0.1ms) select sqlite_version(*)
1145
+  (0.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1146
+  (0.1ms) SELECT version FROM "schema_migrations"
1147
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1148
+  (0.1ms) begin transaction
1149
+ ------------------------------------------------------------------------------------
1150
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1151
+ ------------------------------------------------------------------------------------
1152
+  (0.2ms) rollback transaction
1153
+  (0.0ms) begin transaction
1154
+ ------------------------------------------------------------------------------------
1155
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1156
+ ------------------------------------------------------------------------------------
1157
+  (0.1ms) rollback transaction
1158
+  (0.1ms) begin transaction
1159
+ ------------------------------------------------------------------------------------------
1160
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1161
+ ------------------------------------------------------------------------------------------
1162
+  (0.2ms) rollback transaction
1163
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1164
+  (0.1ms) select sqlite_version(*)
1165
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1166
+  (0.0ms) SELECT version FROM "schema_migrations"
1167
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1168
+  (0.1ms) begin transaction
1169
+ ------------------------------------------------------------------------------------
1170
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1171
+ ------------------------------------------------------------------------------------
1172
+  (0.2ms) rollback transaction
1173
+  (0.1ms) begin transaction
1174
+ ------------------------------------------------------------------------------------
1175
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1176
+ ------------------------------------------------------------------------------------
1177
+  (0.0ms) rollback transaction
1178
+  (0.1ms) begin transaction
1179
+ ------------------------------------------------------------------------------------------
1180
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1181
+ ------------------------------------------------------------------------------------------
1182
+  (0.2ms) rollback transaction
1183
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1184
+  (0.1ms) select sqlite_version(*)
1185
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1186
+  (0.0ms) SELECT version FROM "schema_migrations"
1187
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1188
+  (0.1ms) begin transaction
1189
+ ------------------------------------------------------------------------------------
1190
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1191
+ ------------------------------------------------------------------------------------
1192
+  (0.1ms) rollback transaction
1193
+  (0.0ms) begin transaction
1194
+ ------------------------------------------------------------------------------------
1195
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1196
+ ------------------------------------------------------------------------------------
1197
+  (0.0ms) rollback transaction
1198
+  (0.0ms) begin transaction
1199
+ ------------------------------------------------------------------------------------------
1200
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1201
+ ------------------------------------------------------------------------------------------
1202
+  (0.1ms) rollback transaction
1203
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1204
+  (0.1ms) select sqlite_version(*)
1205
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1206
+  (0.1ms) SELECT version FROM "schema_migrations"
1207
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1208
+  (0.1ms) begin transaction
1209
+ ------------------------------------------------------------------------------------
1210
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1211
+ ------------------------------------------------------------------------------------
1212
+  (0.1ms) rollback transaction
1213
+  (0.1ms) begin transaction
1214
+ ------------------------------------------------------------------------------------
1215
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1216
+ ------------------------------------------------------------------------------------
1217
+  (0.0ms) rollback transaction
1218
+  (0.0ms) begin transaction
1219
+ ------------------------------------------------------------------------------------------
1220
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1221
+ ------------------------------------------------------------------------------------------
1222
+  (0.1ms) rollback transaction
1223
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1224
+  (0.2ms) select sqlite_version(*)
1225
+  (0.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1226
+  (0.1ms) SELECT version FROM "schema_migrations"
1227
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1228
+  (0.1ms) begin transaction
1229
+ ------------------------------------------------------------------------------------
1230
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1231
+ ------------------------------------------------------------------------------------
1232
+  (0.2ms) rollback transaction
1233
+  (0.1ms) begin transaction
1234
+ ------------------------------------------------------------------------------------
1235
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1236
+ ------------------------------------------------------------------------------------
1237
+  (0.0ms) rollback transaction
1238
+  (0.0ms) begin transaction
1239
+ ------------------------------------------------------------------------------------------
1240
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1241
+ ------------------------------------------------------------------------------------------
1242
+  (0.1ms) rollback transaction
1243
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1244
+  (0.1ms) select sqlite_version(*)
1245
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1246
+  (0.1ms) SELECT version FROM "schema_migrations"
1247
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1248
+  (0.1ms) begin transaction
1249
+ ------------------------------------------------------------------------------------
1250
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1251
+ ------------------------------------------------------------------------------------
1252
+  (0.0ms) rollback transaction
1253
+  (0.0ms) begin transaction
1254
+ ------------------------------------------------------------------------------------
1255
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1256
+ ------------------------------------------------------------------------------------
1257
+  (0.0ms) rollback transaction
1258
+  (0.0ms) begin transaction
1259
+ ------------------------------------------------------------------------------------------
1260
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1261
+ ------------------------------------------------------------------------------------------
1262
+  (0.0ms) rollback transaction
1263
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1264
+  (0.1ms) select sqlite_version(*)
1265
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1266
+  (0.1ms) SELECT version FROM "schema_migrations"
1267
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1268
+  (0.1ms) begin transaction
1269
+ ------------------------------------------------------------------------------------
1270
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1271
+ ------------------------------------------------------------------------------------
1272
+  (0.0ms) rollback transaction
1273
+  (0.0ms) begin transaction
1274
+ ------------------------------------------------------------------------------------
1275
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1276
+ ------------------------------------------------------------------------------------
1277
+  (0.0ms) rollback transaction
1278
+  (0.0ms) begin transaction
1279
+ ------------------------------------------------------------------------------------------
1280
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1281
+ ------------------------------------------------------------------------------------------
1282
+  (0.0ms) rollback transaction
1283
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1284
+  (0.1ms) select sqlite_version(*)
1285
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1286
+  (0.1ms) SELECT version FROM "schema_migrations"
1287
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1288
+  (0.1ms) begin transaction
1289
+ ------------------------------------------------------------------------------------
1290
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1291
+ ------------------------------------------------------------------------------------
1292
+  (0.1ms) rollback transaction
1293
+  (0.0ms) begin transaction
1294
+ ------------------------------------------------------------------------------------
1295
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1296
+ ------------------------------------------------------------------------------------
1297
+  (0.0ms) rollback transaction
1298
+  (0.0ms) begin transaction
1299
+ ------------------------------------------------------------------------------------------
1300
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1301
+ ------------------------------------------------------------------------------------------
1302
+  (0.0ms) rollback transaction
1303
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1304
+  (0.1ms) select sqlite_version(*)
1305
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1306
+  (0.1ms) SELECT version FROM "schema_migrations"
1307
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1308
+  (0.1ms) begin transaction
1309
+ ------------------------------------------------------------------------------------
1310
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1311
+ ------------------------------------------------------------------------------------
1312
+  (0.1ms) rollback transaction
1313
+  (0.1ms) begin transaction
1314
+ ------------------------------------------------------------------------------------
1315
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1316
+ ------------------------------------------------------------------------------------
1317
+  (0.1ms) rollback transaction
1318
+  (0.1ms) begin transaction
1319
+ ------------------------------------------------------------------------------------------
1320
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1321
+ ------------------------------------------------------------------------------------------
1322
+  (0.1ms) rollback transaction
1323
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
1324
+  (0.1ms) select sqlite_version(*)
1325
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1326
+  (0.0ms) SELECT version FROM "schema_migrations"
1327
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
1328
+  (0.1ms) begin transaction
1329
+ ------------------------------------------------------------------------------------
1330
+ IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
1331
+ ------------------------------------------------------------------------------------
1332
+  (0.1ms) rollback transaction
1333
+  (0.0ms) begin transaction
1334
+ ------------------------------------------------------------------------------------
1335
+ IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
1336
+ ------------------------------------------------------------------------------------
1337
+  (0.0ms) rollback transaction
1338
+  (0.0ms) begin transaction
1339
+ ------------------------------------------------------------------------------------------
1340
+ IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
1341
+ ------------------------------------------------------------------------------------------
1342
+  (0.0ms) rollback transaction
@@ -1,45 +1,44 @@
1
1
  require 'test_helper'
2
2
 
3
- class IncludeTagTest < ActionDispatch::IntegrationTest
3
+ class IncludeTagTest < ActionView::TestCase
4
4
 
5
- test "should show adsense code if env is production and there is no renderer" do
6
- assert ::Rails.application.config.ads.renderer.nil?
7
- with_env 'production' do
8
- get '/'
9
- assert_response :success
10
- assert response.body.include?("<script type=\"text/javascript\">google_ad_client = 'client';\ngoogle_ad_slot = 'slot';\ngoogle_ad_width = 728;\ngoogle_ad_height = 90;\n</script>")
11
- assert response.body.include?('<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">')
12
- end
5
+ setup do
6
+ self.request = OpenStruct.new(protocol: 'http://')
7
+ end
8
+
9
+ test "show adsense code if env is production and there is no renderer" do
10
+ ::Rails.application.config.ads.renderer = nil
13
11
  with_env 'production' do
14
- https!
15
- get '/'
16
- assert_response :success
17
- assert response.body.include?("<script type=\"text/javascript\">google_ad_client = 'client';\ngoogle_ad_slot = 'slot';\ngoogle_ad_width = 728;\ngoogle_ad_height = 90;\n</script>")
18
- assert response.body.include?('<script src="https://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">')
12
+ assert_equal(
13
+ %Q(<script type="text/javascript">google_ad_client = 'pub-1234';\ngoogle_ad_width = 728;\n</script>) +
14
+ %Q(<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>),
15
+ google_adsense_include_tag(client: 'pub-1234', width: 728)
16
+ )
19
17
  end
20
18
  end
21
19
 
22
- test "should show renderer output if env is not production and there is a renderer" do
23
- with_env 'development' do
24
- ::Rails.application.config.ads.renderer = lambda { |options| content_tag :script, "client = '#{options[:client]}';\nslot = '#{options[:slot]}';\nwidth = #{options[:width]};\nheight = #{options[:height]};".html_safe }
25
- get '/'
26
- assert_response :success
27
- assert response.body.include?("<script>client = 'client';\nslot = 'slot';\nwidth = 728;\nheight = 90;</script>")
28
- end
20
+ test "show renderer output if env is not production and there is a renderer" do
21
+ ::Rails.application.config.ads.renderer = lambda { |options|
22
+ tag(
23
+ :img,
24
+ src: "http://placehold.it/#{options[:width]}x#{options[:height]}&text=Adsense"
25
+ )
26
+ }
29
27
  with_env 'development' do
30
- ::Rails.application.config.ads.renderer = proc { |options| content_tag :script, "<script>client = '#{options[:client]}';\nslot = '#{options[:slot]}';\nwidth = #{options[:width]};\nheight = #{options[:height]};".html_safe }
31
- get '/'
32
- assert_response :success
33
- assert response.body.include?("<script>client = 'client';\nslot = 'slot';\nwidth = 728;\nheight = 90;</script>")
28
+ assert_equal(
29
+ '<img src="http://placehold.it/728x90&amp;text=Adsense" />',
30
+ google_adsense_include_tag(width: 728, height:90)
31
+ )
34
32
  end
35
33
  end
36
34
 
37
- test "should show gray div if env is not production and there is no renderer" do
38
- assert ::Rails.application.config.ads.renderer.nil?
35
+ test "show gray div if env is not production and there is no renderer" do
36
+ ::Rails.application.config.ads.renderer = nil
39
37
  with_env 'development' do
40
- get '/'
41
- assert_response :success
42
- assert response.body.include?('<div style="width:728px;height:90px;background:#c8c8c8;"></div>')
38
+ assert_equal(
39
+ '<div style="width:728px;height:90px;background:#c8c8c8;"></div>',
40
+ google_adsense_include_tag(width: 728, height:90)
41
+ )
43
42
  end
44
43
  end
45
44
 
data/test/test_helper.rb CHANGED
@@ -19,3 +19,6 @@ config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', _
19
19
  config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
20
20
  ActiveRecord::Base.establish_connection(config['test'])
21
21
  load(File.expand_path('../dummy/db/schema.rb', __FILE__))
22
+
23
+ # Include helpers
24
+ ActionView::TestCase.send :include, Ads::Rails::ActionView::Base
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ads-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Museways
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,7 +44,8 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.3'
47
- description: Adds a simple view helper to create the google adsense include tag.
47
+ description: Adds a simple view helper to create the google adsense include tag in
48
+ rails.
48
49
  email:
49
50
  - hello@museways.com
50
51
  executables: []
@@ -64,10 +65,8 @@ files:
64
65
  - test/dummy/app/assets/javascripts/application.js
65
66
  - test/dummy/app/assets/stylesheets/application.css
66
67
  - test/dummy/app/controllers/application_controller.rb
67
- - test/dummy/app/controllers/pages_controller.rb
68
68
  - test/dummy/app/helpers/application_helper.rb
69
69
  - test/dummy/app/views/layouts/application.html.erb
70
- - test/dummy/app/views/pages/index.html.erb
71
70
  - test/dummy/bin/bundle
72
71
  - test/dummy/bin/rails
73
72
  - test/dummy/bin/rake
@@ -134,15 +133,13 @@ rubyforge_project:
134
133
  rubygems_version: 2.2.2
135
134
  signing_key:
136
135
  specification_version: 4
137
- summary: Google Adsense for Rails.
136
+ summary: Google adsense for rails.
138
137
  test_files:
139
138
  - test/dummy/app/assets/javascripts/application.js
140
139
  - test/dummy/app/assets/stylesheets/application.css
141
140
  - test/dummy/app/controllers/application_controller.rb
142
- - test/dummy/app/controllers/pages_controller.rb
143
141
  - test/dummy/app/helpers/application_helper.rb
144
142
  - test/dummy/app/views/layouts/application.html.erb
145
- - test/dummy/app/views/pages/index.html.erb
146
143
  - test/dummy/bin/bundle
147
144
  - test/dummy/bin/rails
148
145
  - test/dummy/bin/rake
@@ -1,6 +0,0 @@
1
- class PagesController < ApplicationController
2
-
3
- def index
4
- end
5
-
6
- end
@@ -1 +0,0 @@
1
- <%= google_adsense_include_tag client: 'client', slot: 'slot', width: 728, height: 90 %>