Module: TFSGraph::TFSClient

Included in:
BranchStore, ChangesetMergeStore, ChangesetStore, ProjectStore
Defined in:
lib/tfs_graph/tfs_client.rb

Constant Summary collapse

InvalidConfig =
Class.new(RuntimeError)
REQUIRED_KEYS =
[:endpoint, :collection, :username, :password]

Instance Method Summary collapse

Instance Method Details

#endpoint(settings) ⇒ Object



33
34
35
# File 'lib/tfs_graph/tfs_client.rb', line 33

def endpoint(settings)
  "#{settings[:endpoint]}/#{settings[:collection]}"
end

#setup(settings = TFSGraph.config.tfs) ⇒ Object

Requires a hash of settings

Raises:



11
12
13
14
15
16
17
18
19
20
# File 'lib/tfs_graph/tfs_client.rb', line 11

def setup(settings=TFSGraph.config.tfs)
  raise InvalidConfig unless REQUIRED_KEYS.all? {|key| settings.keys.include? key }

  TFS.configure do |c|
    c.endpoint = endpoint(settings)
    c.username = settings[:username]
    c.password = settings[:password]
    c.namespace = settings[:namespace] || "TFS"
  end
end

#tfsObject



22
23
24
25
26
27
# File 'lib/tfs_graph/tfs_client.rb', line 22

def tfs
  @tfs ||= begin
    setup
    TFS.client
  end
end

#tfs=(client) ⇒ Object



29
30
31
# File 'lib/tfs_graph/tfs_client.rb', line 29

def tfs=(client)
  @tfs = client
end