Class: Pod::Tdfire::BinaryConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-tdfire-binary/binary_config.rb

Constant Summary collapse

REPO_URL_KEY =
'repo_url'.freeze
SERVER_ROOT_KEY =
'server_host'.freeze
TEMPLATE_URL_KEY =
'template_url'.freeze
THREE_PARTY_GROUP_KEY =
'third_party_group'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



14
15
16
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 14

def self.instance
  @instance ||= new
end

Instance Method Details

#binary_setting_fileObject



47
48
49
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 47

def binary_setting_file
  config.home_dir + setting_file_name
end

#clone_default_configObject



70
71
72
73
74
75
76
77
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 70

def clone_default_config
  FileUtils.cd(config.home_dir) do
    `git clone http://git.2dfire.net/qingmu/cocoapods-tdfire-binary-config`

    FileUtils.mv("cocoapods-tdfire-binary-config/#{setting_file_name}", '.')
    FileUtils.rm_rf(config.home_dir + 'cocoapods-tdfire-binary-config')
  end
end

#config_with_setting(setting) ⇒ Object



51
52
53
54
55
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 51

def config_with_setting(setting)
  File.open(binary_setting_file, 'w+') do |f|
    f.write(setting.to_yaml)
  end
end

#private_sources(keywords = repo_url) ⇒ Object

Raises:

  • (Pod::Informative)


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 57

def private_sources(keywords = repo_url)
  keywords = keywords.strip
  sources = config.sources_manager.all.select do |source|
    next false unless source.url
    source.url.downcase.include? keywords
  end

  raise Pod::Informative, "匹配 #{keywords} 私有源不能为空,执行 pod repo add 添加私有源,或者 pod bianry init 调整私有源 Git 地址." if sources.empty?

  sources
end

#repo_urlObject



18
19
20
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 18

def repo_url
  setting_for_key(REPO_URL_KEY)
end

#server_hostObject



22
23
24
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 22

def server_host
  setting_for_key(SERVER_ROOT_KEY)
end

#setting_file_nameObject



43
44
45
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 43

def setting_file_name
  'binary_config.yml'
end

#setting_hashObject



34
35
36
37
38
39
40
41
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 34

def setting_hash
  @setting ||= begin
    if File.exist?(binary_setting_file)
      @setting = YAML.load_file(binary_setting_file)
    end
  end
  @setting
end

#template_urlObject



26
27
28
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 26

def template_url
  setting_for_key(TEMPLATE_URL_KEY)
end

#three_party_groupObject



30
31
32
# File 'lib/cocoapods-tdfire-binary/binary_config.rb', line 30

def three_party_group
  setting_for_key(THREE_PARTY_GROUP_KEY, 'cocoapods-repos')
end