itunes-affiliate 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +9 -6
- data/lib/itunes-affiliate.rb +5 -0
- data/lib/itunes_affiliate/itunes_link.rb +5 -0
- data/lib/itunes_affiliate/version.rb +1 -1
- data/spec/itunes_link_spec.rb +46 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -16,12 +16,12 @@ gem 'itunes-affiliate'
|
|
16
16
|
## Configure
|
17
17
|
Create an initializer if you use rails in config/initializers named itunes_affiliate.rb and add the following code snippet with your keys. If a key is not present it will be ignored.
|
18
18
|
|
19
|
-
ItunesAffiliate.configure do |config|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
ItunesAffiliate.configure do |config|
|
20
|
+
config.linkshare_key = '<LINKSHARE_KEY>'
|
21
|
+
config.linkshare_japan_key = '<LINKSHARE_JAPAN_KEY>'
|
22
|
+
config.tradedoubler_key = '<TRADEDOUBLE_KEY>'
|
23
|
+
config.dgm_key = '<DGM_KEY>'
|
24
|
+
end
|
25
25
|
|
26
26
|
## Use
|
27
27
|
A more detailed description can be found at <http://rubydoc.info/gems/itunes-affiliate>.
|
@@ -47,6 +47,9 @@ rake install
|
|
47
47
|
rake release
|
48
48
|
## Release Notes
|
49
49
|
|
50
|
+
### 0.0.2
|
51
|
+
* Added affiliate_link to ItunesAffiliate as class method.
|
52
|
+
|
50
53
|
### 0.0.1
|
51
54
|
* First version
|
52
55
|
|
data/lib/itunes-affiliate.rb
CHANGED
data/spec/itunes_link_spec.rb
CHANGED
@@ -94,7 +94,52 @@ describe ItunesAffiliate::ItunesLink do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
context "when converting through the class method" do
|
98
|
+
before(:each) do
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should pass nil values along" do
|
102
|
+
res = ItunesAffiliate.affiliate_link(nil,:linkshare)
|
103
|
+
res.should be_nil
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should pass empty values along" do
|
107
|
+
res = ItunesAffiliate.affiliate_link('',:linkshare)
|
108
|
+
res.should == ''
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should pass random urls along" do
|
112
|
+
res = ItunesAffiliate.affiliate_link("http://latimes.com",:linkshare)
|
113
|
+
res.should == "http://latimes.com"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should convert itunes urls" do
|
117
|
+
params = link_to_hash ItunesAffiliate.affiliate_link(RawLinkWithoutQuestionMark,:linkshare)
|
118
|
+
params['siteID'].should == LinkShareAffiliateCode
|
119
|
+
params['partnerId'].should == '30'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "testing urls" do
|
124
|
+
it "should recognize nil as not an itunes url" do
|
125
|
+
ItunesAffiliate::ItunesLink.is_valid_link?(nil).should be(false)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should recognize empty as not an itunes url" do
|
129
|
+
ItunesAffiliate::ItunesLink.is_valid_link?("").should be(false)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should recognize http://latimes.com as not an itunes url" do
|
133
|
+
ItunesAffiliate::ItunesLink.is_valid_link?("http://latimes.com").should be(false)
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
it "should recognize a valid itunes url." do
|
138
|
+
ItunesAffiliate::ItunesLink.is_valid_link?(RawLinkWithoutQuestionMark).should be(true)
|
139
|
+
ItunesAffiliate::ItunesLink.is_valid_link?(RawLinkWithQuestionMark).should be(true)
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
98
143
|
# Missing specs:
|
99
144
|
# Must raise ArgumentException if invalid affiliate link
|
100
145
|
# Must raise ArgumentException if no link is passed
|