Class: Establish::AppMetadata
- Inherits:
-
Object
- Object
- Establish::AppMetadata
- Defined in:
- lib/establish/app_metadata.rb
Constant Summary collapse
- ITUNES_NAMESPACE =
"http://apple.com/itunes/importer"
Instance Attribute Summary collapse
-
#metadata_dir ⇒ Object
Returns the value of attribute metadata_dir.
Instance Method Summary collapse
-
#fetch_value(xpath) ⇒ Object
Usage: ‘//x:keyword’.
-
#initialize(app, dir) ⇒ AppMetadata
constructor
A new instance of AppMetadata.
- #transporter ⇒ Object
-
#update_changelog(hash) ⇒ Object
Set the changelog.
-
#update_description(hash) ⇒ Object
Update the app description which is shown in the AppStore.
-
#update_keywords(hash) ⇒ Object
Update the app keywords.
-
#update_marketing_url(hash) ⇒ Object
Update the Marketing URL.
-
#update_support_url(hash) ⇒ Object
Update the support URL.
-
#update_title(hash) ⇒ Object
Update the app title.
-
#upload! ⇒ Object
Actually upload the updated metadata to Apple.
Constructor Details
#initialize(app, dir) ⇒ AppMetadata
Returns a new instance of AppMetadata.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/establish/app_metadata.rb', line 18 def initialize(app, dir) self. = dir @app = app # we want to update the metadata, so first we have to download the existing one transporter.download(app, dir) # Parse the downloaded package parse_package(dir) end |
Instance Attribute Details
#metadata_dir ⇒ Object
Returns the value of attribute metadata_dir.
12 13 14 |
# File 'lib/establish/app_metadata.rb', line 12 def @metadata_dir end |
Instance Method Details
#fetch_value(xpath) ⇒ Object
Usage: ‘//x:keyword’
93 94 95 |
# File 'lib/establish/app_metadata.rb', line 93 def fetch_value(xpath) @data.xpath(xpath, "x" => ITUNES_NAMESPACE) end |
#transporter ⇒ Object
14 15 16 |
# File 'lib/establish/app_metadata.rb', line 14 def transporter @transporter ||= ItunesTransporter.new end |
#update_changelog(hash) ⇒ Object
Set the changelog
51 52 53 54 55 56 |
# File 'lib/establish/app_metadata.rb', line 51 def update_changelog(hash) update_localized_value('version_whats_new', hash) do |field, new_val| raise AppMetadataParameterError.new("Parameter needs to be as hash, containing strings with the new description") unless new_val.kind_of?String field.content = new_val end end |
#update_description(hash) ⇒ Object
Update the app description which is shown in the AppStore
43 44 45 46 47 48 |
# File 'lib/establish/app_metadata.rb', line 43 def update_description(hash) update_localized_value('description', hash) do |field, new_val| raise AppMetadataParameterError.new("Parameter needs to be as hash, containing strings with the new description") unless new_val.kind_of?String field.content = new_val end end |
#update_keywords(hash) ⇒ Object
Update the app keywords
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/establish/app_metadata.rb', line 75 def update_keywords(hash) update_localized_value('keywords', hash) do |field, keywords| raise AppMetadataParameterError.new("Parameter needs to be a hash (each language) with an array of keywords in it") unless keywords.kind_of?Array field.children.remove # remove old keywords node_set = Nokogiri::XML::NodeSet.new(@data) keywords.each do |word| keyword = Nokogiri::XML::Node.new('Keyword', @data) keyword.content = word node_set << keywrod end field.children = node_set end end |
#update_marketing_url(hash) ⇒ Object
Update the Marketing URL
59 60 61 62 63 64 |
# File 'lib/establish/app_metadata.rb', line 59 def update_marketing_url(hash) update_localized_value('software_url', hash) do |field, new_val| raise AppMetadataParameterError.new("Parameter needs to be an hash, containing strings with the new description") unless new_val.kind_of?String field.content = new_val end end |
#update_support_url(hash) ⇒ Object
Update the support URL
67 68 69 70 71 72 |
# File 'lib/establish/app_metadata.rb', line 67 def update_support_url(hash) update_localized_value('support_url', hash) do |field, new_val| raise AppMetadataParameterError.new("Parameter needs to be an hash, containing strings with the new description") unless new_val.kind_of?String field.content = new_val end end |
#update_title(hash) ⇒ Object
Update the app title
35 36 37 38 39 40 |
# File 'lib/establish/app_metadata.rb', line 35 def update_title(hash) update_localized_value('title', hash) do |field, new_val| raise AppMetadataParameterError.new("Parameter needs to be an hash, containing strings with the new description") unless new_val.kind_of?String field.content = new_val end end |
#upload! ⇒ Object
Actually upload the updated metadata to Apple
103 104 105 |
# File 'lib/establish/app_metadata.rb', line 103 def upload! transporter.upload(@app, @app.) end |