parseitc 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/Changelog +3 -0
  2. data/LICENSE +19 -0
  3. data/README +59 -0
  4. data/demo.rb +18 -0
  5. data/demo1.txt +54 -0
  6. data/demo2.txt +56 -0
  7. data/lib/parseitc.rb +109 -0
  8. metadata +61 -0
data/Changelog ADDED
@@ -0,0 +1,3 @@
1
+ Sun 2010-01-31 - v0.1
2
+ - Started project
3
+ - Parse fields and count by them
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 Hwan-Joon Choi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,59 @@
1
+ parseitc
2
+ by Hwan-Joon Choi
3
+ http://www.choibean.com/parseitc
4
+
5
+ == DESCRIPTION:
6
+
7
+ parseitc is a Ruby gem written to parse iPhone app transaction reports from
8
+ iTunes Connect. The
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ Parsing of standard Sales/Trend Report tsv files from https://itts.apple.com/
13
+ Allows ruby applications as well as Bash Init scripts to use the same config.
14
+
15
+ == SYNOPSIS:
16
+
17
+ require 'rubygems'
18
+ require 'lib/parseitc'
19
+ include ParseITC
20
+ reports = ParseConfig.new('/path/to/tsv/file1')
21
+ reports.add_file('/path/to/tsv/file2')
22
+ by_country = report.numbers_by_country
23
+ by_country.sort.each {|k, v| puts "#{k}: #{v}"}
24
+ ...
25
+
26
+ == REQUIREMENTS:
27
+
28
+ * Ruby (Developed on 1.8.7)
29
+ * RubyGems
30
+
31
+ == INSTALL:
32
+
33
+ sudo gem install parseitc
34
+
35
+ == TODO:
36
+
37
+ parse monthly and weekly reports
38
+
39
+ == LICENSE:
40
+
41
+ Copyright (c) 2010 Hwan-Joon Choi
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining a copy
44
+ of this software and associated documentation files (the "Software"), to deal
45
+ in the Software without restriction, including without limitation the rights
46
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
47
+ copies of the Software, and to permit persons to whom the Software is
48
+ furnished to do so, subject to the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be included in
51
+ all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
56
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
59
+ THE SOFTWARE.
data/demo.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'lib/parseitc'
3
+ include ParseITC
4
+
5
+ begin
6
+ report = TrasactionParser.new('demo1.txt')
7
+ report.add_file('demo2.txt')
8
+ by_country = report.numbers_by_country
9
+ by_country.sort.each {|k, v| puts "#{k}: #{v}"}
10
+ by_date = report.numbers_by_date
11
+ by_date.sort.each {|k, v| puts "#{k}: #{v}"}
12
+ by_royalty_currency = report.numbers_by_price_tier
13
+ by_royalty_currency.sort.each {|k, v| puts "#{k}: #{v}"}
14
+ rescue Errno::ENOENT
15
+ puts "The data file you specified was not found"
16
+ rescue Errno::EACCES
17
+ puts "The data file you specified is not readable"
18
+ end
data/demo1.txt ADDED
@@ -0,0 +1,54 @@
1
+ Provider Provider Country Vendor Identifier UPC ISRC Artist / Show Title / Episode / Season Label/Studio/Network Product Type Identifier Units Royalty Price Begin Date End Date Customer Currency Country Code Royalty Currency Preorder Season Pass ISAN Apple Identifier Customer Price CMA Asset/Content Flavor Vendor Offer Code Grid Promo Code Parent Identifier
2
+ APPLE US 000000001 Acme Corp Widgets 1 1 0 1/21/10 1/21/10 USD US USD 350525324 0 CR-RW
3
+ APPLE US 000000001 Acme Corp Widgets 1 2 1.4 01/21/2010 01/21/2010 CAD CA CAD 350525324 1.99
4
+ APPLE US 000000000 Acme Corp Sprockets 1 13 0 01/21/2010 01/21/2010 USD HK USD 350523538 0
5
+ APPLE US 000000000 Acme Corp Sprockets 1 11 0 01/21/2010 01/21/2010 USD CN USD 350523538 0
6
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 USD AE USD 350523538 0
7
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 EUR RO EUR 350523538 0
8
+ APPLE US 000000000 Acme Corp Sprockets 1 463 0 01/21/2010 01/21/2010 USD US USD 350523538 0
9
+ APPLE US 000000000 Acme Corp Sprockets 1 4 0 01/21/2010 01/21/2010 EUR LU EUR 350523538 0
10
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 USD CO USD 350523538 0
11
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/21/2010 01/21/2010 USD EC USD 350523538 0
12
+ APPLE US 000000000 Acme Corp Sprockets 1 151 0 01/21/2010 01/21/2010 EUR DE EUR 350523538 0
13
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/21/2010 01/21/2010 EUR IT EUR 350525324 1.59
14
+ APPLE US 000000000 Acme Corp Sprockets 1 34 0 01/21/2010 01/21/2010 EUR NL EUR 350523538 0
15
+ APPLE US 000000000 Acme Corp Sprockets 1 28 0 01/21/2010 01/21/2010 EUR ES EUR 350523538 0
16
+ APPLE US 000000000 Acme Corp Sprockets 1 20 0 01/21/2010 01/21/2010 SEK SE EUR 350523538 0
17
+ APPLE US 000000000 Acme Corp Sprockets 1 12 0 01/21/2010 01/21/2010 NOK NO EUR 350523538 0
18
+ APPLE US 000000000 Acme Corp Sprockets 1 45 0 01/21/2010 01/21/2010 CHF CH EUR 350523538 0
19
+ APPLE US 000000000 Acme Corp Sprockets 1 24 0 01/21/2010 01/21/2010 AUD AU AUD 350523538 0
20
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/21/2010 01/21/2010 USD TW USD 350523538 0
21
+ APPLE US 000000000 Acme Corp Sprockets 1 8 0 01/21/2010 01/21/2010 EUR PL EUR 350523538 0
22
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/21/2010 01/21/2010 EUR HU EUR 350523538 0
23
+ APPLE US 000000000 Acme Corp Sprockets 1 5 0 01/21/2010 01/21/2010 EUR CZ EUR 350523538 0
24
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 EUR SK EUR 350523538 0
25
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 USD AR USD 350523538 0
26
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/21/2010 01/21/2010 EUR FI EUR 350523538 0
27
+ APPLE US 000000000 Acme Corp Sprockets 1 41 0 01/21/2010 01/21/2010 JPY JP JPY 350523538 0
28
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 USD IN USD 350523538 0
29
+ APPLE US 000000000 Acme Corp Sprockets 1 7 0 01/21/2010 01/21/2010 MXN MX USD 350523538 0
30
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 USD TH USD 350523538 0
31
+ APPLE US 000000000 Acme Corp Sprockets 1 9 0 01/21/2010 01/21/2010 USD IL USD 350523538 0
32
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/21/2010 01/21/2010 USD LB USD 350523538 0
33
+ APPLE US 000000000 Acme Corp Sprockets 1 5 0 01/21/2010 01/21/2010 EUR AT EUR 350523538 0
34
+ APPLE US 000000001 Acme Corp Widgets 1 1 1.58 01/21/2010 01/21/2010 NZD NZ AUD 350525324 2.59
35
+ APPLE US 000000000 Acme Corp Sprockets 1 12 0 01/21/2010 01/21/2010 USD RU USD 350523538 0
36
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/21/2010 01/21/2010 USD PK USD 350523538 0
37
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 USD SA USD 350523538 0
38
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 USD HR USD 350523538 0
39
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/21/2010 01/21/2010 USD EG USD 350523538 0
40
+ APPLE US 000000001 Acme Corp Widgets 1 16 1.4 01/21/2010 01/21/2010 USD US USD 350525324 1.99
41
+ APPLE US 000000001 Acme Corp Widgets 1 3 .72 01/21/2010 01/21/2010 GBP GB GBP 350525324 1.19
42
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/21/2010 01/21/2010 EUR PT EUR 350523538 0
43
+ APPLE US 000000000 Acme Corp Sprockets 1 208 0 01/21/2010 01/21/2010 CAD CA CAD 350523538 0
44
+ APPLE US 000000000 Acme Corp Sprockets 1 15 0 01/21/2010 01/21/2010 DKK DK EUR 350523538 0
45
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/21/2010 01/21/2010 NZD NZ AUD 350523538 0
46
+ APPLE US 000000000 Acme Corp Sprockets 1 204 0 01/21/2010 01/21/2010 GBP GB GBP 350523538 0
47
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 EUR IE EUR 350523538 0
48
+ APPLE US 000000000 Acme Corp Sprockets 1 104 0 01/21/2010 01/21/2010 EUR IT EUR 350523538 0
49
+ APPLE US 000000000 Acme Corp Sprockets 1 11 0 01/21/2010 01/21/2010 USD SG USD 350523538 0
50
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/21/2010 01/21/2010 USD KW USD 350523538 0
51
+ APPLE US 000000000 Acme Corp Sprockets 1 230 0 01/21/2010 01/21/2010 EUR FR EUR 350523538 0
52
+ APPLE US 000000000 Acme Corp Sprockets 1 8 0 01/21/2010 01/21/2010 EUR BE EUR 350523538 0
53
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/21/2010 01/21/2010 EUR GR EUR 350523538 0
54
+ APPLE US 000000000 Acme Corp Sprockets 1 9 0 01/21/2010 01/21/2010 USD TR USD 350523538 0
data/demo2.txt ADDED
@@ -0,0 +1,56 @@
1
+ Provider Provider Country Vendor Identifier UPC ISRC Artist / Show Title / Episode / Season Label/Studio/Network Product Type Identifier Units Royalty Price Begin Date End Date Customer Currency Country Code Royalty Currency Preorder Season Pass ISAN Apple Identifier Customer Price CMA Asset/Content Flavor Vendor Offer Code Grid Promo Code Parent Identifier
2
+ APPLE US 000000000 Acme Corp Sprockets 1 205 0 01/23/2010 01/23/2010 USD US USD 350523538 0
3
+ APPLE US 000000001 Acme Corp Widgets 1 4 .36 01/23/2010 01/23/2010 GBP GB GBP 350525324 .59
4
+ APPLE US 000000000 Acme Corp Sprockets 1 82 0 01/23/2010 01/23/2010 EUR IT EUR 350523538 0
5
+ APPLE US 000000000 Acme Corp Sprockets 1 153 0 01/23/2010 01/23/2010 CAD CA CAD 350523538 0
6
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/23/2010 01/23/2010 EUR FR EUR 350525324 1.59
7
+ APPLE US 000000001 Acme Corp Widgets 1 2 .97 01/23/2010 01/23/2010 EUR DE EUR 350525324 1.59
8
+ APPLE US 000000000 Acme Corp Sprockets 1 63 0 01/23/2010 01/23/2010 EUR DE EUR 350523538 0
9
+ APPLE US 000000001 Acme Corp Widgets 1 3 .72 01/23/2010 01/23/2010 GBP GB GBP 350525324 1.19
10
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/23/2010 01/23/2010 EUR PT EUR 350523538 0
11
+ APPLE US 000000001 Acme Corp Widgets 1 8 .7 01/23/2010 01/23/2010 CAD CA CAD 350525324 .99
12
+ APPLE US 000000001 Acme Corp Widgets 1 2 1.4 01/23/2010 01/23/2010 CAD CA CAD 350525324 1.99
13
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/23/2010 01/23/2010 NOK NO EUR 350525324 11
14
+ APPLE US 000000000 Acme Corp Sprockets 1 43 0 01/23/2010 01/23/2010 JPY JP JPY 350523538 0
15
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/23/2010 01/23/2010 USD ID USD 350523538 0
16
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/23/2010 01/23/2010 USD TR USD 350523538 0
17
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/23/2010 01/23/2010 EUR CZ EUR 350523538 0
18
+ APPLE US 000000001 Acme Corp Widgets 1 28 .7 01/23/2010 01/23/2010 USD US USD 350525324 .99
19
+ APPLE US 000000000 Acme Corp Sprockets 1 15 0 01/23/2010 01/23/2010 EUR NL EUR 350523538 0
20
+ APPLE US 000000001 Acme Corp Widgets 1 1 .48 01/23/2010 01/23/2010 EUR ES EUR 350525324 .79
21
+ APPLE US 000000000 Acme Corp Sprockets 1 14 0 01/23/2010 01/23/2010 SEK SE EUR 350523538 0
22
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/23/2010 01/23/2010 CHF CH EUR 350525324 2.2
23
+ APPLE US 000000000 Acme Corp Sprockets 1 4 0 01/23/2010 01/23/2010 USD SG USD 350523538 0
24
+ APPLE US 000000000 Acme Corp Sprockets 1 4 0 01/23/2010 01/23/2010 USD TH USD 350523538 0
25
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/23/2010 01/23/2010 EUR GR EUR 350523538 0
26
+ APPLE US 000000000 Acme Corp Sprockets 1 10 0 01/23/2010 01/23/2010 EUR ES EUR 350523538 0
27
+ APPLE US 000000000 Acme Corp Sprockets 1 4 0 01/23/2010 01/23/2010 EUR PL EUR 350523538 0
28
+ APPLE US 000000000 Acme Corp Sprockets 1 8 0 01/23/2010 01/23/2010 EUR AT EUR 350523538 0
29
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/23/2010 01/23/2010 EUR BE EUR 350523538 0
30
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/23/2010 01/23/2010 EUR LU EUR 350523538 0
31
+ APPLE US 000000000 Acme Corp Sprockets 1 41 0 01/23/2010 01/23/2010 CHF CH EUR 350523538 0
32
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/23/2010 01/23/2010 NZD NZ AUD 350523538 0
33
+ APPLE US 000000000 Acme Corp Sprockets 1 114 0 01/23/2010 01/23/2010 EUR FR EUR 350523538 0
34
+ APPLE US 000000001 Acme Corp Widgets 1 3 .48 01/23/2010 01/23/2010 EUR FR EUR 350525324 .79
35
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/23/2010 01/23/2010 EUR IE EUR 350523538 0
36
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/23/2010 01/23/2010 USD TW USD 350523538 0
37
+ APPLE US 000000000 Acme Corp Sprockets 1 2 0 01/23/2010 01/23/2010 USD IL USD 350523538 0
38
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/23/2010 01/23/2010 EUR BE EUR 350525324 1.59
39
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/23/2010 01/23/2010 EUR FI EUR 350523538 0
40
+ APPLE US 000000001 Acme Corp Widgets 1 1 .48 01/23/2010 01/23/2010 EUR NL EUR 350525324 .79
41
+ APPLE US 000000001 Acme Corp Widgets 1 1 .97 01/23/2010 01/23/2010 EUR NL EUR 350525324 1.59
42
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/23/2010 01/23/2010 DKK DK EUR 350523538 0
43
+ APPLE US 000000000 Acme Corp Sprockets 1 9 0 01/23/2010 01/23/2010 AUD AU AUD 350523538 0
44
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/23/2010 01/23/2010 USD HK USD 350523538 0
45
+ APPLE US 000000000 Acme Corp Sprockets 1 6 0 01/23/2010 01/23/2010 USD CN USD 350523538 0
46
+ APPLE US 000000000 Acme Corp Sprockets 1 3 0 01/23/2010 01/23/2010 MXN MX USD 350523538 0
47
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/23/2010 01/23/2010 USD LB USD 350523538 0
48
+ APPLE US 000000001 Acme Corp Widgets 1 5 1.4 01/23/2010 01/23/2010 USD US USD 350525324 1.99
49
+ APPLE US 000000000 Acme Corp Sprockets 1 124 0 01/23/2010 01/23/2010 GBP GB GBP 350523538 0
50
+ APPLE US 000000001 Acme Corp Widgets 1 1 .48 01/23/2010 01/23/2010 EUR BE EUR 350525324 .79
51
+ APPLE US 000000000 Acme Corp Sprockets 1 8 0 01/23/2010 01/23/2010 NOK NO EUR 350523538 0
52
+ APPLE US 000000000 Acme Corp Sprockets 1 4 0 01/23/2010 01/23/2010 USD IN USD 350523538 0
53
+ APPLE US 000000001 Acme Corp Widgets 1 1 1.4 01/23/2010 01/23/2010 USD RU USD 350525324 1.99
54
+ APPLE US 000000000 Acme Corp Sprockets 1 7 0 01/23/2010 01/23/2010 USD RU USD 350523538 0
55
+ APPLE US 000000000 Acme Corp Sprockets 1 1 0 01/23/2010 01/23/2010 EUR HU EUR 350523538 0
56
+ APPLE US 000000001 Acme Corp Widgets 1 1 .7 01/23/2010 01/23/2010 USD CO USD 350525324 .99
data/lib/parseitc.rb ADDED
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+ module ParseITC
3
+ class TrasactionParser
4
+ attr_accessor :transactions
5
+ Version = '0.1'
6
+ def initialize(filename=nil)
7
+ @transactions = []
8
+ add_file filename if filename
9
+ end
10
+
11
+ def add_file filename
12
+ lines = File.readlines(filename)
13
+ lines.shift if lines.first.match(/^Provider/)
14
+ lines.each do |t|
15
+ add_transaction t
16
+ end
17
+ end
18
+
19
+ def add_transaction transaction
20
+ values = transaction.split(/\t|\n/)
21
+ raise WrongNumberOfElementsException.new(27, values.length) unless values.length == 27
22
+ @transactions << Transaction.new(values)
23
+ end
24
+
25
+ private
26
+ def method_missing(method_id, *arguments)
27
+ if match = /numbers_by_([_a-zA-Z]\w*)/.match(method_id.to_s)
28
+ numbers_by(match)
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ def numbers_by(match)
35
+ # puts match.captures.first == "country"
36
+ field = match.captures.first
37
+ allowed_fields = @transactions.first.instance_variables.map{|f| f[1..-1]} +
38
+ @transactions.first.public_methods
39
+ raise NoMethodError.new("#{match}") unless allowed_fields.include? field
40
+ values = {}
41
+ @transactions.map do |t|
42
+ value = t.send(field.to_sym)
43
+ values[value] ||= 0
44
+ values[value] += t.units.to_i
45
+ end
46
+ values
47
+ end
48
+ # end private
49
+ end
50
+
51
+ class Transaction
52
+ YEAR_TWO_THOUSAND = Date.parse("1/1/2000")
53
+ TWO_THOUSAND_YEARS = YEAR_TWO_THOUSAND - Date.parse("1/1/0")
54
+
55
+ # ignoring some columns that are ignored by iphone apps
56
+ attr_accessor :provider, # Apple (always)
57
+ :provider_country, # US (always?)
58
+ :company, # company x
59
+ :product, # widgets and sprockets
60
+ :vendor_identifier, # id you give the product
61
+ :date, # just take the begin date
62
+ :units,
63
+ :price,
64
+ :royalty_currency,
65
+ :customer_price,
66
+ :customer_currency,
67
+ :country,
68
+ :apple_identifier # itunes link id
69
+ def initialize array
70
+ @provider = array[0]
71
+ @provider_country = array[1]
72
+ @company = array[5]
73
+ @product = array[6]
74
+ @vendor_identifier = array[2]
75
+ @date = Date.parse(array[11])
76
+ @units = array[9]
77
+ @price = array[10]
78
+ @royalty_currency = array[15]
79
+ @customer_price = array[20]
80
+ @customer_currency = array[13]
81
+ @country = array[14]
82
+ @apple_identifier = array[19]
83
+
84
+ # Adjust date if necessary ("1/5/10" should not be 10 A.D.)
85
+ @date += TWO_THOUSAND_YEARS if @date < YEAR_TWO_THOUSAND
86
+ end
87
+
88
+ def price_tier
89
+ prices = ApplePricing[@royalty_currency.downcase.to_sym]
90
+ prices.find_index(@price.to_f)
91
+ end
92
+ end
93
+
94
+ class WrongNumberOfElementsException < Exception
95
+ def initialize(expected, actual)
96
+ super "Invalid number of elements (#{actual}). Expected #{expected} values"
97
+ end
98
+ end
99
+
100
+ # pricing tier info
101
+ ApplePricing = {
102
+ :usd => [0, 0.7, 1.4, 2.1, 2.8, 3.5, 4.2, 4.9, 5.6, 6.3, 7, 7.7, 8.4, 9.1, 9.8, 10.5, 11.2, 11.9, 12.6, 13.3, 14, 14.7, 15.4, 16.1, 16.8, 17.5, 18.2, 18.9, 19.6, 20.3, 21, 21.7, 22.4, 23.1, 23.8, 24.5, 25.2, 25.9, 26.6, 27.3, 28, 28.7, 29.4, 30.1, 30.8, 31.5, 32.2, 32.9, 33.6, 34.3, 35, 38.5, 42, 45.5, 49, 52.5, 56, 59.5, 63, 66.5, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 210, 245, 280, 315, 350, 420, 490, 560, 630, 700],
103
+ :cad => [0, 0.7, 1.4, 2.1, 2.8, 3.5, 4.2, 4.9, 5.6, 6.3, 7, 7.7, 8.4, 9.1, 9.8, 10.5, 11.2, 11.9, 12.6, 13.3, 14, 14.7, 15.4, 16.1, 16.8, 17.5, 18.2, 18.9, 19.6, 20.3, 21, 21.7, 22.4, 23.1, 23.8, 24.5, 25.2, 25.9, 26.6, 27.3, 28, 28.7, 29.4, 30.1, 30.8, 31.5, 32.2, 32.9, 33.6, 34.3, 35, 38.5, 42, 45.5, 49, 52.5, 56, 59.5, 63, 66.5, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 210, 245, 280, 315, 350, 420, 490, 560, 630, 700],
104
+ :aud => [0, 0.76, 1.58, 2.54, 3.18, 3.81, 5.08, 5.72, 6.36, 7.63, 8.27, 8.9, 9.54, 10.18, 10.81, 11.45, 12.08, 12.72, 13.99, 14.63, 15.27, 15.9, 17.18, 17.81, 18.45, 19.08, 20.36, 20.99, 21.63, 22.27, 23.54, 24.18, 24.81, 25.45, 26.72, 27.36, 27.99, 28.63, 29.27, 29.9, 30.54, 31.18, 31.81, 33.08, 33.72, 34.36, 34.99, 36.27, 36.9, 37.54, 38.18, 44.54, 47.72, 50.9, 57.27, 60.45, 63.63, 66.81, 69.99, 73.18, 76.36, 89.08, 95.45, 101.81, 108.18, 120.9, 127.27, 139.99, 146.36, 152.72, 159.08, 165.45, 171.81, 178.18, 184.54, 190.9, 222.72, 254.54, 286.36, 318.18, 381.81, 445.45, 509.08, 572.72, 636.36, 763.63],
105
+ :jpy => [0, 81, 161, 245, 315, 420, 490, 560, 630, 700, 840, 910, 980, 1050, 1120, 1190, 1260, 1400, 1470, 1540, 1610, 1680, 1750, 1820, 1960, 2030, 2100, 2170, 2240, 2310, 2450, 2520, 2590, 2660, 2730, 2800, 2870, 3010, 3080, 3150, 3220, 3290, 3360, 3430, 3500, 3640, 3710, 3780, 3850, 3920, 4060, 4200, 4900, 5250, 5600, 5950, 6300, 7000, 7350, 7700, 8050, 9100, 9800, 10500, 11200, 12600, 13300, 14000, 14700, 15400, 16100, 16800, 17500, 18200, 18900, 20300, 24500, 28000, 31500, 35000, 40600, 49000, 56000, 63000, 70000, 80500],
106
+ :eur => [0, 0.48, 0.97, 1.45, 1.82, 2.43, 3.04, 3.34, 3.65, 4.25, 4.86, 5.47, 6.08, 6.39, 6.69, 7.3, 7.91, 8.52, 8.82, 9.12, 9.73, 10.34, 10.95, 11.25, 11.56, 12.17, 12.78, 13.08, 13.39, 13.99, 14.6, 15.21, 15.52, 15.82, 16.43, 17.04, 17.65, 17.95, 18.25, 18.86, 19.47, 20.08, 20.39, 20.69, 21.3, 21.91, 22.52, 22.82, 23.12, 23.73, 24.34, 26.17, 27.39, 30.43, 33.47, 36.52, 38.34, 39.56, 42.6, 45.65, 48.69, 51.73, 54.78, 57.82, 60.86, 66.95, 73.04, 76.08, 79.12, 85.21, 91.3, 97.39, 103.47, 109.56, 115.65, 121.73, 146.08, 170.43, 194.78, 219.12, 243.47, 292.17, 340.86, 389.56, 438.25, 486.95],
107
+ :gbp => [0, 0.36, 0.72, 1.09, 1.45, 1.82, 2.12, 2.43, 3.04, 3.34, 3.65, 3.95, 4.25, 4.56, 4.86, 5.47, 5.78, 6.08, 6.69, 6.99, 7.3, 7.6, 7.91, 8.52, 8.82, 9.12, 9.43, 9.73, 10.34, 10.65, 10.95, 11.25, 11.56, 12.17, 12.47, 12.78, 13.08, 13.39, 13.99, 14.3, 14.6, 14.91, 15.21, 15.82, 16.12, 16.43, 16.73, 17.04, 17.65, 17.95, 18.25, 20.08, 21.3, 23.12, 24.34, 26.17, 27.39, 30.43, 32.25, 33.47, 36.52, 39.56, 42.6, 45.65, 48.69, 51.73, 54.78, 57.82, 60.86, 66.95, 69.99, 73.04, 76.08, 79.12, 85.21, 91.3, 109.56, 121.73, 146.08, 170.43, 182.6, 213.04, 243.47, 273.91, 304.34, 365.21]
108
+ }
109
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: parseitc
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - HJ Choi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-09-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ParseITC (Parse iTunes Connect) provides parsing of iPhone app transaction reports from iTunes Connect.
17
+ email: hc5duke@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - Changelog
27
+ - LICENSE
28
+ - demo.rb
29
+ - demo1.txt
30
+ - demo2.txt
31
+ - lib/parseitc.rb
32
+ has_rdoc: true
33
+ homepage: http://www.choibean.com/parseitc
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.3.5
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Parse iTunes Connect transaction reports
60
+ test_files: []
61
+