bbbevents 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 402bf3f128e1214280f944e01ee9d205f5957e9b032982a095e61204e679a8a4
4
- data.tar.gz: 109f47bab718e9bb1a0479fced8383bcfc6192f418c9ca42c7943cc41e6aa19c
3
+ metadata.gz: e9f0ea583b187441128084badd6a7671aca2289135b15e11dbe2ca03473f8a89
4
+ data.tar.gz: 79f8ade1f3d3b035c66d63578118e97c688c62015cd37c782bb50b6c5880aade
5
5
  SHA512:
6
- metadata.gz: 8c4f90600b6b3d85d9ebb7325e0a6279fc9d7f94ec1ee20d91448f3aca4014ae16a356cd75d74a84b99851cd7e329f5dd7d670e38aff1554f9bdc1f410567117
7
- data.tar.gz: '0733278cf563072dc656c51bfceb823491800b4b9089764a835600fa95ee21bec84147c07055840bf08332492a6aca77ccebc8a65497f865bfb90a33fa635c4e'
6
+ metadata.gz: bb7bdf62e41f2d56101ef656358b33a6a98fe093d6f6abd99e842766906b93c71db103bfdbd7689a1ad4a3414ad1efdddb5fba32e45995bce556d471c681e855
7
+ data.tar.gz: 84e933f01582767c3e9f1626bb77671fb21ca4ad8d63b159065616aed78b7d10b744d32875c338f4d493700e9db40ce50bbbdc21c10c9bce1716be0bb203f18d
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -13,3 +12,6 @@
13
12
 
14
13
  # testing csv file
15
14
  /spec/testing.csv
15
+ testdata/*.xml
16
+
17
+ /bbbevents-*
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bbbevents (1.1.0)
5
+ activesupport
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (5.2.3)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ concurrent-ruby (1.1.5)
16
+ diff-lcs (1.3)
17
+ i18n (1.6.0)
18
+ concurrent-ruby (~> 1.0)
19
+ minitest (5.11.3)
20
+ rake (10.5.0)
21
+ rspec (3.8.0)
22
+ rspec-core (~> 3.8.0)
23
+ rspec-expectations (~> 3.8.0)
24
+ rspec-mocks (~> 3.8.0)
25
+ rspec-core (3.8.2)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-expectations (3.8.4)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-mocks (3.8.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.8.0)
33
+ rspec-support (3.8.2)
34
+ thread_safe (0.3.6)
35
+ tzinfo (1.2.5)
36
+ thread_safe (~> 0.1)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bbbevents!
43
+ bundler (>= 1.15)
44
+ rake (~> 10.0)
45
+ rspec (~> 3.4)
46
+
47
+ BUNDLED WITH
48
+ 1.16.3
data/README.md CHANGED
@@ -6,6 +6,18 @@ bbbevents is a simple ruby gem that makes it easier to parse data from a recordi
6
6
 
7
7
  This gem is currently being used on the recording server to parse events and build meeting dashboards.
8
8
 
9
+ ## Testing
10
+
11
+ ```
12
+ bundle install --path vendor/bundle
13
+ ```
14
+
15
+ Copy an `events.xml` file into `testdata/` dir.
16
+
17
+ ```
18
+ bundle exec ./example.rb spec/fixtures/files/sample-events.xml
19
+ ```
20
+
9
21
  ## Installation
10
22
 
11
23
  Add this line to your application's Gemfile:
data/bbbevents.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "bundler", ">= 1.15"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.4"
27
27
 
data/example.rb ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'bbbevents'
4
+
5
+ exit if ARGV.length < 1
6
+
7
+ eventsxml = ARGV[0]
8
+
9
+ # Parse the recording's events.xml.
10
+ recording = BBBEvents.parse(eventsxml)
11
+
12
+ # Access recording data.
13
+ recording.metadata
14
+ recording.meeting_id
15
+
16
+ # Retrieve start, finish time objects or total duration in seconds.
17
+ recording.start
18
+ recording.finish
19
+ recording.duration
20
+
21
+ # Returns a list of Attendee objects.
22
+ recording.attendees
23
+ recording.moderators
24
+ recording.viewers
25
+
26
+ # Returns a list of Poll objects.
27
+ recording.polls
28
+ recording.published_polls
29
+ recording.unpublished_polls
30
+
31
+ # Returns a list of upload files (names only).
32
+ recording.files
33
+
34
+ # Generate a CSV file with the data.
35
+ recording.create_csv("data.csv")
36
+
37
+ puts "Writing the JSON data"
38
+
39
+ # Write JSON data to file.
40
+ File.open("data.json", 'w') do |f|
41
+ f.write(recording.to_json)
42
+ end
43
+
44
+
@@ -7,6 +7,7 @@ module BBBEvents
7
7
 
8
8
  def initialize(join_event)
9
9
  @id = join_event["userId"]
10
+ @extUserId = join_event["externalUserId"]
10
11
  @name = join_event["name"]
11
12
  @moderator = (join_event["role"] == MODERATOR_ROLE)
12
13
 
@@ -57,6 +58,12 @@ module BBBEvents
57
58
  ].map(&:to_s)
58
59
  end
59
60
 
61
+ def to_h
62
+ hash = {}
63
+ instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) }
64
+ hash
65
+ end
66
+
60
67
  def to_json
61
68
  hash = {}
62
69
  instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) }
@@ -9,8 +9,3 @@ module BBBEvents
9
9
  Recording.new(events_xml)
10
10
  end
11
11
  end
12
-
13
- require 'bbbevents/attendee'
14
- require 'bbbevents/events'
15
- require 'bbbevents/poll'
16
- require 'bbbevents/recording'
@@ -20,18 +20,37 @@ module BBBEvents
20
20
 
21
21
  # Log a users join.
22
22
  def participant_join_event(e)
23
- id = e["userId"]
23
+ intUserId = e['userId']
24
+ extUserId = e['externalUserId']
24
25
 
25
- @attendees[id] = Attendee.new(e) unless @attendees.key?(id)
26
- @attendees[id].joins << Time.at(timestamp_conversion(e["timestamp"]))
26
+ # If they don't exist, initialize the user.
27
+ unless @externalUserId.key?(intUserId)
28
+ @externalUserId[intUserId] = extUserId
29
+ end
30
+
31
+ # We need to track the user using external userids so that 3rd party
32
+ # integrations will be able to correlate the users with their own data.
33
+ unless @attendees.key?(extUserId)
34
+ @attendees[extUserId] = Attendee.new(e) unless @attendees.key?(extUserId)
35
+ end
36
+
37
+ # Handle updates for re-joining users
38
+ att = @attendees[extUserId]
39
+ att.joins << Time.at(timestamp_conversion(e["timestamp"]))
40
+ att.name = e['name']
41
+ if e['role'] == 'MODERATOR'
42
+ att.moderator = true
43
+ end
27
44
  end
28
45
 
29
46
  # Log a users leave.
30
47
  def participant_left_event(e)
31
- return unless attendee = @attendees[e["userId"]]
32
-
33
- left = Time.at(timestamp_conversion(e["timestamp"]))
34
- attendee.leaves << left
48
+ intUserId = e['userId']
49
+ # If the attendee exists, set their leave time.
50
+ if att = @attendees[@externalUserId[intUserId]]
51
+ left = Time.at(timestamp_conversion(e["timestamp"]))
52
+ att.leaves << left
53
+ end
35
54
  end
36
55
 
37
56
  # Log the uploaded file name.
@@ -41,14 +60,18 @@ module BBBEvents
41
60
 
42
61
  # Log a users public chat message
43
62
  def public_chat_event(e)
44
- return unless attendee = @attendees[e["senderId"]]
45
-
46
- attendee.engagement[:chats] += 1 if attendee
63
+ intUserId = e['senderId']
64
+ # If the attendee exists, increment their messages.
65
+ if att = @attendees[@externalUserId[intUserId]]
66
+ att.engagement[:chats] += 1
67
+ end
47
68
  end
48
69
 
49
70
  # Log user status changes.
50
71
  def participant_status_change_event(e)
51
- return unless attendee = @attendees[e["userId"]]
72
+ intUserId = e['userId']
73
+
74
+ return unless attendee = @attendees[@externalUserId[intUserId]]
52
75
  status = e["value"]
53
76
 
54
77
  if attendee
@@ -62,7 +85,9 @@ module BBBEvents
62
85
 
63
86
  # Log number of speaking events and total talk time.
64
87
  def participant_talking_event(e)
65
- return unless attendee = @attendees[e["participant"]]
88
+ intUserId = e["participant"]
89
+
90
+ return unless attendee = @attendees[@externalUserId[intUserId]]
66
91
 
67
92
  if e["talking"] == "true"
68
93
  attendee.engagement[:talks] += 1
@@ -82,11 +107,13 @@ module BBBEvents
82
107
 
83
108
  # Log user responses to polls.
84
109
  def user_responded_to_poll_record_event(e)
85
- user_id = e["userId"]
86
- return unless attendee = @attendees[user_id]
110
+ intUserId = e['userId']
111
+ poll_id = e['pollId']
112
+
113
+ return unless attendee = @attendees[@externalUserId[intUserId]]
87
114
 
88
- if poll = @polls[e["pollId"]]
89
- poll.votes[user_id] = poll.options[e["answerId"].to_i]
115
+ if poll = @polls[poll_id]
116
+ poll.votes[@externalUserId[intUserId]] = poll.options[e["answerId"].to_i]
90
117
  end
91
118
 
92
119
  attendee.engagement[:poll_votes] += 1
@@ -13,6 +13,12 @@ module BBBEvents
13
13
  @published
14
14
  end
15
15
 
16
+ def to_h
17
+ hash = {}
18
+ instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) }
19
+ hash
20
+ end
21
+
16
22
  def to_json
17
23
  hash = {}
18
24
  instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) }
@@ -21,7 +21,8 @@ module BBBEvents
21
21
  raise "#{filename} is missing recording key." unless raw_recording_data.key?("recording")
22
22
 
23
23
  recording_data = raw_recording_data["recording"]
24
- events = recording_data["event"]
24
+ events = recording_data["event"]
25
+ events = [events] unless events.is_a?(Array)
25
26
 
26
27
  @metadata = recording_data["metadata"]
27
28
  @meeting_id = recording_data["meeting"]["id"]
@@ -38,6 +39,10 @@ module BBBEvents
38
39
  @polls = {}
39
40
  @files = []
40
41
 
42
+ # Map to look up external user id (for @data[:attendees]) from the
43
+ # internal user id in most recording events
44
+ @externalUserId = {}
45
+
41
46
  process_events(events)
42
47
 
43
48
  @attendees.values.each do |att|
@@ -86,17 +91,21 @@ module BBBEvents
86
91
  end
87
92
  end
88
93
 
89
- def to_json
94
+ def to_h
90
95
  {
91
96
  metadata: @metadata,
92
97
  meeting_id: @meeting_id,
93
98
  duration: @duration,
94
99
  start: @start,
95
100
  finish: @finish,
96
- attendees: attendees.map(&:to_json),
101
+ attendees: attendees.map(&:to_h),
97
102
  files: @files,
98
- polls: polls.map(&:to_json),
99
- }.to_json
103
+ polls: polls.map(&:to_h)
104
+ }
105
+ end
106
+
107
+ def to_json
108
+ to_h.to_json
100
109
  end
101
110
 
102
111
  private
@@ -1,3 +1,3 @@
1
1
  module BBBEvents
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/bbbevents.rb CHANGED
@@ -1 +1,6 @@
1
1
  require "bbbevents/base"
2
+ require 'bbbevents/version'
3
+ require 'bbbevents/attendee'
4
+ require 'bbbevents/events'
5
+ require 'bbbevents/poll'
6
+ require 'bbbevents/recording'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbbevents
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blindside Networks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-23 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.15'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
@@ -77,12 +77,14 @@ files:
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
79
  - Gemfile
80
+ - Gemfile.lock
80
81
  - LICENSE
81
82
  - README.md
82
83
  - Rakefile
83
84
  - bbbevents.gemspec
84
85
  - bin/console
85
86
  - bin/setup
87
+ - example.rb
86
88
  - lib/bbbevents.rb
87
89
  - lib/bbbevents/attendee.rb
88
90
  - lib/bbbevents/base.rb