Class: Confetti::Template::BlackberryWidgetsConfig

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

Constant Summary collapse

ORIENTATIONS_MAP =
{
  :default => "auto",
  :landscape => "landscape",
  :portrait => "portrait"
}
@@legacy_template =
File.read(
  File.join(
    File.dirname(__FILE__),
    "blackberry_widgets_config_legacy.mustache"
))

Instance Method Summary collapse

Methods included from VersionHelper

#normalize_version

Constructor Details

#initialize(*args) ⇒ BlackberryWidgetsConfig

Returns a new instance of BlackberryWidgetsConfig.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 18

def initialize *args
  super *args

  return self unless @config

  # old = 0.x, 1.0, 1.1, or 1.2
  old = /^(0)|(1[.][0-2])/

  if @config.phonegap_version and @config.phonegap_version.match(old)
    self.template = @@legacy_template
  end
end

Instance Method Details

#accessObject



102
103
104
105
106
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 102

def access
  @config.access_set.map do |a| 
    { :subdomains => !!a.subdomains, :uri => a.origin }
  end
end

#app_orientationObject



87
88
89
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 87

def app_orientation
  ORIENTATIONS_MAP[@config.orientation]
end

#author_emailObject



51
52
53
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 51

def author_email
  @config.author.email
end

#author_hrefObject



47
48
49
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 47

def author_href
  @config.author.href
end

#author_nameObject



55
56
57
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 55

def author_name
  @config.author.name
end

#framework_namespaceObject



95
96
97
98
99
100
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 95

def framework_namespace
  # phonegap = 0.x, 1.0, 1.1, 1.2, 1.3, 1.4
  gap = @config.phonegap_version.match(/^(0)|(1[.][0-4])/)

  gap ? 'com.phonegap' : 'org.apache.cordova'
end

#license_hrefObject



63
64
65
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 63

def license_href
  @config.license.href
end

#license_textObject



67
68
69
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 67

def license_text
  @config.license.text
end

#no_cursor?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 91

def no_cursor?
  @config.preference("disable-cursor") == :true
end

#output_filenameObject



83
84
85
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 83

def output_filename
  "config.xml"
end

#phonegap_versionObject



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 71

def phonegap_version
  # should be 1.0.0, unless below 1
  # @config.phonegap_version
  pg = @config.phonegap_version

  if pg.nil? or pg.empty? or pg.match(/^1/)
    "1.0.0"
  else
    pg
  end
end

#versionObject



39
40
41
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 39

def version
  normalize_version(@config.version_string)
end

#widget_descriptionObject



59
60
61
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 59

def widget_description
  @config.description
end

#widget_idObject



31
32
33
34
35
36
37
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 31

def widget_id
  if @config.package.nil? or @config.package.empty?
    "com.default.noname"
  else
    @config.package
  end
end

#widget_nameObject



43
44
45
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 43

def widget_name
  @config.name.name
end