adsense_helper 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 749d7d4e47cb9c88f68ef09d268dd50a509621fa
4
+ data.tar.gz: 226d48de21d4e43c54f73ae6255f4c4210adc8a2
5
+ SHA512:
6
+ metadata.gz: 40797bf11cb26302f2ec2b80297f2c9451cd7546a0ff54e71abf23e20329cb62dda2528ecdc4645fc789778cc14e8b0971c57a3c635b6040f0cb954ba15db35d
7
+ data.tar.gz: c8f21f131b53810015fb807b5dfead7823a12fd6f68ae2d071907ba808ab5f52a46997931dfd6f0e0eed82728776019ad69d339dfde8bb1bec66c7a07e851b0f
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - 2
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
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,31 @@
1
+ # adsense_helper
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/adsense_helper.png)](http://badge.fury.io/rb/adsense_helper) [![Build Status](https://secure.travis-ci.org/swordray/adsense_helper.png?branch=master)](http://travis-ci.org/swordray/adsense_helper) [![Dependency Status](https://gemnasium.com/swordray/adsense_helper.png?travis)](https://gemnasium.com/swordray/adsense_helper) [![Code Climate](https://codeclimate.com/github/swordray/adsense_helper.png)](https://codeclimate.com/github/swordray/adsense_helper)
4
+
5
+ Helper for Google Adsense Content
6
+
7
+ ## Requirements
8
+
9
+ * Ruby ~> 2.0
10
+
11
+ ## Installation
12
+
13
+ Include the gem in your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'adsense_helper'
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ adsense_tag(client: 0000000000000000, slot: 1111111111, dimension: '336x280')
23
+ ```
24
+
25
+ ## Credits
26
+
27
+ * swordray @[ihaveu](http://www.ihaveu.com/home) @[shuhai](http://tw.shuhai.org/) @[leaf](http://leaf.iacger.com)
28
+
29
+ ## License
30
+
31
+ Copyright © 2014 Jianqiu Xiao <swordray@gmail.com> under The [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ task :default do |t|
2
+ `gem build adsense_helper.gemspec`
3
+ end
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
+ require 'adsense_helper/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "adsense_helper"
6
+ s.version = AdsenseHelper::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/adsense_helper"
11
+ s.summary = "Helper for Google Adsense Content"
12
+ s.description = "An elegant way to write Google Adsense Code."
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.required_ruby_version = "~> 2.0"
21
+ end
@@ -0,0 +1,40 @@
1
+ # = Google Adsense Helper
2
+ module AdsenseHelper
3
+ # Parameters:
4
+ #
5
+ # client :: 16 digits
6
+ # slot :: 10 digits
7
+ # dimension :: "#{width}x#{height}", default is 336x280
8
+ #
9
+ # Example:
10
+ #
11
+ # adsense_tag(client: 0000000000000000, slot: 1111111111, dimension: '336x280')
12
+ #
13
+ # Generated code:
14
+ #
15
+ # <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
16
+ # <ins class="adsbygoogle"
17
+ # style="display:inline-block;width:336px;height:280px"
18
+ # data-ad-client="ca-pub-0000000000000000"
19
+ # data-ad-slot="1111111111"></ins>
20
+ # <script>
21
+ # (adsbygoogle = window.adsbygoogle || []).push({});
22
+ # </script>
23
+ #
24
+ def adsense_tag(options = {})
25
+ defaults = { dimension: '336x280' }
26
+ options = options.to_h.reverse_merge(defaults).with_indifferent_access
27
+ width, height = options[:dimension].split('x').to_a
28
+
29
+ raise 'Invalid ad client, should be 16 digits' unless options[:client].to_s[/^\d{16}$/]
30
+ raise 'Invalid ad slot, should be 10 digits' unless options[:slot].to_s[/^\d{10}$/]
31
+ raise 'Invalid ad dimension, should be "#{width}x#{height}"' unless width.to_s[/^\d+$/] && height.to_s[/^\d+$/]
32
+
33
+ tags = [
34
+ content_tag('script', '', async: '', src: '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'),
35
+ 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]),
36
+ content_tag('script', '(adsbygoogle = window.adsbygoogle || []).push({});'),
37
+ ]
38
+ safe_join(tags)
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ require 'adsense_helper'
2
+
3
+ ActionView::Base.send :include, AdsenseHelper if defined? Rails
@@ -0,0 +1,3 @@
1
+ module AdsenseHelper #:nodoc:
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,2 @@
1
+ require "adsense_helper/adsense_helper"
2
+ require "adsense_helper/railtie"
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: 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-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: An elegant way to write Google Adsense Code.
14
+ email:
15
+ - swordray@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".travis.yml"
22
+ - CHANGELOG.md
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - adsense_helper.gemspec
28
+ - lib/adsense_helper.rb
29
+ - lib/adsense_helper/adsense_helper.rb
30
+ - lib/adsense_helper/railtie.rb
31
+ - lib/adsense_helper/version.rb
32
+ homepage: https://github.com/swordray/adsense_helper
33
+ licenses:
34
+ - MIT
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '2.0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.2.2
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Helper for Google Adsense Content
56
+ test_files: []