smart-app-banner 0.0.1

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: f8bd3811e5ac568dca15971f6df9ea9d20b33500
4
+ data.tar.gz: e15154f81aca0f4e0f58b3e01550501caa6b7ec8
5
+ SHA512:
6
+ metadata.gz: 43d5c318363c1bdc0e62dd3c09ca7fd91029163335d0e469334bcdf7ca425ad2184748f0cd24f6c621d7ffb2dbbe2a658905f806ac59354569605bfb453b8876
7
+ data.tar.gz: cbbc8c8df079b976b18a5d5b491047f2d934a5d16d446ee7ff09018f0ba9d60dbd3142860b1f98e64d05a758733e4066c3739d606b38f3b3ad7d444db3168b7b
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.un~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rake'
3
+
4
+ # Specify your gem's dependencies in smart-app-banner.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kristian Freeman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Smart App Banner
2
+
3
+ `smart-app-banner` is a Rails helper for providing [Smart App Banners](apple)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'smart-app-banner'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install smart-app-banner
18
+
19
+ ## Usage
20
+
21
+ `smart-app-banner` uses a text tag, which means it can be easily integrated into any Rails view.
22
+
23
+ ```erb
24
+ <%= smart_app_banner(app_id) %>
25
+ ```
26
+
27
+ As per Apple's guidelines, there are two optional arguments:
28
+
29
+ ```erb
30
+ <%= smart_app_banner(app_id, { affiliate-data: "imkmf", app-argument: "from-website" } %>
31
+ ```
32
+
33
+ You can read more about these [here](apple).
34
+
35
+ ## Contributing
36
+
37
+ Pull requests always welcome!
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
44
+
45
+ [apple]: https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new('spec')
4
+
5
+ # If you want to make this the default task
6
+ task :default => :spec
@@ -0,0 +1,20 @@
1
+ require "smart-app-banner/helper"
2
+ require "smart-app-banner/version"
3
+
4
+ module Rails
5
+ module SmartAppBanner
6
+ if defined?(::Rails::Engine)
7
+ class Engine < ::Rails::Engine
8
+ initializer 'smart-app-banner', group: :all do |app|
9
+ ActiveSupport.on_load(:action_controller) do
10
+ include Rails::SmartAppBanner::Helper
11
+ end
12
+
13
+ ActiveSupport.on_load(:action_view) do
14
+ include Rails::SmartAppBanner::Helper
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ module Rails
2
+ module SmartAppBanner
3
+ module Helper
4
+ def smart_app_banner(id, options = {})
5
+ unless id
6
+ raise AppIDNotDefined
7
+ end
8
+
9
+ app_id = "app-id=#{ id }"
10
+
11
+ if options[:affiliate_data].nil?
12
+ affiliate_data = nil
13
+ else
14
+ affiliate_data = "affiliate-data=#{ options[:affiliate_data] }"
15
+ end
16
+
17
+ if options[:app_argument].nil?
18
+ app_argument = nil
19
+ else
20
+ app_argument = "app-argument=#{ options[:app_argument] }"
21
+ end
22
+
23
+ metadata = [app_id, affiliate_data, app_argument].
24
+ delete_if(&:nil?).
25
+ join(', ')
26
+
27
+ output = "<meta name=\"apple-itunes-app\" content=\"#{ metadata }\">"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module SmartAppBanner
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'smart-app-banner/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "smart-app-banner"
8
+ gem.version = SmartAppBanner::VERSION
9
+ gem.authors = ["Kristian Freeman"]
10
+ gem.email = ["kristian@kristianfreeman.com"]
11
+ gem.description = %q{A Rails helper for including iTunes app 'Smart App Banners'}
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://kristianfreeman.com"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rails::SmartAppBanner::Helper do
4
+ let(:banner_helper) { SmartAppBannerHelperStub.new }
5
+ let(:id) { "389801252" }
6
+
7
+ it "should return a correct tag with an app id" do
8
+ output = "<meta name=\"apple-itunes-app\" content=\"app-id=389801252\">"
9
+ expect(banner_helper.smart_app_banner(id)).to eq(output)
10
+ end
11
+
12
+ it "should allow arguments" do
13
+ output = "<meta name=\"apple-itunes-app\" content=\"app-id=389801252, affiliate-data=foobar\">"
14
+ input = banner_helper.smart_app_banner(id, { affiliate_data: 'foobar' })
15
+ expect(input).to eq(output)
16
+ end
17
+
18
+ it "should fail without an id" do
19
+ expect {
20
+ banner_helper.smart_app_banner(nil)
21
+ }.to raise_error
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'smart-app-banner'
4
+ require 'stub'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+ end
data/spec/stub.rb ADDED
@@ -0,0 +1,29 @@
1
+ class SmartAppBannerHelperStub
2
+ include Rails::SmartAppBanner::Helper
3
+
4
+ def smart_app_banner(id, options = {})
5
+ unless id
6
+ raise AppIDNotDefined
7
+ end
8
+
9
+ app_id = "app-id=#{ id }"
10
+
11
+ if options[:affiliate_data].nil?
12
+ affiliate_data = nil
13
+ else
14
+ affiliate_data = "affiliate-data=#{ options[:affiliate_data] }"
15
+ end
16
+
17
+ if options[:app_argument].nil?
18
+ app_argument = nil
19
+ else
20
+ app_argument = "app-argument=#{ options[:app_argument] }"
21
+ end
22
+
23
+ metadata = [app_id, affiliate_data, app_argument].
24
+ delete_if(&:nil?).
25
+ join(', ')
26
+
27
+ output = "<meta name=\"apple-itunes-app\" content=\"#{ metadata }\">"
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smart-app-banner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Freeman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A Rails helper for including iTunes app 'Smart App Banners'
28
+ email:
29
+ - kristian@kristianfreeman.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .rspec
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - lib/smart-app-banner.rb
41
+ - lib/smart-app-banner/helper.rb
42
+ - lib/smart-app-banner/version.rb
43
+ - smart-app-banner.gemspec
44
+ - spec/smart_app_banner_spec.rb
45
+ - spec/spec_helper.rb
46
+ - spec/stub.rb
47
+ homepage: https://kristianfreeman.com
48
+ licenses: []
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.0.3
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: A Rails helper for including iTunes app 'Smart App Banners'
70
+ test_files:
71
+ - spec/smart_app_banner_spec.rb
72
+ - spec/spec_helper.rb
73
+ - spec/stub.rb