Class: Confetti::Template::WindowsPhone7Manifest

Inherits:
Base
  • Object
show all
Includes:
VersionHelper
Defined in:
lib/confetti/templates/windows_phone7_manifest.rb

Constant Summary collapse

GAP_PERMISSIONS_MAP =
{
  'camera' => %w{ID_CAP_ISV_CAMERA
                 ID_HW_FRONTCAMERA},
  'contacts' => %w{ID_CAP_CONTACTS},
  'device' => %w{ID_CAP_IDENTITY_DEVICE},
  'geolocation' => %w{ID_CAP_LOCATION},
  'network' => %w{ID_CAP_NETWORKING},
  'media' => %w{ID_CAP_MICROPHONE},
}

Instance Method Summary collapse

Methods included from VersionHelper

#normalize_version

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Confetti::Template::Base

Instance Method Details

#authorObject



20
21
22
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 20

def author
  @config.author.name
end

#capabilitiesObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 46

def capabilities
  default_permissions = %w{camera contacts device geolocation
      network media}
  permissions = []                                                
  capabilities = []                                                
  phonegap_api = /http\:\/\/api.phonegap.com\/1[.]0\/(\w+)/          
  filtered_features = @config.feature_set.clone

  filtered_features.each { |f|
      next if f.name.nil?
      matches = f.name.match(phonegap_api)
      next if matches.nil? or matches.length < 1 
      next unless GAP_PERMISSIONS_MAP.has_key?(matches[1])
      permissions << matches[1]
  }

  if @config.feature_set.empty? and
      @config.preference(:permissions) != :none
      permissions = default_permissions
  end

  permissions.each { |p|
      capabilities.concat(GAP_PERMISSIONS_MAP[p])
  }

  capabilities.sort! 
  capabilities.map { |f| { :name => f } }
end

#descriptionObject



33
34
35
36
37
38
39
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 33

def description
  if @config.description && @config.description.length >= 250
    "#{ @config.description[0..245] }..."
  else
    @config.description
  end
end

#guidObject



24
25
26
27
28
29
30
31
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 24

def guid
  package = @config.package
  package ||= 'com.example.app'
  guid = Digest::MD5.hexdigest package 
  res = "{#{ guid[0..7] }-#{ guid[8..11] }-"
  res << "#{ guid[12..15] }-#{ guid[16..19] }-"
  res << "#{ guid[20,guid.length-1]}}"
end

#output_filenameObject



75
76
77
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 75

def output_filename 
  "WMAppManifest.xml"
end

#titleObject



16
17
18
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 16

def title
  @config.name.name
end

#versionObject



41
42
43
44
# File 'lib/confetti/templates/windows_phone7_manifest.rb', line 41

def version
  version = normalize_version @config.version_string
  version << ".0" 
end