app_store_pricing_matrix 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -4
- data/Gemfile.lock +5 -9
- data/README.rdoc +6 -18
- data/Rakefile +1 -41
- data/VERSION +1 -1
- data/app_store_pricing_matrix.gemspec +16 -15
- data/lib/app_store_pricing_matrix.rb +16 -3
- data/lib/prices/aud +31 -31
- data/lib/prices/aud_pro +31 -31
- data/lib/prices/chf +49 -49
- data/lib/prices/chf_pro +86 -0
- data/lib/prices/gbp +24 -24
- data/lib/prices/gbp_pro +24 -24
- data/lib/prices/jpy +31 -31
- data/lib/prices/jpy_pro +31 -31
- data/lib/prices/mxn +33 -33
- data/lib/prices/mxn_pro +86 -0
- data/lib/prices/nok +75 -75
- data/lib/prices/nok_pro +86 -0
- data/lib/prices/nzd_pro +86 -0
- data/spec/app_store_pricing_matrix_spec.rb +25 -0
- metadata +14 -20
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
diff-lcs (1.1.2)
|
4
|
+
diff-lcs (1.1.3)
|
6
5
|
git (1.2.5)
|
7
|
-
jeweler (1.6.
|
6
|
+
jeweler (1.6.4)
|
8
7
|
bundler (~> 1.0)
|
9
8
|
git (>= 1.2.5)
|
10
9
|
rake
|
11
|
-
pdf-reader (0.9.2)
|
12
|
-
Ascii85 (>= 0.9)
|
13
10
|
rake (0.9.2)
|
14
11
|
rspec (2.6.0)
|
15
12
|
rspec-core (~> 2.6.0)
|
@@ -24,7 +21,6 @@ PLATFORMS
|
|
24
21
|
ruby
|
25
22
|
|
26
23
|
DEPENDENCIES
|
27
|
-
bundler
|
28
|
-
jeweler
|
29
|
-
|
30
|
-
rspec (~> 2.6.0)
|
24
|
+
bundler
|
25
|
+
jeweler
|
26
|
+
rspec
|
data/README.rdoc
CHANGED
@@ -17,10 +17,10 @@ That will give you the currency string like "USD" or "EUR", and this library exp
|
|
17
17
|
Some constants, useful for validation:
|
18
18
|
|
19
19
|
AppStorePricingMatrix::CUSTOMER_CURRENCIES
|
20
|
-
=> ["USD", "
|
20
|
+
=> ["USD", "CAD", "MXN", "AUD", "NZD", "JPY", "EUR", "DKK", "SEK", "CHF", "NOK", "GBP"]
|
21
21
|
|
22
22
|
AppStorePricingMatrix::DEVELOPER_CURRENCIES
|
23
|
-
=> ["USD", "CAD", "AUD", "JPY", "EUR", "GBP"]
|
23
|
+
=> ["USD", "CAD", "MXN", "AUD", "NZD", "JPY", "EUR", "CHF", "NOK", "GBP"]
|
24
24
|
|
25
25
|
To retrieve a customer price, query with the currency and the tier number:
|
26
26
|
|
@@ -28,29 +28,17 @@ To retrieve a customer price, query with the currency and the tier number:
|
|
28
28
|
=> "0.99"
|
29
29
|
|
30
30
|
AppStorePricingMatrix::CUSTOMER_PRICES['JPY'][1]
|
31
|
-
=> "
|
31
|
+
=> "85"
|
32
32
|
|
33
33
|
For developer proceeds:
|
34
34
|
|
35
35
|
AppStorePricingMatrix::DEVELOPER_PROCEEDS['GBP'][30]
|
36
|
-
=> "
|
36
|
+
=> "12.78"
|
37
37
|
|
38
38
|
To retrieve a developer currency from a given customer currency:
|
39
39
|
|
40
|
-
AppStorePricingMatrix::REVERSE_CURRENCY_MAP['
|
41
|
-
=> "
|
40
|
+
AppStorePricingMatrix::REVERSE_CURRENCY_MAP['SEK']
|
41
|
+
=> "EUR"
|
42
42
|
|
43
43
|
AppStorePricingMatrix::REVERSE_CURRENCY_MAP['DKK']
|
44
44
|
=> "EUR"
|
45
|
-
|
46
|
-
== Updating the price table
|
47
|
-
|
48
|
-
The price table was generated by parsing the exhibit C part of the paid app contract PDF file. As of June 10, 2011, it was versioned as v8.
|
49
|
-
|
50
|
-
However Apple haven't changed it much so far, it's reasonable to expect changes in the future. When that happens, strip the PDF down to 2 pages only containing the price table, rename it to "input.pdf", put it in the project root, then run the following rake task.
|
51
|
-
|
52
|
-
rake aspm:generate
|
53
|
-
|
54
|
-
Then run the spec to verify the generated content:
|
55
|
-
|
56
|
-
rake
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.summary = "Constants for App Store Pricing Matrix"
|
19
19
|
gem.description = "A simple module that holds currencies and prices from the Apple's iOS App Store."
|
20
20
|
gem.email = "kenn.ejima@gmail.com"
|
21
|
-
gem.authors = ["Kenn Ejima"]
|
21
|
+
gem.authors = ["Kenn Ejima", "Elliot Bowes"]
|
22
22
|
end
|
23
23
|
Jeweler::RubygemsDotOrgTasks.new
|
24
24
|
|
@@ -29,43 +29,3 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
29
29
|
end
|
30
30
|
|
31
31
|
task :default => :spec
|
32
|
-
|
33
|
-
namespace :aspm do
|
34
|
-
desc "Parse PDF and generate files"
|
35
|
-
task :generate do
|
36
|
-
require 'pdf-reader'
|
37
|
-
|
38
|
-
receiver = PDF::Reader::RegisterReceiver.new
|
39
|
-
pdf = PDF::Reader.file("input.pdf", receiver)
|
40
|
-
|
41
|
-
targets = receiver.callbacks.select{|callback| callback[:name] == :show_text }[17..-1].map{|i| i[:args].first }
|
42
|
-
split_at = 11*86-1
|
43
|
-
|
44
|
-
page1_headers = [ :tier, :usd, :mxn, :usd_pro, :cad, :cad_pro, :aud, :nzd, :aud_pro, :jpy, :jpy_pro ]
|
45
|
-
page2_headers = [ :tier, :eur, :dkk, :nok, :sek, :chf, :eur_pro, :gbp, :gbp_pro ]
|
46
|
-
|
47
|
-
# Page 1 of Exhibit C
|
48
|
-
page1 = Hash.new{|h,k| h[k] = Array.new }.tap do |hash|
|
49
|
-
targets.each_with_index do |v,i|
|
50
|
-
next if i > split_at
|
51
|
-
key = page1_headers[i % 11]
|
52
|
-
hash[key.to_s] << v unless key == :tier
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
targets = targets[split_at+22..-1]
|
57
|
-
|
58
|
-
# Page 2 of Exhibit C
|
59
|
-
page2 = Hash.new{|h,k| h[k] = Array.new }.tap do |hash|
|
60
|
-
targets.each_with_index do |v,i|
|
61
|
-
key = page2_headers[i % 9]
|
62
|
-
hash[key.to_s] << v unless key == :tier
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
whole = page1.merge(page2)
|
67
|
-
whole.keys.each do |key|
|
68
|
-
File.open("lib/prices/#{key}", 'w') {|file| file.write whole[key].join("\n") }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{app_store_pricing_matrix}
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Kenn Ejima"]
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = ["Kenn Ejima", "Elliot Bowes"]
|
12
|
+
s.date = %q{2011-09-26}
|
13
13
|
s.description = %q{A simple module that holds currencies and prices from the Apple's iOS App Store.}
|
14
14
|
s.email = %q{kenn.ejima@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/prices/cad",
|
33
33
|
"lib/prices/cad_pro",
|
34
34
|
"lib/prices/chf",
|
35
|
+
"lib/prices/chf_pro",
|
35
36
|
"lib/prices/dkk",
|
36
37
|
"lib/prices/eur",
|
37
38
|
"lib/prices/eur_pro",
|
@@ -40,8 +41,11 @@ Gem::Specification.new do |s|
|
|
40
41
|
"lib/prices/jpy",
|
41
42
|
"lib/prices/jpy_pro",
|
42
43
|
"lib/prices/mxn",
|
44
|
+
"lib/prices/mxn_pro",
|
43
45
|
"lib/prices/nok",
|
46
|
+
"lib/prices/nok_pro",
|
44
47
|
"lib/prices/nzd",
|
48
|
+
"lib/prices/nzd_pro",
|
45
49
|
"lib/prices/sek",
|
46
50
|
"lib/prices/usd",
|
47
51
|
"lib/prices/usd_pro",
|
@@ -58,21 +62,18 @@ Gem::Specification.new do |s|
|
|
58
62
|
s.specification_version = 3
|
59
63
|
|
60
64
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
|
-
s.add_development_dependency(%q<rspec>, ["
|
62
|
-
s.add_development_dependency(%q<bundler>, ["
|
63
|
-
s.add_development_dependency(%q<jeweler>, ["
|
64
|
-
s.add_development_dependency(%q<pdf-reader>, [">= 0.9.1"])
|
65
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
65
68
|
else
|
66
|
-
s.add_dependency(%q<rspec>, ["
|
67
|
-
s.add_dependency(%q<bundler>, ["
|
68
|
-
s.add_dependency(%q<jeweler>, ["
|
69
|
-
s.add_dependency(%q<pdf-reader>, [">= 0.9.1"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
71
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
70
72
|
end
|
71
73
|
else
|
72
|
-
s.add_dependency(%q<rspec>, ["
|
73
|
-
s.add_dependency(%q<bundler>, ["
|
74
|
-
s.add_dependency(%q<jeweler>, ["
|
75
|
-
s.add_dependency(%q<pdf-reader>, [">= 0.9.1"])
|
74
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
75
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
76
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
@@ -1,12 +1,18 @@
|
|
1
1
|
module AppStorePricingMatrix
|
2
2
|
CURRENCY_MAP = {
|
3
|
-
:usd => [ :usd
|
3
|
+
:usd => [ :usd ].freeze,
|
4
4
|
:cad => [ :cad ].freeze,
|
5
|
-
:
|
5
|
+
:mxn => [ :mxn ].freeze,
|
6
|
+
:aud => [ :aud ].freeze,
|
7
|
+
:nzd => [ :nzd ].freeze,
|
6
8
|
:jpy => [ :jpy ].freeze,
|
7
|
-
:eur => [ :eur, :dkk, :
|
9
|
+
:eur => [ :eur, :dkk, :sek ].freeze,
|
10
|
+
:chf => [ :chf ].freeze,
|
11
|
+
:nok => [ :nok ].freeze,
|
8
12
|
:gbp => [ :gbp ].freeze
|
9
13
|
}.freeze
|
14
|
+
|
15
|
+
EURO_CURRENCIES = [ :bgn , :czk , :eek , :huf , :lvl , :ltl , :mtl , :pln , :ron ].map {|i| i.to_s.upcase }.freeze
|
10
16
|
CUSTOMER_CURRENCIES = CURRENCY_MAP.values.flatten.map{|i| i.to_s.upcase }.freeze
|
11
17
|
DEVELOPER_CURRENCIES = CURRENCY_MAP.keys.map{|i| i.to_s.upcase }.freeze
|
12
18
|
|
@@ -29,4 +35,11 @@ module AppStorePricingMatrix
|
|
29
35
|
hash[key] = File.read("#{File.dirname(__FILE__)}/prices/#{key.downcase}_pro").split("\n").freeze
|
30
36
|
end
|
31
37
|
end.freeze
|
38
|
+
|
39
|
+
def self.customer_currency_for(currency_code)
|
40
|
+
code = currency_code.to_s.upcase
|
41
|
+
return code if AppStorePricingMatrix::CUSTOMER_CURRENCIES.include? code
|
42
|
+
return "EUR" if AppStorePricingMatrix::EURO_CURRENCIES.include? code
|
43
|
+
return nil
|
44
|
+
end
|
32
45
|
end
|
data/lib/prices/aud
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
0.00
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
4.
|
6
|
-
5.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
0.99
|
3
|
+
1.99
|
4
|
+
2.99
|
5
|
+
4.49
|
6
|
+
5.49
|
7
|
+
6.49
|
8
|
+
7.49
|
9
|
+
8.49
|
10
|
+
9.49
|
11
|
+
10.49
|
12
|
+
11.49
|
11
13
|
12.99
|
12
14
|
13.99
|
13
15
|
14.99
|
@@ -16,22 +18,26 @@
|
|
16
18
|
17.99
|
17
19
|
18.99
|
18
20
|
19.99
|
21
|
+
20.99
|
19
22
|
21.99
|
20
23
|
22.99
|
21
24
|
23.99
|
22
25
|
24.99
|
26
|
+
25.99
|
23
27
|
26.99
|
24
28
|
27.99
|
25
|
-
28.99
|
26
29
|
29.99
|
30
|
+
30.99
|
27
31
|
31.99
|
28
32
|
32.99
|
29
33
|
33.99
|
30
34
|
34.99
|
35
|
+
35.99
|
31
36
|
36.99
|
32
37
|
37.99
|
33
38
|
38.99
|
34
39
|
39.99
|
40
|
+
40.99
|
35
41
|
41.99
|
36
42
|
42.99
|
37
43
|
43.99
|
@@ -41,46 +47,40 @@
|
|
41
47
|
47.99
|
42
48
|
48.99
|
43
49
|
49.99
|
50
|
+
50.99
|
44
51
|
51.99
|
45
|
-
52.99
|
46
|
-
53.99
|
47
|
-
54.99
|
48
|
-
56.99
|
49
|
-
57.99
|
50
|
-
58.99
|
51
52
|
59.99
|
53
|
+
64.99
|
52
54
|
69.99
|
53
55
|
74.99
|
54
56
|
79.99
|
57
|
+
84.99
|
55
58
|
89.99
|
56
59
|
94.99
|
57
60
|
99.99
|
58
|
-
104.99
|
59
61
|
109.99
|
60
|
-
114.99
|
61
62
|
119.99
|
63
|
+
129.99
|
62
64
|
139.99
|
63
65
|
149.99
|
64
66
|
159.99
|
65
67
|
169.99
|
68
|
+
179.99
|
66
69
|
189.99
|
67
70
|
199.99
|
71
|
+
209.99
|
68
72
|
219.99
|
69
73
|
229.99
|
70
74
|
239.99
|
71
75
|
249.99
|
72
|
-
259.99
|
73
76
|
269.99
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
349.99
|
78
|
-
399.99
|
79
|
-
449.99
|
77
|
+
319.99
|
78
|
+
379.99
|
79
|
+
429.99
|
80
80
|
499.99
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
549.99
|
82
|
+
649.99
|
83
|
+
749.99
|
84
|
+
849.99
|
85
|
+
949.99
|
86
|
+
1049.99
|
data/lib/prices/aud_pro
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
0.00
|
2
|
-
0.
|
3
|
-
1.
|
4
|
-
|
5
|
-
|
6
|
-
3.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
0.63
|
3
|
+
1.27
|
4
|
+
1.90
|
5
|
+
2.86
|
6
|
+
3.49
|
7
|
+
4.13
|
8
|
+
4.77
|
9
|
+
5.40
|
10
|
+
6.04
|
11
|
+
6.68
|
12
|
+
7.31
|
11
13
|
8.27
|
12
14
|
8.90
|
13
15
|
9.54
|
@@ -16,22 +18,26 @@
|
|
16
18
|
11.45
|
17
19
|
12.08
|
18
20
|
12.72
|
21
|
+
13.36
|
19
22
|
13.99
|
20
23
|
14.63
|
21
24
|
15.27
|
22
25
|
15.90
|
26
|
+
16.54
|
23
27
|
17.18
|
24
28
|
17.81
|
25
|
-
18.45
|
26
29
|
19.08
|
30
|
+
19.72
|
27
31
|
20.36
|
28
32
|
20.99
|
29
33
|
21.63
|
30
34
|
22.27
|
35
|
+
22.90
|
31
36
|
23.54
|
32
37
|
24.18
|
33
38
|
24.81
|
34
39
|
25.45
|
40
|
+
26.08
|
35
41
|
26.72
|
36
42
|
27.36
|
37
43
|
27.99
|
@@ -41,46 +47,40 @@
|
|
41
47
|
30.54
|
42
48
|
31.18
|
43
49
|
31.81
|
50
|
+
32.45
|
44
51
|
33.08
|
45
|
-
33.72
|
46
|
-
34.36
|
47
|
-
34.99
|
48
|
-
36.27
|
49
|
-
36.90
|
50
|
-
37.54
|
51
52
|
38.18
|
53
|
+
41.36
|
52
54
|
44.54
|
53
55
|
47.72
|
54
56
|
50.90
|
57
|
+
54.08
|
55
58
|
57.27
|
56
59
|
60.45
|
57
60
|
63.63
|
58
|
-
66.81
|
59
61
|
69.99
|
60
|
-
73.18
|
61
62
|
76.36
|
63
|
+
82.72
|
62
64
|
89.08
|
63
65
|
95.45
|
64
66
|
101.81
|
65
67
|
108.18
|
68
|
+
114.54
|
66
69
|
120.90
|
67
70
|
127.27
|
71
|
+
133.63
|
68
72
|
139.99
|
69
73
|
146.36
|
70
74
|
152.72
|
71
75
|
159.08
|
72
|
-
165.45
|
73
76
|
171.81
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
222.72
|
78
|
-
254.54
|
79
|
-
286.36
|
77
|
+
203.63
|
78
|
+
241.81
|
79
|
+
273.63
|
80
80
|
318.18
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
349.99
|
82
|
+
413.63
|
83
|
+
477.27
|
84
|
+
540.90
|
85
|
+
604.54
|
86
|
+
668.18
|