confetti 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confetti (0.7.6)
4
+ confetti (0.7.7)
5
5
  mustache (~> 0.11.2)
6
6
 
7
7
  GEM
@@ -22,7 +22,9 @@ module Confetti
22
22
  end
23
23
 
24
24
  def guid
25
- guid = Digest::MD5.hexdigest @config.package
25
+ package = @config.package
26
+ package ||= 'com.example.app'
27
+ guid = Digest::MD5.hexdigest package
26
28
  res = "{#{ guid[0..7] }-#{ guid[8..11] }-"
27
29
  res << "#{ guid[12..15] }-#{ guid[16..19] }-"
28
30
  res << "#{ guid[20,guid.length-1]}}"
@@ -38,20 +40,32 @@ module Confetti
38
40
  end
39
41
 
40
42
  def capabilities
43
+ default_permissions = %w{camera contacts device geolocation
44
+ networking media}
41
45
  permissions = []
46
+ capabilities = []
42
47
  phonegap_api = /http\:\/\/api.phonegap.com\/1[.]0\/(\w+)/
48
+ filtered_features = @config.feature_set.clone
43
49
 
44
- feature_names = @config.feature_set.map { |f| f.name }
45
- feature_names.sort
50
+ filtered_features.each { |f|
51
+ next if f.name.nil?
52
+ matches = f.name.match(phonegap_api)
53
+ next unless matches.length > 1
54
+ next unless GAP_PERMISSIONS_MAP.has_key?(matches[1])
55
+ permissions << matches[1]
56
+ }
46
57
 
47
- feature_names.each do |f|
48
- feature_name = f.match(phonegap_api)[1] if f.match(phonegap_api)
49
- associated_permissions = GAP_PERMISSIONS_MAP[feature_name]
50
- permissions.concat(associated_permissions) if associated_permissions
58
+ if @config.feature_set.empty? and
59
+ @config.preference(:permissions) != :none
60
+ permissions = default_permissions
51
61
  end
62
+
63
+ permissions.each { |p|
64
+ capabilities.concat(GAP_PERMISSIONS_MAP[p])
65
+ }
52
66
 
53
- permissions.sort!
54
- permissions.map { |f| { :name => f } }
67
+ capabilities.sort!
68
+ capabilities.map { |f| { :name => f } }
55
69
  end
56
70
 
57
71
  def output_filename
@@ -1,3 +1,3 @@
1
1
  module Confetti
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
@@ -8,9 +8,9 @@
8
8
 
9
9
  <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
10
10
  <Capabilities>
11
- <Capability Name="D_HW_FRONTCAMERA" />
12
11
  <Capability Name="ID_CAP_ISV_CAMERA" />
13
12
  <Capability Name="ID_CAP_LOCATION" />
13
+ <Capability Name="ID_HW_FRONTCAMERA" />
14
14
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
15
15
  </Capabilities>
16
16
 
@@ -33,17 +33,79 @@ describe Confetti::Template::WindowsPhone7Manifest do
33
33
  @template.guid.should == "{1005a3fc-23ab-99bd-bdd1-9e83f3d7b989}"
34
34
  end
35
35
 
36
- describe "with a config object" do
36
+ describe "with a bad config object" do
37
37
 
38
- before do
39
- @config = Confetti::Config.new "#{fixture_dir}/config.xml"
38
+ describe "on rendering" do
39
+
40
+ it "should generate a dummy uuid if non provided" do
41
+ @config = Confetti::Config.new
42
+ @config.package = "com.example.app"
43
+ @template = @template_class.new @config
44
+ @template.guid.should == "{a163ec9b-9996-caee-009d-cdac1b7e0722}"
45
+ end
46
+
47
+ it "should not fail when a bad feature is found" do
48
+ @config = Confetti::Config.new
49
+ bad_feature = Confetti::Config::Feature.new(
50
+ "http://api.phonegap.com/1.0/badfeature",
51
+ "true"
52
+ )
53
+ good_feature = Confetti::Config::Feature.new(
54
+ "http://api.phonegap.com/1.0/networking",
55
+ "true"
56
+ )
57
+ @config.feature_set << bad_feature
58
+ @config.feature_set << good_feature
59
+ @template = @template_class.new @config
60
+ @template.capabilities.should == [{:name => "ID_CAP_NETWORKING"}]
61
+ end
40
62
  end
63
+ end
64
+
65
+ describe "with a good config object" do
66
+
67
+ describe "on rendering" do
68
+
69
+ it "should render a valid wp7 manifest" do
70
+ @config = Confetti::Config.new "#{fixture_dir}/config.xml"
71
+ @template = @template_class.new @config
72
+ @template.render.should == File.read(
73
+ "#{fixture_dir}/windowsphone7/WMAppManifest.xml"
74
+ )
75
+ end
76
+
77
+ it "should add a feature when a valid on is found" do
78
+ @config = Confetti::Config.new
79
+ feature = Confetti::Config::Feature.new(
80
+ "http://api.phonegap.com/1.0/geolocation",
81
+ "true"
82
+ )
83
+ @config.feature_set << feature
84
+ @template = @template_class.new @config
85
+ @template.capabilities.should == [{:name=>"ID_CAP_LOCATION"}]
86
+ end
87
+
88
+ it "should add default capabilities when none are specified" do
89
+ @config = Confetti::Config.new
90
+ @template = @template_class.new @config
91
+ @template.capabilities.should == [
92
+ {:name => "ID_CAP_CONTACTS"},
93
+ {:name => "ID_CAP_IDENTITY_DEVICE"},
94
+ {:name => "ID_CAP_ISV_CAMERA"},
95
+ {:name => "ID_CAP_LOCATION"},
96
+ {:name => "ID_CAP_MICROPHONE"},
97
+ {:name => "ID_CAP_NETWORKING"},
98
+ {:name => "ID_HW_FRONTCAMERA"},
99
+ ]
100
+ end
41
101
 
42
- it "should render" do
43
- @template = @template_class.new @config
44
- @template.render.should == File.read(
45
- "#{fixture_dir}/windowsphone7/WMAppManifest.xml"
46
- )
102
+ it "should no add any capabilities when preference permissions is none" do
103
+ @config = Confetti::Config.new
104
+ @template = @template_class.new @config
105
+ @config.preference_set <<
106
+ Confetti::Config::Preference.new("permissions", "none")
107
+ @template.capabilities.should == []
108
+ end
47
109
  end
48
110
  end
49
111
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 6
9
- version: 0.7.6
8
+ - 7
9
+ version: 0.7.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Lunny
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-18 00:00:00 -07:00
19
+ date: 2012-04-25 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency