Class: GooglePlayDevScraper::ScraperConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/googleplay_dev_scraper/scraper_config.rb

Overview

Configurations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScraperConfig

Returns a new instance of ScraperConfig.



32
33
34
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 32

def initialize
  @dev_acc = nil
end

Instance Attribute Details

#dev_accObject

developer account ID



24
25
26
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 24

def dev_acc
  @dev_acc
end

#emailObject

Google account



18
19
20
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 18

def email
  @email
end

#passwordObject

Password to login google account



21
22
23
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 21

def password
  @password
end

#proxy_hostObject

HTTP proxy host



27
28
29
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 27

def proxy_host
  @proxy_host
end

#proxy_portObject

HTTP proxy port



30
31
32
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 30

def proxy_port
  @proxy_port
end

Instance Method Details

#load_config(path = nil) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 36

def load_config(path = nil)
  config_files = [ path, ".googleplay_dev_scraper", "#{ENV['HOME']}/.googleplay_dev_scraper" ]

  config_files.each do |file|
    load_config_file(file)
  end
end

#load_config_file(file) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 44

def load_config_file(file)
  if file && File.exists?(file)
    open(file) do |f|
      begin
        read_config(f.read)
      rescue Psych::SyntaxError => e
        STDERR.puts "Error: configuration file syntax: #{file}"
        exit 1
      rescue
        STDERR.puts "Error: load configuration file: #{file}"
        exit 1
      end
    end
  end
end

#read_config(data) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 60

def read_config(data)
  h = YAML.load(data)
  if h
    @email      ||= h['email']
    @password   ||= h['password']
    @dev_acc    ||= h['dev_acc']
    @proxy_host ||= h['proxy_host']
    @proxy_port ||= h['proxy_port']
  end
end