Class: Pod::Command::JxedtCommand::User
- Inherits:
-
Pod::Command::JxedtCommand
- Object
- Pod::Command
- Pod::Command::JxedtCommand
- Pod::Command::JxedtCommand::User
- Defined in:
- lib/cocoapods-jxedt/command/user/user.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete_dir ⇒ Object
-
#initialize(argv) ⇒ User
constructor
A new instance of User.
- #make_dir ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ User
Returns a new instance of User.
19 20 21 22 23 24 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 19 def initialize(argv) @add = argv.flag?('add', false) @delete = argv.flag?('delete', false) @name = 'cocoapods-jxedt' super end |
Class Method Details
.options ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 13 def self. [ ['--add', '添加用户目录,/Users/cocoapods-jxedt'], ['--delete', '删除用户目录,/Users/cocoapods-jxedt'] ] end |
Instance Method Details
#delete_dir ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 47 def delete_dir help! '因删除操作存在风险,暂不支持删除,请自行删除!' if @name != 'cocoapods-jxedt' dirname = "/Users/#{@name}" help! "目录不存在!" unless File.exist?(dirname) `sudo rm -rf #{dirname}` end |
#make_dir ⇒ Object
40 41 42 43 44 45 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 40 def make_dir dirname = "/Users/#{@name}" help! "目录已存在!" if File.exist?(dirname) `sudo mkdir #{dirname} && sudo chmod -R 777 #{dirname}` end |
#run ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 32 def run if @add make_dir else delete_dir end end |
#validate! ⇒ Object
26 27 28 29 30 |
# File 'lib/cocoapods-jxedt/command/user/user.rb', line 26 def validate! help! "请指定要操作的命令, '--add' 或 '--delete'" unless @add || @delete help! '输入的目录不正确!' if @name.length == 0 super end |