vcardigan 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 432f5d57365fbb6550a8313fe3d6f7fd02a9cc92
4
+ data.tar.gz: c8586a64664d2b2def6891b66d2859aee55f3ce7
5
+ SHA512:
6
+ metadata.gz: 8941aaff5b47521d32615a6d688d6a81b57a254a7ca3e022438d21756215074636fc6695a8161e7b9c2cfbc4a6bc58a539fcb19a7059379b5b57eba61980ca9f
7
+ data.tar.gz: 3c36c99ef74b505445c3abd1c089e931e26e493af98fcaddfb8352127f6b405b1db305168046e651a5b652f6c85369f4ceb106d163e8bb41930bb4e3a405b8c7
@@ -69,6 +69,28 @@ module VCardigan
69
69
  add_prop(property)
70
70
  end
71
71
 
72
+ def remove(name)
73
+ if @fields.has_key?(name)
74
+ fields = @fields.delete(name)
75
+
76
+ fields.each do |field|
77
+ group_name = field.group
78
+ if group_name
79
+ group_field_names = @groups.delete(group_name).reject do |delete_field|
80
+ delete_field == name
81
+ end.map(&:name)
82
+
83
+ group_field_names.each do |field_name|
84
+ named_fields = @fields[field_name]
85
+ if named_fields
86
+ named_fields.delete_if {|prop| prop.group == group_name }
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
72
94
  def field(name)
73
95
  name = name.to_s.downcase
74
96
  if @group and @fields[name]
@@ -1,5 +1,5 @@
1
1
  module VCardigan
2
2
 
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
 
5
5
  end
@@ -110,6 +110,50 @@ describe VCardigan::VCard do
110
110
  end
111
111
  end
112
112
 
113
+ describe "#remove" do
114
+ let(:vcard) { VCardigan.create }
115
+ let(:name) { :email }
116
+ let(:email) { 'joe@strummer.com' }
117
+ let(:params) { { :type => 'uri' } }
118
+ let(:fields) { vcard.instance_variable_get(:@fields) }
119
+
120
+ context "with no group" do
121
+ before do
122
+ vcard.add(name, email, params)
123
+ end
124
+
125
+ it "removes all occurances of the field" do
126
+ fields['email'].should_not be_empty
127
+
128
+ vcard.remove('email')
129
+
130
+ fields['email'].should be_nil
131
+ end
132
+ end
133
+
134
+ context "with groups" do
135
+ let(:group) { 'item1' }
136
+ let(:label) { 'Test Label' }
137
+ before do
138
+ vcard['item0'].add('tel', '235235')
139
+ vcard['item0'].add('x-ablabel', 'iPhone')
140
+ vcard[group].add(name, email)
141
+ vcard[group].add('x-ablabel', label)
142
+ end
143
+
144
+ it "removes all occurances of the field and its group label" do
145
+ vcard[group].email.first.value.should_not be_empty
146
+ vcard[group].send('x-ablabel').first.value.should == label
147
+
148
+ vcard.remove('email')
149
+
150
+ fields['email'].should be_nil
151
+
152
+ vcard[group].send('x-ablabel').should be_empty
153
+ end
154
+ end
155
+ end
156
+
113
157
  describe '#method_missing' do
114
158
  let(:vcard) { VCardigan.create }
115
159
 
metadata CHANGED
@@ -1,93 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vcardigan
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Matt Morgan
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2014-02-07 00:00:00 -08:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 0
30
- version: "2.0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
31
20
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: pry
35
21
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
38
31
  - - ">="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- version: "0"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
43
34
  type: :development
44
- version_requirements: *id002
45
- description: vCardigan is a ruby library for building and parsing vCards that supports both v3.0 and v4.0.
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: vCardigan is a ruby library for building and parsing vCards that supports
42
+ both v3.0 and v4.0.
46
43
  email: matt@mlmorg.com
47
44
  executables: []
48
-
49
45
  extensions: []
50
-
51
46
  extra_rdoc_files: []
52
-
53
- files:
47
+ files:
48
+ - lib/vcardigan.rb
54
49
  - lib/vcardigan/errors.rb
55
50
  - lib/vcardigan/properties/name_property.rb
56
51
  - lib/vcardigan/property.rb
57
52
  - lib/vcardigan/vcard.rb
58
53
  - lib/vcardigan/version.rb
59
- - lib/vcardigan.rb
60
- has_rdoc: true
54
+ - spec/examples/property_spec.rb
55
+ - spec/examples/vcard_spec.rb
56
+ - spec/spec_helper.rb
61
57
  homepage: http://github.com/brewster/vcardigan
62
- licenses:
58
+ licenses:
63
59
  - MIT
60
+ metadata: {}
64
61
  post_install_message:
65
62
  rdoc_options: []
66
-
67
- require_paths:
63
+ require_paths:
68
64
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
70
- requirements:
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
71
67
  - - ">="
72
- - !ruby/object:Gem::Version
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- requirements:
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
78
72
  - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
83
75
  requirements: []
84
-
85
76
  rubyforge_project:
86
- rubygems_version: 1.3.6
77
+ rubygems_version: 2.2.2
87
78
  signing_key:
88
- specification_version: 3
79
+ specification_version: 4
89
80
  summary: Ruby vCard Builder/Parser
90
- test_files:
81
+ test_files:
91
82
  - spec/examples/property_spec.rb
92
83
  - spec/examples/vcard_spec.rb
93
84
  - spec/spec_helper.rb