parseitc 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Changelog +5 -0
  2. data/README.textile +33 -0
  3. data/demo.rb +1 -1
  4. data/lib/parseitc.rb +15 -6
  5. metadata +2 -2
  6. data/README +0 -59
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
1
  Sun 2010-01-31 - v0.1
2
2
  - Started project
3
3
  - Parse fields and count by them
4
+
5
+ Tue 2010-02-02 - v0.1.1
6
+ - Typos were fixed
7
+ - price was renamed to less confusing royalty_price
8
+ - filenames can be array or string
data/README.textile ADDED
@@ -0,0 +1,33 @@
1
+ h1. parseitc
2
+
3
+ h2. DESCRIPTION:
4
+
5
+ parseitc is a Ruby gem written to parse iPhone app transaction reports from iTunes Connect.
6
+
7
+ h2. FEATURES/PROBLEMS:
8
+
9
+ Parsing of standard Sales/Trend Report tsv files from https://itts.apple.com/
10
+ Allows ruby applications as well as Bash Init scripts to use the same config.
11
+
12
+ h2. SYNOPSIS:
13
+
14
+ bc. require 'rubygems'
15
+ require 'lib/parseitc'
16
+ include ParseITC
17
+ reports = TransactionParser.new('/path/to/tsv/file1')
18
+ reports.add_file('/path/to/tsv/file2')
19
+ by_country = report.numbers_by_country
20
+ by_country.sort.each {|k, v| puts "#{k}: #{v}"}
21
+
22
+ h2. REQUIREMENTS:
23
+
24
+ * Ruby (Developed on 1.8.7)
25
+ * RubyGems
26
+
27
+ h2. INSTALL:
28
+
29
+ bc. sudo gem install parseitc
30
+
31
+ h2. TODO:
32
+
33
+ * parse monthly and weekly reports
data/demo.rb CHANGED
@@ -3,7 +3,7 @@ require 'lib/parseitc'
3
3
  include ParseITC
4
4
 
5
5
  begin
6
- report = TrasactionParser.new('demo1.txt')
6
+ report = TransactionParser.new('demo1.txt')
7
7
  report.add_file('demo2.txt')
8
8
  by_country = report.numbers_by_country
9
9
  by_country.sort.each {|k, v| puts "#{k}: #{v}"}
data/lib/parseitc.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  module ParseITC
3
- class TrasactionParser
3
+ class TransactionParser
4
4
  attr_accessor :transactions
5
5
  Version = '0.1'
6
- def initialize(filename=nil)
6
+ # filenames can be either string or array
7
+ def initialize(filenames=[])
7
8
  @transactions = []
8
- add_file filename if filename
9
+ filenames = [filenames].flatten
10
+ filenames.each{|f| add_file f} unless filenames.empty?
9
11
  end
10
12
 
11
13
  def add_file filename
@@ -60,12 +62,17 @@ module ParseITC
60
62
  :vendor_identifier, # id you give the product
61
63
  :date, # just take the begin date
62
64
  :units,
63
- :price,
65
+ :royalty_price, # this is what you get paid
64
66
  :royalty_currency,
65
67
  :customer_price,
66
68
  :customer_currency,
69
+ :vendor_offer_code,
70
+ :promo_code,
67
71
  :country,
68
72
  :apple_identifier # itunes link id
73
+
74
+ alias :price :royalty_price
75
+
69
76
  def initialize array
70
77
  @provider = array[0]
71
78
  @provider_country = array[1]
@@ -74,10 +81,12 @@ module ParseITC
74
81
  @vendor_identifier = array[2]
75
82
  @date = Date.parse(array[11])
76
83
  @units = array[9]
77
- @price = array[10]
84
+ @royalty_price = array[10]
78
85
  @royalty_currency = array[15]
79
86
  @customer_price = array[20]
80
87
  @customer_currency = array[13]
88
+ @vendor_offer_code = array[23]
89
+ @promo_code = array[25]
81
90
  @country = array[14]
82
91
  @apple_identifier = array[19]
83
92
 
@@ -87,7 +96,7 @@ module ParseITC
87
96
 
88
97
  def price_tier
89
98
  prices = ApplePricing[@royalty_currency.downcase.to_sym]
90
- prices.find_index(@price.to_f)
99
+ prices.find_index(@royalty_price.to_f)
91
100
  end
92
101
  end
93
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parseitc
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - HJ Choi
@@ -22,7 +22,7 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - README
25
+ - README.textile
26
26
  - Changelog
27
27
  - LICENSE
28
28
  - demo.rb
data/README DELETED
@@ -1,59 +0,0 @@
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.