hotspot-login 0.1.3 → 0.1.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hl.rb +6 -12
  3. data/lib/hl.rb +5 -20
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a70630d93f452c7cbbff39a618dfa3348b45bad0
4
- data.tar.gz: 4b90b2f9aa69adf1bd24bc42b67b542698164f23
3
+ metadata.gz: 87872bdf0f7f4f9b251f9925f03ff55fae50a0d9
4
+ data.tar.gz: 24a82a907cf180962f83a88cca5ef5df5428ef8e
5
5
  SHA512:
6
- metadata.gz: 716a1e19f5606cac7e07841890b94d7a02b789e3eec382ed9900defb1260c474ffc36c6e23946a5ca55d4e62562332f778f2ac5417cc5a9d1eefb7e40af37464
7
- data.tar.gz: c8902b94884b90787fd759daa0d02308653d4ad08df5c08ad8e0a243c5f52d69a2cbab769cd604b89e94a28929ba6657db8095de436981f854a332a64bbf2143
6
+ metadata.gz: b8a7fbe7601a56e3d9314d3f39014746dae82241de7808efae161b5fc202b04fea59cefe17787cd0cc54dc0b12503cbf4f93f93c11092f7a4d295608ffc3a0cb
7
+ data.tar.gz: ab49db895d888bf3704e9586f591b20a7819ba5e2ea70fbd18c65dce83efc7e5050f317a190fd2333e0dbde444a09f1f023a325e5e2d27b3040a331fa5cd967b
data/bin/hl.rb CHANGED
@@ -4,13 +4,6 @@ require 'optparse'
4
4
  require 'hl'
5
5
 
6
6
  class Hotspot_Login
7
- def initialize
8
- @engine = {
9
- "sfr" => Hotspot::Sfr,
10
- "free" => Hotspot::FreeWifi
11
- }
12
- end
13
-
14
7
  def parse
15
8
  @options = parse!(ARGV) if @options.nil?
16
9
  @options
@@ -47,10 +40,11 @@ class Hotspot_Login
47
40
  end
48
41
 
49
42
  def config!
50
- config = {
51
- "sfr" => {type: "sfr"},
52
- "free" => {type: "free"}
53
- }
43
+ config = Hash.new
44
+
45
+ Hotspot::Hotspot.hotspots.each do |hotspot, val|
46
+ config[hotspot] = {type: hotspot}
47
+ end
54
48
 
55
49
  path = Dir.home + "/.config/hl.yml"
56
50
 
@@ -108,7 +102,7 @@ class Hotspot_Login
108
102
  end
109
103
 
110
104
  def engine?(type)
111
- @engine[type]
105
+ Hotspot::Hotspot.hotspots[type]
112
106
  end
113
107
  end
114
108
 
data/lib/hl.rb CHANGED
@@ -3,6 +3,7 @@ require 'cgi'
3
3
 
4
4
  module Hotspot
5
5
  class Hotspot
6
+ @@hotspots = Hash.new
6
7
  def initialize(user, password)
7
8
  @uri_test = "http://www.example.com"
8
9
  @user = user
@@ -75,24 +76,16 @@ class Hotspot
75
76
  Net::HTTP.post_form(URI(uri), query)
76
77
  end
77
78
 
78
- def sfr?
79
- info.host == "hotspot.wifi.sfr.fr"
79
+ def self.inherited(klass)
80
+ @@hotspots[klass.name.split(/::/).last] = klass
80
81
  end
81
82
 
82
- def uppa?
83
- info.host == "wism.univ-pau.fr"
84
- end
85
-
86
- def free?
87
- info.host == "wifi.free.fr"
83
+ def self.hotspots
84
+ @@hotspots
88
85
  end
89
86
  end
90
87
 
91
88
  class Sfr < Hotspot
92
- def hotspot?
93
- sfr?
94
- end
95
-
96
89
  def auth
97
90
  query = params.merge!({username: @user, username2: @user, password: @password, conditions: "on", lang: "fr", connexion: "Connexion", accessType: "neuf"})
98
91
  t = redirect? post("https://hotspot.wifi.sfr.fr/nb4_crypt.php", query)
@@ -101,10 +94,6 @@ class Sfr < Hotspot
101
94
  end
102
95
 
103
96
  class UPPA < Hotspot
104
- def hotspot?
105
- uppa?
106
- end
107
-
108
97
  def auth
109
98
  query = params.merge!({username: @user, password: @password, buttonClicked: 4, info_msg:nil, info_flag: 0, err_msg: nil, err_flag: 0})
110
99
  post("https://wism.univ-pau.fr/login.html", query)
@@ -112,10 +101,6 @@ class UPPA < Hotspot
112
101
  end
113
102
 
114
103
  class FreeWifi < Hotspot
115
- def hotspot?
116
- free?
117
- end
118
-
119
104
  def auth
120
105
  query = params.merge!({login: @user, password: @password, submit: "Valider"})
121
106
  post("https://wifi.free.fr/Auth", query)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotspot-login
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Jeser