slack_status_tracker 0.1.0.pre.2 → 0.1.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/slack_status_tracker/report_manager.rb +24 -27
- data/lib/slack_status_tracker/scrapper.rb +3 -2
- data/lib/slack_status_tracker/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc9664f509040ec1e50f3f193039098077d0f118
|
4
|
+
data.tar.gz: 44ca0b07d98fc43a2706346304fde7cc534c18a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa11ec553e31f08b1dcd07af5036a2adace11b57ade68cd84df813a1acec4e96f48f9fda2b1dd229b063b404a9de86d52a0d7142169a59f2c1a6610d4b94701
|
7
|
+
data.tar.gz: 32d56e25cd384179df023398f1c4450cf241c43ed04055c9ac90bbd6c08ac05239ae964308a94cd7760c7645e750193a45827b2263a36b67c7632639bf3535b3
|
data/.gitignore
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module SlackStatusTracker
|
2
2
|
class ReportManager
|
3
|
+
FREQUENCY = 30
|
3
4
|
include Singleton
|
4
5
|
|
5
6
|
attr_accessor :output_path
|
@@ -10,10 +11,9 @@ module SlackStatusTracker
|
|
10
11
|
set_output options
|
11
12
|
set_json_hash options
|
12
13
|
frequency = options.fetch :frequency
|
13
|
-
append_to_output "Time\t\t\t\tOnline Users"
|
14
14
|
if options[:start]
|
15
15
|
while true
|
16
|
-
verify_options options
|
16
|
+
Thread.new{ verify_options options }
|
17
17
|
sleep frequency*60
|
18
18
|
end
|
19
19
|
else
|
@@ -28,25 +28,30 @@ module SlackStatusTracker
|
|
28
28
|
process_json options
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
def process_channel(time, username, password, driver, channel)
|
33
|
+
begin
|
34
|
+
scrapper = SlackStatusTracker::Scrapper.new(username, password,
|
35
|
+
driver, channel)
|
36
|
+
scrapper.retrieve_users
|
37
|
+
total = scrapper.current_online_users
|
38
|
+
scrapper.headless.destroy
|
39
|
+
rescue => e
|
40
|
+
puts e.backtrace
|
41
|
+
sleep 10
|
42
|
+
retry
|
43
|
+
end
|
44
|
+
append_to_output channel, "#{time}\t#{total}"
|
45
|
+
end
|
31
46
|
|
32
47
|
def process_json(options)
|
33
48
|
driver = options.fetch :driver
|
34
|
-
total = 0
|
35
49
|
time = Time.now
|
36
50
|
|
37
51
|
self.json_hash[:channels].each do |channel_hash|
|
38
|
-
|
39
|
-
|
40
|
-
driver,
|
41
|
-
channel_hash[:name])
|
42
|
-
begin
|
43
|
-
scrapper.retrieve_users
|
44
|
-
total += scrapper.current_online_users
|
45
|
-
rescue => e
|
46
|
-
puts e.backtrace
|
47
|
-
end
|
52
|
+
process_channel time, channel_hash[:username], channel_hash[:password],
|
53
|
+
driver, channel_hash[:name]
|
48
54
|
end
|
49
|
-
append_to_output "#{time}\t#{total}"
|
50
55
|
end
|
51
56
|
|
52
57
|
def process_options(options = {})
|
@@ -54,20 +59,11 @@ module SlackStatusTracker
|
|
54
59
|
username = options.fetch :username
|
55
60
|
password = options.fetch :password
|
56
61
|
driver = options.fetch :driver
|
57
|
-
total = 0
|
58
62
|
time = Time.now
|
59
63
|
|
60
64
|
channels.each do |c|
|
61
|
-
|
62
|
-
driver, c)
|
63
|
-
begin
|
64
|
-
scrapper.retrieve_users
|
65
|
-
total += scrapper.current_online_users
|
66
|
-
rescue => e
|
67
|
-
puts e.backtrace
|
68
|
-
end
|
65
|
+
process_channel time, username, password, driver, c
|
69
66
|
end
|
70
|
-
append_to_output "#{time}\t#{total}"
|
71
67
|
end
|
72
68
|
|
73
69
|
def parse_options(args)
|
@@ -133,15 +129,16 @@ module SlackStatusTracker
|
|
133
129
|
|
134
130
|
protected
|
135
131
|
|
136
|
-
def append_to_output(content)
|
132
|
+
def append_to_output(channel, content)
|
133
|
+
puts "Channel: #{channel}"
|
137
134
|
puts content
|
138
|
-
open(self.output_path, 'a') { |f| f.puts content }
|
135
|
+
open(File.join(self.output_path, "#{channel}.csv"), 'a') { |f| f.puts content }
|
139
136
|
end
|
140
137
|
|
141
138
|
def set_output(options)
|
142
139
|
self.output_path = options[:output]
|
143
140
|
if self.output_path.nil?
|
144
|
-
self.output_path =
|
141
|
+
self.output_path = Dir.pwd
|
145
142
|
end
|
146
143
|
end
|
147
144
|
|
@@ -5,13 +5,14 @@ module SlackStatusTracker
|
|
5
5
|
attr_accessor :password
|
6
6
|
attr_accessor :channel
|
7
7
|
attr_accessor :current_online_users
|
8
|
+
attr_accessor :headless
|
8
9
|
|
9
10
|
def initialize(username, password, driver, channel)
|
10
11
|
self.username = username
|
11
12
|
self.password = password
|
12
13
|
self.channel = channel
|
13
|
-
headless = Headless.new
|
14
|
-
headless.start
|
14
|
+
self.headless = Headless.new
|
15
|
+
self.headless.start
|
15
16
|
self.browser = Watir::Browser.new driver
|
16
17
|
self.current_online_users = 0
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_status_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyoto Kopz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: 1.3.1
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.4.8
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Command line tool to get the status of current users
|