Module: Ocean::SpecFilesHelper
- Included in:
- Pod::Command::Swordfish
- Defined in:
- lib/swordfish/helpers/spec_files_helper.rb
Instance Method Summary collapse
- #binary_spec ⇒ Object
- #binary_spec_files ⇒ Object
- #binary_template_spec ⇒ Object
- #binary_template_spec_file ⇒ Object
- #binary_template_spec_files ⇒ Object
- #clear_binary_spec_file_if_needed ⇒ Object
- #code_spec ⇒ Object
- #code_spec_files ⇒ Object
- #create_binary_spec_file(code_spec, template_spec) ⇒ Object
- #find_spec_file(podspec) ⇒ Object
- #spec_files ⇒ Object
Instance Method Details
#binary_spec ⇒ Object
33 34 35 36 37 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 33 def binary_spec if binary_spec_files.first Pod::Specification.from_file(binary_spec_files.first) end end |
#binary_spec_files ⇒ Object
11 12 13 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 11 def binary_spec_files @binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}') end |
#binary_template_spec ⇒ Object
39 40 41 42 43 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 39 def binary_template_spec if binary_template_spec_file Pod::Specification.from_file(binary_template_spec_file) end end |
#binary_template_spec_file ⇒ Object
19 20 21 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 19 def binary_template_spec_file @binary_spec_template_file ||= binary_template_spec_files.first end |
#binary_template_spec_files ⇒ Object
15 16 17 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 15 def binary_template_spec_files @binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}') end |
#clear_binary_spec_file_if_needed ⇒ Object
72 73 74 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 72 def clear_binary_spec_file_if_needed @spec_creator&.clear_spec_file end |
#code_spec ⇒ Object
27 28 29 30 31 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 27 def code_spec if code_spec_files.first Pod::Specification.from_file(code_spec_files.first) end end |
#code_spec_files ⇒ Object
23 24 25 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 23 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
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 52 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 = Ocean::Specification::Creator.new(code_spec, template_spec) @spec_creator.create @spec_creator.write_spec_file @spec_creator.filename end |
#find_spec_file(podspec) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 45 def find_spec_file(podspec) path = Pathname(podspec) raise Pod::Informative, "无法找到 #{podspec}" unless path.exist? path end |
#spec_files ⇒ Object
7 8 9 |
# File 'lib/swordfish/helpers/spec_files_helper.rb', line 7 def spec_files @spec_files ||= Pathname.glob('*.podspec{,.json}') end |