itunes-affiliate-link 1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
|
|
1
|
+
module ItunesAffiliate
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../../../templates/', __FILE__)
|
5
|
+
|
6
|
+
def copy_initializer_file
|
7
|
+
copy_file 'itunes_affiliate_link.rb', "config/initializers/itunes_affiliate_link.rb"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'itunes_affiliate_link/configuration'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module ItunesAffiliateLink
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_accessor :config
|
8
|
+
|
9
|
+
# Sets configuration parameters.
|
10
|
+
def configure
|
11
|
+
yield(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns a singleton configuration object
|
15
|
+
def config
|
16
|
+
unless @config
|
17
|
+
@config = Configuration.new
|
18
|
+
@config.reset
|
19
|
+
end
|
20
|
+
@config
|
21
|
+
end
|
22
|
+
|
23
|
+
# Creates iTunes affiliate link, takes optional campaign token
|
24
|
+
def create_link(url, campaign_token=nil)
|
25
|
+
uri = URI.parse(url)
|
26
|
+
uri.query = [uri.query, "at=#{ItunesAffiliateLink.config.affiliate_token}"].compact.join('&')
|
27
|
+
unless campaign_token.nil?
|
28
|
+
uri.query = [uri.query, "ct=#{campaign_token}"].compact.join('&')
|
29
|
+
end
|
30
|
+
return uri.to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ItunesAffiliateLink
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
VALID_OPTION_KEYS = [ :affiliate_token ]
|
5
|
+
DEFAULT_AFFILIATE_TOKEN = ''
|
6
|
+
|
7
|
+
attr_accessor :affiliate_token
|
8
|
+
|
9
|
+
def self.extended(base)
|
10
|
+
base.reset
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure
|
14
|
+
yield self
|
15
|
+
end
|
16
|
+
|
17
|
+
def options
|
18
|
+
options = {}
|
19
|
+
VALID_OPTIONS_KEYS.each { |k| options[k] = send [k] }
|
20
|
+
options
|
21
|
+
end
|
22
|
+
|
23
|
+
def reset
|
24
|
+
self.affiliate_token = DEFAULT_AFFILIATE_TOKEN
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itunes-affiliate-link
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Korhonen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-25 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A simple gem to automate creation of PHG iTunes affiliate links.
|
15
|
+
email: ckorhonen@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/itunes-affiliate-link.rb
|
21
|
+
- lib/itunes_affiliate_link/configuration.rb
|
22
|
+
- lib/generators/itunes_affiliate_link/install/install-generator.rb
|
23
|
+
- lib/generators/templates/itunes_affiliate_link.rb
|
24
|
+
homepage: http://github.com/ckorhonen/itunes-affiliate
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.8.24
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: ITunes affiliate link generator.
|
49
|
+
test_files: []
|