Class: Deliver::Setup
- Inherits:
-
Object
- Object
- Deliver::Setup
- Defined in:
- lib/deliver/setup.rb
Instance Method Summary collapse
- #download_screenshots(deliver_path, options) ⇒ Object
-
#generate_deliver_file(deliver_path, options) ⇒ Object
This method takes care of creating a new ‘deliver’ folder, containg the app metadata and screenshots folders.
- #generate_metadata_files(v, deliver_path) ⇒ Object
- #run(options) ⇒ Object
- #setup_deliver(file_path, data, deliver_path, options) ⇒ Object
Instance Method Details
#download_screenshots(deliver_path, options) ⇒ Object
72 73 74 75 |
# File 'lib/deliver/setup.rb', line 72 def download_screenshots(deliver_path, ) FileUtils.mkdir_p(File.join(deliver_path, 'screenshots')) Deliver::DownloadScreenshots.run(, deliver_path) end |
#generate_deliver_file(deliver_path, options) ⇒ Object
This method takes care of creating a new ‘deliver’ folder, containg the app metadata and screenshots folders
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/deliver/setup.rb', line 24 def generate_deliver_file(deliver_path, ) v = [:app].latest_version (v, deliver_path) # Generate the final Deliverfile here gem_path = Helper.gem_path('deliver') deliver = File.read("#{gem_path}/lib/assets/DeliverfileDefault") deliver.gsub!("[[APP_IDENTIFIER]]", [:app].bundle_id) deliver.gsub!("[[USERNAME]]", Spaceship::Tunes.client.user) return deliver end |
#generate_metadata_files(v, deliver_path) ⇒ Object
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 63 64 65 66 67 68 69 70 |
# File 'lib/deliver/setup.rb', line 36 def (v, deliver_path) app_details = v.application.details containing = File.join(deliver_path, 'metadata') # All the localised metadata (UploadMetadata::LOCALISED_VERSION_VALUES + UploadMetadata::LOCALISED_APP_VALUES).each do |key| v.description.languages.each do |language| if UploadMetadata::LOCALISED_VERSION_VALUES.include?(key) content = v.send(key)[language] else content = app_details.send(key)[language] end resulting_path = File.join(containing, language, "#{key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) Helper.log.debug "Writing to '#{resulting_path}'" end end # All non-localised metadata (UploadMetadata::NON_LOCALISED_VERSION_VALUES + UploadMetadata::NON_LOCALISED_APP_VALUES).each do |key| if UploadMetadata::NON_LOCALISED_VERSION_VALUES.include?(key) content = v.send(key) else content = app_details.send(key) end resulting_path = File.join(containing, "#{key}.txt") File.write(resulting_path, content) Helper.log.debug "Writing to '#{resulting_path}'" end puts "Successfully created new configuration files.".green end |
#run(options) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/deliver/setup.rb', line 3 def run() containing = (File.directory?("fastlane") ? 'fastlane' : '.') file_path = File.join(containing, 'Deliverfile') data = generate_deliver_file(containing, ) setup_deliver(file_path, data, containing, ) end |
#setup_deliver(file_path, data, deliver_path, options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/deliver/setup.rb', line 10 def setup_deliver(file_path, data, deliver_path, ) File.write(file_path, data) download_screenshots(deliver_path, ) # Add a README to the screenshots folder FileUtils.mkdir_p File.join(deliver_path, 'screenshots') # just in case the fetching didn't work File.write(File.join(deliver_path, 'screenshots', 'README.txt'), File.read("#{Helper.gem_path('deliver')}/lib/assets/ScreenshotsHelp")) Helper.log.info "Successfully created new Deliverfile at path '#{file_path}'".green end |