Class: Pod::Command::Repo::RepushCodingAr

Inherits:
Pod::Command::Repo show all
Extended by:
Executable
Defined in:
lib/coding_ar_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ RepushCodingAr

Returns a new instance of RepushCodingAr.



203
204
205
206
207
208
209
# File 'lib/coding_ar_command.rb', line 203

def initialize(argv)
  @repo = argv.shift_argument
  @podspec_name = argv.shift_argument
  @podspec_version = argv.shift_argument
  @new_podspec_version = argv.shift_argument
  super
end

Instance Method Details

#runObject



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/coding_ar_command.rb', line 218

def run
  unless File.file? File.join(Config.instance.repos_dir, @repo, ".coding_ar_url")
    raise Informative, "`#@repo` is not a CODING-AR repo.".red
  end

  # Check if target version already exists
  if version_exists?(@new_podspec_version)
    raise Informative, "Version #{@new_podspec_version} already exists for #{@podspec_name}".red
  end

  FileUtils.mkdir_p tmp_dir
  begin
    UI.section("Repushing pod `#{@podspec_name}` from #{@podspec_version} to #{@new_podspec_version} in CODING-AR repo `#@repo`") do
      # Download original files
      original_tar_gz_path = download_original_tar_gz
      original_spec_path = download_original_spec

      # Create new version files
      new_tar_gz_path = create_new_tar_gz(original_tar_gz_path)
      new_spec_path = create_new_spec(original_spec_path)

      # Push to CODING-AR
      post_pod_with_spec(new_tar_gz_path, new_spec_path)
    end
    UI.puts "Successfully repushed pod `#{@podspec_name} #{@new_podspec_version}` to CODING-AR repo `#@repo`".green
  ensure
    FileUtils.rm_rf tmp_dir
  end
end

#validate!Object



211
212
213
214
215
216
# File 'lib/coding_ar_command.rb', line 211

def validate!
  super
  unless @repo && @podspec_name && @podspec_version && @new_podspec_version
    help! 'This command requires repo name, podspec name, current version and new version.'
  end
end