Class: Factor::Client::Client

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

Constant Summary collapse

HOST =
"http://localhost:3000"

Instance Method Summary collapse

Instance Method Details

#load_channels(engine) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/client/client.rb', line 42

def load_channels(engine)

  # get list of channels
  channels = rest_get("channels")

  #load each channel
  channels.each do |channel|
  
    # URI of the zip file containing the module
    uri = URI.parse(channel['zip_url'])
  
    # temp file to store the zip for download
    temp_file = Tempfile.new([uri.to_s.gsub(/\W+/,'-'), '.zip'], :encoding => 'ascii-8bit')
  
    # temp directory where zip will be decompressed
    unzip_dir=temp_file.path[0..-5]
  
    # download
    open(uri.to_s,"rb") do |bin|
      temp_file.print bin.read
    end
    temp_file.close
  
    # unzip download zip into unzipped directory
    unzip(temp_file.path,unzip_dir)
  
    Dir.glob("#{unzip_dir}/#{channel['name'].downcase}/*.rb").each do |file|
      engine.load_channel(file)
    end
  
  end


  engine
end

#load_credentials(engine) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/client/client.rb', line 32

def load_credentials(engine)

  credentials_definition = rest_get("credentials")
  credentials = JSON.parse(credentials_definition["bag"])
  engine.load_credentials(credentials)

  engine
end

#load_workflows(engine) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/client/client.rb', line 22

def load_workflows(engine)
  workflows = rest_get("workflows")
  workflows.each do |workflow|
    workflow_definition = JSON.parse(workflow['definition'])
    workflow=Factor::Workflow.new(workflow_definition)
    engine.load_workflow(workflow)
  end
  engine
end

#login(email, password) ⇒ Object



15
16
# File 'lib/client/client.rb', line 15

def (email, password)
end

#login_token(token) ⇒ Object



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

def (token)
  @token=token
end

#register(email, password) ⇒ Object



12
13
# File 'lib/client/client.rb', line 12

def register(email,password)
end