-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.rb
More file actions
49 lines (43 loc) · 1.15 KB
/
Copy pathsource.rb
File metadata and controls
49 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
48
require './trello_source'
require './github_source'
require 'yaml'
class Source
def initialize(scheduler)
File.open("sources.yml", "r") do |infile|
conf = YAML.load(infile.read())
@trello_source = TrelloSource.new(conf['trello'])
@github_source = GithubSource.new(conf['github'], scheduler)
end
end
def merge(hash1, hash2)
ret = {}
handle_hash = Proc.new do |key, value|
if ret.has_key?(key) then
ret[key].merge_with(value)
else
ret[key] = value
end
end
hash1.each &handle_hash
hash2.each &handle_hash
ret
end
def members()
github_members = @github_source.members()
trello_members = @trello_source.members()
merge(github_members, trello_members)
end
def projects()
puts 'Getting projects'
trello_projects = @trello_source.projects()
$logger.debug trello_projects
github_projects = @github_source.projects()
$logger.debug github_projects
merge(github_projects, trello_projects)
end
def events()
trello_events = @trello_source.events()
guthub_events = @github_source.events()
merge(guthub_events, trello_events)
end
end