Class: CocoapodsSourceFix::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-source-fix/rule.rb

Overview

单条替换规则

目标定位(互斥,均不指定则为全局): pod: 'SomePod' → 定位到 installer.sandbox.pod_dir('SomePod'),glob 相对该 Pod 目录 dir: 'path' → 目录,路径绝对则直接使用,相对则相对 Podfile 目录 file: 'path' → 文件,路径绝对则直接使用,相对则相对 Podfile 目录 (无以上字段) → 全局,glob 相对 Podfile 目录(如 'Pods/**/*.h,m')

替换内容(至少一组): from/to 单组字面量替换;pairs 多组替换;均可选 regex: true 启用正则

排除(可选): exclude: '模式' 或 ['模式1', '模式2'],glob 模式,基准与 glob 相同 (pod → Pod 目录;dir → 目标目录;全局 → Podfile 目录),命中文件不修复

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, base_dir:) ⇒ Rule

Returns a new instance of Rule.



21
22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods-source-fix/rule.rb', line 21

def initialize(raw, base_dir:)
  @raw = raw || {}
  @base_dir = base_dir
  @name = @raw['name']
  @glob = @raw['glob']
  @enabled = @raw.fetch('enabled', true)
  @excludes = Array(@raw['exclude']).compact.map(&:to_s)
  @replaces = parse_replaces
  resolve_target
end

Instance Attribute Details

#enabledObject (readonly)

Returns the value of attribute enabled.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def enabled
  @enabled
end

#excludesObject (readonly)

Returns the value of attribute excludes.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def excludes
  @excludes
end

#globObject (readonly)

Returns the value of attribute glob.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def glob
  @glob
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def name
  @name
end

#replacesObject (readonly)

Returns the value of attribute replaces.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def replaces
  @replaces
end

#targetObject (readonly)

Returns the value of attribute target.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def target
  @target
end

#target_typeObject (readonly)

Returns the value of attribute target_type.



19
20
21
# File 'lib/cocoapods-source-fix/rule.rb', line 19

def target_type
  @target_type
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/cocoapods-source-fix/rule.rb', line 32

def enabled?
  @enabled
end

#labelObject



36
37
38
# File 'lib/cocoapods-source-fix/rule.rb', line 36

def label
  @name || "target=#{@target_type}#{@target ? "(#{@target})" : ''}"
end