Class: Refresh

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions, Util
Defined in:
lib/commands/refresh.rb

Instance Method Summary collapse

Methods included from Util

#add_to_git, #alter_index_html, #alter_link, #content_root, #each_presentation, #git_repository?, #has_remote?, #init_git, #parse_config, #presentation, #pull_from_git, #request_token

Instance Method Details

#refresh_presentationObject



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
# File 'lib/commands/refresh.rb', line 15

def refresh_presentation

  block = Proc.new do |master,client|
    say "refreshing tokens and secrets for #{File.basename(master)}"
    master = "#{master}/index.html"
    client = "#{client}/index.html"
    master_content = File.read(master)
    token = request_token
    config = parse_config
    multiplex = %Q( multiplex: {
          secret: "#{token.secret}",
          id: "#{token.socket_id}",
          url: "#{config.host}:#{config.port}"
      },
    )
    regex = /multiplex: \{.*?\},/m
    master_content.sub!(regex,multiplex)
    File.write(master, master_content)

    client_content = File.read(client)
    multiplex = %Q( multiplex: {
          secret: null,
          id: "#{token.socket_id}",
          url: "#{config.host}:#{config.port}"
      },
    )
    client_content.sub!(regex,multiplex)
    File.write(client, client_content)
  end

  @presentation_name ?
    presentation(@presentation_name,&block) : each_presentation(&block)
end