network_connector 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 004406164b847e9f5a0f172dfc47cc5a3622b5995d483d6026075f6c13693966
4
+ data.tar.gz: d6252ff46574dda961a85d54ff37ce543e6903afaed2cb328ec5dd62a25a8ddf
5
+ SHA512:
6
+ metadata.gz: 971290440264a9bb7911835fccd605cdde21e6ed7eaaa558a4d13810813109fb9d7c084650f4fe56377031a14351b6214bf377550c4cc9cfa099c60786273df6
7
+ data.tar.gz: 849c9f577377ec5c7e329dd9dc62cb4cb843954368ffcb43858d6e1fd507ce902a029232a4d1cc5012a7bf778922232c96080daf4a8f0ed3bbd146acdf0455c2
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-04-14
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at katakeynii@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in network_connector.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+
14
+ gem "open-uri"
15
+ gem "watir"
16
+ gem "webdrivers"
17
+ gem "dotenv/load"
18
+ gem "net-ping"
19
+ gem "colorize"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Mohamed Camara Gueye
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # NetworkConnector
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/network_connector`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem install network_connector
13
+ ```
14
+ ## Usage
15
+ Once the gem installed you'll need to set your credentials in order to have access to the network.
16
+ You'll need to create an env file name under your user home.
17
+ the name should be ~/.network_informations ou ~/.network_informations.env ou ~/network_informations ou ~/network_informations.env
18
+ The content should be the following:
19
+ ```env
20
+ USERNAME=<your-username>
21
+ PASSWORD=<your-password>
22
+ HAS_CONFIRMATION=true
23
+ HOST=<your-username>
24
+ INPUT_USERNAME_ID=user.username
25
+ INPUT_PASSWORD_ID=user.password
26
+ SUBMIT_BTN=<html id fo the button>
27
+ CONFIRMATION_BTN=<html id of the confirmation button>
28
+ ```
29
+
30
+ Once it is done you can type the following command to connect to the network
31
+ ```bash
32
+ $ workconnektor
33
+ ```
34
+ ## Development
35
+
36
+ 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.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/network_connector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/network_connector/blob/master/CODE_OF_CONDUCT.md).
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the NetworkConnector project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/network_connector/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
13
+
14
+ GEM_NAME = "network_connector"
15
+ GEM_VERSION = NetworkConnector::VERSION
16
+
17
+ # task :default => :build
18
+
19
+ task :build do
20
+ system "gem build " + GEM_NAME + ".gemspec"
21
+ end
22
+
23
+ task :install => :build do
24
+ system "gem install " + GEM_NAME + "-" + GEM_VERSION + ".gem"
25
+ end
26
+
27
+ task :publish => :build do
28
+ system 'gem push ' + GEM_NAME + "-" + GEM_VERSION + ".gem"
29
+ end
30
+
31
+ task :clean do
32
+ system "rm *.gem"
33
+ end
data/bin/workconnektor ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'network_connector'
3
+ NetworkConnector.start
data/build.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ gem build network_connector.gemspec
4
+ gem install ./network_connector-0.1.0.gem
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NetworkConnector
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "network_connector/version"
4
+ require "net/ping"
5
+ require 'open-uri'
6
+ require 'watir'
7
+ require 'webdrivers'
8
+ require 'dotenv/load'
9
+ require "colorize"
10
+ require 'dotenv'
11
+ Dotenv.load('~/network_informations.env',
12
+ "~/.network_informations.env",
13
+ "~/network_informations",
14
+ "~/.network_informations")
15
+
16
+ module NetworkConnector
17
+ class Error < StandardError; end
18
+ # Your code goes here...
19
+
20
+ class << self
21
+ @@tries = 3
22
+ @@connected = false
23
+ def tries
24
+ @@tries
25
+ end
26
+
27
+ def connected?
28
+ @@connected
29
+ end
30
+
31
+ def start
32
+ @@connected = has_internet?
33
+
34
+ unless @@connected
35
+ @@tries -= 1
36
+ connect
37
+ if @@tries.eql?(0)
38
+ puts "Ooops ! \n" \
39
+ "We're sorry ! We've tried 3 times it failed \n" \
40
+ "- Verify that you set all correct for network informations \n" \
41
+ "- Perhaps the connection process is not support. \nIf so email us so we try to integrate it \n".red
42
+ else
43
+ start
44
+ end
45
+ else
46
+ puts "Great ! You're connected !".green
47
+ puts "Developed ❤️ by @katakeynii!"
48
+ @@connected = false
49
+ end
50
+ end
51
+
52
+ def has_internet?
53
+ Net::Ping::TCP.new("google.com", 'http').ping?
54
+ end
55
+
56
+ def connect
57
+ begin
58
+ url = ENV["HOST"]
59
+ browser = Watir::Browser.new :safari
60
+ browser.goto(url)
61
+ browser.send_keys :enter
62
+
63
+ credentials = [
64
+ {path: {id: ENV["INPUT_USERNAME_ID"]}, value: ENV["USERNAME"]},
65
+ {path: {id: ENV["INPUT_PASSWORD_ID"]}, value: ENV["PASSWORD"]}
66
+ ]
67
+ button_id = ENV["SUBMIT_BTN"]
68
+ credentials.each do |element|
69
+ text_field = browser.text_field(element[:path])
70
+ text_field.set element[:value]
71
+ end
72
+ browser.wait(20)
73
+ browser.input({id: button_id}).click
74
+
75
+ if ENV["HAS_CONFIRMATION_BUTTON"].eql?("true")
76
+ browser.input({id: ENV["CONFIRMATION_BUTTON"]}).click
77
+ browser.wait(30)
78
+ end
79
+
80
+ browser.close
81
+ rescue => exception
82
+ puts "Ooops ! \n" \
83
+ "Please make sure that you are connected to the private wifi\n".red
84
+
85
+ end
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,4 @@
1
+ module NetworkConnector
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: network_connector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mohamed Camara Gueye
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: You might be working in a big company with high security policies. Where
14
+ you need to connect to and login into a web page in order to have access to internet.
15
+ This libray will helps you automate the connection so that you dont have to always
16
+ open the website and conenct manually
17
+ email:
18
+ - katakeynii@gmail.com
19
+ executables:
20
+ - workconnektor
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - ".rspec"
25
+ - ".rubocop.yml"
26
+ - CHANGELOG.md
27
+ - CODE_OF_CONDUCT.md
28
+ - Gemfile
29
+ - LICENSE.txt
30
+ - README.md
31
+ - Rakefile
32
+ - bin/workconnektor
33
+ - build.sh
34
+ - lib/network_connector.rb
35
+ - lib/network_connector/version.rb
36
+ - sig/network_connector.rbs
37
+ homepage: https://github.com/katakeynii/network_connector
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ allowed_push_host: https://rubygems.org
42
+ homepage_uri: https://github.com/katakeynii/network_connector
43
+ source_code_uri: https://github.com/katakeynii/network_connector/blob/main/CHANGELOG.md
44
+ changelog_uri: https://github.com/katakeynii/network_connector/blob/main/CHANGELOG.md
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.2.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: This gem helps connect to a private network by accessing it
64
+ test_files: []