sakura-cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +170 -0
- data/Rakefile +10 -0
- data/exe/sakura +8 -0
- data/lib/sakura.rb +5 -0
- data/lib/sakura/cli/mail.rb +153 -0
- data/lib/sakura/cli/root.rb +11 -0
- data/lib/sakura/cli/version.rb +5 -0
- data/lib/sakura/client.rb +73 -0
- data/lib/sakura/mail_address.rb +164 -0
- data/sakura-cli.gemspec +27 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: efd5e983753789e52601e9ac4a964b12126a4332
|
4
|
+
data.tar.gz: 738d21ce3ec8ead5bbc4a299cc2facb31d01c780
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e0ff298884e5271b0b22a4b30d9500c603fa0597b6db756546a225b77ce0f64d17efd72c58f19d0c59bc95a23b22cc30e021f9b67bb422dbc1dd1cb649a3f4a
|
7
|
+
data.tar.gz: 7ea1e26078515dc5bffd37667870683d1a9c2380c0a6fa0f6da8b452fbf9a022d3903f6c0fdcf91d65b2e97335675f258c4517101530c49e2986487672bddfad
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Shintaro Kojima
|
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,170 @@
|
|
1
|
+
# Sakura CLI
|
2
|
+
|
3
|
+
Sakura CLI は, [さくらのレンタルサーバー](http://www.sakura.ne.jp/)のコントロールパネルをコマンドラインから制御するためのツールです.
|
4
|
+
|
5
|
+
:construction: このバージョンでは, ライト/スタンダード/プレミアムに共通する **メールアドレス管理** 機能のみサポートします
|
6
|
+
|
7
|
+
## セットアップ
|
8
|
+
|
9
|
+
Sakura CLI をインストールします.
|
10
|
+
|
11
|
+
```zsh
|
12
|
+
gem install sakura-cli
|
13
|
+
```
|
14
|
+
|
15
|
+
Sakura CLI は[PhantomJS](http://phantomjs.org/download.html) に依存しています.
|
16
|
+
お使いのOS に合った方法でインストールしてください.
|
17
|
+
|
18
|
+
Mac の場合は
|
19
|
+
|
20
|
+
```zsh
|
21
|
+
brew install phantomjs
|
22
|
+
```
|
23
|
+
|
24
|
+
でもインストールできます.
|
25
|
+
|
26
|
+
### 環境設定
|
27
|
+
|
28
|
+
ログイン情報を環境変数に設定します.
|
29
|
+
|
30
|
+
```zsh
|
31
|
+
export SAKURA_DOMAIN='example.com'
|
32
|
+
export SAKURA_PASSWD='your_password'
|
33
|
+
```
|
34
|
+
|
35
|
+
[dotenv](https://github.com/bkeepers/dotenv) を使うと便利かもしれません.
|
36
|
+
|
37
|
+
```zsh
|
38
|
+
# ~/.sakura.env (dotenv の場合)
|
39
|
+
|
40
|
+
SAKURA_DOMAIN='example.com'
|
41
|
+
SAKURA_PASSWD='your_password'
|
42
|
+
```
|
43
|
+
|
44
|
+
場合によっては[direnv](https://github.com/zimbatm/direnv) もいいでしょう.
|
45
|
+
|
46
|
+
|
47
|
+
## 使いかた
|
48
|
+
|
49
|
+
```sakura help``` や ```sakura mail help``` コマンドでヘルプが表示できます.
|
50
|
+
|
51
|
+
```zsh
|
52
|
+
$ sakura help
|
53
|
+
Commands:
|
54
|
+
sakura help [COMMAND] # Describe available commands or one specific command
|
55
|
+
sakura mail # Manage mail addresses
|
56
|
+
|
57
|
+
$ sakura mail help
|
58
|
+
Commands:
|
59
|
+
sakura mail create LOCAL_PART [PASSWORD] # Create a mail address
|
60
|
+
sakura mail delete LOCAL_PART # Delete a mail address
|
61
|
+
sakura mail forward LOCAL_PART [{add|remove} EMAIL] # Add, remove or show mail address(es) to forward
|
62
|
+
sakura mail help [COMMAND] # Describe subcommands or one specific subcommand
|
63
|
+
sakura mail keep LOCAL_PART [enable|disable] # Switch keep or flush mails
|
64
|
+
sakura mail list # List all mail addresses of the domain
|
65
|
+
sakura mail password LOCAL_PART [PASSWORD] # Update password of a mail address
|
66
|
+
sakura mail quota LOCAL_PART [VALUE] # Update or show quota of a mail address
|
67
|
+
sakura mail scan LOCAL_PART [enable|disable] # Switch virus scan
|
68
|
+
```
|
69
|
+
|
70
|
+
### メールアドレス一覧
|
71
|
+
|
72
|
+
```sakura mail list``` コマンドで, メールアドレス一覧とその概要を表示できます.
|
73
|
+
|
74
|
+
```zsh
|
75
|
+
$ sakura mail list
|
76
|
+
# domain: example.com
|
77
|
+
address virus_scan usage / quota
|
78
|
+
---------------------------------------------------------
|
79
|
+
dummy true 379.13KB / 200MB
|
80
|
+
dummy001 true 1.79MB / 2GB
|
81
|
+
dummy002 true 6.28KB / 2GB
|
82
|
+
postmaster true 0B / 2GB
|
83
|
+
```
|
84
|
+
|
85
|
+
### メールアドレス作成
|
86
|
+
|
87
|
+
```sakura mail create``` コマンドで, メールアドレスを作成できます.
|
88
|
+
|
89
|
+
```zsh
|
90
|
+
$ sakura mail create dummy
|
91
|
+
password?
|
92
|
+
password(confirm)?
|
93
|
+
```
|
94
|
+
|
95
|
+
コマンド引数に初期パスワードを指定することもできます.
|
96
|
+
|
97
|
+
### メールアドレス削除
|
98
|
+
|
99
|
+
```sakura mail delete``` コマンドで, メールアドレスを削除できます.
|
100
|
+
|
101
|
+
### クォータ表示・変更
|
102
|
+
|
103
|
+
```sakura mail quota``` コマンドで, 現在のクォータを表示・変更できます.
|
104
|
+
|
105
|
+
```zsh
|
106
|
+
$ sakura mail quota dummy # 現在のクォータを表示
|
107
|
+
200MB
|
108
|
+
|
109
|
+
$ sakura mail quota dummy 300 # 300MB に変更
|
110
|
+
```
|
111
|
+
|
112
|
+
変更する場合, 単位はMB です.
|
113
|
+
|
114
|
+
### パスワード変更
|
115
|
+
|
116
|
+
```sakura mail password``` コマンドで, パスワードをリセットできます.
|
117
|
+
|
118
|
+
```zsh
|
119
|
+
$ sakura mail password dummy
|
120
|
+
password?
|
121
|
+
password(confirm)?
|
122
|
+
```
|
123
|
+
|
124
|
+
コマンド引数に初期パスワードを指定することもできます.
|
125
|
+
|
126
|
+
### メール転送
|
127
|
+
|
128
|
+
```sakura mail forward``` コマンドで, 転送先リストを表示・編集できます.
|
129
|
+
|
130
|
+
```zsh
|
131
|
+
$ sakura mail forward dummy # 転送先リストを表示
|
132
|
+
foo@example.com
|
133
|
+
$ sakura mail forward dummy add bar@example.com # 転送先に追加
|
134
|
+
$ sakura mail forward dummy remove bar@example.com # 転送先から削除
|
135
|
+
```
|
136
|
+
|
137
|
+
```sakura mail keep``` コマンドで, メールをメールボックスに残すか/転送専用にするか の設定を表示・変更できます.
|
138
|
+
|
139
|
+
```zsh
|
140
|
+
$ sakura mail keep dummy # 設定を表示
|
141
|
+
true
|
142
|
+
$ sakura mail keep dummy disable # メールボックスに残す
|
143
|
+
```
|
144
|
+
|
145
|
+
### ウィルスチェック
|
146
|
+
|
147
|
+
```sakura mail scan``` コマンドで, ウィルスチェックの設定を表示・変更できます.
|
148
|
+
|
149
|
+
```zsh
|
150
|
+
$ sakura mail scan dummy # ウィルスチェックの設定を表示
|
151
|
+
false
|
152
|
+
$ sakura mail scan dummy enable # 有効にする
|
153
|
+
```
|
154
|
+
|
155
|
+
## その他
|
156
|
+
|
157
|
+
### dotenv から起動
|
158
|
+
|
159
|
+
```~/.sakura.env``` に環境変数一覧がある場合
|
160
|
+
|
161
|
+
```zsh
|
162
|
+
dotenv -f ~/.sakura.env sakura
|
163
|
+
```
|
164
|
+
|
165
|
+
のように実行します.
|
166
|
+
|
167
|
+
|
168
|
+
## Copyright and License
|
169
|
+
|
170
|
+
Copyright (c) 2015 Shintaro Kojima. Code released under the [MIT license](LICENSE).
|
data/Rakefile
ADDED
data/exe/sakura
ADDED
data/lib/sakura.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'sakura'
|
3
|
+
require 'sakura/client'
|
4
|
+
require 'sakura/mail_address'
|
5
|
+
|
6
|
+
module Sakura
|
7
|
+
module Cli
|
8
|
+
class Mail < Thor
|
9
|
+
desc 'list', 'List all mail addresses of the domain'
|
10
|
+
def list
|
11
|
+
addrs = MailAddress.all
|
12
|
+
|
13
|
+
puts "# domain: #{Client.current_session.domain}"
|
14
|
+
puts MailAddress.header
|
15
|
+
addrs.each {|addr| puts addr.to_s }
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'create LOCAL_PART [PASSWORD]', 'Create a mail address'
|
19
|
+
def create(local_part, password=nil)
|
20
|
+
password ||= ask_password
|
21
|
+
|
22
|
+
begin
|
23
|
+
MailAddress.create local_part, password
|
24
|
+
rescue
|
25
|
+
abort $!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'delete LOCAL_PART', 'Delete a mail address'
|
30
|
+
def delete(local_part)
|
31
|
+
mail = MailAddress.find(local_part)
|
32
|
+
abort %(No mail address: "#{local_part}") unless mail
|
33
|
+
|
34
|
+
begin
|
35
|
+
mail.delete
|
36
|
+
rescue
|
37
|
+
abort $!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'quota LOCAL_PART [VALUE]', 'Update or show quota of a mail address'
|
42
|
+
def quota(local_part, value=nil)
|
43
|
+
mail = MailAddress.find(local_part)
|
44
|
+
abort %(No mail address: "#{local_part}") unless mail
|
45
|
+
|
46
|
+
begin
|
47
|
+
if value
|
48
|
+
mail.quota = value
|
49
|
+
else
|
50
|
+
puts mail.quota
|
51
|
+
end
|
52
|
+
rescue
|
53
|
+
abort $!
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'password LOCAL_PART [PASSWORD]', 'Update password of a mail address'
|
58
|
+
def password(local_part, password=nil)
|
59
|
+
password ||= ask_password
|
60
|
+
mail = MailAddress.find(local_part)
|
61
|
+
abort %(No mail address: "#{local_part}") unless mail
|
62
|
+
|
63
|
+
begin
|
64
|
+
mail.password = password
|
65
|
+
rescue
|
66
|
+
abort $!
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'scan LOCAL_PART [enable|disable]', 'Switch virus scan'
|
71
|
+
def scan(local_part, value=nil)
|
72
|
+
self.class.handle_argument_error if value && value !~ /enable|disable/
|
73
|
+
|
74
|
+
mail = MailAddress.find(local_part)
|
75
|
+
abort %(No mail address: "#{local_part}") unless mail
|
76
|
+
|
77
|
+
begin
|
78
|
+
case value
|
79
|
+
when 'enable'
|
80
|
+
mail.virus_scan = true
|
81
|
+
when 'disable'
|
82
|
+
mail.virus_scan = false
|
83
|
+
when nil
|
84
|
+
puts mail.virus_scan
|
85
|
+
end
|
86
|
+
rescue
|
87
|
+
abort $!
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'forward LOCAL_PART [{add|remove} EMAIL]', 'Add, remove or show mail address(es) to forward'
|
92
|
+
def forward(local_part, operation=nil, mail_to_forward=nil)
|
93
|
+
if (operation && operation !~ /add|remove/) || (!mail_to_forward && operation)
|
94
|
+
self.class.handle_argument_error
|
95
|
+
end
|
96
|
+
|
97
|
+
mail = MailAddress.find(local_part)
|
98
|
+
abort %(No mail address: "#{local_part}") unless mail
|
99
|
+
|
100
|
+
begin
|
101
|
+
case operation
|
102
|
+
when 'add'
|
103
|
+
mail.forward_to mail_to_forward
|
104
|
+
when 'remove'
|
105
|
+
mail.delete_forward_to mail_to_forward
|
106
|
+
when nil
|
107
|
+
mail.forward_list.each {|m| puts m }
|
108
|
+
end
|
109
|
+
rescue
|
110
|
+
abort $!
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
desc 'keep LOCAL_PART [enable|disable]', 'Switch keep or flush mails'
|
115
|
+
def keep(local_part, value=nil)
|
116
|
+
self.class.handle_argument_error if value && value !~ /enable|disable/
|
117
|
+
|
118
|
+
mail = MailAddress.find(local_part)
|
119
|
+
abort %(No mail address: "#{local_part}") unless mail
|
120
|
+
|
121
|
+
begin
|
122
|
+
case value
|
123
|
+
when 'enable'
|
124
|
+
mail.keep = true
|
125
|
+
when 'disable'
|
126
|
+
mail.keep = false
|
127
|
+
when nil
|
128
|
+
puts mail.keep
|
129
|
+
end
|
130
|
+
rescue
|
131
|
+
abort $!
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def ask_password
|
139
|
+
password = ask('password?', echo: false)
|
140
|
+
puts
|
141
|
+
confirm = ask('password(confirm)?', echo: false)
|
142
|
+
puts
|
143
|
+
abort "password doesn't match" unless password == confirm
|
144
|
+
|
145
|
+
password
|
146
|
+
end
|
147
|
+
|
148
|
+
def abort(message)
|
149
|
+
super "\nERROR: #{message}"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'capybara/poltergeist'
|
2
|
+
require 'sakura'
|
3
|
+
require 'sakura/cli/version'
|
4
|
+
|
5
|
+
Capybara.default_driver = :poltergeist
|
6
|
+
Capybara.current_session.driver.headers = {'User-Agent' => "sakura-cli/#{Sakura::Cli::VERSION}"}
|
7
|
+
|
8
|
+
module Sakura
|
9
|
+
class Client
|
10
|
+
include Capybara::DSL
|
11
|
+
|
12
|
+
attr_reader :domain
|
13
|
+
|
14
|
+
def self.current_session
|
15
|
+
@current_session ||= new
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@domain, @passwd = credentials
|
21
|
+
end
|
22
|
+
|
23
|
+
def login?
|
24
|
+
!@last_login.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def login
|
28
|
+
visit BASE_URL
|
29
|
+
fill_in 'domain', with: @domain
|
30
|
+
fill_in 'password', with: @passwd
|
31
|
+
find('form input[type=image]').click
|
32
|
+
|
33
|
+
@last_login = Time.now if page.text =~ /ログインドメイン: #{@domain}/
|
34
|
+
|
35
|
+
raise_when_error
|
36
|
+
login?
|
37
|
+
end
|
38
|
+
|
39
|
+
def get(url)
|
40
|
+
login unless login?
|
41
|
+
visit url
|
42
|
+
page
|
43
|
+
end
|
44
|
+
|
45
|
+
def process(url, &block)
|
46
|
+
login unless login?
|
47
|
+
visit url
|
48
|
+
instance_eval &block
|
49
|
+
|
50
|
+
raise_when_error
|
51
|
+
page
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def credentials
|
58
|
+
warn 'SAKURA_DOMAIN is not set' unless ENV['SAKURA_DOMAIN']
|
59
|
+
warn 'SAKURA_PASSWD is not set' unless ENV['SAKURA_PASSWD']
|
60
|
+
|
61
|
+
if ENV['SAKURA_DOMAIN'] && ENV['SAKURA_PASSWD']
|
62
|
+
[ENV['SAKURA_DOMAIN'], ENV['SAKURA_PASSWD']]
|
63
|
+
else
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def raise_when_error
|
69
|
+
error = page.all('.error-message')
|
70
|
+
raise error.first.text unless error.empty?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'sakura/client'
|
2
|
+
|
3
|
+
module Sakura
|
4
|
+
class MailAddress
|
5
|
+
MAIL_URL = BASE_URL + 'rs/mail'
|
6
|
+
|
7
|
+
attr_reader :address, :virus_scan, :usage, :quota, :link, :link_to_delete
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def create(local_part, password)
|
11
|
+
Client.current_session.process(MAIL_URL) do
|
12
|
+
fill_in 'NewUsername', with: local_part
|
13
|
+
fill_in 'Password1', with: password
|
14
|
+
fill_in 'Password2', with: password
|
15
|
+
find('input[name="Submit_useradd"]').click
|
16
|
+
end
|
17
|
+
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def all
|
22
|
+
page = Client.current_session.get(MAIL_URL)
|
23
|
+
|
24
|
+
page.all(:xpath, '//a[contains(@href, "mail?Username=")]/../..').map{|element|
|
25
|
+
arguments = element.all('td').map(&:text)[0..-2] + element.all('a').map{|i| i[:href] }
|
26
|
+
MailAddress.new(*arguments)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def find(local_part)
|
31
|
+
all.find {|m| m.address == local_part }
|
32
|
+
end
|
33
|
+
|
34
|
+
def header
|
35
|
+
str = tabularize('address', 'virus_scan', 'usage', 'quota')
|
36
|
+
"#{str}\n#{'-' * (str.size+1)}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def tabularize(*args)
|
40
|
+
args[0].ljust(20) <<
|
41
|
+
args[1].to_s.rjust(11) <<
|
42
|
+
"#{args[2]} /".to_s.rjust(15) <<
|
43
|
+
args[3].to_s.rjust(10)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def initialize(address, virus_scan, usage, quota, link, link_to_delete=nil)
|
49
|
+
@address = address
|
50
|
+
@virus_scan = virus_scan == '○'
|
51
|
+
@usage = usage
|
52
|
+
@quota = quota
|
53
|
+
@link = link
|
54
|
+
@link_to_delete = link_to_delete
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete
|
58
|
+
link = @link_to_delete
|
59
|
+
Client.current_session.process(MAIL_URL) do
|
60
|
+
find("a[href=\"#{link}\"]").click
|
61
|
+
end
|
62
|
+
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def quota=(value)
|
67
|
+
page = Client.current_session.process(MAIL_URL + @link) {
|
68
|
+
fill_in 'MailQuota', with: value
|
69
|
+
find('input[name="Submit_quotaedit"]').click
|
70
|
+
}
|
71
|
+
|
72
|
+
page.text =~ /利用中のディスク領域: \S+ \/ (\S+)/
|
73
|
+
@quota = $1
|
74
|
+
end
|
75
|
+
|
76
|
+
def password=(value)
|
77
|
+
Client.current_session.process(MAIL_URL + @link) do
|
78
|
+
fill_in 'Password1', with: value
|
79
|
+
fill_in 'Password2', with: value
|
80
|
+
find('input[name="Submit_password"]').click
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def virus_scan=(value)
|
85
|
+
value = value ? 1 : 0
|
86
|
+
Client.current_session.process(MAIL_URL + @link) do
|
87
|
+
find("input[name='VirusScan'][value='#{value}']").click
|
88
|
+
end
|
89
|
+
|
90
|
+
@virus_scan = value == 1
|
91
|
+
end
|
92
|
+
|
93
|
+
def enable_virus_scan
|
94
|
+
virus_scan = true
|
95
|
+
end
|
96
|
+
|
97
|
+
def disable_virus_scan
|
98
|
+
virus_scan = false
|
99
|
+
end
|
100
|
+
|
101
|
+
def keep
|
102
|
+
if @keep.nil?
|
103
|
+
page = Client.current_session.get(MAIL_URL + @link)
|
104
|
+
@keep = page.find('input[name="Save"]:checked').value == '1'
|
105
|
+
end
|
106
|
+
|
107
|
+
@keep
|
108
|
+
end
|
109
|
+
|
110
|
+
def keep=(value)
|
111
|
+
value = value ? 1 : 0
|
112
|
+
Client.current_session.process(MAIL_URL + @link) do
|
113
|
+
find("input[name='Save'][value='#{value}']").click
|
114
|
+
end
|
115
|
+
|
116
|
+
@keep = value == 1
|
117
|
+
end
|
118
|
+
|
119
|
+
def enable_keep
|
120
|
+
keep = true
|
121
|
+
end
|
122
|
+
|
123
|
+
def disable_keep
|
124
|
+
keep = false
|
125
|
+
end
|
126
|
+
|
127
|
+
def forward_list
|
128
|
+
if @forward_list.nil?
|
129
|
+
page = Client.current_session.get(MAIL_URL + @link)
|
130
|
+
@forward_list = page.all('select[name="DeleteAddress[]"] option').map(&:text)
|
131
|
+
end
|
132
|
+
|
133
|
+
@forward_list
|
134
|
+
end
|
135
|
+
|
136
|
+
def forward_to(mail)
|
137
|
+
Client.current_session.process(MAIL_URL + @link) do
|
138
|
+
execute_script <<-JS
|
139
|
+
var f = document.Transfer;
|
140
|
+
f.Address.value = '#{mail}';
|
141
|
+
f.SubAction.value = 'add';
|
142
|
+
f.submit();
|
143
|
+
JS
|
144
|
+
end
|
145
|
+
|
146
|
+
@forward_list ||= []
|
147
|
+
@forward_list << mail
|
148
|
+
end
|
149
|
+
|
150
|
+
def delete_forward_to(mail)
|
151
|
+
Client.current_session.process(MAIL_URL + @link) do
|
152
|
+
find_field('DeleteAddress[]').select(mail)
|
153
|
+
find('a[href="javascript:tr_delete();"]').click
|
154
|
+
end
|
155
|
+
|
156
|
+
@forward_list ||= []
|
157
|
+
@forward_list.delete mail
|
158
|
+
end
|
159
|
+
|
160
|
+
def to_s
|
161
|
+
self.class.tabularize(@address, @virus_scan, @usage, @quota)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
data/sakura-cli.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sakura/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sakura-cli"
|
8
|
+
spec.version = Sakura::Cli::VERSION
|
9
|
+
spec.authors = ["Shintaro Kojima"]
|
10
|
+
spec.email = ["goodies@codeout.net"]
|
11
|
+
|
12
|
+
spec.summary = %q{Command-line tool for Sakura's Rental Server.}
|
13
|
+
spec.description = %q{Command-line tool and client library to control the dashboard of Sakura Rental Server.}
|
14
|
+
spec.homepage = "https://github.com/codeout/sakura-cli"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "poltergeist"
|
23
|
+
spec.add_runtime_dependency "thor"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.required_ruby_version = '>= 2.0.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sakura-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shintaro Kojima
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: poltergeist
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Command-line tool and client library to control the dashboard of Sakura
|
70
|
+
Rental Server.
|
71
|
+
email:
|
72
|
+
- goodies@codeout.net
|
73
|
+
executables:
|
74
|
+
- sakura
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- exe/sakura
|
84
|
+
- lib/sakura.rb
|
85
|
+
- lib/sakura/cli/mail.rb
|
86
|
+
- lib/sakura/cli/root.rb
|
87
|
+
- lib/sakura/cli/version.rb
|
88
|
+
- lib/sakura/client.rb
|
89
|
+
- lib/sakura/mail_address.rb
|
90
|
+
- sakura-cli.gemspec
|
91
|
+
homepage: https://github.com/codeout/sakura-cli
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.0.0
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Command-line tool for Sakura's Rental Server.
|
115
|
+
test_files: []
|
116
|
+
has_rdoc:
|