Class: CBin::Specification::Creator
- Inherits:
 - 
      Object
      
        
- Object
 - CBin::Specification::Creator
 
 
- Defined in:
 - lib/cocoapods-bb-bin/helpers/spec_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.
 - 
  
    
      #template_spec  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute template_spec.
 
Instance Method Summary collapse
- #clear_spec_file ⇒ Object
 - #create ⇒ Object
 - #filename ⇒ Object
 - 
  
    
      #initialize(code_spec, template_spec, platforms = 'ios')  ⇒ Creator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Creator.
 - #validate! ⇒ Object
 - #write_spec_file(file = filename) ⇒ Object
 
Constructor Details
#initialize(code_spec, template_spec, platforms = 'ios') ⇒ Creator
Returns a new instance of Creator.
      13 14 15 16 17 18  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 13 def initialize(code_spec, template_spec, platforms = 'ios') @code_spec = code_spec @template_spec = template_spec @platforms = Array(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_creator.rb', line 9 def code_spec @code_spec end  | 
  
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
      11 12 13  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 11 def spec @spec end  | 
  
#template_spec ⇒ Object (readonly)
Returns the value of attribute template_spec.
      10 11 12  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 10 def template_spec @template_spec end  | 
  
Instance Method Details
#clear_spec_file ⇒ Object
      48 49 50  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 48 def clear_spec_file File.delete(filename) if File.exist?(filename) end  | 
  
#create ⇒ Object
      27 28 29 30 31 32 33 34 35 36  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 27 def create spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec Pod::UI. '生成二进制 podspec 内容: ' spec.to_pretty_json.split("\n").each do |text| Pod::UI. text end spec end  | 
  
#filename ⇒ Object
      52 53 54  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 52 def filename @filename ||= "#{spec.name}.binary.podspec.json" end  | 
  
#validate! ⇒ Object
      20 21 22 23 24 25  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 20 def validate! raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec if code_spec.subspecs.any? && template_spec.nil? raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ." end end  | 
  
#write_spec_file(file = filename) ⇒ Object
      38 39 40 41 42 43 44 45 46  | 
    
      # File 'lib/cocoapods-bb-bin/helpers/spec_creator.rb', line 38 def write_spec_file(file = filename) create unless spec File.open(file, 'w+') do |f| f.write(spec.to_pretty_json) end @filename = file end  |