repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
sequence
docstring
stringlengths
8
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
jekyll/jekyll
lib/jekyll/filters.rb
Jekyll.Filters.sort_input
def sort_input(input, property, order) input.map { |item| [item_property(item, property), item] } .sort! do |a_info, b_info| a_property = a_info.first b_property = b_info.first if !a_property.nil? && b_property.nil? - order elsif a_property.nil? && !b_property.nil? + order else a_property <=> b_property || a_property.to_s <=> b_property.to_s end end .map!(&:last) end
ruby
def sort_input(input, property, order) input.map { |item| [item_property(item, property), item] } .sort! do |a_info, b_info| a_property = a_info.first b_property = b_info.first if !a_property.nil? && b_property.nil? - order elsif a_property.nil? && !b_property.nil? + order else a_property <=> b_property || a_property.to_s <=> b_property.to_s end end .map!(&:last) end
[ "def", "sort_input", "(", "input", ",", "property", ",", "order", ")", "input", ".", "map", "{", "|", "item", "|", "[", "item_property", "(", "item", ",", "property", ")", ",", "item", "]", "}", ".", "sort!", "do", "|", "a_info", ",", "b_info", "|", "a_property", "=", "a_info", ".", "first", "b_property", "=", "b_info", ".", "first", "if", "!", "a_property", ".", "nil?", "&&", "b_property", ".", "nil?", "-", "order", "elsif", "a_property", ".", "nil?", "&&", "!", "b_property", ".", "nil?", "+", "order", "else", "a_property", "<=>", "b_property", "||", "a_property", ".", "to_s", "<=>", "b_property", ".", "to_s", "end", "end", ".", "map!", "(", ":last", ")", "end" ]
Sort the input Enumerable by the given property. If the property doesn't exist, return the sort order respective of which item doesn't have the property. We also utilize the Schwartzian transform to make this more efficient.
[ "Sort", "the", "input", "Enumerable", "by", "the", "given", "property", ".", "If", "the", "property", "doesn", "t", "exist", "return", "the", "sort", "order", "respective", "of", "which", "item", "doesn", "t", "have", "the", "property", ".", "We", "also", "utilize", "the", "Schwartzian", "transform", "to", "make", "this", "more", "efficient", "." ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/filters.rb#L311-L326
train
jekyll/jekyll
lib/jekyll/filters.rb
Jekyll.Filters.compare_property_vs_target
def compare_property_vs_target(property, target) case target when NilClass return true if property.nil? when Liquid::Expression::MethodLiteral # `empty` or `blank` return true if Array(property).join == target.to_s else Array(property).each do |prop| return true if prop.to_s == target.to_s end end false end
ruby
def compare_property_vs_target(property, target) case target when NilClass return true if property.nil? when Liquid::Expression::MethodLiteral # `empty` or `blank` return true if Array(property).join == target.to_s else Array(property).each do |prop| return true if prop.to_s == target.to_s end end false end
[ "def", "compare_property_vs_target", "(", "property", ",", "target", ")", "case", "target", "when", "NilClass", "return", "true", "if", "property", ".", "nil?", "when", "Liquid", "::", "Expression", "::", "MethodLiteral", "# `empty` or `blank`", "return", "true", "if", "Array", "(", "property", ")", ".", "join", "==", "target", ".", "to_s", "else", "Array", "(", "property", ")", ".", "each", "do", "|", "prop", "|", "return", "true", "if", "prop", ".", "to_s", "==", "target", ".", "to_s", "end", "end", "false", "end" ]
`where` filter helper
[ "where", "filter", "helper" ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/filters.rb#L329-L342
train
jekyll/jekyll
lib/jekyll/collection.rb
Jekyll.Collection.entries
def entries return [] unless exists? @entries ||= Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry| entry["#{collection_dir}/"] = "" entry end end
ruby
def entries return [] unless exists? @entries ||= Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry| entry["#{collection_dir}/"] = "" entry end end
[ "def", "entries", "return", "[", "]", "unless", "exists?", "@entries", "||=", "Utils", ".", "safe_glob", "(", "collection_dir", ",", "[", "\"**\"", ",", "\"*\"", "]", ",", "File", "::", "FNM_DOTMATCH", ")", ".", "map", "do", "|", "entry", "|", "entry", "[", "\"#{collection_dir}/\"", "]", "=", "\"\"", "entry", "end", "end" ]
All the entries in this collection. Returns an Array of file paths to the documents in this collection relative to the collection's directory
[ "All", "the", "entries", "in", "this", "collection", "." ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/collection.rb#L75-L83
train
jekyll/jekyll
lib/jekyll/collection.rb
Jekyll.Collection.collection_dir
def collection_dir(*files) return directory if files.empty? site.in_source_dir(container, relative_directory, *files) end
ruby
def collection_dir(*files) return directory if files.empty? site.in_source_dir(container, relative_directory, *files) end
[ "def", "collection_dir", "(", "*", "files", ")", "return", "directory", "if", "files", ".", "empty?", "site", ".", "in_source_dir", "(", "container", ",", "relative_directory", ",", "files", ")", "end" ]
The full path to the directory containing the collection, with optional subpaths. *files - (optional) any other path pieces relative to the directory to append to the path Returns a String containing th directory name where the collection is stored on the filesystem.
[ "The", "full", "path", "to", "the", "directory", "containing", "the", "collection", "with", "optional", "subpaths", "." ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/collection.rb#L128-L132
train
jekyll/jekyll
lib/jekyll/regenerator.rb
Jekyll.Regenerator.add
def add(path) return true unless File.exist?(path) metadata[path] = { "mtime" => File.mtime(path), "deps" => [], } cache[path] = true end
ruby
def add(path) return true unless File.exist?(path) metadata[path] = { "mtime" => File.mtime(path), "deps" => [], } cache[path] = true end
[ "def", "add", "(", "path", ")", "return", "true", "unless", "File", ".", "exist?", "(", "path", ")", "metadata", "[", "path", "]", "=", "{", "\"mtime\"", "=>", "File", ".", "mtime", "(", "path", ")", ",", "\"deps\"", "=>", "[", "]", ",", "}", "cache", "[", "path", "]", "=", "true", "end" ]
Add a path to the metadata Returns true, also on failure.
[ "Add", "a", "path", "to", "the", "metadata" ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/regenerator.rb#L40-L48
train
jekyll/jekyll
lib/jekyll/regenerator.rb
Jekyll.Regenerator.add_dependency
def add_dependency(path, dependency) return if metadata[path].nil? || disabled unless metadata[path]["deps"].include? dependency metadata[path]["deps"] << dependency add(dependency) unless metadata.include?(dependency) end regenerate? dependency end
ruby
def add_dependency(path, dependency) return if metadata[path].nil? || disabled unless metadata[path]["deps"].include? dependency metadata[path]["deps"] << dependency add(dependency) unless metadata.include?(dependency) end regenerate? dependency end
[ "def", "add_dependency", "(", "path", ",", "dependency", ")", "return", "if", "metadata", "[", "path", "]", ".", "nil?", "||", "disabled", "unless", "metadata", "[", "path", "]", "[", "\"deps\"", "]", ".", "include?", "dependency", "metadata", "[", "path", "]", "[", "\"deps\"", "]", "<<", "dependency", "add", "(", "dependency", ")", "unless", "metadata", ".", "include?", "(", "dependency", ")", "end", "regenerate?", "dependency", "end" ]
Add a dependency of a path Returns nothing.
[ "Add", "a", "dependency", "of", "a", "path" ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/regenerator.rb#L106-L114
train
jekyll/jekyll
lib/jekyll/regenerator.rb
Jekyll.Regenerator.write_metadata
def write_metadata unless disabled? Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata" File.binwrite(metadata_file, Marshal.dump(metadata)) end end
ruby
def write_metadata unless disabled? Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata" File.binwrite(metadata_file, Marshal.dump(metadata)) end end
[ "def", "write_metadata", "unless", "disabled?", "Jekyll", ".", "logger", ".", "debug", "\"Writing Metadata:\"", ",", "\".jekyll-metadata\"", "File", ".", "binwrite", "(", "metadata_file", ",", "Marshal", ".", "dump", "(", "metadata", ")", ")", "end", "end" ]
Write the metadata to disk Returns nothing.
[ "Write", "the", "metadata", "to", "disk" ]
fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b
https://github.com/jekyll/jekyll/blob/fd74fe3e93a1fb506fa6621a2e271d7b9c5c3e3b/lib/jekyll/regenerator.rb#L119-L124
train
fastlane/fastlane
frameit/lib/frameit/config_parser.rb
Frameit.ConfigParser.fetch_value
def fetch_value(path) specifics = @data['data'].select { |a| path.include?(a['filter']) } default = @data['default'] values = default.clone specifics.each do |specific| values = values.fastlane_deep_merge(specific) end change_paths_to_absolutes!(values) validate_values(values) values end
ruby
def fetch_value(path) specifics = @data['data'].select { |a| path.include?(a['filter']) } default = @data['default'] values = default.clone specifics.each do |specific| values = values.fastlane_deep_merge(specific) end change_paths_to_absolutes!(values) validate_values(values) values end
[ "def", "fetch_value", "(", "path", ")", "specifics", "=", "@data", "[", "'data'", "]", ".", "select", "{", "|", "a", "|", "path", ".", "include?", "(", "a", "[", "'filter'", "]", ")", "}", "default", "=", "@data", "[", "'default'", "]", "values", "=", "default", ".", "clone", "specifics", ".", "each", "do", "|", "specific", "|", "values", "=", "values", ".", "fastlane_deep_merge", "(", "specific", ")", "end", "change_paths_to_absolutes!", "(", "values", ")", "validate_values", "(", "values", ")", "values", "end" ]
Fetches the finished configuration for a given path. This will try to look for a specific value and fallback to a default value if nothing was found
[ "Fetches", "the", "finished", "configuration", "for", "a", "given", "path", ".", "This", "will", "try", "to", "look", "for", "a", "specific", "value", "and", "fallback", "to", "a", "default", "value", "if", "nothing", "was", "found" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/config_parser.rb#L28-L42
train
fastlane/fastlane
frameit/lib/frameit/config_parser.rb
Frameit.ConfigParser.change_paths_to_absolutes!
def change_paths_to_absolutes!(values) values.each do |key, value| if value.kind_of?(Hash) change_paths_to_absolutes!(value) # recursive call elsif value.kind_of?(Array) value.each do |current| change_paths_to_absolutes!(current) if current.kind_of?(Hash) # recursive call end else if ['font', 'background'].include?(key) # Change the paths to relative ones # `replace`: to change the content of the string, so it's actually stored if @path # where is the config file. We don't have a config file in tests containing_folder = File.expand_path('..', @path) value.replace(File.join(containing_folder, value)) end end end end end
ruby
def change_paths_to_absolutes!(values) values.each do |key, value| if value.kind_of?(Hash) change_paths_to_absolutes!(value) # recursive call elsif value.kind_of?(Array) value.each do |current| change_paths_to_absolutes!(current) if current.kind_of?(Hash) # recursive call end else if ['font', 'background'].include?(key) # Change the paths to relative ones # `replace`: to change the content of the string, so it's actually stored if @path # where is the config file. We don't have a config file in tests containing_folder = File.expand_path('..', @path) value.replace(File.join(containing_folder, value)) end end end end end
[ "def", "change_paths_to_absolutes!", "(", "values", ")", "values", ".", "each", "do", "|", "key", ",", "value", "|", "if", "value", ".", "kind_of?", "(", "Hash", ")", "change_paths_to_absolutes!", "(", "value", ")", "# recursive call", "elsif", "value", ".", "kind_of?", "(", "Array", ")", "value", ".", "each", "do", "|", "current", "|", "change_paths_to_absolutes!", "(", "current", ")", "if", "current", ".", "kind_of?", "(", "Hash", ")", "# recursive call", "end", "else", "if", "[", "'font'", ",", "'background'", "]", ".", "include?", "(", "key", ")", "# Change the paths to relative ones", "# `replace`: to change the content of the string, so it's actually stored", "if", "@path", "# where is the config file. We don't have a config file in tests", "containing_folder", "=", "File", ".", "expand_path", "(", "'..'", ",", "@path", ")", "value", ".", "replace", "(", "File", ".", "join", "(", "containing_folder", ",", "value", ")", ")", "end", "end", "end", "end", "end" ]
Use absolute paths instead of relative
[ "Use", "absolute", "paths", "instead", "of", "relative" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/config_parser.rb#L45-L64
train
fastlane/fastlane
spaceship/lib/spaceship/portal/portal_client.rb
Spaceship.PortalClient.provisioning_profiles_via_xcode_api
def provisioning_profiles_via_xcode_api(mac: false) req = request(:post) do |r| r.url("https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/listProvisioningProfiles.action") r.params = { teamId: team_id, includeInactiveProfiles: true, onlyCountLists: true } end result = parse_response(req, 'provisioningProfiles') csrf_cache[Spaceship::Portal::ProvisioningProfile] = self.csrf_tokens result end
ruby
def provisioning_profiles_via_xcode_api(mac: false) req = request(:post) do |r| r.url("https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/listProvisioningProfiles.action") r.params = { teamId: team_id, includeInactiveProfiles: true, onlyCountLists: true } end result = parse_response(req, 'provisioningProfiles') csrf_cache[Spaceship::Portal::ProvisioningProfile] = self.csrf_tokens result end
[ "def", "provisioning_profiles_via_xcode_api", "(", "mac", ":", "false", ")", "req", "=", "request", "(", ":post", ")", "do", "|", "r", "|", "r", ".", "url", "(", "\"https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/listProvisioningProfiles.action\"", ")", "r", ".", "params", "=", "{", "teamId", ":", "team_id", ",", "includeInactiveProfiles", ":", "true", ",", "onlyCountLists", ":", "true", "}", "end", "result", "=", "parse_response", "(", "req", ",", "'provisioningProfiles'", ")", "csrf_cache", "[", "Spaceship", "::", "Portal", "::", "ProvisioningProfile", "]", "=", "self", ".", "csrf_tokens", "result", "end" ]
this endpoint is used by Xcode to fetch provisioning profiles. The response is an xml plist but has the added benefit of containing the appId of each provisioning profile. Use this method over `provisioning_profiles` if possible because no secondary API calls are necessary to populate the ProvisioningProfile data model.
[ "this", "endpoint", "is", "used", "by", "Xcode", "to", "fetch", "provisioning", "profiles", ".", "The", "response", "is", "an", "xml", "plist", "but", "has", "the", "added", "benefit", "of", "containing", "the", "appId", "of", "each", "provisioning", "profile", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/portal/portal_client.rb#L645-L660
train
fastlane/fastlane
spaceship/lib/spaceship/portal/portal_client.rb
Spaceship.PortalClient.ensure_csrf
def ensure_csrf(klass) if csrf_cache[klass] self.csrf_tokens = csrf_cache[klass] return end self.csrf_tokens = nil # If we directly create a new resource (e.g. app) without querying anything before # we don't have a valid csrf token, that's why we have to do at least one request block_given? ? yield : klass.all csrf_cache[klass] = self.csrf_tokens end
ruby
def ensure_csrf(klass) if csrf_cache[klass] self.csrf_tokens = csrf_cache[klass] return end self.csrf_tokens = nil # If we directly create a new resource (e.g. app) without querying anything before # we don't have a valid csrf token, that's why we have to do at least one request block_given? ? yield : klass.all csrf_cache[klass] = self.csrf_tokens end
[ "def", "ensure_csrf", "(", "klass", ")", "if", "csrf_cache", "[", "klass", "]", "self", ".", "csrf_tokens", "=", "csrf_cache", "[", "klass", "]", "return", "end", "self", ".", "csrf_tokens", "=", "nil", "# If we directly create a new resource (e.g. app) without querying anything before", "# we don't have a valid csrf token, that's why we have to do at least one request", "block_given?", "?", "yield", ":", "klass", ".", "all", "csrf_cache", "[", "klass", "]", "=", "self", ".", "csrf_tokens", "end" ]
Ensures that there are csrf tokens for the appropriate entity type Relies on store_csrf_tokens to set csrf_tokens to the appropriate value then stores that in the correct place in cache This method also takes a block, if you want to send a custom request, instead of calling `.all` on the given klass. This is used for provisioning profiles.
[ "Ensures", "that", "there", "are", "csrf", "tokens", "for", "the", "appropriate", "entity", "type", "Relies", "on", "store_csrf_tokens", "to", "set", "csrf_tokens", "to", "the", "appropriate", "value", "then", "stores", "that", "in", "the", "correct", "place", "in", "cache", "This", "method", "also", "takes", "a", "block", "if", "you", "want", "to", "send", "a", "custom", "request", "instead", "of", "calling", ".", "all", "on", "the", "given", "klass", ".", "This", "is", "used", "for", "provisioning", "profiles", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/portal/portal_client.rb#L802-L815
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.put_into_frame
def put_into_frame # We have to rotate the screenshot, since the offset information is for portrait # only. Instead of doing the calculations ourselves, it's much easier to let # imagemagick do the hard lifting for landscape screenshots rotation = self.rotation_for_device_orientation frame.rotate(-rotation) @image.rotate(-rotation) # Debug Mode: Add filename to frame if self.debug_mode filename = File.basename(@frame_path, ".*") filename.sub!('Apple', '') # remove 'Apple' width = screenshot.size[0] font_size = width / 20 # magic number that works well offset_top = offset['offset'].split("+")[2].to_f annotate_offset = "+0+#{offset_top}" # magic number that works semi well frame.combine_options do |c| c.gravity('North') c.undercolor('#00000080') c.fill('white') c.pointsize(font_size) c.annotate(annotate_offset.to_s, filename.to_s) end end @image = frame.composite(image, "png") do |c| c.compose("DstOver") c.geometry(offset['offset']) end # Revert the rotation from above frame.rotate(rotation) @image.rotate(rotation) end
ruby
def put_into_frame # We have to rotate the screenshot, since the offset information is for portrait # only. Instead of doing the calculations ourselves, it's much easier to let # imagemagick do the hard lifting for landscape screenshots rotation = self.rotation_for_device_orientation frame.rotate(-rotation) @image.rotate(-rotation) # Debug Mode: Add filename to frame if self.debug_mode filename = File.basename(@frame_path, ".*") filename.sub!('Apple', '') # remove 'Apple' width = screenshot.size[0] font_size = width / 20 # magic number that works well offset_top = offset['offset'].split("+")[2].to_f annotate_offset = "+0+#{offset_top}" # magic number that works semi well frame.combine_options do |c| c.gravity('North') c.undercolor('#00000080') c.fill('white') c.pointsize(font_size) c.annotate(annotate_offset.to_s, filename.to_s) end end @image = frame.composite(image, "png") do |c| c.compose("DstOver") c.geometry(offset['offset']) end # Revert the rotation from above frame.rotate(rotation) @image.rotate(rotation) end
[ "def", "put_into_frame", "# We have to rotate the screenshot, since the offset information is for portrait", "# only. Instead of doing the calculations ourselves, it's much easier to let", "# imagemagick do the hard lifting for landscape screenshots", "rotation", "=", "self", ".", "rotation_for_device_orientation", "frame", ".", "rotate", "(", "-", "rotation", ")", "@image", ".", "rotate", "(", "-", "rotation", ")", "# Debug Mode: Add filename to frame", "if", "self", ".", "debug_mode", "filename", "=", "File", ".", "basename", "(", "@frame_path", ",", "\".*\"", ")", "filename", ".", "sub!", "(", "'Apple'", ",", "''", ")", "# remove 'Apple'", "width", "=", "screenshot", ".", "size", "[", "0", "]", "font_size", "=", "width", "/", "20", "# magic number that works well", "offset_top", "=", "offset", "[", "'offset'", "]", ".", "split", "(", "\"+\"", ")", "[", "2", "]", ".", "to_f", "annotate_offset", "=", "\"+0+#{offset_top}\"", "# magic number that works semi well", "frame", ".", "combine_options", "do", "|", "c", "|", "c", ".", "gravity", "(", "'North'", ")", "c", ".", "undercolor", "(", "'#00000080'", ")", "c", ".", "fill", "(", "'white'", ")", "c", ".", "pointsize", "(", "font_size", ")", "c", ".", "annotate", "(", "annotate_offset", ".", "to_s", ",", "filename", ".", "to_s", ")", "end", "end", "@image", "=", "frame", ".", "composite", "(", "image", ",", "\"png\"", ")", "do", "|", "c", "|", "c", ".", "compose", "(", "\"DstOver\"", ")", "c", ".", "geometry", "(", "offset", "[", "'offset'", "]", ")", "end", "# Revert the rotation from above", "frame", ".", "rotate", "(", "rotation", ")", "@image", ".", "rotate", "(", "rotation", ")", "end" ]
puts the screenshot into the frame
[ "puts", "the", "screenshot", "into", "the", "frame" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L83-L119
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.modify_offset
def modify_offset(multiplicator) # Format: "+133+50" hash = offset['offset'] x = hash.split("+")[1].to_f * multiplicator y = hash.split("+")[2].to_f * multiplicator new_offset = "+#{x.round}+#{y.round}" @offset_information['offset'] = new_offset end
ruby
def modify_offset(multiplicator) # Format: "+133+50" hash = offset['offset'] x = hash.split("+")[1].to_f * multiplicator y = hash.split("+")[2].to_f * multiplicator new_offset = "+#{x.round}+#{y.round}" @offset_information['offset'] = new_offset end
[ "def", "modify_offset", "(", "multiplicator", ")", "# Format: \"+133+50\"", "hash", "=", "offset", "[", "'offset'", "]", "x", "=", "hash", ".", "split", "(", "\"+\"", ")", "[", "1", "]", ".", "to_f", "*", "multiplicator", "y", "=", "hash", ".", "split", "(", "\"+\"", ")", "[", "2", "]", ".", "to_f", "*", "multiplicator", "new_offset", "=", "\"+#{x.round}+#{y.round}\"", "@offset_information", "[", "'offset'", "]", "=", "new_offset", "end" ]
Everything below is related to title, background, etc. and is not used in the easy mode this is used to correct the 1:1 offset information the offset information is stored to work for the template images since we resize the template images to have higher quality screenshots we need to modify the offset information by a certain factor
[ "Everything", "below", "is", "related", "to", "title", "background", "etc", ".", "and", "is", "not", "used", "in", "the", "easy", "mode" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L140-L147
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.horizontal_frame_padding
def horizontal_frame_padding padding = fetch_config['padding'] if padding.kind_of?(String) && padding.split('x').length == 2 padding = padding.split('x')[0] padding = padding.to_i unless padding.end_with?('%') end return scale_padding(padding) end
ruby
def horizontal_frame_padding padding = fetch_config['padding'] if padding.kind_of?(String) && padding.split('x').length == 2 padding = padding.split('x')[0] padding = padding.to_i unless padding.end_with?('%') end return scale_padding(padding) end
[ "def", "horizontal_frame_padding", "padding", "=", "fetch_config", "[", "'padding'", "]", "if", "padding", ".", "kind_of?", "(", "String", ")", "&&", "padding", ".", "split", "(", "'x'", ")", ".", "length", "==", "2", "padding", "=", "padding", ".", "split", "(", "'x'", ")", "[", "0", "]", "padding", "=", "padding", ".", "to_i", "unless", "padding", ".", "end_with?", "(", "'%'", ")", "end", "return", "scale_padding", "(", "padding", ")", "end" ]
Horizontal adding around the frames
[ "Horizontal", "adding", "around", "the", "frames" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L193-L200
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.title_min_height
def title_min_height @title_min_height ||= begin height = fetch_config['title_min_height'] || 0 if height.kind_of?(String) && height.end_with?('%') height = ([image.width, image.height].min * height.to_f * 0.01).ceil end height end end
ruby
def title_min_height @title_min_height ||= begin height = fetch_config['title_min_height'] || 0 if height.kind_of?(String) && height.end_with?('%') height = ([image.width, image.height].min * height.to_f * 0.01).ceil end height end end
[ "def", "title_min_height", "@title_min_height", "||=", "begin", "height", "=", "fetch_config", "[", "'title_min_height'", "]", "||", "0", "if", "height", ".", "kind_of?", "(", "String", ")", "&&", "height", ".", "end_with?", "(", "'%'", ")", "height", "=", "(", "[", "image", ".", "width", ",", "image", ".", "height", "]", ".", "min", "*", "height", ".", "to_f", "*", "0.01", ")", ".", "ceil", "end", "height", "end", "end" ]
Minimum height for the title
[ "Minimum", "height", "for", "the", "title" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L213-L221
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.generate_background
def generate_background background = MiniMagick::Image.open(fetch_config['background']) if background.height != screenshot.size[1] background.resize("#{screenshot.size[0]}x#{screenshot.size[1]}^") # `^` says it should fill area background.merge!(["-gravity", "center", "-crop", "#{screenshot.size[0]}x#{screenshot.size[1]}+0+0"]) # crop from center end background end
ruby
def generate_background background = MiniMagick::Image.open(fetch_config['background']) if background.height != screenshot.size[1] background.resize("#{screenshot.size[0]}x#{screenshot.size[1]}^") # `^` says it should fill area background.merge!(["-gravity", "center", "-crop", "#{screenshot.size[0]}x#{screenshot.size[1]}+0+0"]) # crop from center end background end
[ "def", "generate_background", "background", "=", "MiniMagick", "::", "Image", ".", "open", "(", "fetch_config", "[", "'background'", "]", ")", "if", "background", ".", "height", "!=", "screenshot", ".", "size", "[", "1", "]", "background", ".", "resize", "(", "\"#{screenshot.size[0]}x#{screenshot.size[1]}^\"", ")", "# `^` says it should fill area", "background", ".", "merge!", "(", "[", "\"-gravity\"", ",", "\"center\"", ",", "\"-crop\"", ",", "\"#{screenshot.size[0]}x#{screenshot.size[1]}+0+0\"", "]", ")", "# crop from center", "end", "background", "end" ]
Returns a correctly sized background image
[ "Returns", "a", "correctly", "sized", "background", "image" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L251-L259
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.resize_frame!
def resize_frame! screenshot_width = self.screenshot.portrait? ? screenshot.size[0] : screenshot.size[1] multiplicator = (screenshot_width.to_f / offset['width'].to_f) # by how much do we have to change this? new_frame_width = multiplicator * frame.width # the new width for the frame frame.resize("#{new_frame_width.round}x") # resize it to the calculated width modify_offset(multiplicator) # modify the offset to properly insert the screenshot into the frame later end
ruby
def resize_frame! screenshot_width = self.screenshot.portrait? ? screenshot.size[0] : screenshot.size[1] multiplicator = (screenshot_width.to_f / offset['width'].to_f) # by how much do we have to change this? new_frame_width = multiplicator * frame.width # the new width for the frame frame.resize("#{new_frame_width.round}x") # resize it to the calculated width modify_offset(multiplicator) # modify the offset to properly insert the screenshot into the frame later end
[ "def", "resize_frame!", "screenshot_width", "=", "self", ".", "screenshot", ".", "portrait?", "?", "screenshot", ".", "size", "[", "0", "]", ":", "screenshot", ".", "size", "[", "1", "]", "multiplicator", "=", "(", "screenshot_width", ".", "to_f", "/", "offset", "[", "'width'", "]", ".", "to_f", ")", "# by how much do we have to change this?", "new_frame_width", "=", "multiplicator", "*", "frame", ".", "width", "# the new width for the frame", "frame", ".", "resize", "(", "\"#{new_frame_width.round}x\"", ")", "# resize it to the calculated width", "modify_offset", "(", "multiplicator", ")", "# modify the offset to properly insert the screenshot into the frame later", "end" ]
Resize the frame as it's too low quality by default
[ "Resize", "the", "frame", "as", "it", "s", "too", "low", "quality", "by", "default" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L273-L280
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.put_title_into_background_stacked
def put_title_into_background_stacked(background, title, keyword) resize_text(title) resize_text(keyword) vertical_padding = vertical_frame_padding # assign padding to variable spacing_between_title_and_keyword = (actual_font_size / 2) title_left_space = (background.width / 2.0 - title.width / 2.0).round keyword_left_space = (background.width / 2.0 - keyword.width / 2.0).round self.space_to_device += title.height + keyword.height + spacing_between_title_and_keyword + vertical_padding if title_below_image keyword_top = background.height - effective_text_height / 2 - (keyword.height + spacing_between_title_and_keyword + title.height) / 2 else keyword_top = device_top(background) / 2 - spacing_between_title_and_keyword / 2 - keyword.height end title_top = keyword_top + keyword.height + spacing_between_title_and_keyword # keyword background = background.composite(keyword, "png") do |c| c.compose("Over") c.geometry("+#{keyword_left_space}+#{keyword_top}") end # Place the title below the keyword background = background.composite(title, "png") do |c| c.compose("Over") c.geometry("+#{title_left_space}+#{title_top}") end background end
ruby
def put_title_into_background_stacked(background, title, keyword) resize_text(title) resize_text(keyword) vertical_padding = vertical_frame_padding # assign padding to variable spacing_between_title_and_keyword = (actual_font_size / 2) title_left_space = (background.width / 2.0 - title.width / 2.0).round keyword_left_space = (background.width / 2.0 - keyword.width / 2.0).round self.space_to_device += title.height + keyword.height + spacing_between_title_and_keyword + vertical_padding if title_below_image keyword_top = background.height - effective_text_height / 2 - (keyword.height + spacing_between_title_and_keyword + title.height) / 2 else keyword_top = device_top(background) / 2 - spacing_between_title_and_keyword / 2 - keyword.height end title_top = keyword_top + keyword.height + spacing_between_title_and_keyword # keyword background = background.composite(keyword, "png") do |c| c.compose("Over") c.geometry("+#{keyword_left_space}+#{keyword_top}") end # Place the title below the keyword background = background.composite(title, "png") do |c| c.compose("Over") c.geometry("+#{title_left_space}+#{title_top}") end background end
[ "def", "put_title_into_background_stacked", "(", "background", ",", "title", ",", "keyword", ")", "resize_text", "(", "title", ")", "resize_text", "(", "keyword", ")", "vertical_padding", "=", "vertical_frame_padding", "# assign padding to variable", "spacing_between_title_and_keyword", "=", "(", "actual_font_size", "/", "2", ")", "title_left_space", "=", "(", "background", ".", "width", "/", "2.0", "-", "title", ".", "width", "/", "2.0", ")", ".", "round", "keyword_left_space", "=", "(", "background", ".", "width", "/", "2.0", "-", "keyword", ".", "width", "/", "2.0", ")", ".", "round", "self", ".", "space_to_device", "+=", "title", ".", "height", "+", "keyword", ".", "height", "+", "spacing_between_title_and_keyword", "+", "vertical_padding", "if", "title_below_image", "keyword_top", "=", "background", ".", "height", "-", "effective_text_height", "/", "2", "-", "(", "keyword", ".", "height", "+", "spacing_between_title_and_keyword", "+", "title", ".", "height", ")", "/", "2", "else", "keyword_top", "=", "device_top", "(", "background", ")", "/", "2", "-", "spacing_between_title_and_keyword", "/", "2", "-", "keyword", ".", "height", "end", "title_top", "=", "keyword_top", "+", "keyword", ".", "height", "+", "spacing_between_title_and_keyword", "# keyword", "background", "=", "background", ".", "composite", "(", "keyword", ",", "\"png\"", ")", "do", "|", "c", "|", "c", ".", "compose", "(", "\"Over\"", ")", "c", ".", "geometry", "(", "\"+#{keyword_left_space}+#{keyword_top}\"", ")", "end", "# Place the title below the keyword", "background", "=", "background", ".", "composite", "(", "title", ",", "\"png\"", ")", "do", "|", "c", "|", "c", ".", "compose", "(", "\"Over\"", ")", "c", ".", "geometry", "(", "\"+#{title_left_space}+#{title_top}\"", ")", "end", "background", "end" ]
Add the title above or below the device
[ "Add", "the", "title", "above", "or", "below", "the", "device" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L292-L321
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.build_text_images
def build_text_images(max_width, max_height, stack_title) words = [:keyword, :title].keep_if { |a| fetch_text(a) } # optional keyword/title results = {} trim_boxes = {} top_vertical_trim_offset = Float::INFINITY # Init at a large value, as the code will search for a minimal value. bottom_vertical_trim_offset = 0 words.each do |key| # Create empty background empty_path = File.join(Frameit::ROOT, "lib/assets/empty.png") text_image = MiniMagick::Image.open(empty_path) image_height = max_height # gets trimmed afterwards anyway, and on the iPad the `y` would get cut text_image.combine_options do |i| # Oversize as the text might be larger than the actual image. We're trimming afterwards anyway i.resize("#{max_width * 5.0}x#{image_height}!") # `!` says it should ignore the ratio end current_font = font(key) text = fetch_text(key) UI.verbose("Using #{current_font} as font the #{key} of #{screenshot.path}") if current_font UI.verbose("Adding text '#{text}'") text.gsub!('\n', "\n") text.gsub!(/(?<!\\)(')/) { |s| "\\#{s}" } # escape unescaped apostrophes with a backslash interline_spacing = fetch_config['interline_spacing'] # Add the actual title text_image.combine_options do |i| i.font(current_font) if current_font i.gravity("Center") i.pointsize(actual_font_size) i.draw("text 0,0 '#{text}'") i.interline_spacing(interline_spacing) if interline_spacing i.fill(fetch_config[key.to_s]['color']) end results[key] = text_image # Natively trimming the image with .trim will result in the loss of the common baseline between the text in all images when side-by-side (e.g. stack_title is false). # Hence retrieve the calculated trim bounding box without actually trimming: calculated_trim_box = text_image.identify do |b| b.format("%@") # CALCULATED: trim bounding box (without actually trimming), see: http://www.imagemagick.org/script/escape.php end # Create a Trimbox object from the MiniMagick .identify string with syntax "<width>x<height>+<offset_x>+<offset_y>": trim_box = Frameit::Trimbox.new(calculated_trim_box) # Get the minimum top offset of the trim box: if trim_box.offset_y < top_vertical_trim_offset top_vertical_trim_offset = trim_box.offset_y end # Get the maximum bottom offset of the trim box, this is the top offset + height: if (trim_box.offset_y + trim_box.height) > bottom_vertical_trim_offset bottom_vertical_trim_offset = trim_box.offset_y + trim_box.height end # Store for the crop action: trim_boxes[key] = trim_box end # Crop text images: words.each do |key| # Get matching trim box: trim_box = trim_boxes[key] # For side-by-side text images (e.g. stack_title is false) adjust the trim box based on top_vertical_trim_offset and bottom_vertical_trim_offset to maintain the text baseline: unless stack_title # Determine the trim area by maintaining the same vertical top offset based on the smallest value from all trim boxes (top_vertical_trim_offset). # When the vertical top offset is larger than the smallest vertical top offset, the trim box needs to be adjusted: if trim_box.offset_y > top_vertical_trim_offset # Increase the height of the trim box with the difference in vertical top offset: trim_box.height += trim_box.offset_y - top_vertical_trim_offset # Change the vertical top offset to match that of the others: trim_box.offset_y = top_vertical_trim_offset UI.verbose("Trim box for key \"#{key}\" is adjusted to align top: #{trim_box}\n") end # Check if the height needs to be adjusted to reach the bottom offset: if (trim_box.offset_y + trim_box.height) < bottom_vertical_trim_offset # Set the height of the trim box to the difference between vertical bottom and top offset: trim_box.height = bottom_vertical_trim_offset - trim_box.offset_y UI.verbose("Trim box for key \"#{key}\" is adjusted to align bottom: #{trim_box}\n") end end # Crop image with (adjusted) trim box parameters in MiniMagick string format: results[key].crop(trim_box.string_format) end results end
ruby
def build_text_images(max_width, max_height, stack_title) words = [:keyword, :title].keep_if { |a| fetch_text(a) } # optional keyword/title results = {} trim_boxes = {} top_vertical_trim_offset = Float::INFINITY # Init at a large value, as the code will search for a minimal value. bottom_vertical_trim_offset = 0 words.each do |key| # Create empty background empty_path = File.join(Frameit::ROOT, "lib/assets/empty.png") text_image = MiniMagick::Image.open(empty_path) image_height = max_height # gets trimmed afterwards anyway, and on the iPad the `y` would get cut text_image.combine_options do |i| # Oversize as the text might be larger than the actual image. We're trimming afterwards anyway i.resize("#{max_width * 5.0}x#{image_height}!") # `!` says it should ignore the ratio end current_font = font(key) text = fetch_text(key) UI.verbose("Using #{current_font} as font the #{key} of #{screenshot.path}") if current_font UI.verbose("Adding text '#{text}'") text.gsub!('\n', "\n") text.gsub!(/(?<!\\)(')/) { |s| "\\#{s}" } # escape unescaped apostrophes with a backslash interline_spacing = fetch_config['interline_spacing'] # Add the actual title text_image.combine_options do |i| i.font(current_font) if current_font i.gravity("Center") i.pointsize(actual_font_size) i.draw("text 0,0 '#{text}'") i.interline_spacing(interline_spacing) if interline_spacing i.fill(fetch_config[key.to_s]['color']) end results[key] = text_image # Natively trimming the image with .trim will result in the loss of the common baseline between the text in all images when side-by-side (e.g. stack_title is false). # Hence retrieve the calculated trim bounding box without actually trimming: calculated_trim_box = text_image.identify do |b| b.format("%@") # CALCULATED: trim bounding box (without actually trimming), see: http://www.imagemagick.org/script/escape.php end # Create a Trimbox object from the MiniMagick .identify string with syntax "<width>x<height>+<offset_x>+<offset_y>": trim_box = Frameit::Trimbox.new(calculated_trim_box) # Get the minimum top offset of the trim box: if trim_box.offset_y < top_vertical_trim_offset top_vertical_trim_offset = trim_box.offset_y end # Get the maximum bottom offset of the trim box, this is the top offset + height: if (trim_box.offset_y + trim_box.height) > bottom_vertical_trim_offset bottom_vertical_trim_offset = trim_box.offset_y + trim_box.height end # Store for the crop action: trim_boxes[key] = trim_box end # Crop text images: words.each do |key| # Get matching trim box: trim_box = trim_boxes[key] # For side-by-side text images (e.g. stack_title is false) adjust the trim box based on top_vertical_trim_offset and bottom_vertical_trim_offset to maintain the text baseline: unless stack_title # Determine the trim area by maintaining the same vertical top offset based on the smallest value from all trim boxes (top_vertical_trim_offset). # When the vertical top offset is larger than the smallest vertical top offset, the trim box needs to be adjusted: if trim_box.offset_y > top_vertical_trim_offset # Increase the height of the trim box with the difference in vertical top offset: trim_box.height += trim_box.offset_y - top_vertical_trim_offset # Change the vertical top offset to match that of the others: trim_box.offset_y = top_vertical_trim_offset UI.verbose("Trim box for key \"#{key}\" is adjusted to align top: #{trim_box}\n") end # Check if the height needs to be adjusted to reach the bottom offset: if (trim_box.offset_y + trim_box.height) < bottom_vertical_trim_offset # Set the height of the trim box to the difference between vertical bottom and top offset: trim_box.height = bottom_vertical_trim_offset - trim_box.offset_y UI.verbose("Trim box for key \"#{key}\" is adjusted to align bottom: #{trim_box}\n") end end # Crop image with (adjusted) trim box parameters in MiniMagick string format: results[key].crop(trim_box.string_format) end results end
[ "def", "build_text_images", "(", "max_width", ",", "max_height", ",", "stack_title", ")", "words", "=", "[", ":keyword", ",", ":title", "]", ".", "keep_if", "{", "|", "a", "|", "fetch_text", "(", "a", ")", "}", "# optional keyword/title", "results", "=", "{", "}", "trim_boxes", "=", "{", "}", "top_vertical_trim_offset", "=", "Float", "::", "INFINITY", "# Init at a large value, as the code will search for a minimal value.", "bottom_vertical_trim_offset", "=", "0", "words", ".", "each", "do", "|", "key", "|", "# Create empty background", "empty_path", "=", "File", ".", "join", "(", "Frameit", "::", "ROOT", ",", "\"lib/assets/empty.png\"", ")", "text_image", "=", "MiniMagick", "::", "Image", ".", "open", "(", "empty_path", ")", "image_height", "=", "max_height", "# gets trimmed afterwards anyway, and on the iPad the `y` would get cut", "text_image", ".", "combine_options", "do", "|", "i", "|", "# Oversize as the text might be larger than the actual image. We're trimming afterwards anyway", "i", ".", "resize", "(", "\"#{max_width * 5.0}x#{image_height}!\"", ")", "# `!` says it should ignore the ratio", "end", "current_font", "=", "font", "(", "key", ")", "text", "=", "fetch_text", "(", "key", ")", "UI", ".", "verbose", "(", "\"Using #{current_font} as font the #{key} of #{screenshot.path}\"", ")", "if", "current_font", "UI", ".", "verbose", "(", "\"Adding text '#{text}'\"", ")", "text", ".", "gsub!", "(", "'\\n'", ",", "\"\\n\"", ")", "text", ".", "gsub!", "(", "/", "\\\\", "/", ")", "{", "|", "s", "|", "\"\\\\#{s}\"", "}", "# escape unescaped apostrophes with a backslash", "interline_spacing", "=", "fetch_config", "[", "'interline_spacing'", "]", "# Add the actual title", "text_image", ".", "combine_options", "do", "|", "i", "|", "i", ".", "font", "(", "current_font", ")", "if", "current_font", "i", ".", "gravity", "(", "\"Center\"", ")", "i", ".", "pointsize", "(", "actual_font_size", ")", "i", ".", "draw", "(", "\"text 0,0 '#{text}'\"", ")", "i", ".", "interline_spacing", "(", "interline_spacing", ")", "if", "interline_spacing", "i", ".", "fill", "(", "fetch_config", "[", "key", ".", "to_s", "]", "[", "'color'", "]", ")", "end", "results", "[", "key", "]", "=", "text_image", "# Natively trimming the image with .trim will result in the loss of the common baseline between the text in all images when side-by-side (e.g. stack_title is false).", "# Hence retrieve the calculated trim bounding box without actually trimming:", "calculated_trim_box", "=", "text_image", ".", "identify", "do", "|", "b", "|", "b", ".", "format", "(", "\"%@\"", ")", "# CALCULATED: trim bounding box (without actually trimming), see: http://www.imagemagick.org/script/escape.php", "end", "# Create a Trimbox object from the MiniMagick .identify string with syntax \"<width>x<height>+<offset_x>+<offset_y>\":", "trim_box", "=", "Frameit", "::", "Trimbox", ".", "new", "(", "calculated_trim_box", ")", "# Get the minimum top offset of the trim box:", "if", "trim_box", ".", "offset_y", "<", "top_vertical_trim_offset", "top_vertical_trim_offset", "=", "trim_box", ".", "offset_y", "end", "# Get the maximum bottom offset of the trim box, this is the top offset + height:", "if", "(", "trim_box", ".", "offset_y", "+", "trim_box", ".", "height", ")", ">", "bottom_vertical_trim_offset", "bottom_vertical_trim_offset", "=", "trim_box", ".", "offset_y", "+", "trim_box", ".", "height", "end", "# Store for the crop action:", "trim_boxes", "[", "key", "]", "=", "trim_box", "end", "# Crop text images:", "words", ".", "each", "do", "|", "key", "|", "# Get matching trim box:", "trim_box", "=", "trim_boxes", "[", "key", "]", "# For side-by-side text images (e.g. stack_title is false) adjust the trim box based on top_vertical_trim_offset and bottom_vertical_trim_offset to maintain the text baseline:", "unless", "stack_title", "# Determine the trim area by maintaining the same vertical top offset based on the smallest value from all trim boxes (top_vertical_trim_offset).", "# When the vertical top offset is larger than the smallest vertical top offset, the trim box needs to be adjusted:", "if", "trim_box", ".", "offset_y", ">", "top_vertical_trim_offset", "# Increase the height of the trim box with the difference in vertical top offset:", "trim_box", ".", "height", "+=", "trim_box", ".", "offset_y", "-", "top_vertical_trim_offset", "# Change the vertical top offset to match that of the others:", "trim_box", ".", "offset_y", "=", "top_vertical_trim_offset", "UI", ".", "verbose", "(", "\"Trim box for key \\\"#{key}\\\" is adjusted to align top: #{trim_box}\\n\"", ")", "end", "# Check if the height needs to be adjusted to reach the bottom offset:", "if", "(", "trim_box", ".", "offset_y", "+", "trim_box", ".", "height", ")", "<", "bottom_vertical_trim_offset", "# Set the height of the trim box to the difference between vertical bottom and top offset:", "trim_box", ".", "height", "=", "bottom_vertical_trim_offset", "-", "trim_box", ".", "offset_y", "UI", ".", "verbose", "(", "\"Trim box for key \\\"#{key}\\\" is adjusted to align bottom: #{trim_box}\\n\"", ")", "end", "end", "# Crop image with (adjusted) trim box parameters in MiniMagick string format:", "results", "[", "key", "]", ".", "crop", "(", "trim_box", ".", "string_format", ")", "end", "results", "end" ]
This will build up to 2 individual images with the title and optional keyword, which will then be added to the real image
[ "This", "will", "build", "up", "to", "2", "individual", "images", "with", "the", "title", "and", "optional", "keyword", "which", "will", "then", "be", "added", "to", "the", "real", "image" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L396-L489
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.fetch_text
def fetch_text(type) UI.user_error!("Valid parameters :keyword, :title") unless [:keyword, :title].include?(type) # Try to get it from a keyword.strings or title.strings file strings_path = File.join(File.expand_path("..", screenshot.path), "#{type}.strings") if File.exist?(strings_path) parsed = StringsParser.parse(strings_path) text_array = parsed.find { |k, v| screenshot.path.upcase.include?(k.upcase) } return text_array.last if text_array && text_array.last.length > 0 # Ignore empty string end UI.verbose("Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file") # No string files, fallback to Framefile config text = fetch_config[type.to_s]['text'] if fetch_config[type.to_s] && fetch_config[type.to_s]['text'] && fetch_config[type.to_s]['text'].length > 0 # Ignore empty string return text end
ruby
def fetch_text(type) UI.user_error!("Valid parameters :keyword, :title") unless [:keyword, :title].include?(type) # Try to get it from a keyword.strings or title.strings file strings_path = File.join(File.expand_path("..", screenshot.path), "#{type}.strings") if File.exist?(strings_path) parsed = StringsParser.parse(strings_path) text_array = parsed.find { |k, v| screenshot.path.upcase.include?(k.upcase) } return text_array.last if text_array && text_array.last.length > 0 # Ignore empty string end UI.verbose("Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file") # No string files, fallback to Framefile config text = fetch_config[type.to_s]['text'] if fetch_config[type.to_s] && fetch_config[type.to_s]['text'] && fetch_config[type.to_s]['text'].length > 0 # Ignore empty string return text end
[ "def", "fetch_text", "(", "type", ")", "UI", ".", "user_error!", "(", "\"Valid parameters :keyword, :title\"", ")", "unless", "[", ":keyword", ",", ":title", "]", ".", "include?", "(", "type", ")", "# Try to get it from a keyword.strings or title.strings file", "strings_path", "=", "File", ".", "join", "(", "File", ".", "expand_path", "(", "\"..\"", ",", "screenshot", ".", "path", ")", ",", "\"#{type}.strings\"", ")", "if", "File", ".", "exist?", "(", "strings_path", ")", "parsed", "=", "StringsParser", ".", "parse", "(", "strings_path", ")", "text_array", "=", "parsed", ".", "find", "{", "|", "k", ",", "v", "|", "screenshot", ".", "path", ".", "upcase", ".", "include?", "(", "k", ".", "upcase", ")", "}", "return", "text_array", ".", "last", "if", "text_array", "&&", "text_array", ".", "last", ".", "length", ">", "0", "# Ignore empty string", "end", "UI", ".", "verbose", "(", "\"Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file\"", ")", "# No string files, fallback to Framefile config", "text", "=", "fetch_config", "[", "type", ".", "to_s", "]", "[", "'text'", "]", "if", "fetch_config", "[", "type", ".", "to_s", "]", "&&", "fetch_config", "[", "type", ".", "to_s", "]", "[", "'text'", "]", "&&", "fetch_config", "[", "type", ".", "to_s", "]", "[", "'text'", "]", ".", "length", ">", "0", "# Ignore empty string", "return", "text", "end" ]
Fetches the title + keyword for this particular screenshot
[ "Fetches", "the", "title", "+", "keyword", "for", "this", "particular", "screenshot" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L504-L520
train
fastlane/fastlane
frameit/lib/frameit/editor.rb
Frameit.Editor.font
def font(key) single_font = fetch_config[key.to_s]['font'] return single_font if single_font fonts = fetch_config[key.to_s]['fonts'] if fonts fonts.each do |font| if font['supported'] font['supported'].each do |language| if screenshot.path.include?(language) return font["font"] end end else # No `supported` array, this will always be true UI.verbose("Found a font with no list of supported languages, using this now") return font["font"] end end end UI.verbose("No custom font specified for #{screenshot}, using the default one") return nil end
ruby
def font(key) single_font = fetch_config[key.to_s]['font'] return single_font if single_font fonts = fetch_config[key.to_s]['fonts'] if fonts fonts.each do |font| if font['supported'] font['supported'].each do |language| if screenshot.path.include?(language) return font["font"] end end else # No `supported` array, this will always be true UI.verbose("Found a font with no list of supported languages, using this now") return font["font"] end end end UI.verbose("No custom font specified for #{screenshot}, using the default one") return nil end
[ "def", "font", "(", "key", ")", "single_font", "=", "fetch_config", "[", "key", ".", "to_s", "]", "[", "'font'", "]", "return", "single_font", "if", "single_font", "fonts", "=", "fetch_config", "[", "key", ".", "to_s", "]", "[", "'fonts'", "]", "if", "fonts", "fonts", ".", "each", "do", "|", "font", "|", "if", "font", "[", "'supported'", "]", "font", "[", "'supported'", "]", ".", "each", "do", "|", "language", "|", "if", "screenshot", ".", "path", ".", "include?", "(", "language", ")", "return", "font", "[", "\"font\"", "]", "end", "end", "else", "# No `supported` array, this will always be true", "UI", ".", "verbose", "(", "\"Found a font with no list of supported languages, using this now\"", ")", "return", "font", "[", "\"font\"", "]", "end", "end", "end", "UI", ".", "verbose", "(", "\"No custom font specified for #{screenshot}, using the default one\"", ")", "return", "nil", "end" ]
The font we want to use
[ "The", "font", "we", "want", "to", "use" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/frameit/lib/frameit/editor.rb#L538-L561
train
fastlane/fastlane
pilot/lib/pilot/build_manager.rb
Pilot.BuildManager.transporter_for_selected_team
def transporter_for_selected_team(options) generic_transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider]) return generic_transporter unless options[:itc_provider].nil? && Spaceship::Tunes.client.teams.count > 1 begin team = Spaceship::Tunes.client.teams.find { |t| t['contentProvider']['contentProviderId'].to_s == Spaceship::Tunes.client.team_id } name = team['contentProvider']['name'] provider_id = generic_transporter.provider_ids[name] UI.verbose("Inferred provider id #{provider_id} for team #{name}.") return FastlaneCore::ItunesTransporter.new(options[:username], nil, false, provider_id) rescue => ex UI.verbose("Couldn't infer a provider short name for team with id #{Spaceship::Tunes.client.team_id} automatically: #{ex}. Proceeding without provider short name.") return generic_transporter end end
ruby
def transporter_for_selected_team(options) generic_transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider]) return generic_transporter unless options[:itc_provider].nil? && Spaceship::Tunes.client.teams.count > 1 begin team = Spaceship::Tunes.client.teams.find { |t| t['contentProvider']['contentProviderId'].to_s == Spaceship::Tunes.client.team_id } name = team['contentProvider']['name'] provider_id = generic_transporter.provider_ids[name] UI.verbose("Inferred provider id #{provider_id} for team #{name}.") return FastlaneCore::ItunesTransporter.new(options[:username], nil, false, provider_id) rescue => ex UI.verbose("Couldn't infer a provider short name for team with id #{Spaceship::Tunes.client.team_id} automatically: #{ex}. Proceeding without provider short name.") return generic_transporter end end
[ "def", "transporter_for_selected_team", "(", "options", ")", "generic_transporter", "=", "FastlaneCore", "::", "ItunesTransporter", ".", "new", "(", "options", "[", ":username", "]", ",", "nil", ",", "false", ",", "options", "[", ":itc_provider", "]", ")", "return", "generic_transporter", "unless", "options", "[", ":itc_provider", "]", ".", "nil?", "&&", "Spaceship", "::", "Tunes", ".", "client", ".", "teams", ".", "count", ">", "1", "begin", "team", "=", "Spaceship", "::", "Tunes", ".", "client", ".", "teams", ".", "find", "{", "|", "t", "|", "t", "[", "'contentProvider'", "]", "[", "'contentProviderId'", "]", ".", "to_s", "==", "Spaceship", "::", "Tunes", ".", "client", ".", "team_id", "}", "name", "=", "team", "[", "'contentProvider'", "]", "[", "'name'", "]", "provider_id", "=", "generic_transporter", ".", "provider_ids", "[", "name", "]", "UI", ".", "verbose", "(", "\"Inferred provider id #{provider_id} for team #{name}.\"", ")", "return", "FastlaneCore", "::", "ItunesTransporter", ".", "new", "(", "options", "[", ":username", "]", ",", "nil", ",", "false", ",", "provider_id", ")", "rescue", "=>", "ex", "UI", ".", "verbose", "(", "\"Couldn't infer a provider short name for team with id #{Spaceship::Tunes.client.team_id} automatically: #{ex}. Proceeding without provider short name.\"", ")", "return", "generic_transporter", "end", "end" ]
If itc_provider was explicitly specified, use it. If there are multiple teams, infer the provider from the selected team name. If there are fewer than two teams, don't infer the provider.
[ "If", "itc_provider", "was", "explicitly", "specified", "use", "it", ".", "If", "there", "are", "multiple", "teams", "infer", "the", "provider", "from", "the", "selected", "team", "name", ".", "If", "there", "are", "fewer", "than", "two", "teams", "don", "t", "infer", "the", "provider", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/pilot/lib/pilot/build_manager.rb#L221-L235
train
fastlane/fastlane
spaceship/lib/spaceship/two_step_or_factor_client.rb
Spaceship.Client.update_request_headers
def update_request_headers(req) req.headers["X-Apple-Id-Session-Id"] = @x_apple_id_session_id req.headers["X-Apple-Widget-Key"] = self.itc_service_key req.headers["Accept"] = "application/json" req.headers["scnt"] = @scnt end
ruby
def update_request_headers(req) req.headers["X-Apple-Id-Session-Id"] = @x_apple_id_session_id req.headers["X-Apple-Widget-Key"] = self.itc_service_key req.headers["Accept"] = "application/json" req.headers["scnt"] = @scnt end
[ "def", "update_request_headers", "(", "req", ")", "req", ".", "headers", "[", "\"X-Apple-Id-Session-Id\"", "]", "=", "@x_apple_id_session_id", "req", ".", "headers", "[", "\"X-Apple-Widget-Key\"", "]", "=", "self", ".", "itc_service_key", "req", ".", "headers", "[", "\"Accept\"", "]", "=", "\"application/json\"", "req", ".", "headers", "[", "\"scnt\"", "]", "=", "@scnt", "end" ]
Responsible for setting all required header attributes for the requests to succeed
[ "Responsible", "for", "setting", "all", "required", "header", "attributes", "for", "the", "requests", "to", "succeed" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/two_step_or_factor_client.rb#L301-L306
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/itunes_transporter.rb
FastlaneCore.ItunesTransporter.upload
def upload(app_id, dir) actual_dir = File.join(dir, "#{app_id}.itmsp") UI.message("Going to upload updated app to App Store Connect") UI.success("This might take a few minutes. Please don't interrupt the script.") command = @transporter_executor.build_upload_command(@user, @password, actual_dir, @provider_short_name) UI.verbose(@transporter_executor.build_upload_command(@user, 'YourPassword', actual_dir, @provider_short_name)) begin result = @transporter_executor.execute(command, ItunesTransporter.hide_transporter_output?) rescue TransporterRequiresApplicationSpecificPasswordError => ex handle_two_step_failure(ex) return upload(app_id, dir) end if result UI.header("Successfully uploaded package to App Store Connect. It might take a few minutes until it's visible online.") FileUtils.rm_rf(actual_dir) unless Helper.test? # we don't need the package any more, since the upload was successful else handle_error(@password) end result end
ruby
def upload(app_id, dir) actual_dir = File.join(dir, "#{app_id}.itmsp") UI.message("Going to upload updated app to App Store Connect") UI.success("This might take a few minutes. Please don't interrupt the script.") command = @transporter_executor.build_upload_command(@user, @password, actual_dir, @provider_short_name) UI.verbose(@transporter_executor.build_upload_command(@user, 'YourPassword', actual_dir, @provider_short_name)) begin result = @transporter_executor.execute(command, ItunesTransporter.hide_transporter_output?) rescue TransporterRequiresApplicationSpecificPasswordError => ex handle_two_step_failure(ex) return upload(app_id, dir) end if result UI.header("Successfully uploaded package to App Store Connect. It might take a few minutes until it's visible online.") FileUtils.rm_rf(actual_dir) unless Helper.test? # we don't need the package any more, since the upload was successful else handle_error(@password) end result end
[ "def", "upload", "(", "app_id", ",", "dir", ")", "actual_dir", "=", "File", ".", "join", "(", "dir", ",", "\"#{app_id}.itmsp\"", ")", "UI", ".", "message", "(", "\"Going to upload updated app to App Store Connect\"", ")", "UI", ".", "success", "(", "\"This might take a few minutes. Please don't interrupt the script.\"", ")", "command", "=", "@transporter_executor", ".", "build_upload_command", "(", "@user", ",", "@password", ",", "actual_dir", ",", "@provider_short_name", ")", "UI", ".", "verbose", "(", "@transporter_executor", ".", "build_upload_command", "(", "@user", ",", "'YourPassword'", ",", "actual_dir", ",", "@provider_short_name", ")", ")", "begin", "result", "=", "@transporter_executor", ".", "execute", "(", "command", ",", "ItunesTransporter", ".", "hide_transporter_output?", ")", "rescue", "TransporterRequiresApplicationSpecificPasswordError", "=>", "ex", "handle_two_step_failure", "(", "ex", ")", "return", "upload", "(", "app_id", ",", "dir", ")", "end", "if", "result", "UI", ".", "header", "(", "\"Successfully uploaded package to App Store Connect. It might take a few minutes until it's visible online.\"", ")", "FileUtils", ".", "rm_rf", "(", "actual_dir", ")", "unless", "Helper", ".", "test?", "# we don't need the package any more, since the upload was successful", "else", "handle_error", "(", "@password", ")", "end", "result", "end" ]
Uploads the modified package back to App Store Connect @param app_id [Integer] The unique App ID @param dir [String] the path in which the package file is located @return (Bool) True if everything worked fine @raise [Deliver::TransporterTransferError] when something went wrong when transferring
[ "Uploads", "the", "modified", "package", "back", "to", "App", "Store", "Connect" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/itunes_transporter.rb#L410-L435
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/itunes_transporter.rb
FastlaneCore.ItunesTransporter.load_password_for_transporter
def load_password_for_transporter # 3 different sources for the password # 1) ENV variable for application specific password if ENV[TWO_FACTOR_ENV_VARIABLE].to_s.length > 0 UI.message("Fetching password for transporter from environment variable named `#{TWO_FACTOR_ENV_VARIABLE}`") return ENV[TWO_FACTOR_ENV_VARIABLE] end # 2) TWO_STEP_HOST_PREFIX from keychain account_manager = CredentialsManager::AccountManager.new(user: @user, prefix: TWO_STEP_HOST_PREFIX, note: "application-specific") password = account_manager.password(ask_if_missing: false) return password if password.to_s.length > 0 # 3) standard iTC password account_manager = CredentialsManager::AccountManager.new(user: @user) return account_manager.password(ask_if_missing: true) end
ruby
def load_password_for_transporter # 3 different sources for the password # 1) ENV variable for application specific password if ENV[TWO_FACTOR_ENV_VARIABLE].to_s.length > 0 UI.message("Fetching password for transporter from environment variable named `#{TWO_FACTOR_ENV_VARIABLE}`") return ENV[TWO_FACTOR_ENV_VARIABLE] end # 2) TWO_STEP_HOST_PREFIX from keychain account_manager = CredentialsManager::AccountManager.new(user: @user, prefix: TWO_STEP_HOST_PREFIX, note: "application-specific") password = account_manager.password(ask_if_missing: false) return password if password.to_s.length > 0 # 3) standard iTC password account_manager = CredentialsManager::AccountManager.new(user: @user) return account_manager.password(ask_if_missing: true) end
[ "def", "load_password_for_transporter", "# 3 different sources for the password", "# 1) ENV variable for application specific password", "if", "ENV", "[", "TWO_FACTOR_ENV_VARIABLE", "]", ".", "to_s", ".", "length", ">", "0", "UI", ".", "message", "(", "\"Fetching password for transporter from environment variable named `#{TWO_FACTOR_ENV_VARIABLE}`\"", ")", "return", "ENV", "[", "TWO_FACTOR_ENV_VARIABLE", "]", "end", "# 2) TWO_STEP_HOST_PREFIX from keychain", "account_manager", "=", "CredentialsManager", "::", "AccountManager", ".", "new", "(", "user", ":", "@user", ",", "prefix", ":", "TWO_STEP_HOST_PREFIX", ",", "note", ":", "\"application-specific\"", ")", "password", "=", "account_manager", ".", "password", "(", "ask_if_missing", ":", "false", ")", "return", "password", "if", "password", ".", "to_s", ".", "length", ">", "0", "# 3) standard iTC password", "account_manager", "=", "CredentialsManager", "::", "AccountManager", ".", "new", "(", "user", ":", "@user", ")", "return", "account_manager", ".", "password", "(", "ask_if_missing", ":", "true", ")", "end" ]
Returns the password to be used with the transporter
[ "Returns", "the", "password", "to", "be", "used", "with", "the", "transporter" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/itunes_transporter.rb#L457-L473
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/itunes_transporter.rb
FastlaneCore.ItunesTransporter.handle_two_step_failure
def handle_two_step_failure(ex) if ENV[TWO_FACTOR_ENV_VARIABLE].to_s.length > 0 # Password provided, however we already used it UI.error("") UI.error("Application specific password you provided using") UI.error("environment variable #{TWO_FACTOR_ENV_VARIABLE}") UI.error("is invalid, please make sure it's correct") UI.error("") UI.user_error!("Invalid application specific password provided") end a = CredentialsManager::AccountManager.new(user: @user, prefix: TWO_STEP_HOST_PREFIX, note: "application-specific") if a.password(ask_if_missing: false).to_s.length > 0 # user already entered one.. delete the old one UI.error("Application specific password seems wrong") UI.error("Please make sure to follow the instructions") a.remove_from_keychain end UI.error("") UI.error("Your account has 2 step verification enabled") UI.error("Please go to https://appleid.apple.com/account/manage") UI.error("and generate an application specific password for") UI.error("the iTunes Transporter, which is used to upload builds") UI.error("") UI.error("To set the application specific password on a CI machine using") UI.error("an environment variable, you can set the") UI.error("#{TWO_FACTOR_ENV_VARIABLE} variable") @password = a.password(ask_if_missing: true) # to ask the user for the missing value return true end
ruby
def handle_two_step_failure(ex) if ENV[TWO_FACTOR_ENV_VARIABLE].to_s.length > 0 # Password provided, however we already used it UI.error("") UI.error("Application specific password you provided using") UI.error("environment variable #{TWO_FACTOR_ENV_VARIABLE}") UI.error("is invalid, please make sure it's correct") UI.error("") UI.user_error!("Invalid application specific password provided") end a = CredentialsManager::AccountManager.new(user: @user, prefix: TWO_STEP_HOST_PREFIX, note: "application-specific") if a.password(ask_if_missing: false).to_s.length > 0 # user already entered one.. delete the old one UI.error("Application specific password seems wrong") UI.error("Please make sure to follow the instructions") a.remove_from_keychain end UI.error("") UI.error("Your account has 2 step verification enabled") UI.error("Please go to https://appleid.apple.com/account/manage") UI.error("and generate an application specific password for") UI.error("the iTunes Transporter, which is used to upload builds") UI.error("") UI.error("To set the application specific password on a CI machine using") UI.error("an environment variable, you can set the") UI.error("#{TWO_FACTOR_ENV_VARIABLE} variable") @password = a.password(ask_if_missing: true) # to ask the user for the missing value return true end
[ "def", "handle_two_step_failure", "(", "ex", ")", "if", "ENV", "[", "TWO_FACTOR_ENV_VARIABLE", "]", ".", "to_s", ".", "length", ">", "0", "# Password provided, however we already used it", "UI", ".", "error", "(", "\"\"", ")", "UI", ".", "error", "(", "\"Application specific password you provided using\"", ")", "UI", ".", "error", "(", "\"environment variable #{TWO_FACTOR_ENV_VARIABLE}\"", ")", "UI", ".", "error", "(", "\"is invalid, please make sure it's correct\"", ")", "UI", ".", "error", "(", "\"\"", ")", "UI", ".", "user_error!", "(", "\"Invalid application specific password provided\"", ")", "end", "a", "=", "CredentialsManager", "::", "AccountManager", ".", "new", "(", "user", ":", "@user", ",", "prefix", ":", "TWO_STEP_HOST_PREFIX", ",", "note", ":", "\"application-specific\"", ")", "if", "a", ".", "password", "(", "ask_if_missing", ":", "false", ")", ".", "to_s", ".", "length", ">", "0", "# user already entered one.. delete the old one", "UI", ".", "error", "(", "\"Application specific password seems wrong\"", ")", "UI", ".", "error", "(", "\"Please make sure to follow the instructions\"", ")", "a", ".", "remove_from_keychain", "end", "UI", ".", "error", "(", "\"\"", ")", "UI", ".", "error", "(", "\"Your account has 2 step verification enabled\"", ")", "UI", ".", "error", "(", "\"Please go to https://appleid.apple.com/account/manage\"", ")", "UI", ".", "error", "(", "\"and generate an application specific password for\"", ")", "UI", ".", "error", "(", "\"the iTunes Transporter, which is used to upload builds\"", ")", "UI", ".", "error", "(", "\"\"", ")", "UI", ".", "error", "(", "\"To set the application specific password on a CI machine using\"", ")", "UI", ".", "error", "(", "\"an environment variable, you can set the\"", ")", "UI", ".", "error", "(", "\"#{TWO_FACTOR_ENV_VARIABLE} variable\"", ")", "@password", "=", "a", ".", "password", "(", "ask_if_missing", ":", "true", ")", "# to ask the user for the missing value", "return", "true", "end" ]
Tells the user how to get an application specific password
[ "Tells", "the", "user", "how", "to", "get", "an", "application", "specific", "password" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/itunes_transporter.rb#L476-L508
train
fastlane/fastlane
match/lib/match/runner.rb
Match.Runner.prefixed_working_directory
def prefixed_working_directory(working_directory) if self.storage_mode == "git" return working_directory elsif self.storage_mode == "google_cloud" # We fall back to "*", which means certificates and profiles # from all teams that use this bucket would be installed. This is not ideal, but # unless the user provides a `team_id`, we can't know which one to use # This only happens if `readonly` is activated, and no `team_id` was provided @_folder_prefix ||= self.currently_used_team_id if @_folder_prefix.nil? # We use a `@_folder_prefix` variable, to keep state between multiple calls of this # method, as the value won't change. This way the warning is only printed once UI.important("Looks like you run `match` in `readonly` mode, and didn't provide a `team_id`. This will still work, however it is recommended to provide a `team_id` in your Appfile or Matchfile") @_folder_prefix = "*" end return File.join(working_directory, @_folder_prefix) else UI.crash!("No implementation for `prefixed_working_directory`") end end
ruby
def prefixed_working_directory(working_directory) if self.storage_mode == "git" return working_directory elsif self.storage_mode == "google_cloud" # We fall back to "*", which means certificates and profiles # from all teams that use this bucket would be installed. This is not ideal, but # unless the user provides a `team_id`, we can't know which one to use # This only happens if `readonly` is activated, and no `team_id` was provided @_folder_prefix ||= self.currently_used_team_id if @_folder_prefix.nil? # We use a `@_folder_prefix` variable, to keep state between multiple calls of this # method, as the value won't change. This way the warning is only printed once UI.important("Looks like you run `match` in `readonly` mode, and didn't provide a `team_id`. This will still work, however it is recommended to provide a `team_id` in your Appfile or Matchfile") @_folder_prefix = "*" end return File.join(working_directory, @_folder_prefix) else UI.crash!("No implementation for `prefixed_working_directory`") end end
[ "def", "prefixed_working_directory", "(", "working_directory", ")", "if", "self", ".", "storage_mode", "==", "\"git\"", "return", "working_directory", "elsif", "self", ".", "storage_mode", "==", "\"google_cloud\"", "# We fall back to \"*\", which means certificates and profiles", "# from all teams that use this bucket would be installed. This is not ideal, but", "# unless the user provides a `team_id`, we can't know which one to use", "# This only happens if `readonly` is activated, and no `team_id` was provided", "@_folder_prefix", "||=", "self", ".", "currently_used_team_id", "if", "@_folder_prefix", ".", "nil?", "# We use a `@_folder_prefix` variable, to keep state between multiple calls of this", "# method, as the value won't change. This way the warning is only printed once", "UI", ".", "important", "(", "\"Looks like you run `match` in `readonly` mode, and didn't provide a `team_id`. This will still work, however it is recommended to provide a `team_id` in your Appfile or Matchfile\"", ")", "@_folder_prefix", "=", "\"*\"", "end", "return", "File", ".", "join", "(", "working_directory", ",", "@_folder_prefix", ")", "else", "UI", ".", "crash!", "(", "\"No implementation for `prefixed_working_directory`\"", ")", "end", "end" ]
Used when creating a new certificate or profile
[ "Used", "when", "creating", "a", "new", "certificate", "or", "profile" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/match/lib/match/runner.rb#L127-L146
train
fastlane/fastlane
fastlane/lib/fastlane/setup/setup_ios.rb
Fastlane.SetupIos.find_and_setup_xcode_project
def find_and_setup_xcode_project(ask_for_scheme: true) UI.message("Parsing your local Xcode project to find the available schemes and the app identifier") config = {} # this is needed as the first method call will store information in there if self.project_path.end_with?("xcworkspace") config[:workspace] = self.project_path else config[:project] = self.project_path end FastlaneCore::Project.detect_projects(config) self.project = FastlaneCore::Project.new(config) if ask_for_scheme self.scheme = self.project.select_scheme(preferred_to_include: self.project.project_name) end self.app_identifier = self.project.default_app_identifier # These two vars need to be accessed in order to be set if self.app_identifier.to_s.length == 0 ask_for_bundle_identifier end end
ruby
def find_and_setup_xcode_project(ask_for_scheme: true) UI.message("Parsing your local Xcode project to find the available schemes and the app identifier") config = {} # this is needed as the first method call will store information in there if self.project_path.end_with?("xcworkspace") config[:workspace] = self.project_path else config[:project] = self.project_path end FastlaneCore::Project.detect_projects(config) self.project = FastlaneCore::Project.new(config) if ask_for_scheme self.scheme = self.project.select_scheme(preferred_to_include: self.project.project_name) end self.app_identifier = self.project.default_app_identifier # These two vars need to be accessed in order to be set if self.app_identifier.to_s.length == 0 ask_for_bundle_identifier end end
[ "def", "find_and_setup_xcode_project", "(", "ask_for_scheme", ":", "true", ")", "UI", ".", "message", "(", "\"Parsing your local Xcode project to find the available schemes and the app identifier\"", ")", "config", "=", "{", "}", "# this is needed as the first method call will store information in there", "if", "self", ".", "project_path", ".", "end_with?", "(", "\"xcworkspace\"", ")", "config", "[", ":workspace", "]", "=", "self", ".", "project_path", "else", "config", "[", ":project", "]", "=", "self", ".", "project_path", "end", "FastlaneCore", "::", "Project", ".", "detect_projects", "(", "config", ")", "self", ".", "project", "=", "FastlaneCore", "::", "Project", ".", "new", "(", "config", ")", "if", "ask_for_scheme", "self", ".", "scheme", "=", "self", ".", "project", ".", "select_scheme", "(", "preferred_to_include", ":", "self", ".", "project", ".", "project_name", ")", "end", "self", ".", "app_identifier", "=", "self", ".", "project", ".", "default_app_identifier", "# These two vars need to be accessed in order to be set", "if", "self", ".", "app_identifier", ".", "to_s", ".", "length", "==", "0", "ask_for_bundle_identifier", "end", "end" ]
Helpers Every installation setup that needs an Xcode project should call this method
[ "Helpers", "Every", "installation", "setup", "that", "needs", "an", "Xcode", "project", "should", "call", "this", "method" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/setup/setup_ios.rb#L265-L285
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.team_id=
def team_id=(team_id) # First, we verify the team actually exists, because otherwise iTC would return the # following confusing error message # # invalid content provider id # available_teams = teams.collect do |team| { team_id: (team["contentProvider"] || {})["contentProviderId"], team_name: (team["contentProvider"] || {})["name"] } end result = available_teams.find do |available_team| team_id.to_s == available_team[:team_id].to_s end unless result error_string = "Could not set team ID to '#{team_id}', only found the following available teams:\n\n#{available_teams.map { |team| "- #{team[:team_id]} (#{team[:team_name]})" }.join("\n")}\n" raise Tunes::Error.new, error_string end response = request(:post) do |req| req.url("ra/v1/session/webSession") req.body = { contentProviderId: team_id, dsId: user_detail_data.ds_id # https://github.com/fastlane/fastlane/issues/6711 }.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(response.body) @current_team_id = team_id end
ruby
def team_id=(team_id) # First, we verify the team actually exists, because otherwise iTC would return the # following confusing error message # # invalid content provider id # available_teams = teams.collect do |team| { team_id: (team["contentProvider"] || {})["contentProviderId"], team_name: (team["contentProvider"] || {})["name"] } end result = available_teams.find do |available_team| team_id.to_s == available_team[:team_id].to_s end unless result error_string = "Could not set team ID to '#{team_id}', only found the following available teams:\n\n#{available_teams.map { |team| "- #{team[:team_id]} (#{team[:team_name]})" }.join("\n")}\n" raise Tunes::Error.new, error_string end response = request(:post) do |req| req.url("ra/v1/session/webSession") req.body = { contentProviderId: team_id, dsId: user_detail_data.ds_id # https://github.com/fastlane/fastlane/issues/6711 }.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(response.body) @current_team_id = team_id end
[ "def", "team_id", "=", "(", "team_id", ")", "# First, we verify the team actually exists, because otherwise iTC would return the", "# following confusing error message", "#", "# invalid content provider id", "#", "available_teams", "=", "teams", ".", "collect", "do", "|", "team", "|", "{", "team_id", ":", "(", "team", "[", "\"contentProvider\"", "]", "||", "{", "}", ")", "[", "\"contentProviderId\"", "]", ",", "team_name", ":", "(", "team", "[", "\"contentProvider\"", "]", "||", "{", "}", ")", "[", "\"name\"", "]", "}", "end", "result", "=", "available_teams", ".", "find", "do", "|", "available_team", "|", "team_id", ".", "to_s", "==", "available_team", "[", ":team_id", "]", ".", "to_s", "end", "unless", "result", "error_string", "=", "\"Could not set team ID to '#{team_id}', only found the following available teams:\\n\\n#{available_teams.map { |team| \"- #{team[:team_id]} (#{team[:team_name]})\" }.join(\"\\n\")}\\n\"", "raise", "Tunes", "::", "Error", ".", "new", ",", "error_string", "end", "response", "=", "request", "(", ":post", ")", "do", "|", "req", "|", "req", ".", "url", "(", "\"ra/v1/session/webSession\"", ")", "req", ".", "body", "=", "{", "contentProviderId", ":", "team_id", ",", "dsId", ":", "user_detail_data", ".", "ds_id", "# https://github.com/fastlane/fastlane/issues/6711", "}", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "end", "handle_itc_response", "(", "response", ".", "body", ")", "@current_team_id", "=", "team_id", "end" ]
Set a new team ID which will be used from now on
[ "Set", "a", "new", "team", "ID", "which", "will", "be", "used", "from", "now", "on" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L137-L171
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.persistent_cookie_path
def persistent_cookie_path if ENV["SPACESHIP_COOKIE_PATH"] path = File.expand_path(File.join(ENV["SPACESHIP_COOKIE_PATH"], "spaceship", self.user, "cookie")) else [File.join(self.fastlane_user_dir, "spaceship"), "~/.spaceship", "/var/tmp/spaceship", "#{Dir.tmpdir}/spaceship"].each do |dir| dir_parts = File.split(dir) if directory_accessible?(File.expand_path(dir_parts.first)) path = File.expand_path(File.join(dir, self.user, "cookie")) break end end end return path end
ruby
def persistent_cookie_path if ENV["SPACESHIP_COOKIE_PATH"] path = File.expand_path(File.join(ENV["SPACESHIP_COOKIE_PATH"], "spaceship", self.user, "cookie")) else [File.join(self.fastlane_user_dir, "spaceship"), "~/.spaceship", "/var/tmp/spaceship", "#{Dir.tmpdir}/spaceship"].each do |dir| dir_parts = File.split(dir) if directory_accessible?(File.expand_path(dir_parts.first)) path = File.expand_path(File.join(dir, self.user, "cookie")) break end end end return path end
[ "def", "persistent_cookie_path", "if", "ENV", "[", "\"SPACESHIP_COOKIE_PATH\"", "]", "path", "=", "File", ".", "expand_path", "(", "File", ".", "join", "(", "ENV", "[", "\"SPACESHIP_COOKIE_PATH\"", "]", ",", "\"spaceship\"", ",", "self", ".", "user", ",", "\"cookie\"", ")", ")", "else", "[", "File", ".", "join", "(", "self", ".", "fastlane_user_dir", ",", "\"spaceship\"", ")", ",", "\"~/.spaceship\"", ",", "\"/var/tmp/spaceship\"", ",", "\"#{Dir.tmpdir}/spaceship\"", "]", ".", "each", "do", "|", "dir", "|", "dir_parts", "=", "File", ".", "split", "(", "dir", ")", "if", "directory_accessible?", "(", "File", ".", "expand_path", "(", "dir_parts", ".", "first", ")", ")", "path", "=", "File", ".", "expand_path", "(", "File", ".", "join", "(", "dir", ",", "self", ".", "user", ",", "\"cookie\"", ")", ")", "break", "end", "end", "end", "return", "path", "end" ]
Returns preferred path for storing cookie for two step verification.
[ "Returns", "preferred", "path", "for", "storing", "cookie", "for", "two", "step", "verification", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L285-L299
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.paging
def paging page = 0 results = [] loop do page += 1 current = yield(page) results += current break if (current || []).count < page_size # no more results end return results end
ruby
def paging page = 0 results = [] loop do page += 1 current = yield(page) results += current break if (current || []).count < page_size # no more results end return results end
[ "def", "paging", "page", "=", "0", "results", "=", "[", "]", "loop", "do", "page", "+=", "1", "current", "=", "yield", "(", "page", ")", "results", "+=", "current", "break", "if", "(", "current", "||", "[", "]", ")", ".", "count", "<", "page_size", "# no more results", "end", "return", "results", "end" ]
Handles the paging for you... for free Just pass a block and use the parameter as page number
[ "Handles", "the", "paging", "for", "you", "...", "for", "free", "Just", "pass", "a", "block", "and", "use", "the", "parameter", "as", "page", "number" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L312-L325
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.login
def login(user = nil, password = nil) if user.to_s.empty? || password.to_s.empty? require 'credentials_manager/account_manager' puts("Reading keychain entry, because either user or password were empty") if Spaceship::Globals.verbose? keychain_entry = CredentialsManager::AccountManager.new(user: user, password: password) user ||= keychain_entry.user password = keychain_entry.password end if user.to_s.strip.empty? || password.to_s.strip.empty? raise NoUserCredentialsError.new, "No login data provided" end self.user = user @password = password begin do_login(user, password) # calls `send_login_request` in sub class (which then will redirect back here to `send_shared_login_request`, below) rescue InvalidUserCredentialsError => ex raise ex unless keychain_entry if keychain_entry.invalid_credentials login(user) else raise ex end end end
ruby
def login(user = nil, password = nil) if user.to_s.empty? || password.to_s.empty? require 'credentials_manager/account_manager' puts("Reading keychain entry, because either user or password were empty") if Spaceship::Globals.verbose? keychain_entry = CredentialsManager::AccountManager.new(user: user, password: password) user ||= keychain_entry.user password = keychain_entry.password end if user.to_s.strip.empty? || password.to_s.strip.empty? raise NoUserCredentialsError.new, "No login data provided" end self.user = user @password = password begin do_login(user, password) # calls `send_login_request` in sub class (which then will redirect back here to `send_shared_login_request`, below) rescue InvalidUserCredentialsError => ex raise ex unless keychain_entry if keychain_entry.invalid_credentials login(user) else raise ex end end end
[ "def", "login", "(", "user", "=", "nil", ",", "password", "=", "nil", ")", "if", "user", ".", "to_s", ".", "empty?", "||", "password", ".", "to_s", ".", "empty?", "require", "'credentials_manager/account_manager'", "puts", "(", "\"Reading keychain entry, because either user or password were empty\"", ")", "if", "Spaceship", "::", "Globals", ".", "verbose?", "keychain_entry", "=", "CredentialsManager", "::", "AccountManager", ".", "new", "(", "user", ":", "user", ",", "password", ":", "password", ")", "user", "||=", "keychain_entry", ".", "user", "password", "=", "keychain_entry", ".", "password", "end", "if", "user", ".", "to_s", ".", "strip", ".", "empty?", "||", "password", ".", "to_s", ".", "strip", ".", "empty?", "raise", "NoUserCredentialsError", ".", "new", ",", "\"No login data provided\"", "end", "self", ".", "user", "=", "user", "@password", "=", "password", "begin", "do_login", "(", "user", ",", "password", ")", "# calls `send_login_request` in sub class (which then will redirect back here to `send_shared_login_request`, below)", "rescue", "InvalidUserCredentialsError", "=>", "ex", "raise", "ex", "unless", "keychain_entry", "if", "keychain_entry", ".", "invalid_credentials", "login", "(", "user", ")", "else", "raise", "ex", "end", "end", "end" ]
Authenticates with Apple's web services. This method has to be called once to generate a valid session. The session will automatically be used from then on. This method will automatically use the username from the Appfile (if available) and fetch the password from the Keychain (if available) @param user (String) (optional): The username (usually the email address) @param password (String) (optional): The password @raise InvalidUserCredentialsError: raised if authentication failed @return (Spaceship::Client) The client the login method was called for
[ "Authenticates", "with", "Apple", "s", "web", "services", ".", "This", "method", "has", "to", "be", "called", "once", "to", "generate", "a", "valid", "session", ".", "The", "session", "will", "automatically", "be", "used", "from", "then", "on", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L366-L394
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.send_shared_login_request
def send_shared_login_request(user, password) # Check if we have a cached/valid session # # Background: # December 4th 2017 Apple introduced a rate limit - which is of course fine by itself - # but unfortunately also rate limits successful logins. If you call multiple tools in a # lane (e.g. call match 5 times), this would lock you out of the account for a while. # By loading existing sessions and checking if they're valid, we're sending less login requests. # More context on why this change was necessary https://github.com/fastlane/fastlane/pull/11108 # # If there was a successful manual login before, we have a session on disk if load_session_from_file # Check if the session is still valid here begin # We use the olympus session to determine if the old session is still valid # As this will raise an exception if the old session has expired # If the old session is still valid, we don't have to do anything else in this method # that's why we return true return true if fetch_olympus_session rescue # If the `fetch_olympus_session` method raises an exception # we'll land here, and therefore continue doing a full login process # This happens if the session we loaded from the cache isn't valid any more # which is common, as the session automatically invalidates after x hours (we don't know x) # In this case we don't actually care about the exact exception, and why it was failing # because either way, we'll have to do a fresh login, where we do the actual error handling puts("Available session is not valid any more. Continuing with normal login.") end end # # The user can pass the session via environment variable (Mainly used in CI environments) if load_session_from_env # see above begin # see above return true if fetch_olympus_session rescue puts("Session loaded from environment variable is not valid. Continuing with normal login.") # see above end end # # After this point, we sure have no valid session any more and have to create a new one # data = { accountName: user, password: password, rememberMe: true } begin # The below workaround is only needed for 2 step verified machines # Due to escaping of cookie values we have a little workaround here # By default the cookie jar would generate the following header # DES5c148...=HSARM.......xaA/O69Ws/CHfQ==SRVT # However we need the following # DES5c148...="HSARM.......xaA/O69Ws/CHfQ==SRVT" # There is no way to get the cookie jar value with " around the value # so we manually modify the cookie (only this one) to be properly escaped # Afterwards we pass this value manually as a header # It's not enough to just modify @cookie, it needs to be done after self.cookie # as a string operation important_cookie = @cookie.store.entries.find { |a| a.name.include?("DES") } if important_cookie modified_cookie = self.cookie # returns a string of all cookies unescaped_important_cookie = "#{important_cookie.name}=#{important_cookie.value}" escaped_important_cookie = "#{important_cookie.name}=\"#{important_cookie.value}\"" modified_cookie.gsub!(unescaped_important_cookie, escaped_important_cookie) end response = request(:post) do |req| req.url("https://idmsa.apple.com/appleauth/auth/signin") req.body = data.to_json req.headers['Content-Type'] = 'application/json' req.headers['X-Requested-With'] = 'XMLHttpRequest' req.headers['X-Apple-Widget-Key'] = self.itc_service_key req.headers['Accept'] = 'application/json, text/javascript' req.headers["Cookie"] = modified_cookie if modified_cookie end rescue UnauthorizedAccessError raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." end # Now we know if the login is successful or if we need to do 2 factor case response.status when 403 raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." when 200 fetch_olympus_session return response when 409 # 2 step/factor is enabled for this account, first handle that handle_two_step_or_factor(response) # and then get the olympus session fetch_olympus_session return true else if (response.body || "").include?('invalid="true"') # User Credentials are wrong raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." elsif response.status == 412 && AUTH_TYPES.include?(response.body["authType"]) # Need to acknowledge Apple ID and Privacy statement - https://github.com/fastlane/fastlane/issues/12577 # Looking for status of 412 might be enough but might be safer to keep looking only at what is being reported raise AppleIDAndPrivacyAcknowledgementNeeded.new, "Need to acknowledge to Apple's Apple ID and Privacy statement. Please manually log into https://appleid.apple.com (or https://appstoreconnect.apple.com) to acknowledge the statement." elsif (response['Set-Cookie'] || "").include?("itctx") raise "Looks like your Apple ID is not enabled for App Store Connect, make sure to be able to login online" else info = [response.body, response['Set-Cookie']] raise Tunes::Error.new, info.join("\n") end end end
ruby
def send_shared_login_request(user, password) # Check if we have a cached/valid session # # Background: # December 4th 2017 Apple introduced a rate limit - which is of course fine by itself - # but unfortunately also rate limits successful logins. If you call multiple tools in a # lane (e.g. call match 5 times), this would lock you out of the account for a while. # By loading existing sessions and checking if they're valid, we're sending less login requests. # More context on why this change was necessary https://github.com/fastlane/fastlane/pull/11108 # # If there was a successful manual login before, we have a session on disk if load_session_from_file # Check if the session is still valid here begin # We use the olympus session to determine if the old session is still valid # As this will raise an exception if the old session has expired # If the old session is still valid, we don't have to do anything else in this method # that's why we return true return true if fetch_olympus_session rescue # If the `fetch_olympus_session` method raises an exception # we'll land here, and therefore continue doing a full login process # This happens if the session we loaded from the cache isn't valid any more # which is common, as the session automatically invalidates after x hours (we don't know x) # In this case we don't actually care about the exact exception, and why it was failing # because either way, we'll have to do a fresh login, where we do the actual error handling puts("Available session is not valid any more. Continuing with normal login.") end end # # The user can pass the session via environment variable (Mainly used in CI environments) if load_session_from_env # see above begin # see above return true if fetch_olympus_session rescue puts("Session loaded from environment variable is not valid. Continuing with normal login.") # see above end end # # After this point, we sure have no valid session any more and have to create a new one # data = { accountName: user, password: password, rememberMe: true } begin # The below workaround is only needed for 2 step verified machines # Due to escaping of cookie values we have a little workaround here # By default the cookie jar would generate the following header # DES5c148...=HSARM.......xaA/O69Ws/CHfQ==SRVT # However we need the following # DES5c148...="HSARM.......xaA/O69Ws/CHfQ==SRVT" # There is no way to get the cookie jar value with " around the value # so we manually modify the cookie (only this one) to be properly escaped # Afterwards we pass this value manually as a header # It's not enough to just modify @cookie, it needs to be done after self.cookie # as a string operation important_cookie = @cookie.store.entries.find { |a| a.name.include?("DES") } if important_cookie modified_cookie = self.cookie # returns a string of all cookies unescaped_important_cookie = "#{important_cookie.name}=#{important_cookie.value}" escaped_important_cookie = "#{important_cookie.name}=\"#{important_cookie.value}\"" modified_cookie.gsub!(unescaped_important_cookie, escaped_important_cookie) end response = request(:post) do |req| req.url("https://idmsa.apple.com/appleauth/auth/signin") req.body = data.to_json req.headers['Content-Type'] = 'application/json' req.headers['X-Requested-With'] = 'XMLHttpRequest' req.headers['X-Apple-Widget-Key'] = self.itc_service_key req.headers['Accept'] = 'application/json, text/javascript' req.headers["Cookie"] = modified_cookie if modified_cookie end rescue UnauthorizedAccessError raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." end # Now we know if the login is successful or if we need to do 2 factor case response.status when 403 raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." when 200 fetch_olympus_session return response when 409 # 2 step/factor is enabled for this account, first handle that handle_two_step_or_factor(response) # and then get the olympus session fetch_olympus_session return true else if (response.body || "").include?('invalid="true"') # User Credentials are wrong raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username." elsif response.status == 412 && AUTH_TYPES.include?(response.body["authType"]) # Need to acknowledge Apple ID and Privacy statement - https://github.com/fastlane/fastlane/issues/12577 # Looking for status of 412 might be enough but might be safer to keep looking only at what is being reported raise AppleIDAndPrivacyAcknowledgementNeeded.new, "Need to acknowledge to Apple's Apple ID and Privacy statement. Please manually log into https://appleid.apple.com (or https://appstoreconnect.apple.com) to acknowledge the statement." elsif (response['Set-Cookie'] || "").include?("itctx") raise "Looks like your Apple ID is not enabled for App Store Connect, make sure to be able to login online" else info = [response.body, response['Set-Cookie']] raise Tunes::Error.new, info.join("\n") end end end
[ "def", "send_shared_login_request", "(", "user", ",", "password", ")", "# Check if we have a cached/valid session", "#", "# Background:", "# December 4th 2017 Apple introduced a rate limit - which is of course fine by itself -", "# but unfortunately also rate limits successful logins. If you call multiple tools in a", "# lane (e.g. call match 5 times), this would lock you out of the account for a while.", "# By loading existing sessions and checking if they're valid, we're sending less login requests.", "# More context on why this change was necessary https://github.com/fastlane/fastlane/pull/11108", "#", "# If there was a successful manual login before, we have a session on disk", "if", "load_session_from_file", "# Check if the session is still valid here", "begin", "# We use the olympus session to determine if the old session is still valid", "# As this will raise an exception if the old session has expired", "# If the old session is still valid, we don't have to do anything else in this method", "# that's why we return true", "return", "true", "if", "fetch_olympus_session", "rescue", "# If the `fetch_olympus_session` method raises an exception", "# we'll land here, and therefore continue doing a full login process", "# This happens if the session we loaded from the cache isn't valid any more", "# which is common, as the session automatically invalidates after x hours (we don't know x)", "# In this case we don't actually care about the exact exception, and why it was failing", "# because either way, we'll have to do a fresh login, where we do the actual error handling", "puts", "(", "\"Available session is not valid any more. Continuing with normal login.\"", ")", "end", "end", "#", "# The user can pass the session via environment variable (Mainly used in CI environments)", "if", "load_session_from_env", "# see above", "begin", "# see above", "return", "true", "if", "fetch_olympus_session", "rescue", "puts", "(", "\"Session loaded from environment variable is not valid. Continuing with normal login.\"", ")", "# see above", "end", "end", "#", "# After this point, we sure have no valid session any more and have to create a new one", "#", "data", "=", "{", "accountName", ":", "user", ",", "password", ":", "password", ",", "rememberMe", ":", "true", "}", "begin", "# The below workaround is only needed for 2 step verified machines", "# Due to escaping of cookie values we have a little workaround here", "# By default the cookie jar would generate the following header", "# DES5c148...=HSARM.......xaA/O69Ws/CHfQ==SRVT", "# However we need the following", "# DES5c148...=\"HSARM.......xaA/O69Ws/CHfQ==SRVT\"", "# There is no way to get the cookie jar value with \" around the value", "# so we manually modify the cookie (only this one) to be properly escaped", "# Afterwards we pass this value manually as a header", "# It's not enough to just modify @cookie, it needs to be done after self.cookie", "# as a string operation", "important_cookie", "=", "@cookie", ".", "store", ".", "entries", ".", "find", "{", "|", "a", "|", "a", ".", "name", ".", "include?", "(", "\"DES\"", ")", "}", "if", "important_cookie", "modified_cookie", "=", "self", ".", "cookie", "# returns a string of all cookies", "unescaped_important_cookie", "=", "\"#{important_cookie.name}=#{important_cookie.value}\"", "escaped_important_cookie", "=", "\"#{important_cookie.name}=\\\"#{important_cookie.value}\\\"\"", "modified_cookie", ".", "gsub!", "(", "unescaped_important_cookie", ",", "escaped_important_cookie", ")", "end", "response", "=", "request", "(", ":post", ")", "do", "|", "req", "|", "req", ".", "url", "(", "\"https://idmsa.apple.com/appleauth/auth/signin\"", ")", "req", ".", "body", "=", "data", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "req", ".", "headers", "[", "'X-Requested-With'", "]", "=", "'XMLHttpRequest'", "req", ".", "headers", "[", "'X-Apple-Widget-Key'", "]", "=", "self", ".", "itc_service_key", "req", ".", "headers", "[", "'Accept'", "]", "=", "'application/json, text/javascript'", "req", ".", "headers", "[", "\"Cookie\"", "]", "=", "modified_cookie", "if", "modified_cookie", "end", "rescue", "UnauthorizedAccessError", "raise", "InvalidUserCredentialsError", ".", "new", ",", "\"Invalid username and password combination. Used '#{user}' as the username.\"", "end", "# Now we know if the login is successful or if we need to do 2 factor", "case", "response", ".", "status", "when", "403", "raise", "InvalidUserCredentialsError", ".", "new", ",", "\"Invalid username and password combination. Used '#{user}' as the username.\"", "when", "200", "fetch_olympus_session", "return", "response", "when", "409", "# 2 step/factor is enabled for this account, first handle that", "handle_two_step_or_factor", "(", "response", ")", "# and then get the olympus session", "fetch_olympus_session", "return", "true", "else", "if", "(", "response", ".", "body", "||", "\"\"", ")", ".", "include?", "(", "'invalid=\"true\"'", ")", "# User Credentials are wrong", "raise", "InvalidUserCredentialsError", ".", "new", ",", "\"Invalid username and password combination. Used '#{user}' as the username.\"", "elsif", "response", ".", "status", "==", "412", "&&", "AUTH_TYPES", ".", "include?", "(", "response", ".", "body", "[", "\"authType\"", "]", ")", "# Need to acknowledge Apple ID and Privacy statement - https://github.com/fastlane/fastlane/issues/12577", "# Looking for status of 412 might be enough but might be safer to keep looking only at what is being reported", "raise", "AppleIDAndPrivacyAcknowledgementNeeded", ".", "new", ",", "\"Need to acknowledge to Apple's Apple ID and Privacy statement. Please manually log into https://appleid.apple.com (or https://appstoreconnect.apple.com) to acknowledge the statement.\"", "elsif", "(", "response", "[", "'Set-Cookie'", "]", "||", "\"\"", ")", ".", "include?", "(", "\"itctx\"", ")", "raise", "\"Looks like your Apple ID is not enabled for App Store Connect, make sure to be able to login online\"", "else", "info", "=", "[", "response", ".", "body", ",", "response", "[", "'Set-Cookie'", "]", "]", "raise", "Tunes", "::", "Error", ".", "new", ",", "info", ".", "join", "(", "\"\\n\"", ")", "end", "end", "end" ]
This method is used for both the Apple Dev Portal and App Store Connect This will also handle 2 step verification and 2 factor authentication It is called in `send_login_request` of sub classes (which the method `login`, above, transferred over to via `do_login`)
[ "This", "method", "is", "used", "for", "both", "the", "Apple", "Dev", "Portal", "and", "App", "Store", "Connect", "This", "will", "also", "handle", "2", "step", "verification", "and", "2", "factor", "authentication" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L400-L513
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.fetch_program_license_agreement_messages
def fetch_program_license_agreement_messages all_messages = [] messages_request = request(:get, "https://appstoreconnect.apple.com/olympus/v1/contractMessages") body = messages_request.body if body body = JSON.parse(body) if body.kind_of?(String) body.map do |messages| all_messages.push(messages["message"]) end end return all_messages end
ruby
def fetch_program_license_agreement_messages all_messages = [] messages_request = request(:get, "https://appstoreconnect.apple.com/olympus/v1/contractMessages") body = messages_request.body if body body = JSON.parse(body) if body.kind_of?(String) body.map do |messages| all_messages.push(messages["message"]) end end return all_messages end
[ "def", "fetch_program_license_agreement_messages", "all_messages", "=", "[", "]", "messages_request", "=", "request", "(", ":get", ",", "\"https://appstoreconnect.apple.com/olympus/v1/contractMessages\"", ")", "body", "=", "messages_request", ".", "body", "if", "body", "body", "=", "JSON", ".", "parse", "(", "body", ")", "if", "body", ".", "kind_of?", "(", "String", ")", "body", ".", "map", "do", "|", "messages", "|", "all_messages", ".", "push", "(", "messages", "[", "\"message\"", "]", ")", "end", "end", "return", "all_messages", "end" ]
Get contract messages from App Store Connect's "olympus" endpoint
[ "Get", "contract", "messages", "from", "App", "Store", "Connect", "s", "olympus", "endpoint" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L600-L613
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.raise_insufficient_permission_error!
def raise_insufficient_permission_error!(additional_error_string: nil, caller_location: 2) # get the method name of the request that failed # `block in` is used very often for requests when surrounded for paging or retrying blocks # The ! is part of some methods when they modify or delete a resource, so we don't want to show it # Using `sub` instead of `delete` as we don't want to allow multiple matches calling_method_name = caller_locations(caller_location, 2).first.label.sub("block in", "").delete("!").strip # calling the computed property self.team_id can get us into an exception handling loop team_id = @current_team_id ? "(Team ID #{@current_team_id}) " : "" error_message = "User #{self.user} #{team_id}doesn't have enough permission for the following action: #{calling_method_name}" error_message += " (#{additional_error_string})" if additional_error_string.to_s.length > 0 raise InsufficientPermissions, error_message end
ruby
def raise_insufficient_permission_error!(additional_error_string: nil, caller_location: 2) # get the method name of the request that failed # `block in` is used very often for requests when surrounded for paging or retrying blocks # The ! is part of some methods when they modify or delete a resource, so we don't want to show it # Using `sub` instead of `delete` as we don't want to allow multiple matches calling_method_name = caller_locations(caller_location, 2).first.label.sub("block in", "").delete("!").strip # calling the computed property self.team_id can get us into an exception handling loop team_id = @current_team_id ? "(Team ID #{@current_team_id}) " : "" error_message = "User #{self.user} #{team_id}doesn't have enough permission for the following action: #{calling_method_name}" error_message += " (#{additional_error_string})" if additional_error_string.to_s.length > 0 raise InsufficientPermissions, error_message end
[ "def", "raise_insufficient_permission_error!", "(", "additional_error_string", ":", "nil", ",", "caller_location", ":", "2", ")", "# get the method name of the request that failed", "# `block in` is used very often for requests when surrounded for paging or retrying blocks", "# The ! is part of some methods when they modify or delete a resource, so we don't want to show it", "# Using `sub` instead of `delete` as we don't want to allow multiple matches", "calling_method_name", "=", "caller_locations", "(", "caller_location", ",", "2", ")", ".", "first", ".", "label", ".", "sub", "(", "\"block in\"", ",", "\"\"", ")", ".", "delete", "(", "\"!\"", ")", ".", "strip", "# calling the computed property self.team_id can get us into an exception handling loop", "team_id", "=", "@current_team_id", "?", "\"(Team ID #{@current_team_id}) \"", ":", "\"\"", "error_message", "=", "\"User #{self.user} #{team_id}doesn't have enough permission for the following action: #{calling_method_name}\"", "error_message", "+=", "\" (#{additional_error_string})\"", "if", "additional_error_string", ".", "to_s", ".", "length", ">", "0", "raise", "InsufficientPermissions", ",", "error_message", "end" ]
This also gets called from subclasses
[ "This", "also", "gets", "called", "from", "subclasses" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L747-L760
train
fastlane/fastlane
spaceship/lib/spaceship/client.rb
Spaceship.Client.send_request
def send_request(method, url_or_path, params, headers, &block) with_retry do response = @client.send(method, url_or_path, params, headers, &block) log_response(method, url_or_path, response, headers, &block) resp_hash = response.to_hash if resp_hash[:status] == 401 msg = "Auth lost" logger.warn(msg) raise UnauthorizedAccessError.new, "Unauthorized Access" end if response.body.to_s.include?("<title>302 Found</title>") raise AppleTimeoutError.new, "Apple 302 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime" end if response.body.to_s.include?("<h3>Bad Gateway</h3>") raise BadGatewayError.new, "Apple 502 detected - this might be temporary server error, try again later" end return response end end
ruby
def send_request(method, url_or_path, params, headers, &block) with_retry do response = @client.send(method, url_or_path, params, headers, &block) log_response(method, url_or_path, response, headers, &block) resp_hash = response.to_hash if resp_hash[:status] == 401 msg = "Auth lost" logger.warn(msg) raise UnauthorizedAccessError.new, "Unauthorized Access" end if response.body.to_s.include?("<title>302 Found</title>") raise AppleTimeoutError.new, "Apple 302 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime" end if response.body.to_s.include?("<h3>Bad Gateway</h3>") raise BadGatewayError.new, "Apple 502 detected - this might be temporary server error, try again later" end return response end end
[ "def", "send_request", "(", "method", ",", "url_or_path", ",", "params", ",", "headers", ",", "&", "block", ")", "with_retry", "do", "response", "=", "@client", ".", "send", "(", "method", ",", "url_or_path", ",", "params", ",", "headers", ",", "block", ")", "log_response", "(", "method", ",", "url_or_path", ",", "response", ",", "headers", ",", "block", ")", "resp_hash", "=", "response", ".", "to_hash", "if", "resp_hash", "[", ":status", "]", "==", "401", "msg", "=", "\"Auth lost\"", "logger", ".", "warn", "(", "msg", ")", "raise", "UnauthorizedAccessError", ".", "new", ",", "\"Unauthorized Access\"", "end", "if", "response", ".", "body", ".", "to_s", ".", "include?", "(", "\"<title>302 Found</title>\"", ")", "raise", "AppleTimeoutError", ".", "new", ",", "\"Apple 302 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime\"", "end", "if", "response", ".", "body", ".", "to_s", ".", "include?", "(", "\"<h3>Bad Gateway</h3>\"", ")", "raise", "BadGatewayError", ".", "new", ",", "\"Apple 502 detected - this might be temporary server error, try again later\"", "end", "return", "response", "end", "end" ]
Actually sends the request to the remote server Automatically retries the request up to 3 times if something goes wrong
[ "Actually", "sends", "the", "request", "to", "the", "remote", "server", "Automatically", "retries", "the", "request", "up", "to", "3", "times", "if", "something", "goes", "wrong" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/client.rb#L843-L865
train
fastlane/fastlane
deliver/lib/deliver/html_generator.rb
Deliver.HtmlGenerator.render_relative_path
def render_relative_path(export_path, path) export_path = Pathname.new(export_path) path = Pathname.new(path).relative_path_from(export_path) return path.to_path end
ruby
def render_relative_path(export_path, path) export_path = Pathname.new(export_path) path = Pathname.new(path).relative_path_from(export_path) return path.to_path end
[ "def", "render_relative_path", "(", "export_path", ",", "path", ")", "export_path", "=", "Pathname", ".", "new", "(", "export_path", ")", "path", "=", "Pathname", ".", "new", "(", "path", ")", ".", "relative_path_from", "(", "export_path", ")", "return", "path", ".", "to_path", "end" ]
Returns a path relative to FastlaneFolder.path This is needed as the Preview.html file is located inside FastlaneFolder.path
[ "Returns", "a", "path", "relative", "to", "FastlaneFolder", ".", "path", "This", "is", "needed", "as", "the", "Preview", ".", "html", "file", "is", "located", "inside", "FastlaneFolder", ".", "path" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/html_generator.rb#L37-L41
train
fastlane/fastlane
deliver/lib/deliver/html_generator.rb
Deliver.HtmlGenerator.render
def render(options, screenshots, export_path = nil) @screenshots = screenshots || [] @options = options @export_path = export_path @app_name = (options[:name]['en-US'] || options[:name].values.first) if options[:name] @app_name ||= options[:app].name @languages = options[:description].keys if options[:description] @languages ||= options[:app].latest_version.description.languages html_path = File.join(Deliver::ROOT, "lib/assets/summary.html.erb") html = ERB.new(File.read(html_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system export_path = File.join(export_path, "Preview.html") File.write(export_path, html) return export_path end
ruby
def render(options, screenshots, export_path = nil) @screenshots = screenshots || [] @options = options @export_path = export_path @app_name = (options[:name]['en-US'] || options[:name].values.first) if options[:name] @app_name ||= options[:app].name @languages = options[:description].keys if options[:description] @languages ||= options[:app].latest_version.description.languages html_path = File.join(Deliver::ROOT, "lib/assets/summary.html.erb") html = ERB.new(File.read(html_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system export_path = File.join(export_path, "Preview.html") File.write(export_path, html) return export_path end
[ "def", "render", "(", "options", ",", "screenshots", ",", "export_path", "=", "nil", ")", "@screenshots", "=", "screenshots", "||", "[", "]", "@options", "=", "options", "@export_path", "=", "export_path", "@app_name", "=", "(", "options", "[", ":name", "]", "[", "'en-US'", "]", "||", "options", "[", ":name", "]", ".", "values", ".", "first", ")", "if", "options", "[", ":name", "]", "@app_name", "||=", "options", "[", ":app", "]", ".", "name", "@languages", "=", "options", "[", ":description", "]", ".", "keys", "if", "options", "[", ":description", "]", "@languages", "||=", "options", "[", ":app", "]", ".", "latest_version", ".", "description", ".", "languages", "html_path", "=", "File", ".", "join", "(", "Deliver", "::", "ROOT", ",", "\"lib/assets/summary.html.erb\"", ")", "html", "=", "ERB", ".", "new", "(", "File", ".", "read", "(", "html_path", ")", ")", ".", "result", "(", "binding", ")", "# https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system", "export_path", "=", "File", ".", "join", "(", "export_path", ",", "\"Preview.html\"", ")", "File", ".", "write", "(", "export_path", ",", "html", ")", "return", "export_path", "end" ]
Renders all data available to quickly see if everything was correctly generated. @param export_path (String) The path to a folder where the resulting HTML file should be stored.
[ "Renders", "all", "data", "available", "to", "quickly", "see", "if", "everything", "was", "correctly", "generated", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/html_generator.rb#L45-L63
train
fastlane/fastlane
fastlane/lib/fastlane/fast_file.rb
Fastlane.FastFile.sh
def sh(*command, log: true, error_callback: nil, &b) FastFile.sh(*command, log: log, error_callback: error_callback, &b) end
ruby
def sh(*command, log: true, error_callback: nil, &b) FastFile.sh(*command, log: log, error_callback: error_callback, &b) end
[ "def", "sh", "(", "*", "command", ",", "log", ":", "true", ",", "error_callback", ":", "nil", ",", "&", "b", ")", "FastFile", ".", "sh", "(", "command", ",", "log", ":", "log", ",", "error_callback", ":", "error_callback", ",", "b", ")", "end" ]
Execute shell command
[ "Execute", "shell", "command" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/fast_file.rb#L185-L187
train
fastlane/fastlane
snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb
Snapshot.SimulatorLauncherBase.add_media
def add_media(device_types, media_type, paths) media_type = media_type.to_s device_types.each do |device_type| UI.verbose("Adding #{media_type}s to #{device_type}...") device_udid = TestCommandGenerator.device_udid(device_type) UI.message("Launch Simulator #{device_type}") Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null") paths.each do |path| UI.message("Adding '#{path}'") # Attempting addmedia since addphoto and addvideo are deprecated output = Helper.backticks("xcrun simctl addmedia #{device_udid} #{path.shellescape} &> /dev/null") # Run legacy addphoto and addvideo if addmedia isn't found # Output will be empty strin gif it was a success # Output will contain "usage: simctl" if command not found if output.include?('usage: simctl') Helper.backticks("xcrun simctl add#{media_type} #{device_udid} #{path.shellescape} &> /dev/null") end end end end
ruby
def add_media(device_types, media_type, paths) media_type = media_type.to_s device_types.each do |device_type| UI.verbose("Adding #{media_type}s to #{device_type}...") device_udid = TestCommandGenerator.device_udid(device_type) UI.message("Launch Simulator #{device_type}") Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null") paths.each do |path| UI.message("Adding '#{path}'") # Attempting addmedia since addphoto and addvideo are deprecated output = Helper.backticks("xcrun simctl addmedia #{device_udid} #{path.shellescape} &> /dev/null") # Run legacy addphoto and addvideo if addmedia isn't found # Output will be empty strin gif it was a success # Output will contain "usage: simctl" if command not found if output.include?('usage: simctl') Helper.backticks("xcrun simctl add#{media_type} #{device_udid} #{path.shellescape} &> /dev/null") end end end end
[ "def", "add_media", "(", "device_types", ",", "media_type", ",", "paths", ")", "media_type", "=", "media_type", ".", "to_s", "device_types", ".", "each", "do", "|", "device_type", "|", "UI", ".", "verbose", "(", "\"Adding #{media_type}s to #{device_type}...\"", ")", "device_udid", "=", "TestCommandGenerator", ".", "device_udid", "(", "device_type", ")", "UI", ".", "message", "(", "\"Launch Simulator #{device_type}\"", ")", "Helper", ".", "backticks", "(", "\"xcrun instruments -w #{device_udid} &> /dev/null\"", ")", "paths", ".", "each", "do", "|", "path", "|", "UI", ".", "message", "(", "\"Adding '#{path}'\"", ")", "# Attempting addmedia since addphoto and addvideo are deprecated", "output", "=", "Helper", ".", "backticks", "(", "\"xcrun simctl addmedia #{device_udid} #{path.shellescape} &> /dev/null\"", ")", "# Run legacy addphoto and addvideo if addmedia isn't found", "# Output will be empty strin gif it was a success", "# Output will contain \"usage: simctl\" if command not found", "if", "output", ".", "include?", "(", "'usage: simctl'", ")", "Helper", ".", "backticks", "(", "\"xcrun simctl add#{media_type} #{device_udid} #{path.shellescape} &> /dev/null\"", ")", "end", "end", "end", "end" ]
pass an array of device types
[ "pass", "an", "array", "of", "device", "types" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb#L71-L95
train
fastlane/fastlane
fastlane/lib/fastlane/setup/setup.rb
Fastlane.Setup.append_lane
def append_lane(lane) lane.compact! # remove nil values new_lines = "\n\n" if self.is_swift_fastfile new_lines = "" unless self.fastfile_content.include?("lane() {") # the first lane we don't want new lines self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}\t#{lane.join("\n\t")}[[LANES]]") else new_lines = "" unless self.fastfile_content.include?("lane :") # the first lane we don't want new lines self.fastfile_content.gsub!("[[LANES]]", "#{new_lines} #{lane.join("\n ")}[[LANES]]") end end
ruby
def append_lane(lane) lane.compact! # remove nil values new_lines = "\n\n" if self.is_swift_fastfile new_lines = "" unless self.fastfile_content.include?("lane() {") # the first lane we don't want new lines self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}\t#{lane.join("\n\t")}[[LANES]]") else new_lines = "" unless self.fastfile_content.include?("lane :") # the first lane we don't want new lines self.fastfile_content.gsub!("[[LANES]]", "#{new_lines} #{lane.join("\n ")}[[LANES]]") end end
[ "def", "append_lane", "(", "lane", ")", "lane", ".", "compact!", "# remove nil values", "new_lines", "=", "\"\\n\\n\"", "if", "self", ".", "is_swift_fastfile", "new_lines", "=", "\"\"", "unless", "self", ".", "fastfile_content", ".", "include?", "(", "\"lane() {\"", ")", "# the first lane we don't want new lines", "self", ".", "fastfile_content", ".", "gsub!", "(", "\"[[LANES]]\"", ",", "\"#{new_lines}\\t#{lane.join(\"\\n\\t\")}[[LANES]]\"", ")", "else", "new_lines", "=", "\"\"", "unless", "self", ".", "fastfile_content", ".", "include?", "(", "\"lane :\"", ")", "# the first lane we don't want new lines", "self", ".", "fastfile_content", ".", "gsub!", "(", "\"[[LANES]]\"", ",", "\"#{new_lines} #{lane.join(\"\\n \")}[[LANES]]\"", ")", "end", "end" ]
Append a lane to the current Fastfile template we're generating
[ "Append", "a", "lane", "to", "the", "current", "Fastfile", "template", "we", "re", "generating" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/setup/setup.rb#L146-L157
train
fastlane/fastlane
fastlane/lib/fastlane/setup/setup.rb
Fastlane.Setup.add_or_update_gemfile
def add_or_update_gemfile(update_gemfile_if_needed: false) if gemfile_exists? ensure_gemfile_valid!(update_gemfile_if_needed: update_gemfile_if_needed) else if update_gemfile_if_needed || UI.confirm("It is recommended to run fastlane with a Gemfile set up, do you want fastlane to create one for you?") setup_gemfile! end end return gemfile_path end
ruby
def add_or_update_gemfile(update_gemfile_if_needed: false) if gemfile_exists? ensure_gemfile_valid!(update_gemfile_if_needed: update_gemfile_if_needed) else if update_gemfile_if_needed || UI.confirm("It is recommended to run fastlane with a Gemfile set up, do you want fastlane to create one for you?") setup_gemfile! end end return gemfile_path end
[ "def", "add_or_update_gemfile", "(", "update_gemfile_if_needed", ":", "false", ")", "if", "gemfile_exists?", "ensure_gemfile_valid!", "(", "update_gemfile_if_needed", ":", "update_gemfile_if_needed", ")", "else", "if", "update_gemfile_if_needed", "||", "UI", ".", "confirm", "(", "\"It is recommended to run fastlane with a Gemfile set up, do you want fastlane to create one for you?\"", ")", "setup_gemfile!", "end", "end", "return", "gemfile_path", "end" ]
This method is responsible for ensuring there is a working Gemfile, and that `fastlane` is defined as a dependency while also having `rubygems` as a gem source
[ "This", "method", "is", "responsible", "for", "ensuring", "there", "is", "a", "working", "Gemfile", "and", "that", "fastlane", "is", "defined", "as", "a", "dependency", "while", "also", "having", "rubygems", "as", "a", "gem", "source" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/setup/setup.rb#L250-L259
train
fastlane/fastlane
credentials_manager/lib/credentials_manager/cli.rb
CredentialsManager.CLI.run
def run program :name, 'CredentialsManager' program :version, Fastlane::VERSION program :description, 'Manage credentials for fastlane tools.' # Command to add entry to Keychain command :add do |c| c.syntax = 'fastlane fastlane-credentials add' c.description = 'Adds a fastlane credential to the keychain.' c.option('--username username', String, 'Username to add.') c.option('--password password', String, 'Password to add.') c.action do |args, options| username = options.username || ask('Username: ') password = options.password || ask('Password: ') { |q| q.echo = '*' } add(username, password) puts("Credential #{username}:#{'*' * password.length} added to keychain.") end end # Command to remove credential from Keychain command :remove do |c| c.syntax = 'fastlane fastlane-credentials remove' c.description = 'Removes a fastlane credential from the keychain.' c.option('--username username', String, 'Username to remove.') c.action do |args, options| username = options.username || ask('Username: ') remove(username) end end run! end
ruby
def run program :name, 'CredentialsManager' program :version, Fastlane::VERSION program :description, 'Manage credentials for fastlane tools.' # Command to add entry to Keychain command :add do |c| c.syntax = 'fastlane fastlane-credentials add' c.description = 'Adds a fastlane credential to the keychain.' c.option('--username username', String, 'Username to add.') c.option('--password password', String, 'Password to add.') c.action do |args, options| username = options.username || ask('Username: ') password = options.password || ask('Password: ') { |q| q.echo = '*' } add(username, password) puts("Credential #{username}:#{'*' * password.length} added to keychain.") end end # Command to remove credential from Keychain command :remove do |c| c.syntax = 'fastlane fastlane-credentials remove' c.description = 'Removes a fastlane credential from the keychain.' c.option('--username username', String, 'Username to remove.') c.action do |args, options| username = options.username || ask('Username: ') remove(username) end end run! end
[ "def", "run", "program", ":name", ",", "'CredentialsManager'", "program", ":version", ",", "Fastlane", "::", "VERSION", "program", ":description", ",", "'Manage credentials for fastlane tools.'", "# Command to add entry to Keychain", "command", ":add", "do", "|", "c", "|", "c", ".", "syntax", "=", "'fastlane fastlane-credentials add'", "c", ".", "description", "=", "'Adds a fastlane credential to the keychain.'", "c", ".", "option", "(", "'--username username'", ",", "String", ",", "'Username to add.'", ")", "c", ".", "option", "(", "'--password password'", ",", "String", ",", "'Password to add.'", ")", "c", ".", "action", "do", "|", "args", ",", "options", "|", "username", "=", "options", ".", "username", "||", "ask", "(", "'Username: '", ")", "password", "=", "options", ".", "password", "||", "ask", "(", "'Password: '", ")", "{", "|", "q", "|", "q", ".", "echo", "=", "'*'", "}", "add", "(", "username", ",", "password", ")", "puts", "(", "\"Credential #{username}:#{'*' * password.length} added to keychain.\"", ")", "end", "end", "# Command to remove credential from Keychain", "command", ":remove", "do", "|", "c", "|", "c", ".", "syntax", "=", "'fastlane fastlane-credentials remove'", "c", ".", "description", "=", "'Removes a fastlane credential from the keychain.'", "c", ".", "option", "(", "'--username username'", ",", "String", ",", "'Username to remove.'", ")", "c", ".", "action", "do", "|", "args", ",", "options", "|", "username", "=", "options", ".", "username", "||", "ask", "(", "'Username: '", ")", "remove", "(", "username", ")", "end", "end", "run!", "end" ]
Parses command options and executes actions
[ "Parses", "command", "options", "and", "executes", "actions" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/credentials_manager/lib/credentials_manager/cli.rb#L10-L48
train
fastlane/fastlane
credentials_manager/lib/credentials_manager/cli.rb
CredentialsManager.CLI.add
def add(username, password) CredentialsManager::AccountManager.new( user: username, password: password ).add_to_keychain end
ruby
def add(username, password) CredentialsManager::AccountManager.new( user: username, password: password ).add_to_keychain end
[ "def", "add", "(", "username", ",", "password", ")", "CredentialsManager", "::", "AccountManager", ".", "new", "(", "user", ":", "username", ",", "password", ":", "password", ")", ".", "add_to_keychain", "end" ]
Add entry to Apple Keychain using AccountManager
[ "Add", "entry", "to", "Apple", "Keychain", "using", "AccountManager" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/credentials_manager/lib/credentials_manager/cli.rb#L53-L58
train
fastlane/fastlane
deliver/lib/deliver/setup.rb
Deliver.Setup.generate_deliver_file
def generate_deliver_file(deliver_path, options) v = options[:app].latest_version metadata_path = options[:metadata_path] || File.join(deliver_path, 'metadata') generate_metadata_files(v, metadata_path) # Generate the final Deliverfile here return File.read(deliverfile_path) end
ruby
def generate_deliver_file(deliver_path, options) v = options[:app].latest_version metadata_path = options[:metadata_path] || File.join(deliver_path, 'metadata') generate_metadata_files(v, metadata_path) # Generate the final Deliverfile here return File.read(deliverfile_path) end
[ "def", "generate_deliver_file", "(", "deliver_path", ",", "options", ")", "v", "=", "options", "[", ":app", "]", ".", "latest_version", "metadata_path", "=", "options", "[", ":metadata_path", "]", "||", "File", ".", "join", "(", "deliver_path", ",", "'metadata'", ")", "generate_metadata_files", "(", "v", ",", "metadata_path", ")", "# Generate the final Deliverfile here", "return", "File", ".", "read", "(", "deliverfile_path", ")", "end" ]
This method takes care of creating a new 'deliver' folder, containing the app metadata and screenshots folders
[ "This", "method", "takes", "care", "of", "creating", "a", "new", "deliver", "folder", "containing", "the", "app", "metadata", "and", "screenshots", "folders" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/setup.rb#L42-L49
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_info_collector.rb
Fastlane.PluginInfoCollector.gem_name_taken?
def gem_name_taken?(name) require 'open-uri' require 'json' url = "https://rubygems.org/api/v1/gems/#{name}.json" response = JSON.parse(open(url).read) return !!response['version'] rescue false end
ruby
def gem_name_taken?(name) require 'open-uri' require 'json' url = "https://rubygems.org/api/v1/gems/#{name}.json" response = JSON.parse(open(url).read) return !!response['version'] rescue false end
[ "def", "gem_name_taken?", "(", "name", ")", "require", "'open-uri'", "require", "'json'", "url", "=", "\"https://rubygems.org/api/v1/gems/#{name}.json\"", "response", "=", "JSON", ".", "parse", "(", "open", "(", "url", ")", ".", "read", ")", "return", "!", "!", "response", "[", "'version'", "]", "rescue", "false", "end" ]
Checks if the gem name is still free on RubyGems
[ "Checks", "if", "the", "gem", "name", "is", "still", "free", "on", "RubyGems" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_info_collector.rb#L67-L75
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_info_collector.rb
Fastlane.PluginInfoCollector.fix_plugin_name
def fix_plugin_name(name) name = name.to_s.downcase fixes = { /[\- ]/ => '_', # dashes and spaces become underscores /[^a-z0-9_]/ => '', # anything other than lower case letters, numbers and underscores is removed /fastlane[_]?/ => '', # 'fastlane' or 'fastlane_' is removed /plugin[_]?/ => '' # 'plugin' or 'plugin_' is removed } fixes.each do |regex, replacement| name = name.gsub(regex, replacement) end name end
ruby
def fix_plugin_name(name) name = name.to_s.downcase fixes = { /[\- ]/ => '_', # dashes and spaces become underscores /[^a-z0-9_]/ => '', # anything other than lower case letters, numbers and underscores is removed /fastlane[_]?/ => '', # 'fastlane' or 'fastlane_' is removed /plugin[_]?/ => '' # 'plugin' or 'plugin_' is removed } fixes.each do |regex, replacement| name = name.gsub(regex, replacement) end name end
[ "def", "fix_plugin_name", "(", "name", ")", "name", "=", "name", ".", "to_s", ".", "downcase", "fixes", "=", "{", "/", "\\-", "/", "=>", "'_'", ",", "# dashes and spaces become underscores", "/", "/", "=>", "''", ",", "# anything other than lower case letters, numbers and underscores is removed", "/", "/", "=>", "''", ",", "# 'fastlane' or 'fastlane_' is removed", "/", "/", "=>", "''", "# 'plugin' or 'plugin_' is removed", "}", "fixes", ".", "each", "do", "|", "regex", ",", "replacement", "|", "name", "=", "name", ".", "gsub", "(", "regex", ",", "replacement", ")", "end", "name", "end" ]
Applies a series of replacement rules to turn the requested plugin name into one that is acceptable, returning that suggestion
[ "Applies", "a", "series", "of", "replacement", "rules", "to", "turn", "the", "requested", "plugin", "name", "into", "one", "that", "is", "acceptable", "returning", "that", "suggestion" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_info_collector.rb#L79-L91
train
fastlane/fastlane
sigh/lib/sigh/resign.rb
Sigh.Resign.installed_identities
def installed_identities available = request_valid_identities ids = {} available.split("\n").each do |current| begin sha1 = current.match(/[a-zA-Z0-9]{40}/).to_s name = current.match(/.*\"(.*)\"/)[1] ids[sha1] = name rescue nil end # the last line does not match end ids end
ruby
def installed_identities available = request_valid_identities ids = {} available.split("\n").each do |current| begin sha1 = current.match(/[a-zA-Z0-9]{40}/).to_s name = current.match(/.*\"(.*)\"/)[1] ids[sha1] = name rescue nil end # the last line does not match end ids end
[ "def", "installed_identities", "available", "=", "request_valid_identities", "ids", "=", "{", "}", "available", ".", "split", "(", "\"\\n\"", ")", ".", "each", "do", "|", "current", "|", "begin", "sha1", "=", "current", ".", "match", "(", "/", "/", ")", ".", "to_s", "name", "=", "current", ".", "match", "(", "/", "\\\"", "\\\"", "/", ")", "[", "1", "]", "ids", "[", "sha1", "]", "=", "name", "rescue", "nil", "end", "# the last line does not match", "end", "ids", "end" ]
Hash of available signing identities
[ "Hash", "of", "available", "signing", "identities" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/resign.rb#L188-L202
train
fastlane/fastlane
supply/lib/supply/listing.rb
Supply.Listing.save
def save @google_api.update_listing_for_language(language: language, title: title, short_description: short_description, full_description: full_description, video: video) end
ruby
def save @google_api.update_listing_for_language(language: language, title: title, short_description: short_description, full_description: full_description, video: video) end
[ "def", "save", "@google_api", ".", "update_listing_for_language", "(", "language", ":", "language", ",", "title", ":", "title", ",", "short_description", ":", "short_description", ",", "full_description", ":", "full_description", ",", "video", ":", "video", ")", "end" ]
Initializes the listing to use the given api client, language, and fills it with the current listing if available Updates the listing in the current edit
[ "Initializes", "the", "listing", "to", "use", "the", "given", "api", "client", "language", "and", "fills", "it", "with", "the", "current", "listing", "if", "available", "Updates", "the", "listing", "in", "the", "current", "edit" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/listing.rb#L24-L30
train
fastlane/fastlane
credentials_manager/lib/credentials_manager/account_manager.rb
CredentialsManager.AccountManager.invalid_credentials
def invalid_credentials(force: false) puts("The login credentials for '#{user}' seem to be wrong".red) if fetch_password_from_env puts("The password was taken from the environment variable") puts("Please make sure it is correct") return false end if force || agree("Do you want to re-enter your password? (y/n)", true) puts("Removing Keychain entry for user '#{user}'...".yellow) if mac? remove_from_keychain ask_for_login return true end false end
ruby
def invalid_credentials(force: false) puts("The login credentials for '#{user}' seem to be wrong".red) if fetch_password_from_env puts("The password was taken from the environment variable") puts("Please make sure it is correct") return false end if force || agree("Do you want to re-enter your password? (y/n)", true) puts("Removing Keychain entry for user '#{user}'...".yellow) if mac? remove_from_keychain ask_for_login return true end false end
[ "def", "invalid_credentials", "(", "force", ":", "false", ")", "puts", "(", "\"The login credentials for '#{user}' seem to be wrong\"", ".", "red", ")", "if", "fetch_password_from_env", "puts", "(", "\"The password was taken from the environment variable\"", ")", "puts", "(", "\"Please make sure it is correct\"", ")", "return", "false", "end", "if", "force", "||", "agree", "(", "\"Do you want to re-enter your password? (y/n)\"", ",", "true", ")", "puts", "(", "\"Removing Keychain entry for user '#{user}'...\"", ".", "yellow", ")", "if", "mac?", "remove_from_keychain", "ask_for_login", "return", "true", "end", "false", "end" ]
Call this method to ask the user to re-enter the credentials @param force: if false, the user is asked before it gets deleted @return: Did the user decide to remove the old entry and enter a new password?
[ "Call", "this", "method", "to", "ask", "the", "user", "to", "re", "-", "enter", "the", "credentials" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/credentials_manager/lib/credentials_manager/account_manager.rb#L63-L79
train
fastlane/fastlane
credentials_manager/lib/credentials_manager/account_manager.rb
CredentialsManager.AccountManager.options
def options hash = {} hash[:p] = ENV["FASTLANE_PATH"] if ENV["FASTLANE_PATH"] hash[:P] = ENV["FASTLANE_PORT"] if ENV["FASTLANE_PORT"] hash[:r] = ENV["FASTLANE_PROTOCOL"] if ENV["FASTLANE_PROTOCOL"] hash.empty? ? nil : hash end
ruby
def options hash = {} hash[:p] = ENV["FASTLANE_PATH"] if ENV["FASTLANE_PATH"] hash[:P] = ENV["FASTLANE_PORT"] if ENV["FASTLANE_PORT"] hash[:r] = ENV["FASTLANE_PROTOCOL"] if ENV["FASTLANE_PROTOCOL"] hash.empty? ? nil : hash end
[ "def", "options", "hash", "=", "{", "}", "hash", "[", ":p", "]", "=", "ENV", "[", "\"FASTLANE_PATH\"", "]", "if", "ENV", "[", "\"FASTLANE_PATH\"", "]", "hash", "[", ":P", "]", "=", "ENV", "[", "\"FASTLANE_PORT\"", "]", "if", "ENV", "[", "\"FASTLANE_PORT\"", "]", "hash", "[", ":r", "]", "=", "ENV", "[", "\"FASTLANE_PROTOCOL\"", "]", "if", "ENV", "[", "\"FASTLANE_PROTOCOL\"", "]", "hash", ".", "empty?", "?", "nil", ":", "hash", "end" ]
Use env variables from this method to augment internet password item with additional data. These variables are used by Xamarin Studio to authenticate Apple developers.
[ "Use", "env", "variables", "from", "this", "method", "to", "augment", "internet", "password", "item", "with", "additional", "data", ".", "These", "variables", "are", "used", "by", "Xamarin", "Studio", "to", "authenticate", "Apple", "developers", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/credentials_manager/lib/credentials_manager/account_manager.rb#L100-L106
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb
Fastlane.InspectorReporter.inspector_started_query
def inspector_started_query(query, inspector) puts("") puts("Looking for related GitHub issues on #{inspector.repo_owner}/#{inspector.repo_name}...") puts("Search query: #{query}") if FastlaneCore::Globals.verbose? puts("") end
ruby
def inspector_started_query(query, inspector) puts("") puts("Looking for related GitHub issues on #{inspector.repo_owner}/#{inspector.repo_name}...") puts("Search query: #{query}") if FastlaneCore::Globals.verbose? puts("") end
[ "def", "inspector_started_query", "(", "query", ",", "inspector", ")", "puts", "(", "\"\"", ")", "puts", "(", "\"Looking for related GitHub issues on #{inspector.repo_owner}/#{inspector.repo_name}...\"", ")", "puts", "(", "\"Search query: #{query}\"", ")", "if", "FastlaneCore", "::", "Globals", ".", "verbose?", "puts", "(", "\"\"", ")", "end" ]
Called just as the investigation has begun.
[ "Called", "just", "as", "the", "investigation", "has", "begun", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb#L11-L16
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb
Fastlane.InspectorReporter.inspector_successfully_received_report
def inspector_successfully_received_report(report, inspector) report.issues[0..(NUMBER_OF_ISSUES_INLINE - 1)].each { |issue| print_issue_full(issue) } if report.issues.count > NUMBER_OF_ISSUES_INLINE report.url.sub!('\'', '%27') puts("and #{report.total_results - NUMBER_OF_ISSUES_INLINE} more at: #{report.url}") puts("") end print_open_link_hint end
ruby
def inspector_successfully_received_report(report, inspector) report.issues[0..(NUMBER_OF_ISSUES_INLINE - 1)].each { |issue| print_issue_full(issue) } if report.issues.count > NUMBER_OF_ISSUES_INLINE report.url.sub!('\'', '%27') puts("and #{report.total_results - NUMBER_OF_ISSUES_INLINE} more at: #{report.url}") puts("") end print_open_link_hint end
[ "def", "inspector_successfully_received_report", "(", "report", ",", "inspector", ")", "report", ".", "issues", "[", "0", "..", "(", "NUMBER_OF_ISSUES_INLINE", "-", "1", ")", "]", ".", "each", "{", "|", "issue", "|", "print_issue_full", "(", "issue", ")", "}", "if", "report", ".", "issues", ".", "count", ">", "NUMBER_OF_ISSUES_INLINE", "report", ".", "url", ".", "sub!", "(", "'\\''", ",", "'%27'", ")", "puts", "(", "\"and #{report.total_results - NUMBER_OF_ISSUES_INLINE} more at: #{report.url}\"", ")", "puts", "(", "\"\"", ")", "end", "print_open_link_hint", "end" ]
Called once the inspector has received a report with more than one issue.
[ "Called", "once", "the", "inspector", "has", "received", "a", "report", "with", "more", "than", "one", "issue", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb#L19-L29
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.select_team
def select_team(team_id: nil, team_name: nil) t_id = (team_id || ENV['FASTLANE_ITC_TEAM_ID'] || '').strip t_name = (team_name || ENV['FASTLANE_ITC_TEAM_NAME'] || '').strip if t_name.length > 0 && t_id.length.zero? # we prefer IDs over names, they are unique puts("Looking for App Store Connect Team with name #{t_name}") if Spaceship::Globals.verbose? teams.each do |t| t_id = t['contentProvider']['contentProviderId'].to_s if t['contentProvider']['name'].casecmp(t_name).zero? end puts("Could not find team with name '#{t_name}', trying to fallback to default team") if t_id.length.zero? end t_id = teams.first['contentProvider']['contentProviderId'].to_s if teams.count == 1 if t_id.length > 0 puts("Looking for App Store Connect Team with ID #{t_id}") if Spaceship::Globals.verbose? # actually set the team id here self.team_id = t_id return self.team_id end # user didn't specify a team... #thisiswhywecanthavenicethings loop do puts("Multiple #{'App Store Connect teams'.yellow} found, please enter the number of the team you want to use: ") if ENV["FASTLANE_HIDE_TEAM_INFORMATION"].to_s.length == 0 puts("Note: to automatically choose the team, provide either the App Store Connect Team ID, or the Team Name in your fastlane/Appfile:") puts("Alternatively you can pass the team name or team ID using the `FASTLANE_ITC_TEAM_ID` or `FASTLANE_ITC_TEAM_NAME` environment variable") first_team = teams.first["contentProvider"] puts("") puts(" itc_team_id \"#{first_team['contentProviderId']}\"") puts("") puts("or") puts("") puts(" itc_team_name \"#{first_team['name']}\"") puts("") end # We're not using highline here, as spaceship doesn't have a dependency to fastlane_core or highline teams.each_with_index do |team, i| puts("#{i + 1}) \"#{team['contentProvider']['name']}\" (#{team['contentProvider']['contentProviderId']})") end unless Spaceship::Client::UserInterface.interactive? puts("Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.") puts("Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.") raise "Multiple App Store Connect Teams found; unable to choose, terminal not interactive!" end selected = ($stdin.gets || '').strip.to_i - 1 team_to_use = teams[selected] if selected >= 0 if team_to_use self.team_id = team_to_use['contentProvider']['contentProviderId'].to_s # actually set the team id here return self.team_id end end end
ruby
def select_team(team_id: nil, team_name: nil) t_id = (team_id || ENV['FASTLANE_ITC_TEAM_ID'] || '').strip t_name = (team_name || ENV['FASTLANE_ITC_TEAM_NAME'] || '').strip if t_name.length > 0 && t_id.length.zero? # we prefer IDs over names, they are unique puts("Looking for App Store Connect Team with name #{t_name}") if Spaceship::Globals.verbose? teams.each do |t| t_id = t['contentProvider']['contentProviderId'].to_s if t['contentProvider']['name'].casecmp(t_name).zero? end puts("Could not find team with name '#{t_name}', trying to fallback to default team") if t_id.length.zero? end t_id = teams.first['contentProvider']['contentProviderId'].to_s if teams.count == 1 if t_id.length > 0 puts("Looking for App Store Connect Team with ID #{t_id}") if Spaceship::Globals.verbose? # actually set the team id here self.team_id = t_id return self.team_id end # user didn't specify a team... #thisiswhywecanthavenicethings loop do puts("Multiple #{'App Store Connect teams'.yellow} found, please enter the number of the team you want to use: ") if ENV["FASTLANE_HIDE_TEAM_INFORMATION"].to_s.length == 0 puts("Note: to automatically choose the team, provide either the App Store Connect Team ID, or the Team Name in your fastlane/Appfile:") puts("Alternatively you can pass the team name or team ID using the `FASTLANE_ITC_TEAM_ID` or `FASTLANE_ITC_TEAM_NAME` environment variable") first_team = teams.first["contentProvider"] puts("") puts(" itc_team_id \"#{first_team['contentProviderId']}\"") puts("") puts("or") puts("") puts(" itc_team_name \"#{first_team['name']}\"") puts("") end # We're not using highline here, as spaceship doesn't have a dependency to fastlane_core or highline teams.each_with_index do |team, i| puts("#{i + 1}) \"#{team['contentProvider']['name']}\" (#{team['contentProvider']['contentProviderId']})") end unless Spaceship::Client::UserInterface.interactive? puts("Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.") puts("Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.") raise "Multiple App Store Connect Teams found; unable to choose, terminal not interactive!" end selected = ($stdin.gets || '').strip.to_i - 1 team_to_use = teams[selected] if selected >= 0 if team_to_use self.team_id = team_to_use['contentProvider']['contentProviderId'].to_s # actually set the team id here return self.team_id end end end
[ "def", "select_team", "(", "team_id", ":", "nil", ",", "team_name", ":", "nil", ")", "t_id", "=", "(", "team_id", "||", "ENV", "[", "'FASTLANE_ITC_TEAM_ID'", "]", "||", "''", ")", ".", "strip", "t_name", "=", "(", "team_name", "||", "ENV", "[", "'FASTLANE_ITC_TEAM_NAME'", "]", "||", "''", ")", ".", "strip", "if", "t_name", ".", "length", ">", "0", "&&", "t_id", ".", "length", ".", "zero?", "# we prefer IDs over names, they are unique", "puts", "(", "\"Looking for App Store Connect Team with name #{t_name}\"", ")", "if", "Spaceship", "::", "Globals", ".", "verbose?", "teams", ".", "each", "do", "|", "t", "|", "t_id", "=", "t", "[", "'contentProvider'", "]", "[", "'contentProviderId'", "]", ".", "to_s", "if", "t", "[", "'contentProvider'", "]", "[", "'name'", "]", ".", "casecmp", "(", "t_name", ")", ".", "zero?", "end", "puts", "(", "\"Could not find team with name '#{t_name}', trying to fallback to default team\"", ")", "if", "t_id", ".", "length", ".", "zero?", "end", "t_id", "=", "teams", ".", "first", "[", "'contentProvider'", "]", "[", "'contentProviderId'", "]", ".", "to_s", "if", "teams", ".", "count", "==", "1", "if", "t_id", ".", "length", ">", "0", "puts", "(", "\"Looking for App Store Connect Team with ID #{t_id}\"", ")", "if", "Spaceship", "::", "Globals", ".", "verbose?", "# actually set the team id here", "self", ".", "team_id", "=", "t_id", "return", "self", ".", "team_id", "end", "# user didn't specify a team... #thisiswhywecanthavenicethings", "loop", "do", "puts", "(", "\"Multiple #{'App Store Connect teams'.yellow} found, please enter the number of the team you want to use: \"", ")", "if", "ENV", "[", "\"FASTLANE_HIDE_TEAM_INFORMATION\"", "]", ".", "to_s", ".", "length", "==", "0", "puts", "(", "\"Note: to automatically choose the team, provide either the App Store Connect Team ID, or the Team Name in your fastlane/Appfile:\"", ")", "puts", "(", "\"Alternatively you can pass the team name or team ID using the `FASTLANE_ITC_TEAM_ID` or `FASTLANE_ITC_TEAM_NAME` environment variable\"", ")", "first_team", "=", "teams", ".", "first", "[", "\"contentProvider\"", "]", "puts", "(", "\"\"", ")", "puts", "(", "\" itc_team_id \\\"#{first_team['contentProviderId']}\\\"\"", ")", "puts", "(", "\"\"", ")", "puts", "(", "\"or\"", ")", "puts", "(", "\"\"", ")", "puts", "(", "\" itc_team_name \\\"#{first_team['name']}\\\"\"", ")", "puts", "(", "\"\"", ")", "end", "# We're not using highline here, as spaceship doesn't have a dependency to fastlane_core or highline", "teams", ".", "each_with_index", "do", "|", "team", ",", "i", "|", "puts", "(", "\"#{i + 1}) \\\"#{team['contentProvider']['name']}\\\" (#{team['contentProvider']['contentProviderId']})\"", ")", "end", "unless", "Spaceship", "::", "Client", "::", "UserInterface", ".", "interactive?", "puts", "(", "\"Multiple teams found on App Store Connect, Your Terminal is running in non-interactive mode! Cannot continue from here.\"", ")", "puts", "(", "\"Please check that you set FASTLANE_ITC_TEAM_ID or FASTLANE_ITC_TEAM_NAME to the right value.\"", ")", "raise", "\"Multiple App Store Connect Teams found; unable to choose, terminal not interactive!\"", "end", "selected", "=", "(", "$stdin", ".", "gets", "||", "''", ")", ".", "strip", ".", "to_i", "-", "1", "team_to_use", "=", "teams", "[", "selected", "]", "if", "selected", ">=", "0", "if", "team_to_use", "self", ".", "team_id", "=", "team_to_use", "[", "'contentProvider'", "]", "[", "'contentProviderId'", "]", ".", "to_s", "# actually set the team id here", "return", "self", ".", "team_id", "end", "end", "end" ]
Shows a team selection for the user in the terminal. This should not be called on CI systems @param team_id (String) (optional): The ID of an App Store Connect team @param team_name (String) (optional): The name of an App Store Connect team
[ "Shows", "a", "team", "selection", "for", "the", "user", "in", "the", "terminal", ".", "This", "should", "not", "be", "called", "on", "CI", "systems" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L64-L123
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.fetch_errors_in_data
def fetch_errors_in_data(data_section: nil, sub_section_name: nil, keys: nil) if data_section && sub_section_name sub_section = data_section[sub_section_name] else sub_section = data_section end unless sub_section return {} end error_map = {} keys.each do |key| errors = sub_section.fetch(key, []) error_map[key] = errors if errors.count > 0 end return error_map end
ruby
def fetch_errors_in_data(data_section: nil, sub_section_name: nil, keys: nil) if data_section && sub_section_name sub_section = data_section[sub_section_name] else sub_section = data_section end unless sub_section return {} end error_map = {} keys.each do |key| errors = sub_section.fetch(key, []) error_map[key] = errors if errors.count > 0 end return error_map end
[ "def", "fetch_errors_in_data", "(", "data_section", ":", "nil", ",", "sub_section_name", ":", "nil", ",", "keys", ":", "nil", ")", "if", "data_section", "&&", "sub_section_name", "sub_section", "=", "data_section", "[", "sub_section_name", "]", "else", "sub_section", "=", "data_section", "end", "unless", "sub_section", "return", "{", "}", "end", "error_map", "=", "{", "}", "keys", ".", "each", "do", "|", "key", "|", "errors", "=", "sub_section", ".", "fetch", "(", "key", ",", "[", "]", ")", "error_map", "[", "key", "]", "=", "errors", "if", "errors", ".", "count", ">", "0", "end", "return", "error_map", "end" ]
Sometimes we get errors or info nested in our data This method allows you to pass in a set of keys to check for along with the name of the sub_section of your original data where we should check Returns a mapping of keys to data array if we find anything, otherwise, empty map
[ "Sometimes", "we", "get", "errors", "or", "info", "nested", "in", "our", "data", "This", "method", "allows", "you", "to", "pass", "in", "a", "set", "of", "keys", "to", "check", "for", "along", "with", "the", "name", "of", "the", "sub_section", "of", "your", "original", "data", "where", "we", "should", "check", "Returns", "a", "mapping", "of", "keys", "to", "data", "array", "if", "we", "find", "anything", "otherwise", "empty", "map" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L139-L156
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.create_application!
def create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil, platform: nil, itunes_connect_users: nil) puts("The `version` parameter is deprecated. Use `Spaceship::Tunes::Application.ensure_version!` method instead") if version # First, we need to fetch the data from Apple, which we then modify with the user's values primary_language ||= "English" platform ||= "ios" r = request(:get, "ra/apps/create/v2/?platformString=#{platform}") data = parse_response(r, 'data') # Now fill in the values we have # some values are nil, that's why there is a hash data['name'] = { value: name } data['bundleId'] = { value: bundle_id } data['primaryLanguage'] = { value: primary_language } data['primaryLocaleCode'] = { value: primary_language.to_itc_locale } data['vendorId'] = { value: sku } data['bundleIdSuffix'] = { value: bundle_id_suffix } data['companyName'] = { value: company_name } if company_name data['enabledPlatformsForCreation'] = { value: [platform] } data['initialPlatform'] = platform data['enabledPlatformsForCreation'] = { value: [platform] } unless itunes_connect_users.nil? data['iTunesConnectUsers']['grantedAllUsers'] = false data['iTunesConnectUsers']['grantedUsers'] = data['iTunesConnectUsers']['availableUsers'].select { |user| itunes_connect_users.include?(user['username']) } end # Now send back the modified hash r = request(:post) do |req| req.url('ra/apps/create/v2') req.body = data.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data') handle_itc_response(data) end
ruby
def create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil, platform: nil, itunes_connect_users: nil) puts("The `version` parameter is deprecated. Use `Spaceship::Tunes::Application.ensure_version!` method instead") if version # First, we need to fetch the data from Apple, which we then modify with the user's values primary_language ||= "English" platform ||= "ios" r = request(:get, "ra/apps/create/v2/?platformString=#{platform}") data = parse_response(r, 'data') # Now fill in the values we have # some values are nil, that's why there is a hash data['name'] = { value: name } data['bundleId'] = { value: bundle_id } data['primaryLanguage'] = { value: primary_language } data['primaryLocaleCode'] = { value: primary_language.to_itc_locale } data['vendorId'] = { value: sku } data['bundleIdSuffix'] = { value: bundle_id_suffix } data['companyName'] = { value: company_name } if company_name data['enabledPlatformsForCreation'] = { value: [platform] } data['initialPlatform'] = platform data['enabledPlatformsForCreation'] = { value: [platform] } unless itunes_connect_users.nil? data['iTunesConnectUsers']['grantedAllUsers'] = false data['iTunesConnectUsers']['grantedUsers'] = data['iTunesConnectUsers']['availableUsers'].select { |user| itunes_connect_users.include?(user['username']) } end # Now send back the modified hash r = request(:post) do |req| req.url('ra/apps/create/v2') req.body = data.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data') handle_itc_response(data) end
[ "def", "create_application!", "(", "name", ":", "nil", ",", "primary_language", ":", "nil", ",", "version", ":", "nil", ",", "sku", ":", "nil", ",", "bundle_id", ":", "nil", ",", "bundle_id_suffix", ":", "nil", ",", "company_name", ":", "nil", ",", "platform", ":", "nil", ",", "itunes_connect_users", ":", "nil", ")", "puts", "(", "\"The `version` parameter is deprecated. Use `Spaceship::Tunes::Application.ensure_version!` method instead\"", ")", "if", "version", "# First, we need to fetch the data from Apple, which we then modify with the user's values", "primary_language", "||=", "\"English\"", "platform", "||=", "\"ios\"", "r", "=", "request", "(", ":get", ",", "\"ra/apps/create/v2/?platformString=#{platform}\"", ")", "data", "=", "parse_response", "(", "r", ",", "'data'", ")", "# Now fill in the values we have", "# some values are nil, that's why there is a hash", "data", "[", "'name'", "]", "=", "{", "value", ":", "name", "}", "data", "[", "'bundleId'", "]", "=", "{", "value", ":", "bundle_id", "}", "data", "[", "'primaryLanguage'", "]", "=", "{", "value", ":", "primary_language", "}", "data", "[", "'primaryLocaleCode'", "]", "=", "{", "value", ":", "primary_language", ".", "to_itc_locale", "}", "data", "[", "'vendorId'", "]", "=", "{", "value", ":", "sku", "}", "data", "[", "'bundleIdSuffix'", "]", "=", "{", "value", ":", "bundle_id_suffix", "}", "data", "[", "'companyName'", "]", "=", "{", "value", ":", "company_name", "}", "if", "company_name", "data", "[", "'enabledPlatformsForCreation'", "]", "=", "{", "value", ":", "[", "platform", "]", "}", "data", "[", "'initialPlatform'", "]", "=", "platform", "data", "[", "'enabledPlatformsForCreation'", "]", "=", "{", "value", ":", "[", "platform", "]", "}", "unless", "itunes_connect_users", ".", "nil?", "data", "[", "'iTunesConnectUsers'", "]", "[", "'grantedAllUsers'", "]", "=", "false", "data", "[", "'iTunesConnectUsers'", "]", "[", "'grantedUsers'", "]", "=", "data", "[", "'iTunesConnectUsers'", "]", "[", "'availableUsers'", "]", ".", "select", "{", "|", "user", "|", "itunes_connect_users", ".", "include?", "(", "user", "[", "'username'", "]", ")", "}", "end", "# Now send back the modified hash", "r", "=", "request", "(", ":post", ")", "do", "|", "req", "|", "req", ".", "url", "(", "'ra/apps/create/v2'", ")", "req", ".", "body", "=", "data", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "end", "data", "=", "parse_response", "(", "r", ",", "'data'", ")", "handle_itc_response", "(", "data", ")", "end" ]
Creates a new application on App Store Connect @param name (String): The name of your app as it will appear on the App Store. This can't be longer than 255 characters. @param primary_language (String): If localized app information isn't available in an App Store territory, the information from your primary language will be used instead. @param version *DEPRECATED: Use `Spaceship::Tunes::Application.ensure_version!` method instead* (String): The version number is shown on the App Store and should match the one you used in Xcode. @param sku (String): A unique ID for your app that is not visible on the App Store. @param bundle_id (String): The bundle ID must match the one you used in Xcode. It can't be changed after you submit your first build.
[ "Creates", "a", "new", "application", "on", "App", "Store", "Connect" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L289-L326
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.pricing_tiers
def pricing_tiers @pricing_tiers ||= begin r = request(:get, 'ra/apps/pricing/matrix') data = parse_response(r, 'data')['pricingTiers'] data.map { |tier| Spaceship::Tunes::PricingTier.factory(tier) } end end
ruby
def pricing_tiers @pricing_tiers ||= begin r = request(:get, 'ra/apps/pricing/matrix') data = parse_response(r, 'data')['pricingTiers'] data.map { |tier| Spaceship::Tunes::PricingTier.factory(tier) } end end
[ "def", "pricing_tiers", "@pricing_tiers", "||=", "begin", "r", "=", "request", "(", ":get", ",", "'ra/apps/pricing/matrix'", ")", "data", "=", "parse_response", "(", "r", ",", "'data'", ")", "[", "'pricingTiers'", "]", "data", ".", "map", "{", "|", "tier", "|", "Spaceship", "::", "Tunes", "::", "PricingTier", ".", "factory", "(", "tier", ")", "}", "end", "end" ]
Returns an array of all available pricing tiers @note Although this information is publicly available, the current spaceship implementation requires you to have a logged in client to access it @return [Array] the PricingTier objects (Spaceship::Tunes::PricingTier) [{ "tierStem": "0", "tierName": "Free", "pricingInfo": [{ "country": "United States", "countryCode": "US", "currencySymbol": "$", "currencyCode": "USD", "wholesalePrice": 0.0, "retailPrice": 0.0, "fRetailPrice": "$0.00", "fWholesalePrice": "$0.00" }, { ... }, { ...
[ "Returns", "an", "array", "of", "all", "available", "pricing", "tiers" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L682-L688
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.supported_territories
def supported_territories data = supported_countries data.map { |country| Spaceship::Tunes::Territory.factory(country) } end
ruby
def supported_territories data = supported_countries data.map { |country| Spaceship::Tunes::Territory.factory(country) } end
[ "def", "supported_territories", "data", "=", "supported_countries", "data", ".", "map", "{", "|", "country", "|", "Spaceship", "::", "Tunes", "::", "Territory", ".", "factory", "(", "country", ")", "}", "end" ]
Returns an array of all supported territories @note Although this information is publicly available, the current spaceship implementation requires you to have a logged in client to access it @return [Array] the Territory objects (Spaceship::Tunes::Territory)
[ "Returns", "an", "array", "of", "all", "supported", "territories" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L744-L747
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.upload_watch_icon
def upload_watch_icon(app_version, upload_image) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image du_client.upload_watch_icon(app_version, upload_image, content_provider_id, sso_token_for_image) end
ruby
def upload_watch_icon(app_version, upload_image) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image du_client.upload_watch_icon(app_version, upload_image, content_provider_id, sso_token_for_image) end
[ "def", "upload_watch_icon", "(", "app_version", ",", "upload_image", ")", "raise", "\"app_version is required\"", "unless", "app_version", "raise", "\"upload_image is required\"", "unless", "upload_image", "du_client", ".", "upload_watch_icon", "(", "app_version", ",", "upload_image", ",", "content_provider_id", ",", "sso_token_for_image", ")", "end" ]
Uploads a watch icon @param app_version (AppVersion): The version of your app @param upload_image (UploadFile): The icon to upload @return [JSON] the response
[ "Uploads", "a", "watch", "icon" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L787-L792
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.upload_purchase_review_screenshot
def upload_purchase_review_screenshot(app_id, upload_image) data = du_client.upload_purchase_review_screenshot(app_id, upload_image, content_provider_id, sso_token_for_image) { "value" => { "assetToken" => data["token"], "sortOrder" => 0, "type" => du_client.get_picture_type(upload_image), "originalFileName" => upload_image.file_name, "size" => data["length"], "height" => data["height"], "width" => data["width"], "checksum" => data["md5"] } } end
ruby
def upload_purchase_review_screenshot(app_id, upload_image) data = du_client.upload_purchase_review_screenshot(app_id, upload_image, content_provider_id, sso_token_for_image) { "value" => { "assetToken" => data["token"], "sortOrder" => 0, "type" => du_client.get_picture_type(upload_image), "originalFileName" => upload_image.file_name, "size" => data["length"], "height" => data["height"], "width" => data["width"], "checksum" => data["md5"] } } end
[ "def", "upload_purchase_review_screenshot", "(", "app_id", ",", "upload_image", ")", "data", "=", "du_client", ".", "upload_purchase_review_screenshot", "(", "app_id", ",", "upload_image", ",", "content_provider_id", ",", "sso_token_for_image", ")", "{", "\"value\"", "=>", "{", "\"assetToken\"", "=>", "data", "[", "\"token\"", "]", ",", "\"sortOrder\"", "=>", "0", ",", "\"type\"", "=>", "du_client", ".", "get_picture_type", "(", "upload_image", ")", ",", "\"originalFileName\"", "=>", "upload_image", ".", "file_name", ",", "\"size\"", "=>", "data", "[", "\"length\"", "]", ",", "\"height\"", "=>", "data", "[", "\"height\"", "]", ",", "\"width\"", "=>", "data", "[", "\"width\"", "]", ",", "\"checksum\"", "=>", "data", "[", "\"md5\"", "]", "}", "}", "end" ]
Uploads an In-App-Purchase Review screenshot @param app_id (AppId): The id of the app @param upload_image (UploadFile): The icon to upload @return [JSON] the screenshot data, ready to be added to an In-App-Purchase
[ "Uploads", "an", "In", "-", "App", "-", "Purchase", "Review", "screenshot" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L798-L812
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.upload_screenshot
def upload_screenshot(app_version, upload_image, device, is_messages) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image raise "device is required" unless device du_client.upload_screenshot(app_version, upload_image, content_provider_id, sso_token_for_image, device, is_messages) end
ruby
def upload_screenshot(app_version, upload_image, device, is_messages) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image raise "device is required" unless device du_client.upload_screenshot(app_version, upload_image, content_provider_id, sso_token_for_image, device, is_messages) end
[ "def", "upload_screenshot", "(", "app_version", ",", "upload_image", ",", "device", ",", "is_messages", ")", "raise", "\"app_version is required\"", "unless", "app_version", "raise", "\"upload_image is required\"", "unless", "upload_image", "raise", "\"device is required\"", "unless", "device", "du_client", ".", "upload_screenshot", "(", "app_version", ",", "upload_image", ",", "content_provider_id", ",", "sso_token_for_image", ",", "device", ",", "is_messages", ")", "end" ]
Uploads a screenshot @param app_version (AppVersion): The version of your app @param upload_image (UploadFile): The image to upload @param device (string): The target device @param is_messages (Bool): True if the screenshot is for iMessage @return [JSON] the response
[ "Uploads", "a", "screenshot" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L820-L826
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.upload_messages_screenshot
def upload_messages_screenshot(app_version, upload_image, device) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image raise "device is required" unless device du_client.upload_messages_screenshot(app_version, upload_image, content_provider_id, sso_token_for_image, device) end
ruby
def upload_messages_screenshot(app_version, upload_image, device) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image raise "device is required" unless device du_client.upload_messages_screenshot(app_version, upload_image, content_provider_id, sso_token_for_image, device) end
[ "def", "upload_messages_screenshot", "(", "app_version", ",", "upload_image", ",", "device", ")", "raise", "\"app_version is required\"", "unless", "app_version", "raise", "\"upload_image is required\"", "unless", "upload_image", "raise", "\"device is required\"", "unless", "device", "du_client", ".", "upload_messages_screenshot", "(", "app_version", ",", "upload_image", ",", "content_provider_id", ",", "sso_token_for_image", ",", "device", ")", "end" ]
Uploads an iMessage screenshot @param app_version (AppVersion): The version of your app @param upload_image (UploadFile): The image to upload @param device (string): The target device @return [JSON] the response
[ "Uploads", "an", "iMessage", "screenshot" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L833-L839
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.upload_trailer_preview
def upload_trailer_preview(app_version, upload_trailer_preview, device) raise "app_version is required" unless app_version raise "upload_trailer_preview is required" unless upload_trailer_preview raise "device is required" unless device du_client.upload_trailer_preview(app_version, upload_trailer_preview, content_provider_id, sso_token_for_image, device) end
ruby
def upload_trailer_preview(app_version, upload_trailer_preview, device) raise "app_version is required" unless app_version raise "upload_trailer_preview is required" unless upload_trailer_preview raise "device is required" unless device du_client.upload_trailer_preview(app_version, upload_trailer_preview, content_provider_id, sso_token_for_image, device) end
[ "def", "upload_trailer_preview", "(", "app_version", ",", "upload_trailer_preview", ",", "device", ")", "raise", "\"app_version is required\"", "unless", "app_version", "raise", "\"upload_trailer_preview is required\"", "unless", "upload_trailer_preview", "raise", "\"device is required\"", "unless", "device", "du_client", ".", "upload_trailer_preview", "(", "app_version", ",", "upload_trailer_preview", ",", "content_provider_id", ",", "sso_token_for_image", ",", "device", ")", "end" ]
Uploads the trailer preview @param app_version (AppVersion): The version of your app @param upload_trailer_preview (UploadFile): The trailer preview to upload @param device (string): The target device @return [JSON] the response
[ "Uploads", "the", "trailer", "preview" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L868-L874
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.ref_data
def ref_data r = request(:get, '/WebObjects/iTunesConnect.woa/ra/apps/version/ref') data = parse_response(r, 'data') Spaceship::Tunes::AppVersionRef.factory(data) end
ruby
def ref_data r = request(:get, '/WebObjects/iTunesConnect.woa/ra/apps/version/ref') data = parse_response(r, 'data') Spaceship::Tunes::AppVersionRef.factory(data) end
[ "def", "ref_data", "r", "=", "request", "(", ":get", ",", "'/WebObjects/iTunesConnect.woa/ra/apps/version/ref'", ")", "data", "=", "parse_response", "(", "r", ",", "'data'", ")", "Spaceship", "::", "Tunes", "::", "AppVersionRef", ".", "factory", "(", "data", ")", "end" ]
Fetches the App Version Reference information from ITC @return [AppVersionRef] the response
[ "Fetches", "the", "App", "Version", "Reference", "information", "from", "ITC" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L878-L882
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.all_build_trains
def all_build_trains(app_id: nil, platform: 'ios') platform = 'ios' if platform.nil? r = request(:get, "ra/apps/#{app_id}/buildHistory?platform=#{platform}") handle_itc_response(r.body) end
ruby
def all_build_trains(app_id: nil, platform: 'ios') platform = 'ios' if platform.nil? r = request(:get, "ra/apps/#{app_id}/buildHistory?platform=#{platform}") handle_itc_response(r.body) end
[ "def", "all_build_trains", "(", "app_id", ":", "nil", ",", "platform", ":", "'ios'", ")", "platform", "=", "'ios'", "if", "platform", ".", "nil?", "r", "=", "request", "(", ":get", ",", "\"ra/apps/#{app_id}/buildHistory?platform=#{platform}\"", ")", "handle_itc_response", "(", "r", ".", "body", ")", "end" ]
All build trains, even if there is no TestFlight
[ "All", "build", "trains", "even", "if", "there", "is", "no", "TestFlight" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L960-L964
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.update_iap_family!
def update_iap_family!(app_id: nil, family_id: nil, data: nil) with_tunes_retry do r = request(:put) do |req| req.url("ra/apps/#{app_id}/iaps/family/#{family_id}/") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end end
ruby
def update_iap_family!(app_id: nil, family_id: nil, data: nil) with_tunes_retry do r = request(:put) do |req| req.url("ra/apps/#{app_id}/iaps/family/#{family_id}/") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end end
[ "def", "update_iap_family!", "(", "app_id", ":", "nil", ",", "family_id", ":", "nil", ",", "data", ":", "nil", ")", "with_tunes_retry", "do", "r", "=", "request", "(", ":put", ")", "do", "|", "req", "|", "req", ".", "url", "(", "\"ra/apps/#{app_id}/iaps/family/#{family_id}/\"", ")", "req", ".", "body", "=", "data", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "end", "handle_itc_response", "(", "r", ".", "body", ")", "end", "end" ]
updates an In-App-Purchases-Family
[ "updates", "an", "In", "-", "App", "-", "Purchases", "-", "Family" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L1227-L1236
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.update_iap!
def update_iap!(app_id: nil, purchase_id: nil, data: nil) with_tunes_retry do r = request(:put) do |req| req.url("ra/apps/#{app_id}/iaps/#{purchase_id}") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end end
ruby
def update_iap!(app_id: nil, purchase_id: nil, data: nil) with_tunes_retry do r = request(:put) do |req| req.url("ra/apps/#{app_id}/iaps/#{purchase_id}") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end end
[ "def", "update_iap!", "(", "app_id", ":", "nil", ",", "purchase_id", ":", "nil", ",", "data", ":", "nil", ")", "with_tunes_retry", "do", "r", "=", "request", "(", ":put", ")", "do", "|", "req", "|", "req", ".", "url", "(", "\"ra/apps/#{app_id}/iaps/#{purchase_id}\"", ")", "req", ".", "body", "=", "data", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "end", "handle_itc_response", "(", "r", ".", "body", ")", "end", "end" ]
updates an In-App-Purchases
[ "updates", "an", "In", "-", "App", "-", "Purchases" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L1239-L1248
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.create_iap!
def create_iap!(app_id: nil, type: nil, versions: nil, reference_name: nil, product_id: nil, cleared_for_sale: true, review_notes: nil, review_screenshot: nil, pricing_intervals: nil, family_id: nil, subscription_duration: nil, subscription_free_trial: nil) # Load IAP Template based on Type type ||= "consumable" r = request(:get, "ra/apps/#{app_id}/iaps/#{type}/template") data = parse_response(r, 'data') # Now fill in the values we have # some values are nil, that's why there is a hash data['familyId'] = family_id.to_s if family_id data['productId'] = { value: product_id } data['referenceName'] = { value: reference_name } data['clearedForSale'] = { value: cleared_for_sale } data['pricingDurationType'] = { value: subscription_duration } if subscription_duration data['freeTrialDurationType'] = { value: subscription_free_trial } if subscription_free_trial # pricing tier if pricing_intervals data['pricingIntervals'] = [] pricing_intervals.each do |interval| data['pricingIntervals'] << { value: { country: interval[:country] || "WW", tierStem: interval[:tier].to_s, priceTierEndDate: interval[:end_date], priceTierEffectiveDate: interval[:begin_date] } } end end versions_array = [] versions.each do |k, v| versions_array << { value: { description: { value: v[:description] }, name: { value: v[:name] }, localeCode: k.to_s } } end data["versions"][0]["details"]["value"] = versions_array data['versions'][0]["reviewNotes"] = { value: review_notes } if review_screenshot # Upload Screenshot: upload_file = UploadFile.from_path(review_screenshot) screenshot_data = upload_purchase_review_screenshot(app_id, upload_file) data["versions"][0]["reviewScreenshot"] = screenshot_data end # Now send back the modified hash r = request(:post) do |req| req.url("ra/apps/#{app_id}/iaps") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end
ruby
def create_iap!(app_id: nil, type: nil, versions: nil, reference_name: nil, product_id: nil, cleared_for_sale: true, review_notes: nil, review_screenshot: nil, pricing_intervals: nil, family_id: nil, subscription_duration: nil, subscription_free_trial: nil) # Load IAP Template based on Type type ||= "consumable" r = request(:get, "ra/apps/#{app_id}/iaps/#{type}/template") data = parse_response(r, 'data') # Now fill in the values we have # some values are nil, that's why there is a hash data['familyId'] = family_id.to_s if family_id data['productId'] = { value: product_id } data['referenceName'] = { value: reference_name } data['clearedForSale'] = { value: cleared_for_sale } data['pricingDurationType'] = { value: subscription_duration } if subscription_duration data['freeTrialDurationType'] = { value: subscription_free_trial } if subscription_free_trial # pricing tier if pricing_intervals data['pricingIntervals'] = [] pricing_intervals.each do |interval| data['pricingIntervals'] << { value: { country: interval[:country] || "WW", tierStem: interval[:tier].to_s, priceTierEndDate: interval[:end_date], priceTierEffectiveDate: interval[:begin_date] } } end end versions_array = [] versions.each do |k, v| versions_array << { value: { description: { value: v[:description] }, name: { value: v[:name] }, localeCode: k.to_s } } end data["versions"][0]["details"]["value"] = versions_array data['versions'][0]["reviewNotes"] = { value: review_notes } if review_screenshot # Upload Screenshot: upload_file = UploadFile.from_path(review_screenshot) screenshot_data = upload_purchase_review_screenshot(app_id, upload_file) data["versions"][0]["reviewScreenshot"] = screenshot_data end # Now send back the modified hash r = request(:post) do |req| req.url("ra/apps/#{app_id}/iaps") req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end
[ "def", "create_iap!", "(", "app_id", ":", "nil", ",", "type", ":", "nil", ",", "versions", ":", "nil", ",", "reference_name", ":", "nil", ",", "product_id", ":", "nil", ",", "cleared_for_sale", ":", "true", ",", "review_notes", ":", "nil", ",", "review_screenshot", ":", "nil", ",", "pricing_intervals", ":", "nil", ",", "family_id", ":", "nil", ",", "subscription_duration", ":", "nil", ",", "subscription_free_trial", ":", "nil", ")", "# Load IAP Template based on Type", "type", "||=", "\"consumable\"", "r", "=", "request", "(", ":get", ",", "\"ra/apps/#{app_id}/iaps/#{type}/template\"", ")", "data", "=", "parse_response", "(", "r", ",", "'data'", ")", "# Now fill in the values we have", "# some values are nil, that's why there is a hash", "data", "[", "'familyId'", "]", "=", "family_id", ".", "to_s", "if", "family_id", "data", "[", "'productId'", "]", "=", "{", "value", ":", "product_id", "}", "data", "[", "'referenceName'", "]", "=", "{", "value", ":", "reference_name", "}", "data", "[", "'clearedForSale'", "]", "=", "{", "value", ":", "cleared_for_sale", "}", "data", "[", "'pricingDurationType'", "]", "=", "{", "value", ":", "subscription_duration", "}", "if", "subscription_duration", "data", "[", "'freeTrialDurationType'", "]", "=", "{", "value", ":", "subscription_free_trial", "}", "if", "subscription_free_trial", "# pricing tier", "if", "pricing_intervals", "data", "[", "'pricingIntervals'", "]", "=", "[", "]", "pricing_intervals", ".", "each", "do", "|", "interval", "|", "data", "[", "'pricingIntervals'", "]", "<<", "{", "value", ":", "{", "country", ":", "interval", "[", ":country", "]", "||", "\"WW\"", ",", "tierStem", ":", "interval", "[", ":tier", "]", ".", "to_s", ",", "priceTierEndDate", ":", "interval", "[", ":end_date", "]", ",", "priceTierEffectiveDate", ":", "interval", "[", ":begin_date", "]", "}", "}", "end", "end", "versions_array", "=", "[", "]", "versions", ".", "each", "do", "|", "k", ",", "v", "|", "versions_array", "<<", "{", "value", ":", "{", "description", ":", "{", "value", ":", "v", "[", ":description", "]", "}", ",", "name", ":", "{", "value", ":", "v", "[", ":name", "]", "}", ",", "localeCode", ":", "k", ".", "to_s", "}", "}", "end", "data", "[", "\"versions\"", "]", "[", "0", "]", "[", "\"details\"", "]", "[", "\"value\"", "]", "=", "versions_array", "data", "[", "'versions'", "]", "[", "0", "]", "[", "\"reviewNotes\"", "]", "=", "{", "value", ":", "review_notes", "}", "if", "review_screenshot", "# Upload Screenshot:", "upload_file", "=", "UploadFile", ".", "from_path", "(", "review_screenshot", ")", "screenshot_data", "=", "upload_purchase_review_screenshot", "(", "app_id", ",", "upload_file", ")", "data", "[", "\"versions\"", "]", "[", "0", "]", "[", "\"reviewScreenshot\"", "]", "=", "screenshot_data", "end", "# Now send back the modified hash", "r", "=", "request", "(", ":post", ")", "do", "|", "req", "|", "req", ".", "url", "(", "\"ra/apps/#{app_id}/iaps\"", ")", "req", ".", "body", "=", "data", ".", "to_json", "req", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "end", "handle_itc_response", "(", "r", ".", "body", ")", "end" ]
Creates an In-App-Purchases
[ "Creates", "an", "In", "-", "App", "-", "Purchases" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L1292-L1350
train
fastlane/fastlane
spaceship/lib/spaceship/tunes/tunes_client.rb
Spaceship.TunesClient.group_for_view_by
def group_for_view_by(view_by, measures) if view_by.nil? || measures.nil? return nil else return { metric: measures.first, dimension: view_by, rank: "DESCENDING", limit: 3 } end end
ruby
def group_for_view_by(view_by, measures) if view_by.nil? || measures.nil? return nil else return { metric: measures.first, dimension: view_by, rank: "DESCENDING", limit: 3 } end end
[ "def", "group_for_view_by", "(", "view_by", ",", "measures", ")", "if", "view_by", ".", "nil?", "||", "measures", ".", "nil?", "return", "nil", "else", "return", "{", "metric", ":", "measures", ".", "first", ",", "dimension", ":", "view_by", ",", "rank", ":", "\"DESCENDING\"", ",", "limit", ":", "3", "}", "end", "end" ]
generates group hash used in the analytics time_series API. Using rank=DESCENDING and limit=3 as this is what the App Store Connect analytics dashboard uses.
[ "generates", "group", "hash", "used", "in", "the", "analytics", "time_series", "API", ".", "Using", "rank", "=", "DESCENDING", "and", "limit", "=", "3", "as", "this", "is", "what", "the", "App", "Store", "Connect", "analytics", "dashboard", "uses", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/spaceship/lib/spaceship/tunes/tunes_client.rb#L1512-L1523
train
fastlane/fastlane
snapshot/lib/snapshot/simulator_launchers/simulator_launcher_xcode_8.rb
Snapshot.SimulatorLauncherXcode8.run_for_device_and_language
def run_for_device_and_language(language, locale, device, launch_arguments, retries = 0) return launch_one_at_a_time(language, locale, device, launch_arguments) rescue => ex UI.error(ex.to_s) # show the reason for failure to the user, but still maybe retry if retries < launcher_config.number_of_retries UI.important("Tests failed, re-trying #{retries + 1} out of #{launcher_config.number_of_retries + 1} times") run_for_device_and_language(language, locale, device, launch_arguments, retries + 1) else UI.error("Backtrace:\n\t#{ex.backtrace.join("\n\t")}") if FastlaneCore::Globals.verbose? self.collected_errors << ex raise ex if launcher_config.stop_after_first_error return false # for the results end end
ruby
def run_for_device_and_language(language, locale, device, launch_arguments, retries = 0) return launch_one_at_a_time(language, locale, device, launch_arguments) rescue => ex UI.error(ex.to_s) # show the reason for failure to the user, but still maybe retry if retries < launcher_config.number_of_retries UI.important("Tests failed, re-trying #{retries + 1} out of #{launcher_config.number_of_retries + 1} times") run_for_device_and_language(language, locale, device, launch_arguments, retries + 1) else UI.error("Backtrace:\n\t#{ex.backtrace.join("\n\t")}") if FastlaneCore::Globals.verbose? self.collected_errors << ex raise ex if launcher_config.stop_after_first_error return false # for the results end end
[ "def", "run_for_device_and_language", "(", "language", ",", "locale", ",", "device", ",", "launch_arguments", ",", "retries", "=", "0", ")", "return", "launch_one_at_a_time", "(", "language", ",", "locale", ",", "device", ",", "launch_arguments", ")", "rescue", "=>", "ex", "UI", ".", "error", "(", "ex", ".", "to_s", ")", "# show the reason for failure to the user, but still maybe retry", "if", "retries", "<", "launcher_config", ".", "number_of_retries", "UI", ".", "important", "(", "\"Tests failed, re-trying #{retries + 1} out of #{launcher_config.number_of_retries + 1} times\"", ")", "run_for_device_and_language", "(", "language", ",", "locale", ",", "device", ",", "launch_arguments", ",", "retries", "+", "1", ")", "else", "UI", ".", "error", "(", "\"Backtrace:\\n\\t#{ex.backtrace.join(\"\\n\\t\")}\"", ")", "if", "FastlaneCore", "::", "Globals", ".", "verbose?", "self", ".", "collected_errors", "<<", "ex", "raise", "ex", "if", "launcher_config", ".", "stop_after_first_error", "return", "false", "# for the results", "end", "end" ]
This is its own method so that it can re-try if the tests fail randomly @return true/false depending on if the tests succeeded
[ "This", "is", "its", "own", "method", "so", "that", "it", "can", "re", "-", "try", "if", "the", "tests", "fail", "randomly" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_xcode_8.rb#L34-L48
train
fastlane/fastlane
snapshot/lib/snapshot/simulator_launchers/simulator_launcher_xcode_8.rb
Snapshot.SimulatorLauncherXcode8.launch_one_at_a_time
def launch_one_at_a_time(language, locale, device_type, launch_arguments) prepare_for_launch([device_type], language, locale, launch_arguments) add_media([device_type], :photo, launcher_config.add_photos) if launcher_config.add_photos add_media([device_type], :video, launcher_config.add_videos) if launcher_config.add_videos open_simulator_for_device(device_type) command = TestCommandGeneratorXcode8.generate(device_type: device_type, language: language, locale: locale) if locale UI.header("#{device_type} - #{language} (#{locale})") else UI.header("#{device_type} - #{language}") end execute(command: command, language: language, locale: locale, device_type: device_type, launch_args: launch_arguments) raw_output = File.read(TestCommandGeneratorXcode8.xcodebuild_log_path(device_type: device_type, language: language, locale: locale)) dir_name = locale || language return Collector.fetch_screenshots(raw_output, dir_name, device_type, launch_arguments.first) end
ruby
def launch_one_at_a_time(language, locale, device_type, launch_arguments) prepare_for_launch([device_type], language, locale, launch_arguments) add_media([device_type], :photo, launcher_config.add_photos) if launcher_config.add_photos add_media([device_type], :video, launcher_config.add_videos) if launcher_config.add_videos open_simulator_for_device(device_type) command = TestCommandGeneratorXcode8.generate(device_type: device_type, language: language, locale: locale) if locale UI.header("#{device_type} - #{language} (#{locale})") else UI.header("#{device_type} - #{language}") end execute(command: command, language: language, locale: locale, device_type: device_type, launch_args: launch_arguments) raw_output = File.read(TestCommandGeneratorXcode8.xcodebuild_log_path(device_type: device_type, language: language, locale: locale)) dir_name = locale || language return Collector.fetch_screenshots(raw_output, dir_name, device_type, launch_arguments.first) end
[ "def", "launch_one_at_a_time", "(", "language", ",", "locale", ",", "device_type", ",", "launch_arguments", ")", "prepare_for_launch", "(", "[", "device_type", "]", ",", "language", ",", "locale", ",", "launch_arguments", ")", "add_media", "(", "[", "device_type", "]", ",", ":photo", ",", "launcher_config", ".", "add_photos", ")", "if", "launcher_config", ".", "add_photos", "add_media", "(", "[", "device_type", "]", ",", ":video", ",", "launcher_config", ".", "add_videos", ")", "if", "launcher_config", ".", "add_videos", "open_simulator_for_device", "(", "device_type", ")", "command", "=", "TestCommandGeneratorXcode8", ".", "generate", "(", "device_type", ":", "device_type", ",", "language", ":", "language", ",", "locale", ":", "locale", ")", "if", "locale", "UI", ".", "header", "(", "\"#{device_type} - #{language} (#{locale})\"", ")", "else", "UI", ".", "header", "(", "\"#{device_type} - #{language}\"", ")", "end", "execute", "(", "command", ":", "command", ",", "language", ":", "language", ",", "locale", ":", "locale", ",", "device_type", ":", "device_type", ",", "launch_args", ":", "launch_arguments", ")", "raw_output", "=", "File", ".", "read", "(", "TestCommandGeneratorXcode8", ".", "xcodebuild_log_path", "(", "device_type", ":", "device_type", ",", "language", ":", "language", ",", "locale", ":", "locale", ")", ")", "dir_name", "=", "locale", "||", "language", "return", "Collector", ".", "fetch_screenshots", "(", "raw_output", ",", "dir_name", ",", "device_type", ",", "launch_arguments", ".", "first", ")", "end" ]
Returns true if it succeeded
[ "Returns", "true", "if", "it", "succeeded" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_xcode_8.rb#L51-L74
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/configuration/configuration.rb
FastlaneCore.Configuration.verify_default_value_matches_verify_block
def verify_default_value_matches_verify_block @available_options.each do |item| next unless item.verify_block && item.default_value begin unless @values[item.key] # this is important to not verify if there already is a value there item.verify_block.call(item.default_value) end rescue => ex UI.error(ex) UI.user_error!("Invalid default value for #{item.key}, doesn't match verify_block") end end end
ruby
def verify_default_value_matches_verify_block @available_options.each do |item| next unless item.verify_block && item.default_value begin unless @values[item.key] # this is important to not verify if there already is a value there item.verify_block.call(item.default_value) end rescue => ex UI.error(ex) UI.user_error!("Invalid default value for #{item.key}, doesn't match verify_block") end end end
[ "def", "verify_default_value_matches_verify_block", "@available_options", ".", "each", "do", "|", "item", "|", "next", "unless", "item", ".", "verify_block", "&&", "item", ".", "default_value", "begin", "unless", "@values", "[", "item", ".", "key", "]", "# this is important to not verify if there already is a value there", "item", ".", "verify_block", ".", "call", "(", "item", ".", "default_value", ")", "end", "rescue", "=>", "ex", "UI", ".", "error", "(", "ex", ")", "UI", ".", "user_error!", "(", "\"Invalid default value for #{item.key}, doesn't match verify_block\"", ")", "end", "end", "end" ]
Verifies the default value is also valid
[ "Verifies", "the", "default", "value", "is", "also", "valid" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/configuration/configuration.rb#L141-L154
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/configuration/configuration.rb
FastlaneCore.Configuration.load_configuration_file
def load_configuration_file(config_file_name = nil, block_for_missing = nil, skip_printing_values = false) return unless config_file_name self.config_file_name = config_file_name path = FastlaneCore::Configuration.find_configuration_file_path(config_file_name: config_file_name) return if path.nil? begin configuration_file = ConfigurationFile.new(self, path, block_for_missing, skip_printing_values) options = configuration_file.options rescue FastlaneCore::ConfigurationFile::ExceptionWhileParsingError => e options = e.recovered_options wrapped_exception = e.wrapped_exception end # Make sure all the values set in the config file pass verification options.each do |key, val| option = self.verify_options_key!(key) option.verify!(val) end # Merge the new options into the old ones, keeping all previously set keys self.config_file_options = options.merge(self.config_file_options) verify_conflicts # important, since user can set conflicting options in configuration file # Now that everything is verified, re-raise an exception that was raised in the config file raise wrapped_exception unless wrapped_exception.nil? configuration_file end
ruby
def load_configuration_file(config_file_name = nil, block_for_missing = nil, skip_printing_values = false) return unless config_file_name self.config_file_name = config_file_name path = FastlaneCore::Configuration.find_configuration_file_path(config_file_name: config_file_name) return if path.nil? begin configuration_file = ConfigurationFile.new(self, path, block_for_missing, skip_printing_values) options = configuration_file.options rescue FastlaneCore::ConfigurationFile::ExceptionWhileParsingError => e options = e.recovered_options wrapped_exception = e.wrapped_exception end # Make sure all the values set in the config file pass verification options.each do |key, val| option = self.verify_options_key!(key) option.verify!(val) end # Merge the new options into the old ones, keeping all previously set keys self.config_file_options = options.merge(self.config_file_options) verify_conflicts # important, since user can set conflicting options in configuration file # Now that everything is verified, re-raise an exception that was raised in the config file raise wrapped_exception unless wrapped_exception.nil? configuration_file end
[ "def", "load_configuration_file", "(", "config_file_name", "=", "nil", ",", "block_for_missing", "=", "nil", ",", "skip_printing_values", "=", "false", ")", "return", "unless", "config_file_name", "self", ".", "config_file_name", "=", "config_file_name", "path", "=", "FastlaneCore", "::", "Configuration", ".", "find_configuration_file_path", "(", "config_file_name", ":", "config_file_name", ")", "return", "if", "path", ".", "nil?", "begin", "configuration_file", "=", "ConfigurationFile", ".", "new", "(", "self", ",", "path", ",", "block_for_missing", ",", "skip_printing_values", ")", "options", "=", "configuration_file", ".", "options", "rescue", "FastlaneCore", "::", "ConfigurationFile", "::", "ExceptionWhileParsingError", "=>", "e", "options", "=", "e", ".", "recovered_options", "wrapped_exception", "=", "e", ".", "wrapped_exception", "end", "# Make sure all the values set in the config file pass verification", "options", ".", "each", "do", "|", "key", ",", "val", "|", "option", "=", "self", ".", "verify_options_key!", "(", "key", ")", "option", ".", "verify!", "(", "val", ")", "end", "# Merge the new options into the old ones, keeping all previously set keys", "self", ".", "config_file_options", "=", "options", ".", "merge", "(", "self", ".", "config_file_options", ")", "verify_conflicts", "# important, since user can set conflicting options in configuration file", "# Now that everything is verified, re-raise an exception that was raised in the config file", "raise", "wrapped_exception", "unless", "wrapped_exception", ".", "nil?", "configuration_file", "end" ]
This method takes care of parsing and using the configuration file as values Call this once you know where the config file might be located Take a look at how `gym` uses this method @param config_file_name [String] The name of the configuration file to use (optional) @param block_for_missing [Block] A ruby block that is called when there is an unknown method in the configuration file
[ "This", "method", "takes", "care", "of", "parsing", "and", "using", "the", "configuration", "file", "as", "values", "Call", "this", "once", "you", "know", "where", "the", "config", "file", "might", "be", "located", "Take", "a", "look", "at", "how", "gym", "uses", "this", "method" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/configuration/configuration.rb#L163-L194
train
fastlane/fastlane
fastlane/lib/fastlane/other_action.rb
Fastlane.OtherAction.method_missing
def method_missing(method_sym, *arguments, &_block) # We have to go inside the fastlane directory # since in the fastlane runner.rb we do the following # custom_dir = ".." # Dir.chdir(custom_dir) do # this goes one folder up, since we're inside the "fastlane" # folder at that point # Since we call an action from an action we need to go inside # the fastlane folder too self.runner.trigger_action_by_name(method_sym, FastlaneCore::FastlaneFolder.path, true, *arguments) end
ruby
def method_missing(method_sym, *arguments, &_block) # We have to go inside the fastlane directory # since in the fastlane runner.rb we do the following # custom_dir = ".." # Dir.chdir(custom_dir) do # this goes one folder up, since we're inside the "fastlane" # folder at that point # Since we call an action from an action we need to go inside # the fastlane folder too self.runner.trigger_action_by_name(method_sym, FastlaneCore::FastlaneFolder.path, true, *arguments) end
[ "def", "method_missing", "(", "method_sym", ",", "*", "arguments", ",", "&", "_block", ")", "# We have to go inside the fastlane directory", "# since in the fastlane runner.rb we do the following", "# custom_dir = \"..\"", "# Dir.chdir(custom_dir) do", "# this goes one folder up, since we're inside the \"fastlane\"", "# folder at that point", "# Since we call an action from an action we need to go inside", "# the fastlane folder too", "self", ".", "runner", ".", "trigger_action_by_name", "(", "method_sym", ",", "FastlaneCore", "::", "FastlaneFolder", ".", "path", ",", "true", ",", "arguments", ")", "end" ]
Allows the user to call an action from an action
[ "Allows", "the", "user", "to", "call", "an", "action", "from", "an", "action" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/other_action.rb#L13-L27
train
fastlane/fastlane
produce/lib/produce/itunes_connect.rb
Produce.ItunesConnect.language
def language @language = Produce.config[:language] converted = Spaceship::Tunes::LanguageConverter.from_itc_readable_to_itc(@language) @language = converted if converted # overwrite it with the actual value unless AvailableDefaultLanguages.all_languages.include?(@language) UI.user_error!("Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}") end return @language end
ruby
def language @language = Produce.config[:language] converted = Spaceship::Tunes::LanguageConverter.from_itc_readable_to_itc(@language) @language = converted if converted # overwrite it with the actual value unless AvailableDefaultLanguages.all_languages.include?(@language) UI.user_error!("Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}") end return @language end
[ "def", "language", "@language", "=", "Produce", ".", "config", "[", ":language", "]", "converted", "=", "Spaceship", "::", "Tunes", "::", "LanguageConverter", ".", "from_itc_readable_to_itc", "(", "@language", ")", "@language", "=", "converted", "if", "converted", "# overwrite it with the actual value", "unless", "AvailableDefaultLanguages", ".", "all_languages", ".", "include?", "(", "@language", ")", "UI", ".", "user_error!", "(", "\"Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}\"", ")", "end", "return", "@language", "end" ]
Makes sure to get the value for the language Instead of using the user's value `UK English` spaceship should send `English_UK` to the server
[ "Makes", "sure", "to", "get", "the", "value", "for", "the", "language", "Instead", "of", "using", "the", "user", "s", "value", "UK", "English", "spaceship", "should", "send", "English_UK", "to", "the", "server" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/produce/lib/produce/itunes_connect.rb#L79-L90
train
fastlane/fastlane
fastlane/lib/fastlane/runner.rb
Fastlane.Runner.find_alias
def find_alias(action_name) Actions.alias_actions.each do |key, v| next unless Actions.alias_actions[key] next unless Actions.alias_actions[key].include?(action_name) return key end nil end
ruby
def find_alias(action_name) Actions.alias_actions.each do |key, v| next unless Actions.alias_actions[key] next unless Actions.alias_actions[key].include?(action_name) return key end nil end
[ "def", "find_alias", "(", "action_name", ")", "Actions", ".", "alias_actions", ".", "each", "do", "|", "key", ",", "v", "|", "next", "unless", "Actions", ".", "alias_actions", "[", "key", "]", "next", "unless", "Actions", ".", "alias_actions", "[", "key", "]", ".", "include?", "(", "action_name", ")", "return", "key", "end", "nil", "end" ]
lookup if an alias exists
[ "lookup", "if", "an", "alias", "exists" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/runner.rb#L116-L123
train
fastlane/fastlane
fastlane/lib/fastlane/runner.rb
Fastlane.Runner.trigger_action_by_name
def trigger_action_by_name(method_sym, custom_dir, from_action, *arguments) # First, check if there is a predefined method in the actions folder class_ref = class_reference_from_action_name(method_sym) unless class_ref class_ref = class_reference_from_action_alias(method_sym) # notify action that it has been used by alias if class_ref.respond_to?(:alias_used) orig_action = method_sym.to_s arguments = [{}] if arguments.empty? class_ref.alias_used(orig_action, arguments.first) end end # It's important to *not* have this code inside the rescue block # otherwise all NameErrors will be caught and the error message is # confusing begin return self.try_switch_to_lane(method_sym, arguments) rescue LaneNotAvailableError # We don't actually handle this here yet # We just try to use a user configured lane first # and only if there is none, we're gonna check for the # built-in actions end if class_ref if class_ref.respond_to?(:run) # Action is available, now execute it return self.execute_action(method_sym, class_ref, arguments, custom_dir: custom_dir, from_action: from_action) else UI.user_error!("Action '#{method_sym}' of class '#{class_name}' was found, but has no `run` method.") end end # No lane, no action, let's at least show the correct error message if Fastlane.plugin_manager.plugin_is_added_as_dependency?(PluginManager.plugin_prefix + method_sym.to_s) # That's a plugin, but for some reason we can't find it UI.user_error!("Plugin '#{method_sym}' was not properly loaded, make sure to follow the plugin docs for troubleshooting: #{PluginManager::TROUBLESHOOTING_URL}") elsif Fastlane::Actions.formerly_bundled_actions.include?(method_sym.to_s) # This was a formerly bundled action which is now a plugin. UI.verbose(caller.join("\n")) UI.user_error!("The action '#{method_sym}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{method_sym}`") else # So there is no plugin under that name, so just show the error message generated by the lane switch UI.verbose(caller.join("\n")) UI.user_error!("Could not find action, lane or variable '#{method_sym}'. Check out the documentation for more details: https://docs.fastlane.tools/actions") end end
ruby
def trigger_action_by_name(method_sym, custom_dir, from_action, *arguments) # First, check if there is a predefined method in the actions folder class_ref = class_reference_from_action_name(method_sym) unless class_ref class_ref = class_reference_from_action_alias(method_sym) # notify action that it has been used by alias if class_ref.respond_to?(:alias_used) orig_action = method_sym.to_s arguments = [{}] if arguments.empty? class_ref.alias_used(orig_action, arguments.first) end end # It's important to *not* have this code inside the rescue block # otherwise all NameErrors will be caught and the error message is # confusing begin return self.try_switch_to_lane(method_sym, arguments) rescue LaneNotAvailableError # We don't actually handle this here yet # We just try to use a user configured lane first # and only if there is none, we're gonna check for the # built-in actions end if class_ref if class_ref.respond_to?(:run) # Action is available, now execute it return self.execute_action(method_sym, class_ref, arguments, custom_dir: custom_dir, from_action: from_action) else UI.user_error!("Action '#{method_sym}' of class '#{class_name}' was found, but has no `run` method.") end end # No lane, no action, let's at least show the correct error message if Fastlane.plugin_manager.plugin_is_added_as_dependency?(PluginManager.plugin_prefix + method_sym.to_s) # That's a plugin, but for some reason we can't find it UI.user_error!("Plugin '#{method_sym}' was not properly loaded, make sure to follow the plugin docs for troubleshooting: #{PluginManager::TROUBLESHOOTING_URL}") elsif Fastlane::Actions.formerly_bundled_actions.include?(method_sym.to_s) # This was a formerly bundled action which is now a plugin. UI.verbose(caller.join("\n")) UI.user_error!("The action '#{method_sym}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{method_sym}`") else # So there is no plugin under that name, so just show the error message generated by the lane switch UI.verbose(caller.join("\n")) UI.user_error!("Could not find action, lane or variable '#{method_sym}'. Check out the documentation for more details: https://docs.fastlane.tools/actions") end end
[ "def", "trigger_action_by_name", "(", "method_sym", ",", "custom_dir", ",", "from_action", ",", "*", "arguments", ")", "# First, check if there is a predefined method in the actions folder", "class_ref", "=", "class_reference_from_action_name", "(", "method_sym", ")", "unless", "class_ref", "class_ref", "=", "class_reference_from_action_alias", "(", "method_sym", ")", "# notify action that it has been used by alias", "if", "class_ref", ".", "respond_to?", "(", ":alias_used", ")", "orig_action", "=", "method_sym", ".", "to_s", "arguments", "=", "[", "{", "}", "]", "if", "arguments", ".", "empty?", "class_ref", ".", "alias_used", "(", "orig_action", ",", "arguments", ".", "first", ")", "end", "end", "# It's important to *not* have this code inside the rescue block", "# otherwise all NameErrors will be caught and the error message is", "# confusing", "begin", "return", "self", ".", "try_switch_to_lane", "(", "method_sym", ",", "arguments", ")", "rescue", "LaneNotAvailableError", "# We don't actually handle this here yet", "# We just try to use a user configured lane first", "# and only if there is none, we're gonna check for the", "# built-in actions", "end", "if", "class_ref", "if", "class_ref", ".", "respond_to?", "(", ":run", ")", "# Action is available, now execute it", "return", "self", ".", "execute_action", "(", "method_sym", ",", "class_ref", ",", "arguments", ",", "custom_dir", ":", "custom_dir", ",", "from_action", ":", "from_action", ")", "else", "UI", ".", "user_error!", "(", "\"Action '#{method_sym}' of class '#{class_name}' was found, but has no `run` method.\"", ")", "end", "end", "# No lane, no action, let's at least show the correct error message", "if", "Fastlane", ".", "plugin_manager", ".", "plugin_is_added_as_dependency?", "(", "PluginManager", ".", "plugin_prefix", "+", "method_sym", ".", "to_s", ")", "# That's a plugin, but for some reason we can't find it", "UI", ".", "user_error!", "(", "\"Plugin '#{method_sym}' was not properly loaded, make sure to follow the plugin docs for troubleshooting: #{PluginManager::TROUBLESHOOTING_URL}\"", ")", "elsif", "Fastlane", "::", "Actions", ".", "formerly_bundled_actions", ".", "include?", "(", "method_sym", ".", "to_s", ")", "# This was a formerly bundled action which is now a plugin.", "UI", ".", "verbose", "(", "caller", ".", "join", "(", "\"\\n\"", ")", ")", "UI", ".", "user_error!", "(", "\"The action '#{method_sym}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{method_sym}`\"", ")", "else", "# So there is no plugin under that name, so just show the error message generated by the lane switch", "UI", ".", "verbose", "(", "caller", ".", "join", "(", "\"\\n\"", ")", ")", "UI", ".", "user_error!", "(", "\"Could not find action, lane or variable '#{method_sym}'. Check out the documentation for more details: https://docs.fastlane.tools/actions\"", ")", "end", "end" ]
This is being called from `method_missing` from the Fastfile It's also used when an action is called from another action @param from_action Indicates if this action is being trigged by another action. If so, it won't show up in summary.
[ "This", "is", "being", "called", "from", "method_missing", "from", "the", "Fastfile", "It", "s", "also", "used", "when", "an", "action", "is", "called", "from", "another", "action" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/runner.rb#L129-L176
train
fastlane/fastlane
fastlane/lib/fastlane/runner.rb
Fastlane.Runner.add_lane
def add_lane(lane, override = false) lanes[lane.platform] ||= {} if !override && lanes[lane.platform][lane.name] UI.user_error!("Lane '#{lane.name}' was defined multiple times!") end lanes[lane.platform][lane.name] = lane end
ruby
def add_lane(lane, override = false) lanes[lane.platform] ||= {} if !override && lanes[lane.platform][lane.name] UI.user_error!("Lane '#{lane.name}' was defined multiple times!") end lanes[lane.platform][lane.name] = lane end
[ "def", "add_lane", "(", "lane", ",", "override", "=", "false", ")", "lanes", "[", "lane", ".", "platform", "]", "||=", "{", "}", "if", "!", "override", "&&", "lanes", "[", "lane", ".", "platform", "]", "[", "lane", ".", "name", "]", "UI", ".", "user_error!", "(", "\"Lane '#{lane.name}' was defined multiple times!\"", ")", "end", "lanes", "[", "lane", ".", "platform", "]", "[", "lane", ".", "name", "]", "=", "lane", "end" ]
Called internally to setup the runner object @param lane [Lane] A lane object
[ "Called", "internally", "to", "setup", "the", "runner", "object" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/runner.rb#L304-L312
train
fastlane/fastlane
fastlane/lib/fastlane/commands_generator.rb
Fastlane.CommandsGenerator.ensure_fastfile
def ensure_fastfile return true if FastlaneCore::FastlaneFolder.setup? create = UI.confirm('Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called "fastlane". Would you like to set fastlane up?') if create Fastlane::Setup.start end return false end
ruby
def ensure_fastfile return true if FastlaneCore::FastlaneFolder.setup? create = UI.confirm('Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called "fastlane". Would you like to set fastlane up?') if create Fastlane::Setup.start end return false end
[ "def", "ensure_fastfile", "return", "true", "if", "FastlaneCore", "::", "FastlaneFolder", ".", "setup?", "create", "=", "UI", ".", "confirm", "(", "'Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called \"fastlane\". Would you like to set fastlane up?'", ")", "if", "create", "Fastlane", "::", "Setup", ".", "start", "end", "return", "false", "end" ]
Makes sure a Fastfile is available Shows an appropriate message to the user if that's not the case return true if the Fastfile is available
[ "Makes", "sure", "a", "Fastfile", "is", "available", "Shows", "an", "appropriate", "message", "to", "the", "user", "if", "that", "s", "not", "the", "case", "return", "true", "if", "the", "Fastfile", "is", "available" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/commands_generator.rb#L340-L348
train
fastlane/fastlane
deliver/lib/deliver/runner.rb
Deliver.Runner.verify_version
def verify_version app_version = options[:app_version] UI.message("Making sure the latest version on App Store Connect matches '#{app_version}' from the ipa file...") changed = options[:app].ensure_version!(app_version, platform: options[:platform]) if changed UI.success("Successfully set the version to '#{app_version}'") else UI.success("'#{app_version}' is the latest version on App Store Connect") end end
ruby
def verify_version app_version = options[:app_version] UI.message("Making sure the latest version on App Store Connect matches '#{app_version}' from the ipa file...") changed = options[:app].ensure_version!(app_version, platform: options[:platform]) if changed UI.success("Successfully set the version to '#{app_version}'") else UI.success("'#{app_version}' is the latest version on App Store Connect") end end
[ "def", "verify_version", "app_version", "=", "options", "[", ":app_version", "]", "UI", ".", "message", "(", "\"Making sure the latest version on App Store Connect matches '#{app_version}' from the ipa file...\"", ")", "changed", "=", "options", "[", ":app", "]", ".", "ensure_version!", "(", "app_version", ",", "platform", ":", "options", "[", ":platform", "]", ")", "if", "changed", "UI", ".", "success", "(", "\"Successfully set the version to '#{app_version}'\"", ")", "else", "UI", ".", "success", "(", "\"'#{app_version}' is the latest version on App Store Connect\"", ")", "end", "end" ]
Make sure the version on App Store Connect matches the one in the ipa If not, the new version will automatically be created
[ "Make", "sure", "the", "version", "on", "App", "Store", "Connect", "matches", "the", "one", "in", "the", "ipa", "If", "not", "the", "new", "version", "will", "automatically", "be", "created" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/runner.rb#L88-L99
train
fastlane/fastlane
deliver/lib/deliver/runner.rb
Deliver.Runner.upload_metadata
def upload_metadata upload_metadata = UploadMetadata.new upload_screenshots = UploadScreenshots.new # First, collect all the things for the HTML Report screenshots = upload_screenshots.collect_screenshots(options) upload_metadata.load_from_filesystem(options) # Assign "default" values to all languages upload_metadata.assign_defaults(options) # Handle app icon / watch icon prepare_app_icons(options) # Validate validate_html(screenshots) # Commit upload_metadata.upload(options) upload_screenshots.upload(options, screenshots) UploadPriceTier.new.upload(options) UploadAssets.new.upload(options) # e.g. app icon end
ruby
def upload_metadata upload_metadata = UploadMetadata.new upload_screenshots = UploadScreenshots.new # First, collect all the things for the HTML Report screenshots = upload_screenshots.collect_screenshots(options) upload_metadata.load_from_filesystem(options) # Assign "default" values to all languages upload_metadata.assign_defaults(options) # Handle app icon / watch icon prepare_app_icons(options) # Validate validate_html(screenshots) # Commit upload_metadata.upload(options) upload_screenshots.upload(options, screenshots) UploadPriceTier.new.upload(options) UploadAssets.new.upload(options) # e.g. app icon end
[ "def", "upload_metadata", "upload_metadata", "=", "UploadMetadata", ".", "new", "upload_screenshots", "=", "UploadScreenshots", ".", "new", "# First, collect all the things for the HTML Report", "screenshots", "=", "upload_screenshots", ".", "collect_screenshots", "(", "options", ")", "upload_metadata", ".", "load_from_filesystem", "(", "options", ")", "# Assign \"default\" values to all languages", "upload_metadata", ".", "assign_defaults", "(", "options", ")", "# Handle app icon / watch icon", "prepare_app_icons", "(", "options", ")", "# Validate", "validate_html", "(", "screenshots", ")", "# Commit", "upload_metadata", ".", "upload", "(", "options", ")", "upload_screenshots", ".", "upload", "(", "options", ",", "screenshots", ")", "UploadPriceTier", ".", "new", ".", "upload", "(", "options", ")", "UploadAssets", ".", "new", ".", "upload", "(", "options", ")", "# e.g. app icon", "end" ]
Upload all metadata, screenshots, pricing information, etc. to App Store Connect
[ "Upload", "all", "metadata", "screenshots", "pricing", "information", "etc", ".", "to", "App", "Store", "Connect" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/runner.rb#L102-L124
train
fastlane/fastlane
deliver/lib/deliver/runner.rb
Deliver.Runner.upload_binary
def upload_binary UI.message("Uploading binary to App Store Connect") if options[:ipa] package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate( app_id: options[:app].apple_id, ipa_path: options[:ipa], package_path: "/tmp", platform: options[:platform] ) elsif options[:pkg] package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate( app_id: options[:app].apple_id, pkg_path: options[:pkg], package_path: "/tmp", platform: options[:platform] ) end transporter = transporter_for_selected_team result = transporter.upload(options[:app].apple_id, package_path) UI.user_error!("Could not upload binary to App Store Connect. Check out the error above", show_github_issues: true) unless result end
ruby
def upload_binary UI.message("Uploading binary to App Store Connect") if options[:ipa] package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate( app_id: options[:app].apple_id, ipa_path: options[:ipa], package_path: "/tmp", platform: options[:platform] ) elsif options[:pkg] package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate( app_id: options[:app].apple_id, pkg_path: options[:pkg], package_path: "/tmp", platform: options[:platform] ) end transporter = transporter_for_selected_team result = transporter.upload(options[:app].apple_id, package_path) UI.user_error!("Could not upload binary to App Store Connect. Check out the error above", show_github_issues: true) unless result end
[ "def", "upload_binary", "UI", ".", "message", "(", "\"Uploading binary to App Store Connect\"", ")", "if", "options", "[", ":ipa", "]", "package_path", "=", "FastlaneCore", "::", "IpaUploadPackageBuilder", ".", "new", ".", "generate", "(", "app_id", ":", "options", "[", ":app", "]", ".", "apple_id", ",", "ipa_path", ":", "options", "[", ":ipa", "]", ",", "package_path", ":", "\"/tmp\"", ",", "platform", ":", "options", "[", ":platform", "]", ")", "elsif", "options", "[", ":pkg", "]", "package_path", "=", "FastlaneCore", "::", "PkgUploadPackageBuilder", ".", "new", ".", "generate", "(", "app_id", ":", "options", "[", ":app", "]", ".", "apple_id", ",", "pkg_path", ":", "options", "[", ":pkg", "]", ",", "package_path", ":", "\"/tmp\"", ",", "platform", ":", "options", "[", ":platform", "]", ")", "end", "transporter", "=", "transporter_for_selected_team", "result", "=", "transporter", ".", "upload", "(", "options", "[", ":app", "]", ".", "apple_id", ",", "package_path", ")", "UI", ".", "user_error!", "(", "\"Could not upload binary to App Store Connect. Check out the error above\"", ",", "show_github_issues", ":", "true", ")", "unless", "result", "end" ]
Upload the binary to App Store Connect
[ "Upload", "the", "binary", "to", "App", "Store", "Connect" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/deliver/lib/deliver/runner.rb#L141-L162
train
fastlane/fastlane
supply/lib/supply/uploader.rb
Supply.Uploader.upload_binary_data
def upload_binary_data(apk_path) apk_version_code = nil if apk_path UI.message("Preparing apk at path '#{apk_path}' for upload...") apk_version_code = client.upload_apk(apk_path) UI.user_error!("Could not upload #{apk_path}") unless apk_version_code if Supply.config[:obb_main_references_version] && Supply.config[:obb_main_file_size] update_obb(apk_version_code, 'main', Supply.config[:obb_main_references_version], Supply.config[:obb_main_file_size]) end if Supply.config[:obb_patch_references_version] && Supply.config[:obb_patch_file_size] update_obb(apk_version_code, 'patch', Supply.config[:obb_patch_references_version], Supply.config[:obb_patch_file_size]) end upload_obbs(apk_path, apk_version_code) if metadata_path all_languages.each do |language| next if language.start_with?('.') # e.g. . or .. or hidden folders upload_changelog(language, apk_version_code) end end else UI.message("No apk file found, you can pass the path to your apk using the `apk` option") end apk_version_code end
ruby
def upload_binary_data(apk_path) apk_version_code = nil if apk_path UI.message("Preparing apk at path '#{apk_path}' for upload...") apk_version_code = client.upload_apk(apk_path) UI.user_error!("Could not upload #{apk_path}") unless apk_version_code if Supply.config[:obb_main_references_version] && Supply.config[:obb_main_file_size] update_obb(apk_version_code, 'main', Supply.config[:obb_main_references_version], Supply.config[:obb_main_file_size]) end if Supply.config[:obb_patch_references_version] && Supply.config[:obb_patch_file_size] update_obb(apk_version_code, 'patch', Supply.config[:obb_patch_references_version], Supply.config[:obb_patch_file_size]) end upload_obbs(apk_path, apk_version_code) if metadata_path all_languages.each do |language| next if language.start_with?('.') # e.g. . or .. or hidden folders upload_changelog(language, apk_version_code) end end else UI.message("No apk file found, you can pass the path to your apk using the `apk` option") end apk_version_code end
[ "def", "upload_binary_data", "(", "apk_path", ")", "apk_version_code", "=", "nil", "if", "apk_path", "UI", ".", "message", "(", "\"Preparing apk at path '#{apk_path}' for upload...\"", ")", "apk_version_code", "=", "client", ".", "upload_apk", "(", "apk_path", ")", "UI", ".", "user_error!", "(", "\"Could not upload #{apk_path}\"", ")", "unless", "apk_version_code", "if", "Supply", ".", "config", "[", ":obb_main_references_version", "]", "&&", "Supply", ".", "config", "[", ":obb_main_file_size", "]", "update_obb", "(", "apk_version_code", ",", "'main'", ",", "Supply", ".", "config", "[", ":obb_main_references_version", "]", ",", "Supply", ".", "config", "[", ":obb_main_file_size", "]", ")", "end", "if", "Supply", ".", "config", "[", ":obb_patch_references_version", "]", "&&", "Supply", ".", "config", "[", ":obb_patch_file_size", "]", "update_obb", "(", "apk_version_code", ",", "'patch'", ",", "Supply", ".", "config", "[", ":obb_patch_references_version", "]", ",", "Supply", ".", "config", "[", ":obb_patch_file_size", "]", ")", "end", "upload_obbs", "(", "apk_path", ",", "apk_version_code", ")", "if", "metadata_path", "all_languages", ".", "each", "do", "|", "language", "|", "next", "if", "language", ".", "start_with?", "(", "'.'", ")", "# e.g. . or .. or hidden folders", "upload_changelog", "(", "language", ",", "apk_version_code", ")", "end", "end", "else", "UI", ".", "message", "(", "\"No apk file found, you can pass the path to your apk using the `apk` option\"", ")", "end", "apk_version_code", "end" ]
Upload binary apk and obb and corresponding change logs with client @param [String] apk_path Path of the apk file to upload. @return [Integer] The apk version code returned after uploading, or nil if there was a problem
[ "Upload", "binary", "apk", "and", "obb", "and", "corresponding", "change", "logs", "with", "client" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/uploader.rb#L180-L213
train
fastlane/fastlane
supply/lib/supply/uploader.rb
Supply.Uploader.all_languages
def all_languages Dir.entries(metadata_path) .select { |f| File.directory?(File.join(metadata_path, f)) } .reject { |f| f.start_with?('.') } .sort { |x, y| x <=> y } end
ruby
def all_languages Dir.entries(metadata_path) .select { |f| File.directory?(File.join(metadata_path, f)) } .reject { |f| f.start_with?('.') } .sort { |x, y| x <=> y } end
[ "def", "all_languages", "Dir", ".", "entries", "(", "metadata_path", ")", ".", "select", "{", "|", "f", "|", "File", ".", "directory?", "(", "File", ".", "join", "(", "metadata_path", ",", "f", ")", ")", "}", ".", "reject", "{", "|", "f", "|", "f", ".", "start_with?", "(", "'.'", ")", "}", ".", "sort", "{", "|", "x", ",", "y", "|", "x", "<=>", "y", "}", "end" ]
returns only language directories from metadata_path
[ "returns", "only", "language", "directories", "from", "metadata_path" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/uploader.rb#L276-L281
train
fastlane/fastlane
supply/lib/supply/uploader.rb
Supply.Uploader.upload_obbs
def upload_obbs(apk_path, apk_version_code) expansion_paths = find_obbs(apk_path) ['main', 'patch'].each do |type| if expansion_paths[type] upload_obb(expansion_paths[type], type, apk_version_code) end end end
ruby
def upload_obbs(apk_path, apk_version_code) expansion_paths = find_obbs(apk_path) ['main', 'patch'].each do |type| if expansion_paths[type] upload_obb(expansion_paths[type], type, apk_version_code) end end end
[ "def", "upload_obbs", "(", "apk_path", ",", "apk_version_code", ")", "expansion_paths", "=", "find_obbs", "(", "apk_path", ")", "[", "'main'", ",", "'patch'", "]", ".", "each", "do", "|", "type", "|", "if", "expansion_paths", "[", "type", "]", "upload_obb", "(", "expansion_paths", "[", "type", "]", ",", "type", ",", "apk_version_code", ")", "end", "end", "end" ]
searches for obbs in the directory where the apk is located and upload at most one main and one patch file. Do nothing if it finds more than one of either of them.
[ "searches", "for", "obbs", "in", "the", "directory", "where", "the", "apk", "is", "located", "and", "upload", "at", "most", "one", "main", "and", "one", "patch", "file", ".", "Do", "nothing", "if", "it", "finds", "more", "than", "one", "of", "either", "of", "them", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/uploader.rb#L294-L301
train
fastlane/fastlane
fastlane_core/lib/fastlane_core/configuration/commander_generator.rb
FastlaneCore.CommanderGenerator.generate
def generate(options, command: nil) # First, enable `always_trace`, to show the stack trace always_trace! used_switches = [] options.each do |option| next if option.description.to_s.empty? # "private" options next unless option.display_in_shell short_switch = option.short_option key = option.key validate_short_switch(used_switches, short_switch, key) type = option.data_type # We added type: Hash to code generation, but Ruby's OptionParser doesn't like that # so we need to switch that to something that is supported, luckily, we have an `is_string` # property and if that is false, we'll default to nil if type == Hash type = option.is_string ? String : nil end # Boolean is a fastlane thing, it's either TrueClass, or FalseClass, but we won't know # that until runtime, so nil is the best we get if type == Fastlane::Boolean type = nil end # This is an important bit of trickery to solve the boolean option situation. # # Typically, boolean command line flags do not accept trailing values. If the flag # is present, the value is true, if it is missing, the value is false. fastlane # supports this style of flag. For example, you can specify a flag like `--clean`, # and the :clean option will be true. # # However, fastlane also supports another boolean flag style that accepts trailing # values much like options for Strings and other value types. That looks like # `--include_bitcode false` The problem is that this does not work out of the box # for Commander and OptionsParser. So, we need to get tricky. # # The value_appendix below acts as a placeholder in the switch definition that # states that we expect to have a trailing value for our options. When an option # declares a data type, we use the name of that data type in all caps like: # "--devices ARRAY". When the data type is nil, this implies that we're going # to be doing some special handling on that value. One special thing we do # automatically in Configuration is to coerce special Strings into boolean values. # # If the data type is nil, the trick we do is to specify a value placeholder, but # we wrap it in [] brackets to mark it as optional. That means that the trailing # value may or may not be present for this flag. If the flag is present, but the # value is not, we get a value of `true`. Perfect for the boolean flag base-case! # If the value is there, we'll actually get it back as a String, which we can # later coerce into a boolean. # # In this way we support handling boolean flags with or without trailing values. value_appendix = (type || '[VALUE]').to_s.upcase long_switch = "--#{option.key} #{value_appendix}" description = option.description description += " (#{option.env_name})" unless option.env_name.to_s.empty? # We compact this array here to remove the short_switch variable if it is nil. # Passing a nil value to global_option has been shown to create problems with # option parsing! # # See: https://github.com/fastlane/fastlane_core/pull/89 # # If we don't have a data type for this option, we tell it to act like a String. # This allows us to get a reasonable value for boolean options that can be # automatically coerced or otherwise handled by the ConfigItem for others. args = [short_switch, long_switch, (type || String), description].compact if command command.option(*args) else # This is the call to Commander to set up the option we've been building. global_option(*args) end end end
ruby
def generate(options, command: nil) # First, enable `always_trace`, to show the stack trace always_trace! used_switches = [] options.each do |option| next if option.description.to_s.empty? # "private" options next unless option.display_in_shell short_switch = option.short_option key = option.key validate_short_switch(used_switches, short_switch, key) type = option.data_type # We added type: Hash to code generation, but Ruby's OptionParser doesn't like that # so we need to switch that to something that is supported, luckily, we have an `is_string` # property and if that is false, we'll default to nil if type == Hash type = option.is_string ? String : nil end # Boolean is a fastlane thing, it's either TrueClass, or FalseClass, but we won't know # that until runtime, so nil is the best we get if type == Fastlane::Boolean type = nil end # This is an important bit of trickery to solve the boolean option situation. # # Typically, boolean command line flags do not accept trailing values. If the flag # is present, the value is true, if it is missing, the value is false. fastlane # supports this style of flag. For example, you can specify a flag like `--clean`, # and the :clean option will be true. # # However, fastlane also supports another boolean flag style that accepts trailing # values much like options for Strings and other value types. That looks like # `--include_bitcode false` The problem is that this does not work out of the box # for Commander and OptionsParser. So, we need to get tricky. # # The value_appendix below acts as a placeholder in the switch definition that # states that we expect to have a trailing value for our options. When an option # declares a data type, we use the name of that data type in all caps like: # "--devices ARRAY". When the data type is nil, this implies that we're going # to be doing some special handling on that value. One special thing we do # automatically in Configuration is to coerce special Strings into boolean values. # # If the data type is nil, the trick we do is to specify a value placeholder, but # we wrap it in [] brackets to mark it as optional. That means that the trailing # value may or may not be present for this flag. If the flag is present, but the # value is not, we get a value of `true`. Perfect for the boolean flag base-case! # If the value is there, we'll actually get it back as a String, which we can # later coerce into a boolean. # # In this way we support handling boolean flags with or without trailing values. value_appendix = (type || '[VALUE]').to_s.upcase long_switch = "--#{option.key} #{value_appendix}" description = option.description description += " (#{option.env_name})" unless option.env_name.to_s.empty? # We compact this array here to remove the short_switch variable if it is nil. # Passing a nil value to global_option has been shown to create problems with # option parsing! # # See: https://github.com/fastlane/fastlane_core/pull/89 # # If we don't have a data type for this option, we tell it to act like a String. # This allows us to get a reasonable value for boolean options that can be # automatically coerced or otherwise handled by the ConfigItem for others. args = [short_switch, long_switch, (type || String), description].compact if command command.option(*args) else # This is the call to Commander to set up the option we've been building. global_option(*args) end end end
[ "def", "generate", "(", "options", ",", "command", ":", "nil", ")", "# First, enable `always_trace`, to show the stack trace", "always_trace!", "used_switches", "=", "[", "]", "options", ".", "each", "do", "|", "option", "|", "next", "if", "option", ".", "description", ".", "to_s", ".", "empty?", "# \"private\" options", "next", "unless", "option", ".", "display_in_shell", "short_switch", "=", "option", ".", "short_option", "key", "=", "option", ".", "key", "validate_short_switch", "(", "used_switches", ",", "short_switch", ",", "key", ")", "type", "=", "option", ".", "data_type", "# We added type: Hash to code generation, but Ruby's OptionParser doesn't like that", "# so we need to switch that to something that is supported, luckily, we have an `is_string`", "# property and if that is false, we'll default to nil", "if", "type", "==", "Hash", "type", "=", "option", ".", "is_string", "?", "String", ":", "nil", "end", "# Boolean is a fastlane thing, it's either TrueClass, or FalseClass, but we won't know", "# that until runtime, so nil is the best we get", "if", "type", "==", "Fastlane", "::", "Boolean", "type", "=", "nil", "end", "# This is an important bit of trickery to solve the boolean option situation.", "#", "# Typically, boolean command line flags do not accept trailing values. If the flag", "# is present, the value is true, if it is missing, the value is false. fastlane", "# supports this style of flag. For example, you can specify a flag like `--clean`,", "# and the :clean option will be true.", "#", "# However, fastlane also supports another boolean flag style that accepts trailing", "# values much like options for Strings and other value types. That looks like", "# `--include_bitcode false` The problem is that this does not work out of the box", "# for Commander and OptionsParser. So, we need to get tricky.", "#", "# The value_appendix below acts as a placeholder in the switch definition that", "# states that we expect to have a trailing value for our options. When an option", "# declares a data type, we use the name of that data type in all caps like:", "# \"--devices ARRAY\". When the data type is nil, this implies that we're going", "# to be doing some special handling on that value. One special thing we do", "# automatically in Configuration is to coerce special Strings into boolean values.", "#", "# If the data type is nil, the trick we do is to specify a value placeholder, but", "# we wrap it in [] brackets to mark it as optional. That means that the trailing", "# value may or may not be present for this flag. If the flag is present, but the", "# value is not, we get a value of `true`. Perfect for the boolean flag base-case!", "# If the value is there, we'll actually get it back as a String, which we can", "# later coerce into a boolean.", "#", "# In this way we support handling boolean flags with or without trailing values.", "value_appendix", "=", "(", "type", "||", "'[VALUE]'", ")", ".", "to_s", ".", "upcase", "long_switch", "=", "\"--#{option.key} #{value_appendix}\"", "description", "=", "option", ".", "description", "description", "+=", "\" (#{option.env_name})\"", "unless", "option", ".", "env_name", ".", "to_s", ".", "empty?", "# We compact this array here to remove the short_switch variable if it is nil.", "# Passing a nil value to global_option has been shown to create problems with", "# option parsing!", "#", "# See: https://github.com/fastlane/fastlane_core/pull/89", "#", "# If we don't have a data type for this option, we tell it to act like a String.", "# This allows us to get a reasonable value for boolean options that can be", "# automatically coerced or otherwise handled by the ConfigItem for others.", "args", "=", "[", "short_switch", ",", "long_switch", ",", "(", "type", "||", "String", ")", ",", "description", "]", ".", "compact", "if", "command", "command", ".", "option", "(", "args", ")", "else", "# This is the call to Commander to set up the option we've been building.", "global_option", "(", "args", ")", "end", "end", "end" ]
Calls the appropriate methods for commander to show the available parameters
[ "Calls", "the", "appropriate", "methods", "for", "commander", "to", "show", "the", "available", "parameters" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane_core/lib/fastlane_core/configuration/commander_generator.rb#L11-L90
train
fastlane/fastlane
scan/lib/scan/xcpretty_reporter_options_generator.rb
Scan.XCPrettyReporterOptionsGenerator.generate_reporter_options
def generate_reporter_options reporter = [] valid_types = @output_types & SUPPORTED_REPORT_TYPES valid_types.each do |raw_type| type = raw_type.strip output_path = File.join(File.expand_path(@output_directory), determine_output_file_name(type)) reporter << "--report #{type}" reporter << "--output '#{output_path}'" if type == "html" && @open_report Scan.cache[:open_html_report_path] = output_path end end # adds another junit reporter in case the user does not specify one # this will be used to generate a results table and then discarded require 'tempfile' @temp_junit_report = Tempfile.new("junit_report") Scan.cache[:temp_junit_report] = @temp_junit_report.path reporter << "--report junit" reporter << "--output '#{Scan.cache[:temp_junit_report]}'" return reporter end
ruby
def generate_reporter_options reporter = [] valid_types = @output_types & SUPPORTED_REPORT_TYPES valid_types.each do |raw_type| type = raw_type.strip output_path = File.join(File.expand_path(@output_directory), determine_output_file_name(type)) reporter << "--report #{type}" reporter << "--output '#{output_path}'" if type == "html" && @open_report Scan.cache[:open_html_report_path] = output_path end end # adds another junit reporter in case the user does not specify one # this will be used to generate a results table and then discarded require 'tempfile' @temp_junit_report = Tempfile.new("junit_report") Scan.cache[:temp_junit_report] = @temp_junit_report.path reporter << "--report junit" reporter << "--output '#{Scan.cache[:temp_junit_report]}'" return reporter end
[ "def", "generate_reporter_options", "reporter", "=", "[", "]", "valid_types", "=", "@output_types", "&", "SUPPORTED_REPORT_TYPES", "valid_types", ".", "each", "do", "|", "raw_type", "|", "type", "=", "raw_type", ".", "strip", "output_path", "=", "File", ".", "join", "(", "File", ".", "expand_path", "(", "@output_directory", ")", ",", "determine_output_file_name", "(", "type", ")", ")", "reporter", "<<", "\"--report #{type}\"", "reporter", "<<", "\"--output '#{output_path}'\"", "if", "type", "==", "\"html\"", "&&", "@open_report", "Scan", ".", "cache", "[", ":open_html_report_path", "]", "=", "output_path", "end", "end", "# adds another junit reporter in case the user does not specify one", "# this will be used to generate a results table and then discarded", "require", "'tempfile'", "@temp_junit_report", "=", "Tempfile", ".", "new", "(", "\"junit_report\"", ")", "Scan", ".", "cache", "[", ":temp_junit_report", "]", "=", "@temp_junit_report", ".", "path", "reporter", "<<", "\"--report junit\"", "reporter", "<<", "\"--output '#{Scan.cache[:temp_junit_report]}'\"", "return", "reporter", "end" ]
Intialize with values from Scan.config matching these param names
[ "Intialize", "with", "values", "from", "Scan", ".", "config", "matching", "these", "param", "names" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/scan/lib/scan/xcpretty_reporter_options_generator.rb#L44-L67
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.abort_current_edit
def abort_current_edit ensure_active_edit! call_google_api { client.delete_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
ruby
def abort_current_edit ensure_active_edit! call_google_api { client.delete_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
[ "def", "abort_current_edit", "ensure_active_edit!", "call_google_api", "{", "client", ".", "delete_edit", "(", "current_package_name", ",", "current_edit", ".", "id", ")", "}", "self", ".", "current_edit", "=", "nil", "self", ".", "current_package_name", "=", "nil", "end" ]
Aborts the current edit deleting all pending changes
[ "Aborts", "the", "current", "edit", "deleting", "all", "pending", "changes" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L144-L151
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.commit_current_edit!
def commit_current_edit! ensure_active_edit! call_google_api { client.commit_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
ruby
def commit_current_edit! ensure_active_edit! call_google_api { client.commit_edit(current_package_name, current_edit.id) } self.current_edit = nil self.current_package_name = nil end
[ "def", "commit_current_edit!", "ensure_active_edit!", "call_google_api", "{", "client", ".", "commit_edit", "(", "current_package_name", ",", "current_edit", ".", "id", ")", "}", "self", ".", "current_edit", "=", "nil", "self", ".", "current_package_name", "=", "nil", "end" ]
Commits the current edit saving all pending changes on Google Play
[ "Commits", "the", "current", "edit", "saving", "all", "pending", "changes", "on", "Google", "Play" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L161-L168
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.listing_for_language
def listing_for_language(language) ensure_active_edit! begin result = client.get_listing( current_package_name, current_edit.id, language ) return Listing.new(self, language, result) rescue Google::Apis::ClientError => e return Listing.new(self, language) if e.status_code == 404 # create a new empty listing raise end end
ruby
def listing_for_language(language) ensure_active_edit! begin result = client.get_listing( current_package_name, current_edit.id, language ) return Listing.new(self, language, result) rescue Google::Apis::ClientError => e return Listing.new(self, language) if e.status_code == 404 # create a new empty listing raise end end
[ "def", "listing_for_language", "(", "language", ")", "ensure_active_edit!", "begin", "result", "=", "client", ".", "get_listing", "(", "current_package_name", ",", "current_edit", ".", "id", ",", "language", ")", "return", "Listing", ".", "new", "(", "self", ",", "language", ",", "result", ")", "rescue", "Google", "::", "Apis", "::", "ClientError", "=>", "e", "return", "Listing", ".", "new", "(", "self", ",", "language", ")", "if", "e", ".", "status_code", "==", "404", "# create a new empty listing", "raise", "end", "end" ]
Returns the listing for the given language filled with the current values if it already exists
[ "Returns", "the", "listing", "for", "the", "given", "language", "filled", "with", "the", "current", "values", "if", "it", "already", "exists" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L187-L202
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.apks_version_codes
def apks_version_codes ensure_active_edit! result = call_google_api { client.list_apks(current_package_name, current_edit.id) } return Array(result.apks).map(&:version_code) end
ruby
def apks_version_codes ensure_active_edit! result = call_google_api { client.list_apks(current_package_name, current_edit.id) } return Array(result.apks).map(&:version_code) end
[ "def", "apks_version_codes", "ensure_active_edit!", "result", "=", "call_google_api", "{", "client", ".", "list_apks", "(", "current_package_name", ",", "current_edit", ".", "id", ")", "}", "return", "Array", "(", "result", ".", "apks", ")", ".", "map", "(", ":version_code", ")", "end" ]
Get a list of all APK version codes - returns the list of version codes
[ "Get", "a", "list", "of", "all", "APK", "version", "codes", "-", "returns", "the", "list", "of", "version", "codes" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L205-L211
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.aab_version_codes
def aab_version_codes ensure_active_edit! result = call_google_api { client.list_edit_bundles(current_package_name, current_edit.id) } return Array(result.bundles).map(&:version_code) end
ruby
def aab_version_codes ensure_active_edit! result = call_google_api { client.list_edit_bundles(current_package_name, current_edit.id) } return Array(result.bundles).map(&:version_code) end
[ "def", "aab_version_codes", "ensure_active_edit!", "result", "=", "call_google_api", "{", "client", ".", "list_edit_bundles", "(", "current_package_name", ",", "current_edit", ".", "id", ")", "}", "return", "Array", "(", "result", ".", "bundles", ")", ".", "map", "(", ":version_code", ")", "end" ]
Get a list of all AAB version codes - returns the list of version codes
[ "Get", "a", "list", "of", "all", "AAB", "version", "codes", "-", "returns", "the", "list", "of", "version", "codes" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L214-L220
train
fastlane/fastlane
supply/lib/supply/client.rb
Supply.Client.track_version_codes
def track_version_codes(track) ensure_active_edit! begin result = client.get_track( current_package_name, current_edit.id, track ) return result.version_codes || [] rescue Google::Apis::ClientError => e return [] if e.status_code == 404 && e.to_s.include?("trackEmpty") raise end end
ruby
def track_version_codes(track) ensure_active_edit! begin result = client.get_track( current_package_name, current_edit.id, track ) return result.version_codes || [] rescue Google::Apis::ClientError => e return [] if e.status_code == 404 && e.to_s.include?("trackEmpty") raise end end
[ "def", "track_version_codes", "(", "track", ")", "ensure_active_edit!", "begin", "result", "=", "client", ".", "get_track", "(", "current_package_name", ",", "current_edit", ".", "id", ",", "track", ")", "return", "result", ".", "version_codes", "||", "[", "]", "rescue", "Google", "::", "Apis", "::", "ClientError", "=>", "e", "return", "[", "]", "if", "e", ".", "status_code", "==", "404", "&&", "e", ".", "to_s", ".", "include?", "(", "\"trackEmpty\"", ")", "raise", "end", "end" ]
Get list of version codes for track
[ "Get", "list", "of", "version", "codes", "for", "track" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/supply/lib/supply/client.rb#L337-L351
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_manager.rb
Fastlane.PluginManager.available_gems
def available_gems return [] unless gemfile_path dsl = Bundler::Dsl.evaluate(gemfile_path, nil, true) return dsl.dependencies.map(&:name) end
ruby
def available_gems return [] unless gemfile_path dsl = Bundler::Dsl.evaluate(gemfile_path, nil, true) return dsl.dependencies.map(&:name) end
[ "def", "available_gems", "return", "[", "]", "unless", "gemfile_path", "dsl", "=", "Bundler", "::", "Dsl", ".", "evaluate", "(", "gemfile_path", ",", "nil", ",", "true", ")", "return", "dsl", ".", "dependencies", ".", "map", "(", ":name", ")", "end" ]
Returns an array of gems that are added to the Gemfile or Pluginfile
[ "Returns", "an", "array", "of", "gems", "that", "are", "added", "to", "the", "Gemfile", "or", "Pluginfile" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_manager.rb#L55-L59
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_manager.rb
Fastlane.PluginManager.plugin_is_added_as_dependency?
def plugin_is_added_as_dependency?(plugin_name) UI.user_error!("fastlane plugins must start with '#{self.class.plugin_prefix}' string") unless plugin_name.start_with?(self.class.plugin_prefix) return available_plugins.include?(plugin_name) end
ruby
def plugin_is_added_as_dependency?(plugin_name) UI.user_error!("fastlane plugins must start with '#{self.class.plugin_prefix}' string") unless plugin_name.start_with?(self.class.plugin_prefix) return available_plugins.include?(plugin_name) end
[ "def", "plugin_is_added_as_dependency?", "(", "plugin_name", ")", "UI", ".", "user_error!", "(", "\"fastlane plugins must start with '#{self.class.plugin_prefix}' string\"", ")", "unless", "plugin_name", ".", "start_with?", "(", "self", ".", "class", ".", "plugin_prefix", ")", "return", "available_plugins", ".", "include?", "(", "plugin_name", ")", "end" ]
Check if a plugin is added as dependency to either the Gemfile or the Pluginfile
[ "Check", "if", "a", "plugin", "is", "added", "as", "dependency", "to", "either", "the", "Gemfile", "or", "the", "Pluginfile" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_manager.rb#L71-L74
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_manager.rb
Fastlane.PluginManager.attach_plugins_to_gemfile!
def attach_plugins_to_gemfile!(path_to_gemfile) content = gemfile_content || (AUTOGENERATED_LINE + GEMFILE_SOURCE_LINE) # We have to make sure fastlane is also added to the Gemfile, since we now use # bundler to run fastlane content += "\ngem 'fastlane'\n" unless available_gems.include?('fastlane') content += "\n#{self.class.code_to_attach}\n" File.write(path_to_gemfile, content) end
ruby
def attach_plugins_to_gemfile!(path_to_gemfile) content = gemfile_content || (AUTOGENERATED_LINE + GEMFILE_SOURCE_LINE) # We have to make sure fastlane is also added to the Gemfile, since we now use # bundler to run fastlane content += "\ngem 'fastlane'\n" unless available_gems.include?('fastlane') content += "\n#{self.class.code_to_attach}\n" File.write(path_to_gemfile, content) end
[ "def", "attach_plugins_to_gemfile!", "(", "path_to_gemfile", ")", "content", "=", "gemfile_content", "||", "(", "AUTOGENERATED_LINE", "+", "GEMFILE_SOURCE_LINE", ")", "# We have to make sure fastlane is also added to the Gemfile, since we now use", "# bundler to run fastlane", "content", "+=", "\"\\ngem 'fastlane'\\n\"", "unless", "available_gems", ".", "include?", "(", "'fastlane'", ")", "content", "+=", "\"\\n#{self.class.code_to_attach}\\n\"", "File", ".", "write", "(", "path_to_gemfile", ",", "content", ")", "end" ]
Modify the user's Gemfile to load the plugins
[ "Modify", "the", "user", "s", "Gemfile", "to", "load", "the", "plugins" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_manager.rb#L142-L151
train
fastlane/fastlane
fastlane/lib/fastlane/plugins/plugin_manager.rb
Fastlane.PluginManager.print_plugin_information
def print_plugin_information(references) rows = references.collect do |current| if current[1][:actions].empty? # Something is wrong with this plugin, no available actions [current[0].red, current[1][:version_number], "No actions found".red] else [current[0], current[1][:version_number], current[1][:actions].join("\n")] end end require 'terminal-table' puts(Terminal::Table.new({ rows: FastlaneCore::PrintTable.transform_output(rows), title: "Used plugins".green, headings: ["Plugin", "Version", "Action"] })) puts("") end
ruby
def print_plugin_information(references) rows = references.collect do |current| if current[1][:actions].empty? # Something is wrong with this plugin, no available actions [current[0].red, current[1][:version_number], "No actions found".red] else [current[0], current[1][:version_number], current[1][:actions].join("\n")] end end require 'terminal-table' puts(Terminal::Table.new({ rows: FastlaneCore::PrintTable.transform_output(rows), title: "Used plugins".green, headings: ["Plugin", "Version", "Action"] })) puts("") end
[ "def", "print_plugin_information", "(", "references", ")", "rows", "=", "references", ".", "collect", "do", "|", "current", "|", "if", "current", "[", "1", "]", "[", ":actions", "]", ".", "empty?", "# Something is wrong with this plugin, no available actions", "[", "current", "[", "0", "]", ".", "red", ",", "current", "[", "1", "]", "[", ":version_number", "]", ",", "\"No actions found\"", ".", "red", "]", "else", "[", "current", "[", "0", "]", ",", "current", "[", "1", "]", "[", ":version_number", "]", ",", "current", "[", "1", "]", "[", ":actions", "]", ".", "join", "(", "\"\\n\"", ")", "]", "end", "end", "require", "'terminal-table'", "puts", "(", "Terminal", "::", "Table", ".", "new", "(", "{", "rows", ":", "FastlaneCore", "::", "PrintTable", ".", "transform_output", "(", "rows", ")", ",", "title", ":", "\"Used plugins\"", ".", "green", ",", "headings", ":", "[", "\"Plugin\"", ",", "\"Version\"", ",", "\"Action\"", "]", "}", ")", ")", "puts", "(", "\"\"", ")", "end" ]
Prints a table all the plugins that were loaded
[ "Prints", "a", "table", "all", "the", "plugins", "that", "were", "loaded" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/fastlane/lib/fastlane/plugins/plugin_manager.rb#L319-L336
train
fastlane/fastlane
screengrab/lib/screengrab/runner.rb
Screengrab.Runner.if_device_path_exists
def if_device_path_exists(device_serial, device_path) return if run_adb_command("adb -s #{device_serial} shell ls #{device_path}", print_all: false, print_command: false).include?('No such file') yield(device_path) rescue # Some versions of ADB will have a non-zero exit status for this, which will cause the executor to raise. # We can safely ignore that and treat it as if it returned 'No such file' end
ruby
def if_device_path_exists(device_serial, device_path) return if run_adb_command("adb -s #{device_serial} shell ls #{device_path}", print_all: false, print_command: false).include?('No such file') yield(device_path) rescue # Some versions of ADB will have a non-zero exit status for this, which will cause the executor to raise. # We can safely ignore that and treat it as if it returned 'No such file' end
[ "def", "if_device_path_exists", "(", "device_serial", ",", "device_path", ")", "return", "if", "run_adb_command", "(", "\"adb -s #{device_serial} shell ls #{device_path}\"", ",", "print_all", ":", "false", ",", "print_command", ":", "false", ")", ".", "include?", "(", "'No such file'", ")", "yield", "(", "device_path", ")", "rescue", "# Some versions of ADB will have a non-zero exit status for this, which will cause the executor to raise.", "# We can safely ignore that and treat it as if it returned 'No such file'", "end" ]
Some device commands fail if executed against a device path that does not exist, so this helper method provides a way to conditionally execute a block only if the provided path exists on the device.
[ "Some", "device", "commands", "fail", "if", "executed", "against", "a", "device", "path", "that", "does", "not", "exist", "so", "this", "helper", "method", "provides", "a", "way", "to", "conditionally", "execute", "a", "block", "only", "if", "the", "provided", "path", "exists", "on", "the", "device", "." ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/screengrab/lib/screengrab/runner.rb#L349-L358
train
fastlane/fastlane
screengrab/lib/screengrab/runner.rb
Screengrab.Runner.installed_packages
def installed_packages(device_serial) packages = run_adb_command("adb -s #{device_serial} shell pm list packages", print_all: true, print_command: true) packages.split("\n").map { |package| package.gsub("package:", "") } end
ruby
def installed_packages(device_serial) packages = run_adb_command("adb -s #{device_serial} shell pm list packages", print_all: true, print_command: true) packages.split("\n").map { |package| package.gsub("package:", "") } end
[ "def", "installed_packages", "(", "device_serial", ")", "packages", "=", "run_adb_command", "(", "\"adb -s #{device_serial} shell pm list packages\"", ",", "print_all", ":", "true", ",", "print_command", ":", "true", ")", "packages", ".", "split", "(", "\"\\n\"", ")", ".", "map", "{", "|", "package", "|", "package", ".", "gsub", "(", "\"package:\"", ",", "\"\"", ")", "}", "end" ]
Return an array of packages that are installed on the device
[ "Return", "an", "array", "of", "packages", "that", "are", "installed", "on", "the", "device" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/screengrab/lib/screengrab/runner.rb#L361-L366
train
fastlane/fastlane
sigh/lib/sigh/runner.rb
Sigh.Runner.fetch_profiles
def fetch_profiles UI.message("Fetching profiles...") results = profile_type.find_by_bundle_id(bundle_id: Sigh.config[:app_identifier], mac: Sigh.config[:platform].to_s == 'macos', sub_platform: Sigh.config[:platform].to_s == 'tvos' ? 'tvOS' : nil) results = results.find_all do |current_profile| if current_profile.valid? || Sigh.config[:force] true else UI.message("Provisioning Profile '#{current_profile.name}' is not valid, skipping this one...") false end end # Take the provisioning profile name into account results = filter_profiles_by_name(results) if Sigh.config[:provisioning_name].to_s.length > 0 return results if Sigh.config[:skip_certificate_verification] UI.message("Verifying certificates...") return results.find_all do |current_profile| installed = false # Attempts to download all certificates from this profile # for checking if they are installed. # `cert.download_raw` can fail if the user is a # "member" and not an a "admin" raw_certs = current_profile.certificates.map do |cert| begin raw_cert = cert.download_raw rescue => error UI.important("Cannot download cert #{cert.id} - #{error.message}") raw_cert = nil end { downloaded: raw_cert, cert: cert } end # Makes sure we have the certificate installed on the local machine raw_certs.each do |current_cert| # Skip certificates that failed to download next unless current_cert[:downloaded] file = Tempfile.new('cert') file.write(current_cert[:downloaded]) file.close if FastlaneCore::CertChecker.installed?(file.path) installed = true else UI.message("Certificate for Provisioning Profile '#{current_profile.name}' not available locally: #{current_cert[:cert].id}, skipping this one...") end end installed && current_profile.certificate_valid? end end
ruby
def fetch_profiles UI.message("Fetching profiles...") results = profile_type.find_by_bundle_id(bundle_id: Sigh.config[:app_identifier], mac: Sigh.config[:platform].to_s == 'macos', sub_platform: Sigh.config[:platform].to_s == 'tvos' ? 'tvOS' : nil) results = results.find_all do |current_profile| if current_profile.valid? || Sigh.config[:force] true else UI.message("Provisioning Profile '#{current_profile.name}' is not valid, skipping this one...") false end end # Take the provisioning profile name into account results = filter_profiles_by_name(results) if Sigh.config[:provisioning_name].to_s.length > 0 return results if Sigh.config[:skip_certificate_verification] UI.message("Verifying certificates...") return results.find_all do |current_profile| installed = false # Attempts to download all certificates from this profile # for checking if they are installed. # `cert.download_raw` can fail if the user is a # "member" and not an a "admin" raw_certs = current_profile.certificates.map do |cert| begin raw_cert = cert.download_raw rescue => error UI.important("Cannot download cert #{cert.id} - #{error.message}") raw_cert = nil end { downloaded: raw_cert, cert: cert } end # Makes sure we have the certificate installed on the local machine raw_certs.each do |current_cert| # Skip certificates that failed to download next unless current_cert[:downloaded] file = Tempfile.new('cert') file.write(current_cert[:downloaded]) file.close if FastlaneCore::CertChecker.installed?(file.path) installed = true else UI.message("Certificate for Provisioning Profile '#{current_profile.name}' not available locally: #{current_cert[:cert].id}, skipping this one...") end end installed && current_profile.certificate_valid? end end
[ "def", "fetch_profiles", "UI", ".", "message", "(", "\"Fetching profiles...\"", ")", "results", "=", "profile_type", ".", "find_by_bundle_id", "(", "bundle_id", ":", "Sigh", ".", "config", "[", ":app_identifier", "]", ",", "mac", ":", "Sigh", ".", "config", "[", ":platform", "]", ".", "to_s", "==", "'macos'", ",", "sub_platform", ":", "Sigh", ".", "config", "[", ":platform", "]", ".", "to_s", "==", "'tvos'", "?", "'tvOS'", ":", "nil", ")", "results", "=", "results", ".", "find_all", "do", "|", "current_profile", "|", "if", "current_profile", ".", "valid?", "||", "Sigh", ".", "config", "[", ":force", "]", "true", "else", "UI", ".", "message", "(", "\"Provisioning Profile '#{current_profile.name}' is not valid, skipping this one...\"", ")", "false", "end", "end", "# Take the provisioning profile name into account", "results", "=", "filter_profiles_by_name", "(", "results", ")", "if", "Sigh", ".", "config", "[", ":provisioning_name", "]", ".", "to_s", ".", "length", ">", "0", "return", "results", "if", "Sigh", ".", "config", "[", ":skip_certificate_verification", "]", "UI", ".", "message", "(", "\"Verifying certificates...\"", ")", "return", "results", ".", "find_all", "do", "|", "current_profile", "|", "installed", "=", "false", "# Attempts to download all certificates from this profile", "# for checking if they are installed.", "# `cert.download_raw` can fail if the user is a", "# \"member\" and not an a \"admin\"", "raw_certs", "=", "current_profile", ".", "certificates", ".", "map", "do", "|", "cert", "|", "begin", "raw_cert", "=", "cert", ".", "download_raw", "rescue", "=>", "error", "UI", ".", "important", "(", "\"Cannot download cert #{cert.id} - #{error.message}\"", ")", "raw_cert", "=", "nil", "end", "{", "downloaded", ":", "raw_cert", ",", "cert", ":", "cert", "}", "end", "# Makes sure we have the certificate installed on the local machine", "raw_certs", ".", "each", "do", "|", "current_cert", "|", "# Skip certificates that failed to download", "next", "unless", "current_cert", "[", ":downloaded", "]", "file", "=", "Tempfile", ".", "new", "(", "'cert'", ")", "file", ".", "write", "(", "current_cert", "[", ":downloaded", "]", ")", "file", ".", "close", "if", "FastlaneCore", "::", "CertChecker", ".", "installed?", "(", "file", ".", "path", ")", "installed", "=", "true", "else", "UI", ".", "message", "(", "\"Certificate for Provisioning Profile '#{current_profile.name}' not available locally: #{current_cert[:cert].id}, skipping this one...\"", ")", "end", "end", "installed", "&&", "current_profile", ".", "certificate_valid?", "end", "end" ]
Fetches a profile matching the user's search requirements
[ "Fetches", "a", "profile", "matching", "the", "user", "s", "search", "requirements" ]
457c5d647c77f0e078dafa5129da616914e002c5
https://github.com/fastlane/fastlane/blob/457c5d647c77f0e078dafa5129da616914e002c5/sigh/lib/sigh/runner.rb#L68-L119
train