Class: ItunesConnect::Commands::Import
- Inherits:
-
Object
- Object
- ItunesConnect::Commands::Import
- Defined in:
- lib/itunes_connect/commands/import.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #execute!(opts, args = []) ⇒ Object
-
#initialize(c, rcfile = ItunesConnect::RcFile.default) ⇒ Import
constructor
A new instance of Import.
Constructor Details
#initialize(c, rcfile = ItunesConnect::RcFile.default) ⇒ Import
Returns a new instance of Import.
6 7 8 9 10 |
# File 'lib/itunes_connect/commands/import.rb', line 6 def initialize(c, rcfile=ItunesConnect::RcFile.default) c.opt('b', 'db', :desc => 'Dump report to sqlite DB at the given path') c.req('f', 'file', :desc => 'The file to import, - means standard in') @rcfile = rcfile end |
Instance Method Details
#description ⇒ Object
31 32 33 |
# File 'lib/itunes_connect/commands/import.rb', line 31 def description "Imports report data into a database file" end |
#execute!(opts, args = []) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/itunes_connect/commands/import.rb', line 12 def execute!(opts, args=[]) db = opts.db || @rcfile.database || nil raise ArgumentError.new("Missing :db option") unless db raise ArgumentError.new("Missing :file option") if opts.file.nil? store = ItunesConnect::Store.new(db, opts.verbose?) input = opts.file == '-' ? $stdin : open(opts.file, 'r') count = 0 ItunesConnect::Report.new(input).each do |entry| count += 1 if store.add(entry.date, entry.country, entry.install_count, entry.upgrade_count) end if opts.verbose? $stdout.puts "Added #{count} rows to the database" end end |