titech-pubnet-auth 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ require 'yaml'
6
6
 
7
7
  $:.unshift File.dirname(__FILE__)
8
8
  require 'titech_pubnet_auth/bin_routines'
9
+ require 'titech_pubnet_auth/extensions'
9
10
 
10
11
 
11
12
  class TitechPubnetAuth
@@ -39,7 +40,7 @@ class TitechPubnetAuth
39
40
  form.username = @private['username']
40
41
  form.password = @private['password']
41
42
  end.submit
42
-
43
+
43
44
  return is_connected?
44
45
  end
45
46
 
@@ -47,19 +48,18 @@ class TitechPubnetAuth
47
48
  # called if network_available?
48
49
  #
49
50
  def is_connected?(sample_uri = SAMPLE_URI.call)
50
- return @agent_with_proxy.get(sample_uri).uri.hostname == sample_uri.hostname
51
+ @agent_with_proxy.get(sample_uri).uri.hostname == sample_uri.hostname
51
52
  rescue # retry without the proxy
52
- return @agent.get(sample_uri).uri.hostname == sample_uri.hostname
53
+ @agent.get(sample_uri).uri.hostname == sample_uri.hostname
53
54
  end
54
55
 
55
56
  #
56
57
  # note: titech-pubnet allows to access portal.titech.ac.jp without authentication.
57
58
  #
58
59
  def network_available?(sample_uri = SAMPLE_URI.call)
59
- @agent.get('http://portal.titech.ac.jp')
60
- return true
60
+ @agent.get('http://portal.titech.ac.jp').to_b
61
61
  rescue # check another website just to make sure
62
- return @agent.get(sample_uri).uri.hostname == sample_uri.hostname
62
+ @agent.get(sample_uri).to_b rescue return false
63
63
  end
64
64
 
65
65
  end
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def to_b
3
+ return !!self
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  class TitechPubnetAuth
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: titech-pubnet-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -69,6 +69,7 @@ extensions: []
69
69
  extra_rdoc_files: []
70
70
  files:
71
71
  - lib/titech_pubnet_auth/bin_routines.rb
72
+ - lib/titech_pubnet_auth/extensions.rb
72
73
  - lib/titech_pubnet_auth/version.rb
73
74
  - lib/titech_pubnet_auth.rb
74
75
  - bin/titech-pubnet-auth