Class: AppEntitlementsStatistics::Extracter
- Extended by:
- Forwardable
- Includes:
- Helper::Sigflat, Helper::Utils
- Defined in:
- lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb
Instance Attribute Summary collapse
-
#cur_version ⇒ Object
readonly
Returns the value of attribute cur_version.
-
#entitlements_path ⇒ Object
readonly
Returns the value of attribute entitlements_path.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#info_plist_path ⇒ Object
readonly
Returns the value of attribute info_plist_path.
-
#system_capabilities ⇒ Object
readonly
Returns the value of attribute system_capabilities.
Instance Method Summary collapse
- #entitlementsInfo ⇒ Object
- #extract_capabilities_info ⇒ Object
- #extract_update ⇒ Object
-
#initialize(args) ⇒ Extracter
constructor
A new instance of Extracter.
- #plistInfo ⇒ Object
- #update_versions ⇒ Object
Methods included from Helper::Utils
#defalut_store_path, #entitlements_yaml_name, #report_file_name, #versions_yaml_name
Methods included from Helper::Sigflat
Constructor Details
#initialize(args) ⇒ Extracter
Returns a new instance of Extracter.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 24 def initialize(args) args.each do |key ,value| case key when "cur_version" @cur_version = value when "product_bundle_identifier" @identifier = value when "info_plist_path" @info_plist_path = value when "entitlements_path" @entitlements_path = value when "system_capabilities" @system_capabilities = value end end end |
Instance Attribute Details
#cur_version ⇒ Object (readonly)
Returns the value of attribute cur_version.
22 23 24 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 22 def cur_version @cur_version end |
#entitlements_path ⇒ Object (readonly)
Returns the value of attribute entitlements_path.
20 21 22 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 20 def entitlements_path @entitlements_path end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
21 22 23 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 21 def identifier @identifier end |
#info_plist_path ⇒ Object (readonly)
Returns the value of attribute info_plist_path.
19 20 21 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 19 def info_plist_path @info_plist_path end |
#system_capabilities ⇒ Object (readonly)
Returns the value of attribute system_capabilities.
18 19 20 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 18 def system_capabilities @system_capabilities end |
Instance Method Details
#entitlementsInfo ⇒ Object
106 107 108 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 106 def entitlementsInfo @entitlementsInfo ||= EntitlementsPlist.new(@entitlements_path) end |
#extract_capabilities_info ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 81 def extract_capabilities_info #{"com.apple.BackgroundModes"=>{"enabled"=>"1"}, "com.apple.InAppPurchase"=>{"enabled"=>"1"}, "com.apple.Push"=>{"enabled"=>"1"}} capabilities_info = {} @system_capabilities.each do |key,value| case key when "com.apple.InAppPurchase" capabilities_info["In-App Purchase"] = { key => value } when "com.apple.BackgroundModes" h1 = {key => value} h2 = plistInfo.backgroundModes["Background Modes"] capabilities_info["Background Modes"] = h1.merge(h2) when "com.apple.Push" capabilities_info["Push Notifications"] = { key => value } end end capabilities_info = capabilities_info.merge(entitlementsInfo.enabled_capabilities) capabilities_info = capabilities_info.merge(plistInfo.enabled_capabilities) capabilities_info end |
#extract_update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 41 def extract_update capabilities_summary = Hash.new capabilities = extract_capabilities_info capabilities.each do |key,value| capabilities_summary[key] = createsig(value) end usage_desc_summary = Hash.new usage_desc = plistInfo.permis_usagedescription usage_desc.each do |key,value| usage_desc_summary[key] = createsig(value) end yaml_content = { 'Capabilities_Summary' => capabilities_summary, 'Capabilities' => capabilities, 'PermissionsUsageDescription_Summary' => usage_desc_summary, 'PermissionsUsageDescription' => usage_desc } yaml_name = entitlements_yaml_name(@cur_version, @identifier , path: @store_path) File.open(yaml_name, "w") { |file| file.write(yaml_content.to_yaml) } update_versions yaml_content end |
#plistInfo ⇒ Object
102 103 104 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 102 def plistInfo @plistInfo ||= InfoPlist.new(@info_plist_path) end |
#update_versions ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/cocoapods-entitlements-statistics/app_entitlements_statistics/extracter.rb', line 68 def update_versions yaml_name = versions_yaml_name(@identifier , path: @store_path) yaml_content = [ ] if File.exist?(yaml_name) yaml_content = YAML.load_file(yaml_name) end version = @cur_version if !yaml_content.include?(version) yaml_content.unshift(version) File.open(yaml_name, "w") { |file| file.write(yaml_content.to_yaml) } end end |