Class: Deliver::UploadMetadata
- Inherits:
-
Object
- Object
- Deliver::UploadMetadata
- Defined in:
- lib/deliver/upload_metadata.rb
Overview
upload description, rating, etc.
Constant Summary collapse
- LOCALISED_VERSION_VALUES =
All the localised values attached to the version
[:description, :keywords, :release_notes, :support_url, :marketing_url]
- NON_LOCALISED_VERSION_VALUES =
Everything attached to the version but not being localised
[:copyright]
- LOCALISED_APP_VALUES =
Localised app details values
[:name, :privacy_url]
- NON_LOCALISED_APP_VALUES =
Non localized app details values
[:primary_category, :secondary_category, :primary_first_sub_category, :primary_second_sub_category, :secondary_first_sub_category, :secondary_second_sub_category ]
Instance Method Summary collapse
-
#load_from_filesystem(options) ⇒ Object
Loads the metadata files and stores them into the options object.
-
#upload(options) ⇒ Object
Make sure to call ‘load_from_filesystem` before calling upload.
-
#verify_available_languages!(options) ⇒ Object
Makes sure all languages we need are actually created.
Instance Method Details
#load_from_filesystem(options) ⇒ Object
Loads the metadata files and stores them into the options object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/deliver/upload_metadata.rb', line 94 def load_from_filesystem() return if [:skip_metadata] # Load localised data Loader.language_folders([:metadata_path]).each do |lng_folder| language = File.basename(lng_folder) (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key| path = File.join(lng_folder, "#{key}.txt") next unless File.exist?(path) Helper.log.info "Loading '#{path}'..." [key] ||= {} [key][language] ||= File.read(path) end end # Load non localised data (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key| path = File.join([:metadata_path], "#{key}.txt") next unless File.exist?(path) Helper.log.info "Loading '#{path}'..." [key] ||= File.read(path) end end |
#upload(options) ⇒ Object
Make sure to call ‘load_from_filesystem` before calling upload
20 21 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/deliver/upload_metadata.rb', line 20 def upload() return if [:skip_metadata] verify_available_languages!() app = [:app] details = app.details v = app.edit_version (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key| current = [key] next unless current unless current.kind_of?(Hash) Helper.log.error "Error with provided '#{key}'. Must be a hash, the key being the language.".red next end current.each do |language, value| next unless value.to_s.length > 0 strip_value = value.to_s.strip v.send(key)[language] = strip_value if LOCALISED_VERSION_VALUES.include?(key) details.send(key)[language] = strip_value if LOCALISED_APP_VALUES.include?(key) end end (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key| current = [key].to_s.strip next unless current.to_s.length > 0 v.send("#{key}=", current) if NON_LOCALISED_VERSION_VALUES.include?(key) details.send("#{key}=", current) if NON_LOCALISED_APP_VALUES.include?(key) end v.release_on_approval = [:automatic_release] set_review_information(v, ) (v, ) Helper.log.info "Uploading metadata to iTunes Connect" v.save! details.save! Helper.log.info "Successfully uploaded initial set of metadata to iTunes Connect".green end |
#verify_available_languages!(options) ⇒ Object
Makes sure all languages we need are actually created
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/deliver/upload_metadata.rb', line 65 def verify_available_languages!() return if [:skip_metadata] # Collect all languages we need # We only care about languages from user provided values # as the other languages are on iTC already anyway v = [:app].edit_version raise "Could not find a version to edit for app '#{[:app].name}', the app metadata is read-only currently".red unless v enabled_languages = [] LOCALISED_VERSION_VALUES.each do |key| current = [key] next unless current && current.kind_of?(Hash) current.each do |language, value| enabled_languages << language unless enabled_languages.include?(language) end end if enabled_languages.count > 0 v.create_languages(enabled_languages) lng_text = "language" lng_text += "s" if enabled_languages.count != 1 Helper.log.info "Activating #{lng_text} #{enabled_languages.join(', ')}..." v.save! end true end |