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 +4 -4
- data/README.rdoc +27 -11
- data/lib/ads/rails.rb +0 -1
- data/lib/ads/rails/action_view/base.rb +22 -9
- data/lib/ads/rails/version.rb +1 -1
- data/test/dummy/config/application.rb +0 -1
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/log/test.log +340 -0
- data/test/include_tag_test.rb +29 -30
- data/test/test_helper.rb +3 -0
- metadata +5 -8
- data/test/dummy/app/controllers/pages_controller.rb +0 -6
- data/test/dummy/app/views/pages/index.html.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e3631ccff398d44be0e1a07e2a3ef55298ecd51
|
4
|
+
data.tar.gz: 08fd7244266fc90c3d9cc06562cd2eaa9d607835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1de5d731c51f67e3fdd8f710e74ebc71dc2a6c08cd1fc1ef328ed3889d90d4f5eec282e52a48ea337468954a1da08bd292b19c592e3f7225b2185a566b68ac0
|
7
|
+
data.tar.gz: 9daa6d7394c0ddf2bf817b475bf006985e51fb011b15d5e1b8394651298f51b5b177bb050760f1498682850d9a99a1b3690287886a365dfa14fee0d0b6ec9070
|
data/README.rdoc
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
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
|
22
|
-
<%= google_adsense_include_tag client: '
|
17
|
+
In your views call the helper like this:
|
18
|
+
<%= google_adsense_include_tag client: 'pub-1234', slot: '1234', ... %>
|
23
19
|
|
24
|
-
|
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
|
-
|
29
|
-
config.ads.renderer =
|
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
@@ -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 =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
content_tag(
|
16
|
-
|
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
|
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
|
|
data/lib/ads/rails/version.rb
CHANGED
data/test/dummy/config/routes.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -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
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1003
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1004
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1005
|
+
[1m[36m (0.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1006
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1007
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1008
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1009
|
+
------------------------------------------------------------------------------------
|
1010
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1011
|
+
------------------------------------------------------------------------------------
|
1012
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1013
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1014
|
+
------------------------------------------------------------------------------------
|
1015
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1016
|
+
------------------------------------------------------------------------------------
|
1017
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1018
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1019
|
+
------------------------------------------------------------------------------------------
|
1020
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1021
|
+
------------------------------------------------------------------------------------------
|
1022
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1023
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1024
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1025
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1026
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1027
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1028
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1029
|
+
------------------------------------------------------------------------------------
|
1030
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1031
|
+
------------------------------------------------------------------------------------
|
1032
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1033
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1034
|
+
------------------------------------------------------------------------------------
|
1035
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1036
|
+
------------------------------------------------------------------------------------
|
1037
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1038
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1039
|
+
------------------------------------------------------------------------------------------
|
1040
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1041
|
+
------------------------------------------------------------------------------------------
|
1042
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1043
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1044
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1045
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1046
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1047
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1048
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1049
|
+
------------------------------------------------------------------------------------
|
1050
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1051
|
+
------------------------------------------------------------------------------------
|
1052
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1053
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1054
|
+
------------------------------------------------------------------------------------
|
1055
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1056
|
+
------------------------------------------------------------------------------------
|
1057
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1058
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1059
|
+
------------------------------------------------------------------------------------------
|
1060
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1061
|
+
------------------------------------------------------------------------------------------
|
1062
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1063
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1064
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1065
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1066
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1067
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1068
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1069
|
+
------------------------------------------------------------------------------------
|
1070
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1071
|
+
------------------------------------------------------------------------------------
|
1072
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1073
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1074
|
+
------------------------------------------------------------------------------------
|
1075
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1076
|
+
------------------------------------------------------------------------------------
|
1077
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1078
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1079
|
+
------------------------------------------------------------------------------------------
|
1080
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1081
|
+
------------------------------------------------------------------------------------------
|
1082
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1083
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1084
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1085
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1086
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1087
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1088
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1089
|
+
------------------------------------------------------------------------------------
|
1090
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1091
|
+
------------------------------------------------------------------------------------
|
1092
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1093
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1094
|
+
------------------------------------------------------------------------------------
|
1095
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1096
|
+
------------------------------------------------------------------------------------
|
1097
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1098
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1099
|
+
------------------------------------------------------------------------------------------
|
1100
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1101
|
+
------------------------------------------------------------------------------------------
|
1102
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1103
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1104
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1105
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1106
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1107
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1108
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1109
|
+
------------------------------------------------------------------------------------
|
1110
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1111
|
+
------------------------------------------------------------------------------------
|
1112
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1113
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1114
|
+
------------------------------------------------------------------------------------
|
1115
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1116
|
+
------------------------------------------------------------------------------------
|
1117
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1118
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1119
|
+
------------------------------------------------------------------------------------------
|
1120
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1121
|
+
------------------------------------------------------------------------------------------
|
1122
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1123
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1124
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1125
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1126
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1127
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1128
|
+
[1m[35m (0.4ms)[0m begin transaction
|
1129
|
+
------------------------------------------------------------------------------------
|
1130
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1131
|
+
------------------------------------------------------------------------------------
|
1132
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1133
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1134
|
+
------------------------------------------------------------------------------------
|
1135
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1136
|
+
------------------------------------------------------------------------------------
|
1137
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1138
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1139
|
+
------------------------------------------------------------------------------------------
|
1140
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1141
|
+
------------------------------------------------------------------------------------------
|
1142
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1143
|
+
[1m[36m (0.5ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1144
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1145
|
+
[1m[36m (0.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1146
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1147
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1148
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1149
|
+
------------------------------------------------------------------------------------
|
1150
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1151
|
+
------------------------------------------------------------------------------------
|
1152
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1153
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1154
|
+
------------------------------------------------------------------------------------
|
1155
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1156
|
+
------------------------------------------------------------------------------------
|
1157
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1158
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1159
|
+
------------------------------------------------------------------------------------------
|
1160
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1161
|
+
------------------------------------------------------------------------------------------
|
1162
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1163
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1164
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1165
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1166
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1167
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1168
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1169
|
+
------------------------------------------------------------------------------------
|
1170
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1171
|
+
------------------------------------------------------------------------------------
|
1172
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1173
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1174
|
+
------------------------------------------------------------------------------------
|
1175
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1176
|
+
------------------------------------------------------------------------------------
|
1177
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1178
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1179
|
+
------------------------------------------------------------------------------------------
|
1180
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1181
|
+
------------------------------------------------------------------------------------------
|
1182
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1183
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1184
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1185
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1186
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1187
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1188
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1189
|
+
------------------------------------------------------------------------------------
|
1190
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1191
|
+
------------------------------------------------------------------------------------
|
1192
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1193
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1194
|
+
------------------------------------------------------------------------------------
|
1195
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1196
|
+
------------------------------------------------------------------------------------
|
1197
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1198
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1199
|
+
------------------------------------------------------------------------------------------
|
1200
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1201
|
+
------------------------------------------------------------------------------------------
|
1202
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1203
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1204
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1205
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1206
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1207
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1208
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1209
|
+
------------------------------------------------------------------------------------
|
1210
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1211
|
+
------------------------------------------------------------------------------------
|
1212
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1213
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1214
|
+
------------------------------------------------------------------------------------
|
1215
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1216
|
+
------------------------------------------------------------------------------------
|
1217
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1218
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1219
|
+
------------------------------------------------------------------------------------------
|
1220
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1221
|
+
------------------------------------------------------------------------------------------
|
1222
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1223
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1224
|
+
[1m[35m (0.2ms)[0m select sqlite_version(*)
|
1225
|
+
[1m[36m (0.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1226
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1227
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1228
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1229
|
+
------------------------------------------------------------------------------------
|
1230
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1231
|
+
------------------------------------------------------------------------------------
|
1232
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
1233
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1234
|
+
------------------------------------------------------------------------------------
|
1235
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1236
|
+
------------------------------------------------------------------------------------
|
1237
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1238
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1239
|
+
------------------------------------------------------------------------------------------
|
1240
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1241
|
+
------------------------------------------------------------------------------------------
|
1242
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1243
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1244
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1245
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1246
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1247
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1248
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1249
|
+
------------------------------------------------------------------------------------
|
1250
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1251
|
+
------------------------------------------------------------------------------------
|
1252
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1253
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1254
|
+
------------------------------------------------------------------------------------
|
1255
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1256
|
+
------------------------------------------------------------------------------------
|
1257
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1258
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1259
|
+
------------------------------------------------------------------------------------------
|
1260
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1261
|
+
------------------------------------------------------------------------------------------
|
1262
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1263
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1264
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1265
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1266
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1267
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1268
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1269
|
+
------------------------------------------------------------------------------------
|
1270
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1271
|
+
------------------------------------------------------------------------------------
|
1272
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1273
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1274
|
+
------------------------------------------------------------------------------------
|
1275
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1276
|
+
------------------------------------------------------------------------------------
|
1277
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1278
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1279
|
+
------------------------------------------------------------------------------------------
|
1280
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1281
|
+
------------------------------------------------------------------------------------------
|
1282
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1283
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1284
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1285
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1286
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1287
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1288
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1289
|
+
------------------------------------------------------------------------------------
|
1290
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1291
|
+
------------------------------------------------------------------------------------
|
1292
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1293
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1294
|
+
------------------------------------------------------------------------------------
|
1295
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1296
|
+
------------------------------------------------------------------------------------
|
1297
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1298
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1299
|
+
------------------------------------------------------------------------------------------
|
1300
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1301
|
+
------------------------------------------------------------------------------------------
|
1302
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1303
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1304
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1305
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1306
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
1307
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1308
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1309
|
+
------------------------------------------------------------------------------------
|
1310
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1311
|
+
------------------------------------------------------------------------------------
|
1312
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1313
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1314
|
+
------------------------------------------------------------------------------------
|
1315
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1316
|
+
------------------------------------------------------------------------------------
|
1317
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1318
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1319
|
+
------------------------------------------------------------------------------------------
|
1320
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1321
|
+
------------------------------------------------------------------------------------------
|
1322
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1323
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
1324
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
1325
|
+
[1m[36m (0.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
1326
|
+
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
1327
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
1328
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1329
|
+
------------------------------------------------------------------------------------
|
1330
|
+
IncludeTagTest: test_show_adsense_code_if_env_is_production_and_there_is_no_renderer
|
1331
|
+
------------------------------------------------------------------------------------
|
1332
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1333
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1334
|
+
------------------------------------------------------------------------------------
|
1335
|
+
IncludeTagTest: test_show_gray_div_if_env_is_not_production_and_there_is_no_renderer
|
1336
|
+
------------------------------------------------------------------------------------
|
1337
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
1338
|
+
[1m[35m (0.0ms)[0m begin transaction
|
1339
|
+
------------------------------------------------------------------------------------------
|
1340
|
+
IncludeTagTest: test_show_renderer_output_if_env_is_not_production_and_there_is_a_renderer
|
1341
|
+
------------------------------------------------------------------------------------------
|
1342
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
data/test/include_tag_test.rb
CHANGED
@@ -1,45 +1,44 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class IncludeTagTest <
|
3
|
+
class IncludeTagTest < ActionView::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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 "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
assert_equal(
|
29
|
+
'<img src="http://placehold.it/728x90&text=Adsense" />',
|
30
|
+
google_adsense_include_tag(width: 728, height:90)
|
31
|
+
)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
|
-
test "
|
38
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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.
|
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-
|
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
|
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 +0,0 @@
|
|
1
|
-
<%= google_adsense_include_tag client: 'client', slot: 'slot', width: 728, height: 90 %>
|