Class: Confetti::Template::BlackberryWidgetsConfig
- 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
- #access ⇒ Object
- #app_orientation ⇒ Object
- #author_email ⇒ Object
- #author_href ⇒ Object
- #author_name ⇒ Object
- #framework_namespace ⇒ Object
-
#initialize(*args) ⇒ BlackberryWidgetsConfig
constructor
A new instance of BlackberryWidgetsConfig.
- #license_href ⇒ Object
- #license_text ⇒ Object
- #no_cursor? ⇒ Boolean
- #output_filename ⇒ Object
- #phonegap_version ⇒ Object
- #valid_origin(o) ⇒ Object
- #version ⇒ Object
- #widget_description ⇒ Object
- #widget_id ⇒ Object
- #widget_name ⇒ Object
Methods included from VersionHelper
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
#access ⇒ Object
106 107 108 109 110 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 106 def access @config.access_set.select { |a| valid_origin(a.origin) }.map do |a| { :subdomains => !!a.subdomains, :uri => a.origin } end end |
#app_orientation ⇒ Object
91 92 93 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 91 def app_orientation ORIENTATIONS_MAP[@config.orientation] end |
#author_email ⇒ Object
51 52 53 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 51 def @config..email end |
#author_href ⇒ Object
47 48 49 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 47 def @config..href end |
#author_name ⇒ Object
55 56 57 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 55 def @config..name end |
#framework_namespace ⇒ Object
99 100 101 102 103 104 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 99 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_href ⇒ Object
67 68 69 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 67 def license_href @config.license.href end |
#license_text ⇒ Object
71 72 73 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 71 def license_text @config.license.text end |
#no_cursor? ⇒ Boolean
95 96 97 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 95 def no_cursor? @config.preference("disable-cursor") == :true end |
#output_filename ⇒ Object
87 88 89 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 87 def output_filename "config.xml" end |
#phonegap_version ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 75 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 |
#valid_origin(o) ⇒ Object
112 113 114 115 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 112 def valid_origin o # not nil and (wildcard or with scheme) !o.nil? && (o == '*' || o.match(/^\w+:\/\//)) end |
#version ⇒ Object
39 40 41 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 39 def version normalize_version(@config.version_string) end |
#widget_description ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 59 def if @config.description && @config.description.length >= 500 "#{ @config.description[0..495] }..." else @config.description end end |
#widget_id ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 31 def if @config.package.nil? or @config.package.empty? "com.default.noname" else @config.package end end |
#widget_name ⇒ Object
43 44 45 |
# File 'lib/confetti/templates/blackberry_widgets_config.rb', line 43 def @config.name.name end |