slack_status_tracker 0.1.0.pre.2 → 0.1.0.pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df05f32bd4c8c56530c110cca368241747b05c9e
4
- data.tar.gz: cabaf72d243dd74fb1b22dc0e2374a1c47521905
3
+ metadata.gz: fc9664f509040ec1e50f3f193039098077d0f118
4
+ data.tar.gz: 44ca0b07d98fc43a2706346304fde7cc534c18a1
5
5
  SHA512:
6
- metadata.gz: 596dffe656cf70afb20f5270f4199597845374cd465b6419b34b7f9b0350fe034053fdf67156287021371534292f7d7175bca5c16519099054d32ce574189289
7
- data.tar.gz: 2c0fe046b1bb10cdfaed8614eae59eb1f552ebdfc9ecd89b9831fc7cfa32f12884d60fd27191481d0fff583d1579802937c4f8d17f05c49a7ced3d81bad14f22
6
+ metadata.gz: baa11ec553e31f08b1dcd07af5036a2adace11b57ade68cd84df813a1acec4e96f48f9fda2b1dd229b063b404a9de86d52a0d7142169a59f2c1a6610d4b94701
7
+ data.tar.gz: 32d56e25cd384179df023398f1c4450cf241c43ed04055c9ac90bbd6c08ac05239ae964308a94cd7760c7645e750193a45827b2263a36b67c7632639bf3535b3
data/.gitignore CHANGED
@@ -17,3 +17,5 @@
17
17
  .env
18
18
  # Test output
19
19
  slack_online_users.txt
20
+ sample_input.json
21
+ /*.csv
@@ -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
- scrapper = SlackStatusTracker::Scrapper.new(channel_hash[:username],
39
- channel_hash[:password],
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
- scrapper = SlackStatusTracker::Scrapper.new(username, password,
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 = File.join(Dir.pwd, 'slack_online_users.txt')
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
@@ -1,3 +1,3 @@
1
1
  module SlackStatusTracker
2
- VERSION = "0.1.0.pre.2"
2
+ VERSION = "0.1.0.pre.3"
3
3
  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.2
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-01 00:00:00.000000000 Z
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.5.1
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