slack_invitation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/slack_invitation/invitator.rb +74 -0
- data/lib/slack_invitation/version.rb +3 -0
- data/lib/slack_invitation.rb +5 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 617de4e550a41a49e629683413039f55c6bc1388
|
4
|
+
data.tar.gz: 8bf15d4ac46995780921f24be5453c9acdc50d92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 40db8404cefaf663c7da55dfe55833187d66860d3a0def60ee34c47d3bd6db2a800492bd0ad5e7de47a52eb867930fd2b0b9886e4af7e21e1222ce6787995f66
|
7
|
+
data.tar.gz: 6f2b4f7bd5d3ce85cea7d1df02cb3097e63f2e65a48c6ce2b7ac43e44e0cbec3fdf6a3d3e307aa905a5f7c8e46ba7537f276b72d896df671ff32f4f26d22a7db
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module SlackInvitation
|
5
|
+
class Invitator
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
attr_writer :team, :admin_email, :admin_password
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@driver = Selenium::WebDriver.for :firefox
|
12
|
+
target_size = Selenium::WebDriver::Dimension.new(1024, 768)
|
13
|
+
@driver.manage.window.size = target_size
|
14
|
+
end
|
15
|
+
|
16
|
+
def quit
|
17
|
+
@driver.quit
|
18
|
+
end
|
19
|
+
|
20
|
+
def invite(email)
|
21
|
+
login
|
22
|
+
send_invitation_mail(email)
|
23
|
+
test_success
|
24
|
+
end
|
25
|
+
|
26
|
+
def config(team, email, password)
|
27
|
+
@team = team
|
28
|
+
@admin_email = email
|
29
|
+
@admin_password = password
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def login
|
35
|
+
@driver.navigate.to slack_url
|
36
|
+
@driver.find_element(:id, 'email').send_keys(@admin_email)
|
37
|
+
@driver.find_element(:id, 'password').send_keys(@admin_password)
|
38
|
+
@driver.find_element(:id, 'signin_btn').click
|
39
|
+
end
|
40
|
+
|
41
|
+
def send_invitation_mail(email)
|
42
|
+
tries ||= 0
|
43
|
+
@driver.navigate.to invitation_url
|
44
|
+
wait tries
|
45
|
+
@driver.find_element(:class, 'email_field').send_keys(email)
|
46
|
+
@driver.find_element(:class, 'api_send_invites').click
|
47
|
+
wait tries
|
48
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
49
|
+
wait tries
|
50
|
+
retry unless (tries += 1) == 5
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_success
|
54
|
+
error = @driver.find_element(:class, 'error_msg').displayed?
|
55
|
+
success = @driver.find_element(:class, 'seafoam_green').displayed?
|
56
|
+
|
57
|
+
return true if success
|
58
|
+
return false if error
|
59
|
+
end
|
60
|
+
|
61
|
+
def slack_url
|
62
|
+
"http://#{ @team }.slack.com/"
|
63
|
+
end
|
64
|
+
|
65
|
+
def invitation_url
|
66
|
+
"https://#{ @team }.slack.com/admin/invites/full"
|
67
|
+
end
|
68
|
+
|
69
|
+
def wait(try = nil)
|
70
|
+
sleep(3) unless try
|
71
|
+
sleep(0.5 + try*1) if try
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack_invitation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daekwon Kim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: selenium-webdriver
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
description: Slack invitation automation using selenium
|
28
|
+
email:
|
29
|
+
- propellerheaven@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/slack_invitation.rb
|
35
|
+
- lib/slack_invitation/invitator.rb
|
36
|
+
- lib/slack_invitation/version.rb
|
37
|
+
homepage: http://slack.invitation.nacyot.com
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.0.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.2.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Slack invitation automation using selenium
|
61
|
+
test_files: []
|