ads-rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +9 -4
  3. data/Rakefile +1 -1
  4. data/lib/ads/rails/action_view/base.rb +10 -4
  5. data/lib/ads/rails/railtie.rb +3 -0
  6. data/lib/ads/rails/version.rb +1 -1
  7. data/test/dummy/app/controllers/pages_controller.rb +6 -0
  8. data/test/dummy/app/views/layouts/application.html.erb +2 -2
  9. data/test/dummy/app/views/pages/index.html.erb +1 -0
  10. data/test/dummy/config/application.rb +4 -8
  11. data/test/dummy/config/environments/development.rb +1 -4
  12. data/test/dummy/config/environments/production.rb +3 -0
  13. data/test/dummy/config/environments/test.rb +2 -5
  14. data/test/dummy/config/routes.rb +1 -1
  15. data/test/dummy/log/test.log +58 -0
  16. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  17. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  18. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  19. data/test/dummy/tmp/cache/assets/test/sprockets/6ee31c758c2207128f3b2fb9f1e7fc1c +0 -0
  20. data/test/dummy/tmp/cache/assets/test/sprockets/78bbdd3d4b68f961ea76c51d172aec6b +0 -0
  21. data/test/dummy/tmp/cache/assets/test/sprockets/c7342e04b6a4ad6af1bb72c5c094c804 +0 -0
  22. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  23. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  24. data/test/dummy/tmp/cache/assets/test/sprockets/f09692c097713119fa701a4122205808 +0 -0
  25. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  26. data/test/include_tag_test.rb +11 -0
  27. metadata +41 -26
  28. data/test/ads_rails_test.rb +0 -9
  29. data/test/dummy/app/controllers/statics_controller.rb +0 -6
  30. data/test/dummy/app/views/statics/home.html.erb +0 -1
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f4b9987a010bf556a30a96a89bab6011034b872
4
+ data.tar.gz: e318f119583b4401330192c67e080b8376e6dbc1
5
+ SHA512:
6
+ metadata.gz: b6c11e42e2bbcbfe1e87be9affee6727136f001ef3841084c1a3681ea3f0e7a6f7d468b6c1f133175fcb1b6611f4bfe54bd74bf256084f4648db3f41649dc886
7
+ data.tar.gz: 31731b597f3819916573a77b1e743bf035c3c7fd8eadd1eeca052c4d43cc67a70269b02be5b30380008a061a137a8f5449ec6395af75de76385be0eae2f05473
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  {<img src="https://codeclimate.com/github/mattways/ads-rails.png" />}[https://codeclimate.com/github/mattways/ads-rails] {<img src="https://travis-ci.org/mattways/ads-rails.png?branch=master" alt="Build Status" />}[https://travis-ci.org/mattways/ads-rails] {<img src="https://gemnasium.com/mattways/ads-rails.png" alt="Dependency Status" />}[https://gemnasium.com/mattways/ads-rails]
2
2
 
3
- = Fonts Rails
3
+ = Ads Rails
4
4
 
5
5
  Adds a simple helper to create the google adsense include tag.
6
6
 
@@ -14,7 +14,12 @@ Then bundle:
14
14
 
15
15
  = Usage
16
16
 
17
- In your layout add a line like this in your head:
18
- = google_adsense_include_tag :client => 'client', :slot => 'slot', :width => 'width', :height => 'height'
17
+ In your view add a line like this wherever you like:
18
+ <%= google_adsense_include_tag client: 'client', slot: 'slot', width: 'width', height: 'height' %>
19
19
 
20
- (Will only show the include tag in production env)
20
+ (Will only show the include tag in production and test env)
21
+
22
+ = Configuration
23
+
24
+ If you want to renderer different the placeholder, put something like this in your application.rb:
25
+ config.ads.renderer = proc { |options| tag(:img, src: "http://placehold.it/#{options[:width]}x#{options[:height]}&text=Google+AdSense") }
data/Rakefile CHANGED
@@ -35,4 +35,4 @@ Rake::TestTask.new(:test) do |t|
35
35
  end
36
36
 
37
37
 
38
- task :default => :test
38
+ task default: :test
@@ -4,16 +4,22 @@ module Ads
4
4
  module Base
5
5
 
6
6
  def google_adsense_include_tag(*args)
7
- if ::Rails.env.production?
8
- options = args.extract_options!
7
+ options = args.extract_options!
8
+ if ['production','test'].include? ::Rails.env
9
9
  script = <<-SCRIPT
10
10
  google_ad_client = '#{options[:client]}';
11
11
  google_ad_slot = '#{options[:slot]}';
12
12
  google_ad_width = #{options[:width]};
13
13
  google_ad_height = #{options[:height]};
14
14
  SCRIPT
15
- content_tag(:script, script.html_safe, :type => 'text/javascript') +
16
- content_tag(:script, nil, :type => 'text/javascript', :src => 'http://pagead2.googlesyndication.com/pagead/show_ads.js')
15
+ content_tag(:script, script.html_safe, type: 'text/javascript') +
16
+ content_tag(:script, nil, type: 'text/javascript', src: 'http://pagead2.googlesyndication.com/pagead/show_ads.js')
17
+ elsif ::Rails.env.development?
18
+ if ::Rails.application.config.ads.renderer.is_a? Proc
19
+ instance_exec(options, &::Rails.application.config.ads.renderer)
20
+ else
21
+ content_tag(:div, nil, style: "width:#{options[:width]}px;height:#{options[:height]}px;background:#c8c8c8;")
22
+ end
17
23
  end
18
24
  end
19
25
 
@@ -2,6 +2,9 @@ module Ads
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
4
 
5
+ config.ads = ActiveSupport::OrderedOptions.new
6
+ config.ads.renderer = nil
7
+
5
8
  initializer 'ads.rails' do
6
9
  ::ActionView::Base.send :include, Ads::Rails::ActionView::Base
7
10
  end
@@ -1,7 +1,7 @@
1
1
  module Ads
2
2
  module Rails
3
3
 
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
 
6
6
  end
7
7
  end
@@ -0,0 +1,6 @@
1
+ class PagesController < ApplicationController
2
+
3
+ def index
4
+ end
5
+
6
+ end
@@ -2,8 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= javascript_include_tag 'application' %>
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
@@ -0,0 +1 @@
1
+ <%= google_adsense_include_tag client: 'client', slot: 'slot', width: 'width', height: 'height' %>
@@ -30,7 +30,7 @@ module Dummy
30
30
  # config.i18n.default_locale = :de
31
31
 
32
32
  # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
33
+ config.encoding = 'utf-8'
34
34
 
35
35
  # Configure sensitive parameters which will be filtered from the log file.
36
36
  config.filter_parameters += [:password]
@@ -43,17 +43,13 @@ module Dummy
43
43
  # like if you have constraints or database-specific column types
44
44
  # config.active_record.schema_format = :sql
45
45
 
46
- # Enforce whitelist mode for mass assignment.
47
- # This will create an empty whitelist of attributes available for mass-assignment for all models
48
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
- # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
51
-
52
46
  # Enable the asset pipeline
53
47
  config.assets.enabled = true
54
48
 
55
49
  # Version of your assets, change this if you want to expire all your assets
56
50
  config.assets.version = '1.0'
51
+
52
+ # Rails 4 fix
53
+ config.secret_key_base = 'blipblapblup'
57
54
  end
58
55
  end
59
-
@@ -7,7 +7,7 @@ Dummy::Application.configure do
7
7
  config.cache_classes = false
8
8
 
9
9
  # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
10
+ config.eager_load = true
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
@@ -22,9 +22,6 @@ Dummy::Application.configure do
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
25
  # Log the query plan for queries taking more than this (works
29
26
  # with SQLite, MySQL, and PostgreSQL)
30
27
  config.active_record.auto_explain_threshold_in_seconds = 0.5
@@ -11,6 +11,9 @@ Dummy::Application.configure do
11
11
  # Disable Rails's static asset server (Apache or nginx will already do this)
12
12
  config.serve_static_assets = false
13
13
 
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.config.eager_load = false
16
+
14
17
  # Compress JavaScripts and CSS
15
18
  config.assets.compress = true
16
19
 
@@ -9,10 +9,10 @@ Dummy::Application.configure do
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
11
  config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
12
+ config.static_cache_control = 'public, max-age=3600'
13
13
 
14
14
  # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ config.eager_load = false
16
16
 
17
17
  # Show full error reports and disable caching
18
18
  config.consider_all_requests_local = true
@@ -29,9 +29,6 @@ Dummy::Application.configure do
29
29
  # ActionMailer::Base.deliveries array.
30
30
  config.action_mailer.delivery_method = :test
31
31
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
32
  # Print deprecation notices to the stderr
36
33
  config.active_support.deprecation = :stderr
37
34
  end
@@ -1,6 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
2
 
3
- root :to => 'statics#home'
3
+ root to: 'pages#index'
4
4
 
5
5
  # The priority is based upon order of creation:
6
6
  # first created -> highest priority.
@@ -7,3 +7,61 @@ Connecting to database specified by database.yml
7
7
  Connecting to database specified by database.yml
8
8
   (0.2ms) begin transaction
9
9
   (0.1ms) rollback transaction
10
+  (0.3ms) begin transaction
11
+ ------------------------
12
+ AdsRailsTest: test_truth
13
+ ------------------------
14
+  (0.1ms) rollback transaction
15
+  (0.3ms) begin transaction
16
+ ------------------------
17
+ AdsRailsTest: test_truth
18
+ ------------------------
19
+  (0.2ms) rollback transaction
20
+  (0.1ms) begin transaction
21
+ --------------------------
22
+ IncludeTagTest: test_truth
23
+ --------------------------
24
+  (0.1ms) rollback transaction
25
+  (0.2ms) begin transaction
26
+ ------------------------
27
+ AdsRailsTest: test_truth
28
+ ------------------------
29
+  (0.1ms) rollback transaction
30
+  (0.0ms) begin transaction
31
+ --------------------------
32
+ IncludeTagTest: test_truth
33
+ --------------------------
34
+  (0.0ms) rollback transaction
35
+  (0.2ms) begin transaction
36
+ --------------------------------------------
37
+ IncludeTagTest: test_should_show_include_tag
38
+ --------------------------------------------
39
+ Started GET "/" for 127.0.0.1 at 2013-08-05 17:51:01 -0300
40
+  (0.1ms) rollback transaction
41
+  (0.2ms) begin transaction
42
+ --------------------------------------------
43
+ IncludeTagTest: test_should_show_include_tag
44
+ --------------------------------------------
45
+ Started GET "/" for 127.0.0.1 at 2013-08-05 17:51:40 -0300
46
+ Processing by PagesController#index as HTML
47
+ Rendered pages/index.html.erb within layouts/application (1.1ms)
48
+ Completed 200 OK in 95ms (Views: 94.7ms | ActiveRecord: 0.0ms)
49
+  (0.1ms) rollback transaction
50
+  (0.2ms) begin transaction
51
+ --------------------------------------------
52
+ IncludeTagTest: test_should_show_include_tag
53
+ --------------------------------------------
54
+ Started GET "/" for 127.0.0.1 at 2013-08-05 17:56:39 -0300
55
+ Processing by PagesController#index as HTML
56
+ Rendered pages/index.html.erb within layouts/application (1.0ms)
57
+ Completed 200 OK in 14ms (Views: 13.6ms | ActiveRecord: 0.0ms)
58
+  (0.1ms) rollback transaction
59
+  (0.2ms) begin transaction
60
+ --------------------------------------------
61
+ IncludeTagTest: test_should_show_include_tag
62
+ --------------------------------------------
63
+ Started GET "/" for 127.0.0.1 at 2013-08-05 18:35:36 -0300
64
+ Processing by PagesController#index as HTML
65
+ Rendered pages/index.html.erb within layouts/application (1.0ms)
66
+ Completed 200 OK in 14ms (Views: 13.9ms | ActiveRecord: 0.0ms)
67
+  (0.1ms) rollback transaction
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class IncludeTagTest < ActionDispatch::IntegrationTest
4
+
5
+ test "should show include tag" do
6
+ get '/'
7
+ assert_response :success
8
+ assert response.body.include?("google_ad_client = 'client'")
9
+ end
10
+
11
+ end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ads-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mattways
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.8
19
+ version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.8
26
+ version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sqlite3
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Adds a simple view helper to create the google adsense include tag.
@@ -58,14 +53,13 @@ files:
58
53
  - MIT-LICENSE
59
54
  - Rakefile
60
55
  - README.rdoc
61
- - test/ads_rails_test.rb
62
56
  - test/dummy/app/assets/javascripts/application.js
63
57
  - test/dummy/app/assets/stylesheets/application.css
64
58
  - test/dummy/app/controllers/application_controller.rb
65
- - test/dummy/app/controllers/statics_controller.rb
59
+ - test/dummy/app/controllers/pages_controller.rb
66
60
  - test/dummy/app/helpers/application_helper.rb
67
61
  - test/dummy/app/views/layouts/application.html.erb
68
- - test/dummy/app/views/statics/home.html.erb
62
+ - test/dummy/app/views/pages/index.html.erb
69
63
  - test/dummy/config/application.rb
70
64
  - test/dummy/config/boot.rb
71
65
  - test/dummy/config/database.yml
@@ -102,40 +96,50 @@ files:
102
96
  - test/dummy/tmp/cache/assets/DEF/100/sprockets%2F8b9d88bfa8f8eed7910469ef2ab8a8c7
103
97
  - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
104
98
  - test/dummy/tmp/cache/assets/E29/AA0/sprockets%2F6eaab4ab4dbae1b8b5a6f9286aa966d4
99
+ - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
100
+ - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
101
+ - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
102
+ - test/dummy/tmp/cache/assets/test/sprockets/6ee31c758c2207128f3b2fb9f1e7fc1c
103
+ - test/dummy/tmp/cache/assets/test/sprockets/78bbdd3d4b68f961ea76c51d172aec6b
104
+ - test/dummy/tmp/cache/assets/test/sprockets/c7342e04b6a4ad6af1bb72c5c094c804
105
+ - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
106
+ - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
107
+ - test/dummy/tmp/cache/assets/test/sprockets/f09692c097713119fa701a4122205808
108
+ - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
109
+ - test/include_tag_test.rb
105
110
  - test/test_helper.rb
106
111
  homepage: https://github.com/mattways/ads-rails
107
- licenses: []
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
108
115
  post_install_message:
109
116
  rdoc_options: []
110
117
  require_paths:
111
118
  - lib
112
119
  required_ruby_version: !ruby/object:Gem::Requirement
113
- none: false
114
120
  requirements:
115
- - - ! '>='
121
+ - - '>='
116
122
  - !ruby/object:Gem::Version
117
123
  version: '0'
118
124
  required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
125
  requirements:
121
- - - ! '>='
126
+ - - '>='
122
127
  - !ruby/object:Gem::Version
123
128
  version: '0'
124
129
  requirements: []
125
130
  rubyforge_project:
126
- rubygems_version: 1.8.23
131
+ rubygems_version: 2.0.3
127
132
  signing_key:
128
- specification_version: 3
133
+ specification_version: 4
129
134
  summary: Google Adsense for Rails.
130
135
  test_files:
131
- - test/ads_rails_test.rb
132
136
  - test/dummy/app/assets/javascripts/application.js
133
137
  - test/dummy/app/assets/stylesheets/application.css
134
138
  - test/dummy/app/controllers/application_controller.rb
135
- - test/dummy/app/controllers/statics_controller.rb
139
+ - test/dummy/app/controllers/pages_controller.rb
136
140
  - test/dummy/app/helpers/application_helper.rb
137
141
  - test/dummy/app/views/layouts/application.html.erb
138
- - test/dummy/app/views/statics/home.html.erb
142
+ - test/dummy/app/views/pages/index.html.erb
139
143
  - test/dummy/config/application.rb
140
144
  - test/dummy/config/boot.rb
141
145
  - test/dummy/config/database.yml
@@ -172,4 +176,15 @@ test_files:
172
176
  - test/dummy/tmp/cache/assets/DEF/100/sprockets%2F8b9d88bfa8f8eed7910469ef2ab8a8c7
173
177
  - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
174
178
  - test/dummy/tmp/cache/assets/E29/AA0/sprockets%2F6eaab4ab4dbae1b8b5a6f9286aa966d4
179
+ - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
180
+ - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
181
+ - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
182
+ - test/dummy/tmp/cache/assets/test/sprockets/6ee31c758c2207128f3b2fb9f1e7fc1c
183
+ - test/dummy/tmp/cache/assets/test/sprockets/78bbdd3d4b68f961ea76c51d172aec6b
184
+ - test/dummy/tmp/cache/assets/test/sprockets/c7342e04b6a4ad6af1bb72c5c094c804
185
+ - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
186
+ - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
187
+ - test/dummy/tmp/cache/assets/test/sprockets/f09692c097713119fa701a4122205808
188
+ - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
189
+ - test/include_tag_test.rb
175
190
  - test/test_helper.rb
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AdsRailsTest < ActiveSupport::TestCase
4
-
5
- test "truth" do
6
- assert_kind_of Module, Ads::Rails
7
- end
8
-
9
- end
@@ -1,6 +0,0 @@
1
- class StaticsController < ApplicationController
2
-
3
- def home
4
- end
5
-
6
- end
@@ -1 +0,0 @@
1
- <%= google_adsense_include_tag :client => 'client', :slot => 'slot', :width => 'width', :height => 'height' %>