ads-rails 0.2.3 → 4.0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +17 -20
  4. data/Rakefile +1 -14
  5. data/lib/ads-rails.rb +4 -7
  6. data/lib/ads/configuration.rb +13 -0
  7. data/lib/ads/rails.rb +2 -1
  8. data/lib/ads/rails/extensions/action_view/base.rb +34 -0
  9. data/lib/ads/rails/railtie.rb +4 -2
  10. data/lib/ads/rails/version.rb +1 -1
  11. data/lib/generators/ads/install/install_generator.rb +15 -0
  12. data/lib/generators/ads/install/templates/initializer.rb +8 -0
  13. data/test/dummy/Rakefile +1 -2
  14. data/test/dummy/app/assets/javascripts/application.js +2 -2
  15. data/test/dummy/app/assets/stylesheets/application.css +6 -4
  16. data/test/dummy/app/views/layouts/application.html.erb +9 -11
  17. data/test/dummy/bin/bundle +1 -0
  18. data/test/dummy/bin/rails +2 -1
  19. data/test/dummy/bin/rake +1 -0
  20. data/test/dummy/bin/setup +30 -0
  21. data/test/dummy/config.ru +1 -1
  22. data/test/dummy/config/application.rb +6 -1
  23. data/test/dummy/config/boot.rb +1 -1
  24. data/test/dummy/config/environment.rb +1 -1
  25. data/test/dummy/config/environments/development.rb +14 -5
  26. data/test/dummy/config/environments/production.rb +18 -26
  27. data/test/dummy/config/environments/test.rb +10 -12
  28. data/test/dummy/config/initializers/ads.rb +8 -0
  29. data/test/dummy/config/initializers/assets.rb +11 -0
  30. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  31. data/test/dummy/config/initializers/mime_types.rb +1 -2
  32. data/test/dummy/config/initializers/session_store.rb +1 -1
  33. data/test/dummy/config/routes.rb +1 -1
  34. data/test/dummy/config/secrets.yml +22 -0
  35. data/test/dummy/log/development.log +0 -0
  36. data/test/dummy/log/test.log +60 -0
  37. data/test/dummy/public/404.html +58 -55
  38. data/test/dummy/public/422.html +58 -55
  39. data/test/dummy/public/500.html +57 -54
  40. data/test/generator_test.rb +5 -5
  41. data/test/test_helper.rb +5 -14
  42. data/test/view_test.rb +28 -0
  43. metadata +28 -60
  44. data/lib/ads/rails/action_view/base.rb +0 -40
  45. data/lib/generators/ads/install_generator.rb +0 -13
  46. data/lib/generators/ads/templates/ads.rb +0 -2
  47. data/test/dummy/README.rdoc +0 -28
  48. data/test/dummy/config/database.yml +0 -25
  49. data/test/dummy/config/initializers/secret_token.rb +0 -13
  50. data/test/dummy/db/schema.rb +0 -16
  51. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  57. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  58. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  59. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  60. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  61. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  62. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  63. data/test/include_tag_test.rb +0 -47
@@ -1,57 +1,60 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/500.html -->
52
- <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
54
- </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
- </body>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+ div.dialog {
15
+ width: 95%;
16
+ max-width: 33em;
17
+ margin: 4em auto 0;
18
+ }
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+ h1 {
32
+ font-size: 100%;
33
+ color: #730E15;
34
+ line-height: 1.5em;
35
+ }
36
+ div.dialog > p {
37
+ margin: 0 0 1em;
38
+ padding: 1em;
39
+ background-color: #F7F7F7;
40
+ border: 1px solid #CCC;
41
+ border-right-color: #999;
42
+ border-left-color: #999;
43
+ border-bottom-color: #999;
44
+ border-bottom-left-radius: 4px;
45
+ border-bottom-right-radius: 4px;
46
+ border-top-color: #DADADA;
47
+ color: #666;
48
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="dialog">
54
+ <div>
55
+ <h1>We're sorry, but something went wrong.</h1>
56
+ </div>
57
+ <p>If you are the application owner check the logs for more information.</p>
58
+ </div>
59
+ </body>
57
60
  </html>
@@ -1,16 +1,16 @@
1
1
  require 'test_helper'
2
2
  require 'rails/generators'
3
- require 'generators/ads/install_generator'
3
+ require 'generators/ads/install/install_generator'
4
4
 
5
5
  class GeneratorsTest < ::Rails::Generators::TestCase
6
- tests Ads::InstallGenerator
7
- destination File.expand_path('../tmp', File.dirname(__FILE__))
6
+ destination Rails.root.join('tmp')
8
7
 
9
8
  teardown do
10
- FileUtils.rm_rf self.destination_root
9
+ FileUtils.rm_rf destination_root
11
10
  end
12
11
 
13
- test 'initializer generator' do
12
+ test 'install' do
13
+ self.class.tests Ads::Generators::InstallGenerator
14
14
  run_generator
15
15
  assert_file 'config/initializers/ads.rb'
16
16
  end
data/test/test_helper.rb CHANGED
@@ -1,24 +1,15 @@
1
1
  # Configure Rails Environment
2
2
  ENV['RAILS_ENV'] = 'test'
3
3
 
4
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+ require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
5
  require 'rails/test_help'
6
6
 
7
- Rails.backtrace_cleaner.remove_silencers!
7
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
8
+ # to be shown.
9
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
8
10
 
9
11
  # Load support files
10
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
13
 
12
- # Load fixtures from the engine
13
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
- end
16
-
17
- # Load database
18
- config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
19
- config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
20
- ActiveRecord::Base.establish_connection(config['test'])
21
- load(File.expand_path('../dummy/db/schema.rb', __FILE__))
22
-
23
14
  # Include helpers
24
- ActionView::TestCase.send :include, Ads::Rails::ActionView::Base
15
+ ActionView::TestCase.include Ads::Rails::Extensions::ActionView::Base
data/test/view_test.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class ViewTest < ActionView::TestCase
4
+
5
+ test 'tag' do
6
+ self.request = ActionDispatch::TestRequest.new
7
+
8
+ with_env 'production' do
9
+ tag = google_adsense_include_tag(client: 'pub-1234', width: 728)
10
+ assert_includes tag, %Q(google_ad_client = "pub-1234";\ngoogle_ad_width = 728;)
11
+ end
12
+
13
+ with_env 'development' do
14
+ tag = google_adsense_include_tag(width: 728, height:90)
15
+ assert_includes tag, 'style="width: 728px; height: 90px; background: #c8c8c8;"'
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def with_env(value)
22
+ old_env = Rails.env
23
+ Rails.env = value
24
+ yield
25
+ Rails.env = old_env
26
+ end
27
+
28
+ end
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.2.3
4
+ version: 4.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.3.0
@@ -26,28 +26,13 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.0.0
29
+ version: 4.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.3.0
33
- - !ruby/object:Gem::Dependency
34
- name: sqlite3
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.3'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.3'
47
- description: Adds a simple view helper to create the google adsense include tag in
48
- rails.
33
+ description: Helper to create the google adsense include tag in rails.
49
34
  email:
50
- - mmontossi@buyin.io
35
+ - mmontossi@gmail.com
51
36
  executables: []
52
37
  extensions: []
53
38
  extra_rdoc_files: []
@@ -56,13 +41,13 @@ files:
56
41
  - README.md
57
42
  - Rakefile
58
43
  - lib/ads-rails.rb
44
+ - lib/ads/configuration.rb
59
45
  - lib/ads/rails.rb
60
- - lib/ads/rails/action_view/base.rb
46
+ - lib/ads/rails/extensions/action_view/base.rb
61
47
  - lib/ads/rails/railtie.rb
62
48
  - lib/ads/rails/version.rb
63
- - lib/generators/ads/install_generator.rb
64
- - lib/generators/ads/templates/ads.rb
65
- - test/dummy/README.rdoc
49
+ - lib/generators/ads/install/install_generator.rb
50
+ - lib/generators/ads/install/templates/initializer.rb
66
51
  - test/dummy/Rakefile
67
52
  - test/dummy/app/assets/javascripts/application.js
68
53
  - test/dummy/app/assets/stylesheets/application.css
@@ -72,43 +57,35 @@ files:
72
57
  - test/dummy/bin/bundle
73
58
  - test/dummy/bin/rails
74
59
  - test/dummy/bin/rake
60
+ - test/dummy/bin/setup
75
61
  - test/dummy/config.ru
76
62
  - test/dummy/config/application.rb
77
63
  - test/dummy/config/boot.rb
78
- - test/dummy/config/database.yml
79
64
  - test/dummy/config/environment.rb
80
65
  - test/dummy/config/environments/development.rb
81
66
  - test/dummy/config/environments/production.rb
82
67
  - test/dummy/config/environments/test.rb
68
+ - test/dummy/config/initializers/ads.rb
69
+ - test/dummy/config/initializers/assets.rb
83
70
  - test/dummy/config/initializers/backtrace_silencers.rb
71
+ - test/dummy/config/initializers/cookies_serializer.rb
84
72
  - test/dummy/config/initializers/filter_parameter_logging.rb
85
73
  - test/dummy/config/initializers/inflections.rb
86
74
  - test/dummy/config/initializers/mime_types.rb
87
- - test/dummy/config/initializers/secret_token.rb
88
75
  - test/dummy/config/initializers/session_store.rb
89
76
  - test/dummy/config/initializers/wrap_parameters.rb
90
77
  - test/dummy/config/locales/en.yml
91
78
  - test/dummy/config/routes.rb
92
- - test/dummy/db/schema.rb
79
+ - test/dummy/config/secrets.yml
80
+ - test/dummy/log/development.log
81
+ - test/dummy/log/test.log
93
82
  - test/dummy/public/404.html
94
83
  - test/dummy/public/422.html
95
84
  - test/dummy/public/500.html
96
85
  - test/dummy/public/favicon.ico
97
- - test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705
98
- - test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
99
- - test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953
100
- - test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
101
- - test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6
102
- - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
103
- - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
104
- - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
105
- - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
106
- - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
107
- - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
108
- - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
109
86
  - test/generator_test.rb
110
- - test/include_tag_test.rb
111
87
  - test/test_helper.rb
88
+ - test/view_test.rb
112
89
  homepage: https://github.com/mmontossi/ads-rails
113
90
  licenses:
114
91
  - MIT
@@ -121,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
98
  requirements:
122
99
  - - ">="
123
100
  - !ruby/object:Gem::Version
124
- version: 1.9.3
101
+ version: 2.1.0
125
102
  required_rubygems_version: !ruby/object:Gem::Requirement
126
103
  requirements:
127
104
  - - ">="
@@ -129,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
106
  version: '0'
130
107
  requirements: []
131
108
  rubyforge_project:
132
- rubygems_version: 2.4.5
109
+ rubygems_version: 2.5.1
133
110
  signing_key:
134
111
  specification_version: 4
135
112
  summary: Google adsense for rails.
@@ -142,42 +119,33 @@ test_files:
142
119
  - test/dummy/bin/bundle
143
120
  - test/dummy/bin/rails
144
121
  - test/dummy/bin/rake
122
+ - test/dummy/bin/setup
145
123
  - test/dummy/config/application.rb
146
124
  - test/dummy/config/boot.rb
147
- - test/dummy/config/database.yml
148
125
  - test/dummy/config/environment.rb
149
126
  - test/dummy/config/environments/development.rb
150
127
  - test/dummy/config/environments/production.rb
151
128
  - test/dummy/config/environments/test.rb
129
+ - test/dummy/config/initializers/ads.rb
130
+ - test/dummy/config/initializers/assets.rb
152
131
  - test/dummy/config/initializers/backtrace_silencers.rb
132
+ - test/dummy/config/initializers/cookies_serializer.rb
153
133
  - test/dummy/config/initializers/filter_parameter_logging.rb
154
134
  - test/dummy/config/initializers/inflections.rb
155
135
  - test/dummy/config/initializers/mime_types.rb
156
- - test/dummy/config/initializers/secret_token.rb
157
136
  - test/dummy/config/initializers/session_store.rb
158
137
  - test/dummy/config/initializers/wrap_parameters.rb
159
138
  - test/dummy/config/locales/en.yml
160
139
  - test/dummy/config/routes.rb
140
+ - test/dummy/config/secrets.yml
161
141
  - test/dummy/config.ru
162
- - test/dummy/db/schema.rb
142
+ - test/dummy/log/development.log
143
+ - test/dummy/log/test.log
163
144
  - test/dummy/public/404.html
164
145
  - test/dummy/public/422.html
165
146
  - test/dummy/public/500.html
166
147
  - test/dummy/public/favicon.ico
167
148
  - test/dummy/Rakefile
168
- - test/dummy/README.rdoc
169
- - test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705
170
- - test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af
171
- - test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953
172
- - test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994
173
- - test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6
174
- - test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
175
- - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
176
- - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
177
- - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
178
- - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
179
- - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
180
- - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
181
149
  - test/generator_test.rb
182
- - test/include_tag_test.rb
183
150
  - test/test_helper.rb
151
+ - test/view_test.rb
@@ -1,40 +0,0 @@
1
- module Ads
2
- module Rails
3
- module ActionView
4
- module Base
5
-
6
- def google_adsense_include_tag(*args)
7
- options = args.extract_options!
8
- if ::Rails.env.production?
9
- variables = options.map do |key, value|
10
- if value.is_a? String
11
- value = "'#{value}'"
12
- end
13
- "google_ad_#{key} = #{value};"
14
- end
15
- content_tag(
16
- :script,
17
- variables.join("\n").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
- )
26
- elsif Ads.config.renderer.is_a? Proc
27
- instance_exec options, &Ads.config.renderer
28
- else
29
- content_tag(
30
- :div,
31
- nil,
32
- style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;"
33
- )
34
- end
35
- end
36
-
37
- end
38
- end
39
- end
40
- end
@@ -1,13 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module Ads
4
- class InstallGenerator < ::Rails::Generators::Base
5
-
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_initializer
9
- copy_file 'ads.rb', 'config/initializers/ads.rb'
10
- end
11
-
12
- end
13
- end