Class: Pluto::Updater

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/pluto/updater.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts, config) ⇒ Updater

fix!!!!!: change config to text - yes/no - why? why not?? or pass along struct - with hash and text and format(e.g. ini/yml) as fields???

- why? - we need to get handle on md5 digest/hash plus on plain text, ideally to store in db
  • pass along unparsed text!! - not hash struct
    • will get saved in db plus we need to generate md5 hash
    • add filename e.g. ruby.ini|ruby.conf|ruby.yml as opt ?? or add config format as opt e.g. ini or yml?


17
18
19
20
# File 'lib/pluto/updater.rb', line 17

def initialize( opts, config )
  @opts    = opts
  @config  = config
end

Instance Attribute Details

#config ⇒ Object (readonly)

Returns the value of attribute config.



22
23
24
# File 'lib/pluto/updater.rb', line 22

def config
  @config
end

#opts ⇒ Object (readonly)

Returns the value of attribute opts.



22
23
24
# File 'lib/pluto/updater.rb', line 22

def opts
  @opts
end

Instance Method Details

#run(arg) ⇒ Object



24
25
26
27
28
# File 'lib/pluto/updater.rb', line 24

def run( arg )
  arg = arg.downcase.gsub('.ini','').gsub('.yml','')  # remove file extension if present

  update_for( arg )
end

#update_for(site_key) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pluto/updater.rb', line 30

def update_for( site_key )
  ###################
  # step 1) update subscriptions
  subscriber = Subscriber.new

  # pass along debug/verbose setting/switch
  subscriber.debug = true    if opts.verbose?
  subscriber.update_subscriptions_for( site_key, config )

  ##############################
  # step 2) update feeds
  refresher = Refresher.new

  # pass along debug/verbose setting/switch
  refresher.debug = true    if opts.verbose?
  refresher.update_feeds_for( site_key )
end