Class: CBin::SpecificationSource::Creator
- Inherits:
-
Object
- Object
- CBin::SpecificationSource::Creator
- Defined in:
- lib/cocoapods-mtxx-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 ⇒ Object
创建二进制podspec.
- #filename ⇒ Object
-
#initialize(code_spec, platforms = 'ios') ⇒ Creator
constructor
A new instance of Creator.
- #validate! ⇒ Object
-
#write_spec_file(file = filename) ⇒ Object
将二进制podspec写入文件.
Constructor Details
#initialize(code_spec, platforms = 'ios') ⇒ Creator
Returns a new instance of Creator.
10 11 12 13 14 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 10 def initialize(code_spec, platforms = 'ios') @code_spec = code_spec @platforms = Array(platforms) validate! end |
Instance Attribute Details
#code_spec ⇒ Object (readonly)
Returns the value of attribute code_spec.
7 8 9 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 7 def code_spec @code_spec end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
8 9 10 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 8 def spec @spec end |
Instance Method Details
#clear_spec_file ⇒ Object
49 50 51 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 49 def clear_spec_file File.delete(filename) if File.exist?(filename) end |
#create ⇒ Object
创建二进制podspec
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 21 def create # spec = nil if CBin::Build::Utils.is_framework(@code_spec) # .framework spec = create_framework_from_code_spec else # .a spec = create_from_code_spec end spec end |
#filename ⇒ Object
53 54 55 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 53 def filename @filename ||= "#{CBin::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json" end |
#validate! ⇒ Object
16 17 18 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 16 def validate! raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec end |
#write_spec_file(file = filename) ⇒ Object
将二进制podspec写入文件
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb', line 35 def write_spec_file(file = filename) create unless spec FileUtils.mkdir_p(CBin::Config::Builder.instance.binary_json_dir) unless File.exist?(CBin::Config::Builder.instance.binary_json_dir) FileUtils.rm_rf(file) if File.exist?(file) File.open(file, 'w+') do |f| # f.write("# MARK: converted automatically by plugin cocoapods-mtxx-bin @slj \r\n") f.write(spec.to_pretty_json) end @filename = file end |