Class: Orsos::Commands::Get

Inherits:
Thor
  • Object
show all
Defined in:
lib/orsos/commands/get.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



86
87
88
# File 'lib/orsos/commands/get.rb', line 86

def self.banner(command, namespace = nil, subcommand = false)
  "#{basename} #{@package_name} #{command.usage}"
end

Instance Method Details

#candidate_filings(from, to = Date.today) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/orsos/commands/get.rb', line 60

def candidate_filings(from, to=Date.today)
  from_date = case from
    when Date
      from
    when String
      Date.parse from
    else
      raise 'invalid from date'
  end

  to_date = case to
    when Date
      to
    when String
      Date.parse to
    else
      raise 'invalid to date'
  end

  Orsos::Webdownloader.new(get_downloader_options(filename: "sos_candidate_filings_#{from_date.strftime("%Y%m%d")}-#{to_date.strftime("%Y%m%d")}-#{DateTime.now.strftime("%Y%m%d%H%M%S")}", options: options))
                      .save_candidate_filings from_date: from_date, to_date: to_date
end

#committeesObject



54
55
56
57
# File 'lib/orsos/commands/get.rb', line 54

def committees
  Orsos::Webdownloader.new(get_downloader_options(filename: "sos_committees_#{options['committee_name_contains']}", options: options))
                      .save_committees committee_name_contains: options['committee_name_contains']
end

#transactions(from, to = Date.today) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/orsos/commands/get.rb', line 15

def transactions(from, to=Date.today)
  from_date = case from
    when Date
      from
    when String
      Date.parse from
    else
      raise 'invalid from date'
  end

  to_date = case to
    when Date
      to
    when String
      Date.parse to
    else
      raise 'invalid to date'
  end

  trans_opts = options.select{|k,v| ['filer_id'].include?(k) }

  if !options['single_file'].nil?
    Orsos::Webdownloader.new(get_downloader_options(filename: "sos_transactions_#{from_date.strftime("%Y%m%d")}-#{to_date.strftime("%Y%m%d")}-#{DateTime.now.strftime("%Y%m%d%H%M%S")}", options: options))
                        .save_campaign_finance_transactions from_date: from_date, 
                                                            to_date: to_date, 
                                                            options: trans_opts

  else
    (from_date..to_date).each do |date|
      Orsos::Webdownloader.new(get_downloader_options(filename: "sos_transactions_#{date.strftime("%Y%m%d")}-#{DateTime.now.strftime("%Y%m%d%H%M%S")}", options: options))
                          .save_campaign_finance_transactions from_date: date, 
                                                              to_date: date, 
                                                              options: trans_opts
    end
  end
end