Module: CBin::SpecFilesHelper

Included in:
Pod::Command::Bin
Defined in:
lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb

Instance Method Summary collapse

Instance Method Details

#binary_specObject



34
35
36
37
38
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 34

def binary_spec
  if binary_spec_files.first
    Pod::Specification.from_file(binary_spec_files.first)
 end
end

#binary_spec_filesObject



12
13
14
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 12

def binary_spec_files
  @binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
end

#binary_template_specObject



40
41
42
43
44
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 40

def binary_template_spec
  if binary_template_spec_file
    Pod::Specification.from_file(binary_template_spec_file)
 end
end

#binary_template_spec_fileObject



20
21
22
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 20

def binary_template_spec_file
  @binary_spec_template_file ||= binary_template_spec_files.first
end

#binary_template_spec_filesObject



16
17
18
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 16

def binary_template_spec_files
  @binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}')
end

#clear_binary_spec_file_if_neededObject



73
74
75
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 73

def clear_binary_spec_file_if_needed
  @spec_creator&.clear_spec_file
end

#code_specObject



28
29
30
31
32
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 28

def code_spec
  if code_spec_files.first
    Pod::Specification.from_file(code_spec_files.first)
 end
end

#code_spec_filesObject



24
25
26
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 24

def code_spec_files
  @code_spec_files ||= spec_files - binary_spec_files - binary_template_spec_files
end

#create_binary_spec_file(code_spec, template_spec) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 53

def create_binary_spec_file(code_spec, template_spec)
  # 1. code spec 是否有 subpsec
  # 1.1 有,查找 template spec,并生成
  # 1.2 没有,是否有 template spec
  # 1.2.1 有,根据 template spec 生成
  # 1.2.2 没有,根据 code spec 生成

  unless code_spec
    raise Pod::Informative, '没有二进制 podspec 的情况下,必须要提供源码 podspec.'
 end
  if code_spec.subspecs.any? && template_spec.nil?
    raise Pod::Informative, '拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec.'
 end

  @spec_creator = CBin::Specification::Creator.new(code_spec, template_spec)
  @spec_creator.create
  @spec_creator.write_spec_file
  @spec_creator.filename
end

#find_spec_file(podspec) ⇒ Object

Raises:

  • (Pod::Informative)


46
47
48
49
50
51
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 46

def find_spec_file(podspec)
  path = Pathname(podspec)
  raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?

  path
end

#spec_filesObject



8
9
10
# File 'lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb', line 8

def spec_files
  @spec_files ||= Pathname.glob('*.podspec{,.json}')
end