slack_status_tracker 0.1.0.pre → 0.1.0.pre.1

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
  SHA1:
3
- metadata.gz: 6be6ef55f798ad9138a45627c33de4b7495e4c51
4
- data.tar.gz: 9e12274c476c0552188bd6bb1e22470da58631c2
3
+ metadata.gz: bf46e949211f3729296e03c2521f0b5ef7d0376f
4
+ data.tar.gz: 1d2c56ffeb23198a31fe5b5b8c02353cb2f5cc56
5
5
  SHA512:
6
- metadata.gz: 789c8d5582d4c5f64bf42b35e3a6f2ca0ba7360e5be852c4e7d7629202f6f5f590dc48a1ebf062bdd159b54c217ec3e41da19491b686b1c17506a2d4ba9bc5fe
7
- data.tar.gz: 2ffad31ddd23ab6ed7a0a7f7e991c3573ee152b1f506d26ded4e20eacd454edb1c79a0607561ec1108597a2e3eed84a9946acb998978957ea38e3927788d20d5
6
+ metadata.gz: 2bc9a2575e75fab6cf128132d561299ee6eb8e21a8daeabaaeb94b8667ba86f9ccaf4f2876199cbf49fce4e6ba9254dd410cc882f32ab08c68822ba87f80b5ec
7
+ data.tar.gz: e668a263023471cbe21e109b2772edb98c5479e9b75b728aebdd5a6628c918c85f60bcad2ecaf50dec4c828ee3a24fde4631a8640fe8507073825099f49087e6
data/README.md CHANGED
@@ -31,6 +31,7 @@ You should get the available options:
31
31
  Usage: slack_status_tracker [options]
32
32
  -s, --start Start to track
33
33
  -o, --output [FILE_PATH] Output file (default slack_online_users.txt)
34
+ -i, --input [FILE_PATH] JSON file with credentials about channels
34
35
  --channels c1,c2,c3 Slack channels
35
36
  --driver [BROWSER_DRIVER] Browser Driver (default chrome)
36
37
  -f, --frequency [MINUTES] Time minutes frequency (default 30)
@@ -82,6 +83,33 @@ Time Online Users
82
83
  2016-08-01 09:00:55 +0000 11
83
84
  ```
84
85
 
86
+ ### Multiple channels
87
+ In order to support multiple channels you need to pass a JSON configuration
88
+ file with the username and password for each channel. Specify the path to the
89
+ file with the proper settings.
90
+
91
+ ```json
92
+ // spec/fixtures/sample_input.json
93
+ {
94
+ "channels": [
95
+ {
96
+ "name": "channel 1",
97
+ "username": "user1",
98
+ "password": "secret1"
99
+ },
100
+ {
101
+ "name": "channel 2",
102
+ "username": "user2",
103
+ "password": "secret2"
104
+ }
105
+ ]
106
+ }
107
+ ```
108
+
109
+ ```bash
110
+ slack_status_tracker -i spec/fixtures/sample_input.json
111
+ ```
112
+
85
113
  ## Development
86
114
 
87
115
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
File without changes
@@ -3,23 +3,53 @@ module SlackStatusTracker
3
3
  include Singleton
4
4
 
5
5
  attr_accessor :output_path
6
+ attr_accessor :json_hash
6
7
 
7
8
  def cmd
8
9
  options = parse_options ARGV
9
10
  set_output options
11
+ set_json_hash options
10
12
  frequency = options.fetch :frequency
11
13
  append_to_output "Time\t\t\t\tOnline Users"
12
14
  if options[:start]
13
15
  while true
14
- process_channels options
16
+ verify_options options
15
17
  sleep frequency*60
16
18
  end
17
19
  else
18
- process_channels options
20
+ verify_options options
19
21
  end
20
22
  end
21
23
 
22
- def process_channels(options = {})
24
+ def verify_options(options = {})
25
+ if self.json_hash.nil?
26
+ process_options options
27
+ else
28
+ process_json options
29
+ end
30
+ end
31
+
32
+ def process_json(options)
33
+ driver = options.fetch :driver
34
+ total = 0
35
+ time = Time.now
36
+
37
+ 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
48
+ end
49
+ append_to_output "#{time}\t#{total}"
50
+ end
51
+
52
+ def process_options(options = {})
23
53
  channels = options.fetch :channels
24
54
  username = options.fetch :username
25
55
  password = options.fetch :password
@@ -54,6 +84,11 @@ module SlackStatusTracker
54
84
  options[:output] = o
55
85
  end
56
86
 
87
+ opts.on("-i", "--input [FILE_PATH]",
88
+ "JSON file with credentials about channels") do |i|
89
+ options[:input] = i
90
+ end
91
+
57
92
  opts.on("--channels c1,c2,c3", Array,
58
93
  "Slack channels") do |channels|
59
94
  options[:channels] = channels
@@ -109,5 +144,12 @@ module SlackStatusTracker
109
144
  self.output_path = File.join(Dir.pwd, 'slack_online_users.txt')
110
145
  end
111
146
  end
147
+
148
+ def set_json_hash(options)
149
+ if (input_path = options[:input])
150
+ self.json_hash =
151
+ JSON.parse(File.read(input_path), symbolize_names: true)
152
+ end
153
+ end
112
154
  end
113
155
  end
@@ -1,3 +1,3 @@
1
1
  module SlackStatusTracker
2
- VERSION = "0.1.0.pre"
2
+ VERSION = "0.1.0.pre.1"
3
3
  end
@@ -3,6 +3,7 @@ require "singleton"
3
3
  require "watir"
4
4
  require 'headless'
5
5
  require 'optparse'
6
+ require 'json'
6
7
  # App
7
8
  require "slack_status_tracker/version"
8
9
  require "slack_status_tracker/report_manager"
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.1
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-08-01 00:00:00.000000000 Z
11
+ date: 2016-08-04 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.4.8
162
+ rubygems_version: 2.5.1
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Command line tool to get the status of current users