Class: Pod::Command::Spec::Create

Inherits:
Pod::Command::Spec show all
Defined in:
lib/cocoapods/command/spec.rb

Overview

———————————————————————–#

Instance Method Summary collapse

Methods inherited from Pod::Command

options, parse, report_error, run, verify_git_version!

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Create

Returns a new instance of Create.



25
26
27
28
# File 'lib/cocoapods/command/spec.rb', line 25

def initialize(argv)
  @name_or_url, @url = argv.shift_argument, argv.shift_argument
  super
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cocoapods/command/spec.rb', line 35

def run
  if repo_id_match = (@url || @name_or_url).match(/github.com\/([^\/\.]*\/[^\/\.]*)\.*/)
    repo_id = repo_id_match[1]
    data = github_data_for_template(repo_id)
    data[:name] = @name_or_url if @url
    UI.puts semantic_versioning_notice(repo_id, data[:name]) if data[:version] == '0.0.1'
  else
    data = default_data_for_template(@name_or_url)
  end
  spec = spec_template(data)
  (Pathname.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec }
  UI.puts "\nSpecification created at #{data[:name]}.podspec".green
end

#validate!Object



30
31
32
33
# File 'lib/cocoapods/command/spec.rb', line 30

def validate!
  super
  help! 'A pod name or repo URL is required.' unless @name_or_url
end