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
-
#initialize(app, dir) ⇒ AppMetadata
constructor
A new instance of AppMetadata.
- #transporter ⇒ Object
-
#update_description(hash) ⇒ Object
Update the app description which is shown in the AppStore.
-
#update_keywords(hash) ⇒ Object
Update the app keywords.
-
#upload! ⇒ Object
Actually upload the updated metadata to Apple.
Constructor Details
#initialize(app, dir) ⇒ 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 end |
Instance Method Details
#transporter ⇒ Object
14 15 16 |
# File 'lib/establish/app_metadata.rb', line 14 def transporter @transporter ||= ItunesTransporter.new end |
#update_description(hash) ⇒ Object
Update the app description which is shown in the AppStore
35 36 37 38 39 40 41 |
# File 'lib/establish/app_metadata.rb', line 35 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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/establish/app_metadata.rb', line 44 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('Keyord', @data) node_set << keywrod end field.children = node_set end end |
#upload! ⇒ Object
Actually upload the updated metadata to Apple
66 67 68 |
# File 'lib/establish/app_metadata.rb', line 66 def upload! transporter.upload(@app, @app.) end |