Class: Pod::Command::Nexus::Add
- Inherits:
-
Pod::Command::Nexus
- Object
- Pod::Command
- Pod::Command::Nexus
- Pod::Command::Nexus::Add
- Defined in:
- lib/cocoapods-nexus/command/nexus/add.rb
Instance Method Summary collapse
- #create_nexus_file(repo_dir_root) ⇒ Object
-
#initialize(argv) ⇒ Add
constructor
A new instance of Add.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Add
Returns a new instance of Add.
18 19 20 21 22 23 24 |
# File 'lib/cocoapods-nexus/command/nexus/add.rb', line 18 def initialize(argv) @name = argv.shift_argument @url = argv.shift_argument @silent = argv.flag?('silent', false) @silent = false super end |
Instance Method Details
#create_nexus_file(repo_dir_root) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/cocoapods-nexus/command/nexus/add.rb', line 48 def create_nexus_file(repo_dir_root) nexus_path = "#{repo_dir_root}/.nexus" nexus_path = File.new(nexus_path, 'wb') nexus_path << @url nexus_path.close nexus_path end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cocoapods-nexus/command/nexus/add.rb', line 31 def run UI.section("从#{@url}添加#{@name}仓库") do repos_path = File.join(@repos_nexus_dir, @name) raise Pod::Informative.exception "#{repos_path}已经存在. 请删除或者执行'pod nexus add #{@name} #{@url}'" if File.exist?(repos_path) && !@silent repo_dir_root = "#{@repos_nexus_dir}/#{@name}" FileUtils.mkdir_p repo_dir_root begin nexus_path = create_nexus_file(repo_dir_root) rescue StandardError => e raise Informative, "Cannot create file '#{nexus_path}' because : #{e.}." end UI.puts "Successfully added repo #{@name}".green unless @silent end end |
#validate! ⇒ Object
26 27 28 29 |
# File 'lib/cocoapods-nexus/command/nexus/add.rb', line 26 def validate! super help! '需要配置`NAME`和`URL`.' unless @name && @url end |