rails-adsense-helper 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +30 -0
- data/lib/action_view/helpers/adsense_helper.rb +47 -0
- data/lib/rails-adsense-helper.rb +5 -0
- data/lib/rails-adsense-helper/version.rb +3 -0
- data/rails-adsense-helper.gemspec +28 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 786cfbb2db870602d4dd9f1fd4cc989a43e1f296
|
4
|
+
data.tar.gz: faf03bfd9e2b2f63b1c2012ee77091d97cbc1935
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8acd00254f5d0efd707883f4deee69604d8d3581791ae2216904fe78f46c382fd9e423c0479de7f60fa7247f9ed785332e1a96c69c51facb1c622aedbddcc825
|
7
|
+
data.tar.gz: 1091f6feda35f193482fb0aded390f8ded73709d49b3adbca1e5d6a0d831f8570f18dd7040d038efada47616314ce46bf5d8fe435d91da5ad57fc4d17ec493d6
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Jianqiu Xiao <swordray@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# rails-adsense-helper
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rails-adsense-helper.png)](http://badge.fury.io/rb/rails-adsense-helper) [![Build Status](https://secure.travis-ci.org/swordray/rails-adsense-helper.png?branch=master)](http://travis-ci.org/swordray/rails-adsense-helper) [![Dependency Status](https://gemnasium.com/swordray/rails-adsense-helper.png?travis)](https://gemnasium.com/swordray/rails-adsense-helper) [![Code Climate](https://codeclimate.com/github/swordray/rails-adsense-helper.png)](https://codeclimate.com/github/swordray/rails-adsense-helper)
|
4
|
+
|
5
|
+
ActionView Helper for Google Adsense Content.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby ~> 2.0
|
10
|
+
* Rails
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Include the gem in your Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'rails-adsense-helper'
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
adsense_tag(client: 0000000000000000, slot: 1111111111, dimension: '336x280')
|
23
|
+
|
24
|
+
## Credits
|
25
|
+
|
26
|
+
* swordray @[ihaveu](http://www.ihaveu.com/home) @[shuhai](http://tw.shuhai.org/) @[leaf](http://leaf.iacger.com)
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
Copyright © 2014 Jianqiu Xiao <swordray@gmail.com> under The [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'action_view/helpers'
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Helpers
|
5
|
+
# = Action View Google Adsense Helper
|
6
|
+
module AdsenseHelper
|
7
|
+
# Parameters:
|
8
|
+
#
|
9
|
+
# client :: 16 digits
|
10
|
+
# slot :: 10 digits
|
11
|
+
# dimension :: "#{width}x#{height}", default is 336x280
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
#
|
15
|
+
# adsense_tag(client: 0000000000000000, slot: 1111111111, dimension: '336x280')
|
16
|
+
#
|
17
|
+
# Generated code:
|
18
|
+
#
|
19
|
+
# <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
20
|
+
# <ins class="adsbygoogle"
|
21
|
+
# style="display:inline-block;width:336px;height:280px"
|
22
|
+
# data-ad-client="ca-pub-0000000000000000"
|
23
|
+
# data-ad-slot="1111111111"></ins>
|
24
|
+
# <script>
|
25
|
+
# (adsbygoogle = window.adsbygoogle || []).push({});
|
26
|
+
# </script>
|
27
|
+
#
|
28
|
+
def adsense_tag(options = {})
|
29
|
+
defaults = { dimension: '336x280' }
|
30
|
+
options = options.to_h.reverse_merge(defaults).with_indifferent_access
|
31
|
+
width, height = options[:dimension].split('x').to_a
|
32
|
+
|
33
|
+
raise 'Invalid ad client, should be 16 digits' unless options[:client].to_s[/^\d{16}$/]
|
34
|
+
raise 'Invalid ad slot, should be 10 digits' unless options[:slot].to_s[/^\d{10}$/]
|
35
|
+
raise 'Invalid ad dimension, should be "#{width}x#{height}"' unless width.to_s[/^\d+$/] && height.to_s[/^\d+$/]
|
36
|
+
|
37
|
+
tags = [
|
38
|
+
content_tag('script', '', async: '', src: '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'),
|
39
|
+
content_tag('ins', '', class: 'adsbygoogle', style: "display:inline-block;width:#{width}px;height:#{height}px", 'data-ad-client' => "ca-pub-#{options[:client]}", 'data-ad-slot' => options[:slot]),
|
40
|
+
content_tag('script', '(adsbygoogle = window.adsbygoogle || []).push({});'),
|
41
|
+
]
|
42
|
+
|
43
|
+
safe_join(tags)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'rails-adsense-helper/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "rails-adsense-helper"
|
6
|
+
s.version = RailsAdsenseHelper::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.author = ["Jianqiu Xiao"]
|
9
|
+
s.email = ["swordray@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/swordray/rails-adsense-helper"
|
11
|
+
s.summary = "ActionView Helper for Google Adsense Content."
|
12
|
+
s.description = "Thanks to ihaveu.com team."
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
# s.rubyforge_project = ""
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
# s.requirements << ""
|
23
|
+
s.required_ruby_version = "~> 2.0"
|
24
|
+
|
25
|
+
s.add_dependency 'rails'
|
26
|
+
|
27
|
+
# s.add_development_dependency('', '')
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-adsense-helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jianqiu Xiao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Thanks to ihaveu.com team.
|
28
|
+
email:
|
29
|
+
- swordray@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- lib/action_view/helpers/adsense_helper.rb
|
40
|
+
- lib/rails-adsense-helper.rb
|
41
|
+
- lib/rails-adsense-helper/version.rb
|
42
|
+
- rails-adsense-helper.gemspec
|
43
|
+
homepage: https://github.com/swordray/rails-adsense-helper
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.2.2
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: ActionView Helper for Google Adsense Content.
|
67
|
+
test_files: []
|