wifi_login 0.0.2 → 0.0.3
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.
data/Gemfile
CHANGED
data/bin/wifi_login
CHANGED
@@ -1,38 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'wifi_login'
|
3
|
-
|
4
|
-
if ['--version', '-v'].include?(ARGV.first)
|
5
|
-
puts "wifi_login #{WifiLogin::VERSION}"
|
6
|
-
exit(0)
|
7
|
-
end
|
3
|
+
require 'wifi_login/cli'
|
8
4
|
|
9
5
|
begin
|
10
|
-
|
11
|
-
when 'install'
|
12
|
-
puts 'not implemented'
|
13
|
-
when 'login'
|
14
|
-
success = WifiLogin.login
|
15
|
-
puts 'login success' if success
|
16
|
-
when 'logout'
|
17
|
-
puts 'not implemented'
|
18
|
-
when 'ssid'
|
19
|
-
puts "current SSID: #{WifiLogin.ssid}"
|
20
|
-
when 'help'
|
21
|
-
puts <<-"EOS"
|
22
|
-
wifi_login #{WifiLogin::VERSION}
|
23
|
-
usage: wifi_login COMMAND
|
24
|
-
|
25
|
-
install # install trigger to your Mac OS X System (launchd)
|
26
|
-
uninstall # uninstall trigger
|
27
|
-
login # login public wi-fi access point
|
28
|
-
ssid # show current SSID
|
29
|
-
help # show this message
|
30
|
-
|
31
|
-
EOS
|
32
|
-
else
|
33
|
-
STDERR.puts "wifi_login: unknown command #{ARGV.first} (see `wifi_login help`)"
|
34
|
-
exit(1)
|
35
|
-
end
|
6
|
+
WifiLogin::CLI.start
|
36
7
|
rescue WifiLogin::Error => e
|
37
8
|
STDERR.puts "ERROR! #{e.message}"
|
38
9
|
exit(1)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'thor'
|
3
|
+
require 'wifi_login'
|
4
|
+
|
5
|
+
module WifiLogin
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
LAUNCH_AGENT_DIR = "#{ENV['HOME']}/Library/LaunchAgents"
|
10
|
+
LAUNCH_AGENT_FILE = "#{LAUNCH_AGENT_DIR}/jp.machu.wifi_login.plist"
|
11
|
+
LOG_DIR = "#{ENV['HOME']}/Library/Logs/jp.machu.wifi_login"
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.dirname(__FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "install", "Install trigger to your Mac OS X System (launchd)."
|
18
|
+
def install
|
19
|
+
empty_directory LOG_DIR
|
20
|
+
if WifiLogin.in_rbenv?
|
21
|
+
template "templates/jp.machu.wifi_login.plist.rbenv.tt", "#{LAUNCH_AGENT_FILE}"
|
22
|
+
else
|
23
|
+
template "templates/jp.machu.wifi_login.plist.tt", "#{LAUNCH_AGENT_FILE}"
|
24
|
+
end
|
25
|
+
run "launchctl load #{LAUNCH_AGENT_FILE}"
|
26
|
+
say
|
27
|
+
say "Complete install. Please run `pit set docomo` to set your ID/Password.", Thor::Shell::Color::GREEN
|
28
|
+
say "Example"
|
29
|
+
say "--"
|
30
|
+
say "id: your-id-spmode@docomo"
|
31
|
+
say "password: your-password"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "uninstall", "Uninstall trigger."
|
35
|
+
def uninstall
|
36
|
+
run "launchctl unload #{LAUNCH_AGENT_FILE}"
|
37
|
+
return unless File.exist?(LAUNCH_AGENT_FILE)
|
38
|
+
remove_file LAUNCH_AGENT_FILE
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "ssid", "Show current SSID"
|
42
|
+
def ssid
|
43
|
+
say "current SSID: #{WifiLogin.ssid}"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "login", "Login public wi-fi access point."
|
47
|
+
def login
|
48
|
+
success = WifiLogin.login
|
49
|
+
say 'Login success!', Thor::Shell::Color::GREEN if success
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "version", "Prints the bundler's version information"
|
53
|
+
def version
|
54
|
+
say "wifi_login #{WifiLogin::VERSION}"
|
55
|
+
end
|
56
|
+
map %w(-v --version) => :version
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>Label</key>
|
6
|
+
<string>jp.machu.wifi_login</string>
|
7
|
+
<key>ProgramArguments</key>
|
8
|
+
<array>
|
9
|
+
<string>/bin/bash</string>
|
10
|
+
<string>-c</string>
|
11
|
+
<string>export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; wifi_login login</string>
|
12
|
+
</array>
|
13
|
+
<key>RunAtLoad</key>
|
14
|
+
<true/>
|
15
|
+
<key>StandardErrorPath</key>
|
16
|
+
<string><%= ENV['HOME'] %>/Library/Logs/jp.machu.wifi_login/stderr</string>
|
17
|
+
<key>StandardOutPath</key>
|
18
|
+
<string><%= ENV['HOME'] %>/Library/Logs/jp.machu.wifi_login/stdout</string>
|
19
|
+
<key>WatchPaths</key>
|
20
|
+
<array>
|
21
|
+
<string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string>
|
22
|
+
</array>
|
23
|
+
</dict>
|
24
|
+
</plist>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>Label</key>
|
6
|
+
<string>jp.machu.wifi_login</string>
|
7
|
+
<key>ProgramArguments</key>
|
8
|
+
<array>
|
9
|
+
<string>wifi_login login</string>
|
10
|
+
</array>
|
11
|
+
<key>RunAtLoad</key>
|
12
|
+
<true/>
|
13
|
+
<key>StandardErrorPath</key>
|
14
|
+
<string><%= ENV['HOME'] %>/Library/Logs/jp.machu.wifi_login/stderr</string>
|
15
|
+
<key>StandardOutPath</key>
|
16
|
+
<string><%= ENV['HOME'] %>/Library/Logs/jp.machu.wifi_login/stdout</string>
|
17
|
+
<key>WatchPaths</key>
|
18
|
+
<array>
|
19
|
+
<string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string>
|
20
|
+
</array>
|
21
|
+
</dict>
|
22
|
+
</plist>
|
data/lib/wifi_login/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wifi_login
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -74,8 +74,11 @@ files:
|
|
74
74
|
- Rakefile
|
75
75
|
- bin/wifi_login
|
76
76
|
- lib/wifi_login.rb
|
77
|
+
- lib/wifi_login/cli.rb
|
77
78
|
- lib/wifi_login/provider.rb
|
78
79
|
- lib/wifi_login/providers/docomo.rb
|
80
|
+
- lib/wifi_login/templates/jp.machu.wifi_login.plist.rbenv.tt
|
81
|
+
- lib/wifi_login/templates/jp.machu.wifi_login.plist.tt
|
79
82
|
- lib/wifi_login/version.rb
|
80
83
|
- spec/spec_helper.rb
|
81
84
|
- spec/wifi_login/providers/docomo_spec.rb
|