Class: GooglePlayDevScraper::ScraperConfig
- Inherits:
-
Object
- Object
- GooglePlayDevScraper::ScraperConfig
- Defined in:
- lib/googleplay_dev_scraper/scraper_config.rb
Overview
Configurations
Instance Attribute Summary collapse
-
#dev_acc ⇒ Object
developer account ID.
-
#email ⇒ Object
Google account.
-
#password ⇒ Object
Password to login google account.
-
#proxy_host ⇒ Object
HTTP proxy host.
-
#proxy_port ⇒ Object
HTTP proxy port.
Instance Method Summary collapse
-
#initialize ⇒ ScraperConfig
constructor
A new instance of ScraperConfig.
- #load_config(path = nil) ⇒ Object
- #load_config_file(file) ⇒ Object
- #read_config(data) ⇒ Object
Constructor Details
#initialize ⇒ ScraperConfig
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_acc ⇒ Object
developer account ID
24 25 26 |
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 24 def dev_acc @dev_acc end |
#email ⇒ Object
Google account
18 19 20 |
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 18 def email @email end |
#password ⇒ Object
Password to login google account
21 22 23 |
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 21 def password @password end |
#proxy_host ⇒ Object
HTTP proxy host
27 28 29 |
# File 'lib/googleplay_dev_scraper/scraper_config.rb', line 27 def proxy_host @proxy_host end |
#proxy_port ⇒ Object
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 |