office-login 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/office-login +4 -0
- data/lib/office-login.rb +82 -0
- data/lib/office-login/version.rb +5 -0
- data/office-login.gemspec +20 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Sebastian Georgi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Office::Login
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'office-login'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install office-login
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/office-login
ADDED
data/lib/office-login.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require "office-login/version"
|
2
|
+
require 'watir-webdriver'
|
3
|
+
require 'headless'
|
4
|
+
require 'optparse'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Office
|
8
|
+
module Login
|
9
|
+
def self.login(args)
|
10
|
+
|
11
|
+
options = Login::get_options(args)
|
12
|
+
configuration = Login::get_configuration
|
13
|
+
configuration.merge!(options)
|
14
|
+
Login::store_configuration(configuration)
|
15
|
+
|
16
|
+
Headless.ly do |headless|
|
17
|
+
browser = Watir::Browser.new
|
18
|
+
browser.goto configuration[:log_out]
|
19
|
+
browser.goto configuration[:log_in]
|
20
|
+
browser.text_field(:name => 'username').set(configuration[:username])
|
21
|
+
browser.text_field(:name => 'password').set(configuration[:password])
|
22
|
+
browser.button(:name => 'Submit').click
|
23
|
+
browser.close
|
24
|
+
end
|
25
|
+
rescue => error
|
26
|
+
puts "Something did not work: #{error.inspect}"
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.get_configuration
|
31
|
+
file = File.expand_path("~") + '/.office-login'
|
32
|
+
if File.exists?(file)
|
33
|
+
configuration = YAML.load_file file
|
34
|
+
else
|
35
|
+
configuration = {
|
36
|
+
:log_in => 'https://host/login.html',
|
37
|
+
:log_out => 'https://host/logout.html',
|
38
|
+
:username => 'username',
|
39
|
+
:password => 'password'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
configuration
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.store_configuration configuration
|
47
|
+
file_name = File.expand_path("~") + '/.office-login'
|
48
|
+
File.open(file_name, 'w') { |file| file.puts(configuration.to_yaml) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.get_options(args)
|
52
|
+
options = { }
|
53
|
+
OptionParser.new do |opts|
|
54
|
+
opts.banner = "Usage: office-login [options]"
|
55
|
+
|
56
|
+
opts.on("-a", "--log-in [STRING]", "URL for LOGIN-action") do |li|
|
57
|
+
options[:log_in] = li
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on("-b", "--log-out [STRING]", "URL for LOGOUT-action") do |lo|
|
61
|
+
options[:log_out] = lo
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on("-u", "--username [STRING]", "The username to be used") do |u|
|
65
|
+
options[:username] = u
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on("-p", "--password [STRING]", "The password to be used") do |p|
|
69
|
+
options[:password] = p
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
73
|
+
puts opts
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
end.parse!(args)
|
77
|
+
|
78
|
+
options
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/office-login/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Sebastian Georgi"]
|
6
|
+
gem.email = ["sgeorgi@sgeorgi.de"]
|
7
|
+
gem.description = %q{CLI tool to log-in to the office's network via headless browser}
|
8
|
+
gem.summary = %q{...}
|
9
|
+
gem.homepage = "https://github.com/sgeorgi/office-login"
|
10
|
+
|
11
|
+
gem.add_dependency 'watir-webdriver'
|
12
|
+
gem.add_dependency 'headless'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "office-login"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Office::Login::VERSION
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: office-login
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sebastian Georgi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: watir-webdriver
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: headless
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: CLI tool to log-in to the office's network via headless browser
|
47
|
+
email:
|
48
|
+
- sgeorgi@sgeorgi.de
|
49
|
+
executables:
|
50
|
+
- office-login
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/office-login
|
60
|
+
- lib/office-login.rb
|
61
|
+
- lib/office-login/version.rb
|
62
|
+
- office-login.gemspec
|
63
|
+
homepage: https://github.com/sgeorgi/office-login
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.24
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: ! '...'
|
87
|
+
test_files: []
|