Class: Podrpt::Configuration
- Inherits:
-
Object
- Object
- Podrpt::Configuration
- Defined in:
- lib/podrpt/configuration.rb
Constant Summary collapse
- CONFIG_FILE =
'.podrpt.yml'.freeze
- RISK_FILE =
'PodsRisk.yaml'.freeze
- ALLOWLIST_FILE =
'PodsAllowlist.yaml'.freeze
Class Method Summary collapse
- .create_allowlist_file(pod_names: []) ⇒ Object
- .create_risk_file(pod_names: []) ⇒ Object
- .load_slack_url ⇒ Object
- .save_slack_url(url) ⇒ Object
Class Method Details
.create_allowlist_file(pod_names: []) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/podrpt/configuration.rb', line 48 def self.create_allowlist_file(pod_names: []) return if File.exist?(ALLOWLIST_FILE) header = <<~YAML # The allowlist is used to filter transitive dependencies (sub-dependencies) # and focus only on the pods you manage directly in your Podfile. # # For each "group" (e.g., Firebase), only the pods listed here will appear in the report. # Pods that don't belong to any group (e.g., Alamofire) will appear by default. # # Uncomment and adjust the examples below, or create your own groups. YAML example_content = { 'allowlist' => { 'Firebase' => ['FirebaseAnalytics', 'FirebaseCrashlytics'] } } project_pods_comment = pod_names.sort_by(&:downcase).map { |name| "# - #{name}" }.join("\n") final_content = header + example_content.to_yaml unless pod_names.empty? final_content += "\n# --- Pods Encontrados no seu Projeto (descomente para usar) ---\n" final_content += "# allowlist:\n" final_content += "# MeuGrupo:\n" final_content += project_pods_comment end File.write(ALLOWLIST_FILE, final_content) puts "✅ Arquivo de exemplo '#{ALLOWLIST_FILE}' criado." end |
.create_risk_file(pod_names: []) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/podrpt/configuration.rb', line 22 def self.create_risk_file(pod_names: []) return if File.exist?(RISK_FILE) bands_config = { 'green_max' => 400, 'yellow_max' => 700 } default_config = { 'owners' => [], 'risk' => 500 } pods_hash = {} if pod_names.empty? puts "⚠️ Nenhum pod encontrado para pré-popular. Criando arquivo de risco com um exemplo." pods_hash['Firebase'] = { 'owners' => ['core-team'], 'risk' => 100 } else pod_names.sort_by(&:downcase).each do |name| pods_hash[name] = YAML.load(default_config.to_yaml) end end final_structure = { 'bands' => bands_config, 'default' => default_config, 'pods' => pods_hash } File.write(RISK_FILE, final_structure.to_yaml) puts "✅ Arquivo '#{RISK_FILE}' criado e pré-populado com #{pods_hash.count} pods." end |
.load_slack_url ⇒ Object
17 18 19 20 |
# File 'lib/podrpt/configuration.rb', line 17 def self.load_slack_url return nil unless File.exist?(CONFIG_FILE) YAML.load_file(CONFIG_FILE)['slack_webhook_url'] end |
.save_slack_url(url) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/podrpt/configuration.rb', line 10 def self.save_slack_url(url) config = File.exist?(CONFIG_FILE) ? YAML.load_file(CONFIG_FILE) || {} : {} config['slack_webhook_url'] = url File.write(CONFIG_FILE, config.to_yaml) puts "✅ URL do Slack salva em #{CONFIG_FILE}" end |