frameit/lib/frameit/editor.rb
# Fetches the title + keyword for this particular screenshot
Fetches the title + keyword for this particular screenshot
Fetches the title + keyword for this particular screenshot
def fetch_text(type)
      UI.user_error!("Valid parameters :keyword, :title") unless [:keyword, :title].include?(type)
      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 
      end
      UI.verbose("Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file")
      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 
      if type == :title and !text
        UI.user_error!("Could not get title for screenshot #{screenshot.path}. Please provide one in your Framefile.json or title.strings")
      end
      return text
    end
def fetch_text ( type ) UI . user_error! ( "Valid parameters :keyword, :title" ) unless [ :keyword , :title ] . include? ( type ) 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 end UI . verbose ( "Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file" ) 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 if type == :title and ! text UI . user_error! ( "Could not get title for screenshot #{screenshot.path}. Please provide one in your Framefile.json or title.strings" ) end return text end
Fetches the title + keyword for this particular screenshot
Fetches the title + keyword for this particular screenshot
# Try to get it from a keyword.strings or title.strings file # Ignore empty string # No string files, fallback to Framefile config # Ignore empty string # title is mandatory
type
<not_specific>