Class: CBin::SpecificationSource::Creator
- Inherits:
-
Object
- Object
- CBin::SpecificationSource::Creator
- Defined in:
- lib/cocoapods-bb-bin/helpers/spec_source_creator.rb
Instance Attribute Summary collapse
-
#code_spec ⇒ Object
readonly
Returns the value of attribute code_spec.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #clear_spec_file ⇒ Object
- #create(frameworkName = nil, is_xcframework = false, isUpRes = false) ⇒ Object
-
#filename ⇒ Object
二进制spec路径.
-
#initialize(code_spec, platforms = nil) ⇒ Creator
constructor
‘ios’).
-
#sourceSpecFilePath ⇒ Object
源码spec路径(指向二进制库).
- #validate! ⇒ Object
- #write_spec_file(file = filename) ⇒ Object
Constructor Details
#initialize(code_spec, platforms = nil) ⇒ Creator
‘ios’)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 12 def initialize(code_spec, platforms = nil) #'ios') @code_spec = code_spec if platforms.nil? || Array(platforms).empty? spec_hash = code_spec.to_hash if spec_hash['platforms'] @platforms = spec_hash['platforms'].keys elsif spec_hash['platform'] @platforms = [spec_hash['platform']] else @platforms = ['ios'] end else @platforms = Array(platforms).map(&:to_s) end puts "@platforms:#{@platforms}" validate! end |
Instance Attribute Details
#code_spec ⇒ Object (readonly)
Returns the value of attribute code_spec.
9 10 11 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 9 def code_spec @code_spec end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
10 11 12 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 10 def spec @spec end |
Instance Method Details
#clear_spec_file ⇒ Object
74 75 76 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 74 def clear_spec_file File.delete(filename) if File.exist?(filename) end |
#create(frameworkName = nil, is_xcframework = false, isUpRes = false) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 34 def create(frameworkName=nil, is_xcframework=false, isUpRes=false) # spec = nil if CBin::Build::Utils.is_framework(@code_spec) if isUpRes Pod::UI::puts "make res spec. vendored_framework_name:#{frameworkName}" else Pod::UI::puts "make framework spec. vendored_framework_name:#{frameworkName} is_xcframework:#{is_xcframework}" end if !frameworkName # 如果外部没有传入fk名称默认组件名称 frameworkName = code_spec.root.name end spec = create_framework_from_code_spec(frameworkName, is_xcframework) else Pod::UI::puts "make source code spec. vendored_framework_name:#{frameworkName}" spec = create_from_code_spec end spec end |
#filename ⇒ Object
二进制spec路径
79 80 81 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 79 def filename @filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json" end |
#sourceSpecFilePath ⇒ Object
源码spec路径(指向二进制库)
83 84 85 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 83 def sourceSpecFilePath @sourcefilename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.podspec.json" end |
#validate! ⇒ Object
30 31 32 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 30 def validate! raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec end |
#write_spec_file(file = filename) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cocoapods-bb-bin/helpers/spec_source_creator.rb', line 53 def write_spec_file(file = filename) create unless spec dir = CBin::Config::Builder.instance.binary_json_dir unless File.exist?(dir) require "fileutils" FileUtils.mkdir_p(dir) end # FileUtils.mkdir_p(dir) unless File.exist?(dir) FileUtils.rm_rf(file) if File.exist?(file) File.open(file, 'w+') do |f| f.write(spec.to_pretty_json) end @filename = file # Pod::UI::puts "===copy origin file: #{file}".red # Pod::UI::puts "===copy desc file: #{sourceSpecFilePath}".red # 拷贝二进制spec到源码spec by hm 22/1/19 `cp -fa #{file} #{sourceSpecFilePath}` end |