ppl 1.14.1 → 1.15.0
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 +2 -1
- data/Gemfile.lock +3 -1
- data/lib/ppl/adapter/color/colored.rb +15 -0
- data/lib/ppl/adapter/color.rb +9 -0
- data/lib/ppl/application/bootstrap.rb +309 -61
- data/lib/ppl/application/configuration.rb +15 -0
- data/lib/ppl/command/age.rb +0 -5
- data/lib/ppl/command/bday.rb +0 -5
- data/lib/ppl/command/email.rb +1 -3
- data/lib/ppl/command/ls.rb +0 -5
- data/lib/ppl/command/mutt.rb +0 -4
- data/lib/ppl/command/name.rb +0 -5
- data/lib/ppl/command/nick.rb +1 -3
- data/lib/ppl/command/org.rb +1 -3
- data/lib/ppl/command/phone.rb +1 -3
- data/lib/ppl/command/post.rb +0 -5
- data/lib/ppl/command/url.rb +1 -3
- data/lib/ppl/format/address_book/ages.rb +2 -4
- data/lib/ppl/format/address_book/birthdays.rb +2 -2
- data/lib/ppl/format/address_book/email_addresses.rb +3 -3
- data/lib/ppl/format/address_book/names.rb +2 -2
- data/lib/ppl/format/address_book/nicknames.rb +2 -2
- data/lib/ppl/format/address_book/one_line.rb +2 -2
- data/lib/ppl/format/address_book/organizations.rb +2 -2
- data/lib/ppl/format/address_book/phone_numbers.rb +2 -2
- data/lib/ppl/format/address_book/postal_addresses.rb +2 -2
- data/lib/ppl/format/address_book/urls.rb +2 -2
- data/lib/ppl/format/contact/age.rb +13 -1
- data/lib/ppl/format/contact/birthday.rb +11 -0
- data/lib/ppl/format/contact/email_addresses.rb +19 -1
- data/lib/ppl/format/contact/name.rb +18 -2
- data/lib/ppl/format/contact/nicknames.rb +19 -1
- data/lib/ppl/format/contact/organization.rb +19 -1
- data/lib/ppl/format/contact/phone_number.rb +19 -1
- data/lib/ppl/format/contact/urls.rb +19 -1
- data/lib/ppl/format/table.rb +15 -6
- data/lib/ppl.rb +3 -1
- data/ppl.gemspec +4 -2
- data/spec/ppl/adapter/color/colored_spec.rb +24 -0
- data/spec/ppl/adapter/color_spec.rb +15 -0
- data/spec/ppl/application/bootstrap_spec.rb +403 -25
- data/spec/ppl/application/configuration_spec.rb +46 -0
- data/spec/ppl/command/mutt_spec.rb +4 -0
- data/spec/ppl/format/address_book/ages_spec.rb +10 -0
- data/spec/ppl/format/address_book/birthdays_spec.rb +10 -0
- data/spec/ppl/format/address_book/email_addresses_spec.rb +12 -2
- data/spec/ppl/format/address_book/names_spec.rb +10 -0
- data/spec/ppl/format/address_book/nicknames_spec.rb +10 -0
- data/spec/ppl/format/address_book/one_line_spec.rb +10 -0
- data/spec/ppl/format/address_book/organizations_spec.rb +10 -0
- data/spec/ppl/format/address_book/phone_numbers_spec.rb +10 -0
- data/spec/ppl/format/address_book/postal_addresses_spec.rb +10 -0
- data/spec/ppl/format/address_book/urls_spec.rb +10 -0
- data/spec/ppl/format/contact/age_spec.rb +10 -0
- data/spec/ppl/format/contact/birthday_spec.rb +8 -0
- data/spec/ppl/format/contact/email_addresses_spec.rb +8 -0
- data/spec/ppl/format/contact/name_spec.rb +8 -0
- data/spec/ppl/format/contact/nicknames_spec.rb +8 -0
- data/spec/ppl/format/contact/organization_spec.rb +8 -0
- data/spec/ppl/format/contact/phone_number_spec.rb +8 -0
- data/spec/ppl/format/contact/urls_spec.rb +8 -0
- data/spec/ppl/format/table_spec.rb +20 -0
- metadata +38 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,11 +5,12 @@ GIT
|
|
5
5
|
vpim (12.1.12)
|
6
6
|
|
7
7
|
GEM
|
8
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.1.3)
|
11
11
|
fakefs (0.4.1)
|
12
12
|
inifile (2.0.2)
|
13
|
+
morphine (0.1.1)
|
13
14
|
rake (10.0.1)
|
14
15
|
rspec (2.12.0)
|
15
16
|
rspec-core (~> 2.12.0)
|
@@ -27,6 +28,7 @@ PLATFORMS
|
|
27
28
|
DEPENDENCIES
|
28
29
|
fakefs
|
29
30
|
inifile (= 2.0.2)
|
31
|
+
morphine (= 0.1.1)
|
30
32
|
rake
|
31
33
|
rspec
|
32
34
|
rugged (= 0.17.0.b6)
|
@@ -1,101 +1,349 @@
|
|
1
1
|
|
2
|
+
require "morphine"
|
3
|
+
|
2
4
|
class Ppl::Application::Bootstrap
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
6
|
+
include Morphine
|
7
|
+
|
8
|
+
register :command_add do
|
9
|
+
add = Ppl::Command::Add.new
|
10
|
+
add.storage = storage_adapter
|
11
|
+
add
|
12
|
+
end
|
13
|
+
|
14
|
+
register :command_age do
|
15
|
+
age = Ppl::Command::Age.new
|
16
|
+
age.storage = storage_adapter
|
17
|
+
age.list_format = format_address_book_ages
|
18
|
+
age.show_format = format_contact_age
|
19
|
+
age
|
20
|
+
end
|
21
|
+
|
22
|
+
register :command_bday do
|
23
|
+
bday = Ppl::Command::Bday.new
|
24
|
+
bday.storage = storage_adapter
|
25
|
+
bday.list_format = format_address_book_birthdays
|
26
|
+
bday.show_format = format_contact_birthday
|
27
|
+
bday
|
28
|
+
end
|
29
|
+
|
30
|
+
register :command_email do
|
31
|
+
email = Ppl::Command::Email.new
|
32
|
+
email.storage = storage_adapter
|
33
|
+
email.list_format = format_address_book_email_addresses
|
34
|
+
email.show_format = format_contact_email_addresses
|
35
|
+
email
|
36
|
+
end
|
37
|
+
|
38
|
+
register :command_help do
|
39
|
+
help = Ppl::Command::Help.new
|
40
|
+
help.storage = storage_adapter
|
41
|
+
help
|
42
|
+
end
|
43
|
+
|
44
|
+
register :command_init do
|
45
|
+
init = Ppl::Command::Init.new
|
46
|
+
init.storage = storage_adapter
|
47
|
+
init
|
48
|
+
end
|
49
|
+
|
50
|
+
register :command_ls do
|
51
|
+
ls = Ppl::Command::Ls.new
|
52
|
+
ls.storage = storage_adapter
|
53
|
+
ls.format = format_address_book_one_line
|
54
|
+
ls
|
55
|
+
end
|
56
|
+
|
57
|
+
register :command_mutt do
|
58
|
+
mutt = Ppl::Command::Mutt.new
|
59
|
+
mutt.storage = storage_adapter
|
60
|
+
mutt.format = format_address_book_mutt_query
|
61
|
+
mutt
|
62
|
+
end
|
63
|
+
|
64
|
+
register :command_mv do
|
65
|
+
mv = Ppl::Command::Mv.new
|
66
|
+
mv.storage = storage_adapter
|
67
|
+
mv
|
68
|
+
end
|
69
|
+
|
70
|
+
register :command_name do
|
71
|
+
name = Ppl::Command::Name.new
|
72
|
+
name.storage = storage_adapter
|
73
|
+
name.list_format = format_address_book_names
|
74
|
+
name.show_format = format_contact_name
|
75
|
+
name
|
76
|
+
end
|
77
|
+
|
78
|
+
register :command_nick do
|
79
|
+
nick = Ppl::Command::Nick.new
|
80
|
+
nick.storage = storage_adapter
|
81
|
+
nick.list_format = format_address_book_nicknames
|
82
|
+
nick.show_format = format_contact_nicknames
|
83
|
+
nick
|
84
|
+
end
|
85
|
+
|
86
|
+
register :command_org do
|
87
|
+
org = Ppl::Command::Org.new
|
88
|
+
org.list_format = format_address_book_organizations
|
89
|
+
org.show_format = format_contact_organizations
|
90
|
+
org.storage = storage_adapter
|
91
|
+
org
|
92
|
+
end
|
93
|
+
|
94
|
+
register :command_phone do
|
95
|
+
phone = Ppl::Command::Phone.new
|
96
|
+
phone.storage = storage_adapter
|
97
|
+
phone.list_format = format_address_book_phone_numbers
|
98
|
+
phone.show_format = format_contact_phone_numbers
|
99
|
+
phone
|
100
|
+
end
|
101
|
+
|
102
|
+
register :command_post do
|
103
|
+
post = Ppl::Command::Post.new
|
104
|
+
post.storage = storage_adapter
|
105
|
+
post.list_format = format_address_book_postal_addresses
|
106
|
+
post.show_format = format_contact_postal_addresses
|
107
|
+
post
|
108
|
+
end
|
109
|
+
|
110
|
+
register :command_pull do
|
111
|
+
pull = Ppl::Command::Execute.new("pull", "git pull", "Execute 'git pull' in the address book directory")
|
112
|
+
pull.storage = storage_adapter
|
113
|
+
pull
|
114
|
+
end
|
115
|
+
|
116
|
+
register :command_push do
|
117
|
+
push = Ppl::Command::Execute.new("push", "git push", "Execute 'git push' in the address book directory")
|
118
|
+
push.storage = storage_adapter
|
119
|
+
push
|
120
|
+
end
|
121
|
+
|
122
|
+
register :command_remote do
|
123
|
+
remote = Ppl::Command::Execute.new("remote", "git remote", "Execute 'git remote' in the address book directory")
|
124
|
+
remote.storage = storage_adapter
|
125
|
+
remote
|
126
|
+
end
|
127
|
+
|
128
|
+
register :command_rm do
|
129
|
+
rm = Ppl::Command::Rm.new
|
130
|
+
rm.storage = storage_adapter
|
131
|
+
rm
|
132
|
+
end
|
133
|
+
|
134
|
+
register :command_shell do
|
135
|
+
shell = Ppl::Command::Shell.new
|
136
|
+
shell.storage = storage_adapter
|
137
|
+
shell
|
138
|
+
end
|
139
|
+
|
140
|
+
register :command_show do
|
141
|
+
show = Ppl::Command::Show.new
|
142
|
+
show.storage = storage_adapter
|
143
|
+
show
|
144
|
+
end
|
145
|
+
|
146
|
+
register :command_url do
|
147
|
+
url = Ppl::Command::Url.new
|
148
|
+
url.storage = storage_adapter
|
149
|
+
url.list_format = format_address_book_urls
|
150
|
+
url.show_format = format_contact_urls
|
151
|
+
url
|
152
|
+
end
|
153
|
+
|
154
|
+
register :command_version do
|
155
|
+
version = Ppl::Command::Version.new
|
156
|
+
version.storage = storage_adapter
|
157
|
+
version
|
158
|
+
end
|
159
|
+
|
160
|
+
register :command_suite do
|
34
161
|
suite = Ppl::Application::CommandSuite.new
|
35
|
-
|
36
|
-
|
37
|
-
|
162
|
+
suite.add_command command_add
|
163
|
+
suite.add_command command_age
|
164
|
+
suite.add_command command_bday
|
165
|
+
suite.add_command command_email
|
166
|
+
suite.add_command command_help
|
167
|
+
suite.add_command command_init
|
168
|
+
suite.add_command command_ls
|
169
|
+
suite.add_command command_mutt
|
170
|
+
suite.add_command command_mv
|
171
|
+
suite.add_command command_name
|
172
|
+
suite.add_command command_nick
|
173
|
+
suite.add_command command_org
|
174
|
+
suite.add_command command_phone
|
175
|
+
suite.add_command command_post
|
176
|
+
suite.add_command command_pull
|
177
|
+
suite.add_command command_push
|
178
|
+
suite.add_command command_remote
|
179
|
+
suite.add_command command_rm
|
180
|
+
suite.add_command command_shell
|
181
|
+
suite.add_command command_show
|
182
|
+
suite.add_command command_url
|
183
|
+
suite.add_command command_version
|
38
184
|
suite.find_command("help").command_suite = suite
|
39
|
-
|
185
|
+
suite
|
40
186
|
end
|
41
187
|
|
42
|
-
|
43
|
-
|
44
|
-
return config
|
188
|
+
register :configuration do
|
189
|
+
Ppl::Application::Configuration.new
|
45
190
|
end
|
46
191
|
|
47
|
-
|
192
|
+
register :execute_command do
|
48
193
|
command = Ppl::Command::Execute.new(nil, nil, nil)
|
49
194
|
command.storage = storage_adapter
|
50
195
|
command
|
51
196
|
end
|
52
197
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
198
|
+
register :format_address_book_ages do
|
199
|
+
config = configuration
|
200
|
+
colors = config.color_enabled("age") ? config.command_colors("age") : {}
|
201
|
+
Ppl::Format::AddressBook::Ages.new(colors)
|
202
|
+
end
|
203
|
+
|
204
|
+
register :format_address_book_birthdays do
|
205
|
+
config = configuration
|
206
|
+
colors = config.color_enabled("bday") ? config.command_colors("bday") : {}
|
207
|
+
Ppl::Format::AddressBook::Birthdays.new(colors)
|
208
|
+
end
|
209
|
+
|
210
|
+
register :format_address_book_email_addresses do
|
211
|
+
config = configuration
|
212
|
+
colors = config.color_enabled("email") ? config.command_colors("email") : {}
|
213
|
+
Ppl::Format::AddressBook::EmailAddresses.new(colors)
|
214
|
+
end
|
215
|
+
|
216
|
+
register :format_address_book_mutt_query do
|
217
|
+
Ppl::Format::AddressBook::MuttQuery.new
|
218
|
+
end
|
219
|
+
|
220
|
+
register :format_address_book_names do
|
221
|
+
config = configuration
|
222
|
+
colors = config.color_enabled("name") ? config.command_colors("name") : {}
|
223
|
+
Ppl::Format::AddressBook::Names.new(colors)
|
224
|
+
end
|
225
|
+
|
226
|
+
register :format_address_book_nicknames do
|
227
|
+
config = configuration
|
228
|
+
colors = config.color_enabled("nick") ? config.command_colors("nick") : {}
|
229
|
+
Ppl::Format::AddressBook::Nicknames.new(colors)
|
230
|
+
end
|
231
|
+
|
232
|
+
register :format_address_book_one_line do
|
233
|
+
config = configuration
|
234
|
+
colors = config.color_enabled("ls") ? config.command_colors("ls") : {}
|
235
|
+
Ppl::Format::AddressBook::OneLine.new(colors)
|
236
|
+
end
|
237
|
+
|
238
|
+
register :format_address_book_organizations do
|
239
|
+
config = configuration
|
240
|
+
colors = config.color_enabled("org") ? config.command_colors("org") : {}
|
241
|
+
Ppl::Format::AddressBook::Organizations.new(colors)
|
242
|
+
end
|
243
|
+
|
244
|
+
register :format_address_book_phone_numbers do
|
245
|
+
config = configuration
|
246
|
+
colors = config.color_enabled("phone") ? config.command_colors("phone") : {}
|
247
|
+
Ppl::Format::AddressBook::PhoneNumbers.new(colors)
|
248
|
+
end
|
249
|
+
|
250
|
+
register :format_address_book_postal_addresses do
|
251
|
+
config = configuration
|
252
|
+
colors = config.color_enabled("post") ? config.command_colors("post") : {}
|
253
|
+
Ppl::Format::AddressBook::PostalAddresses.new(colors)
|
254
|
+
end
|
255
|
+
|
256
|
+
register :format_address_book_urls do
|
257
|
+
config = configuration
|
258
|
+
colors = config.color_enabled("url") ? config.command_colors("url") : {}
|
259
|
+
Ppl::Format::AddressBook::Urls.new(colors)
|
260
|
+
end
|
261
|
+
|
262
|
+
register :format_contact_age do
|
263
|
+
config = configuration
|
264
|
+
colors = config.color_enabled("age") ? config.command_colors("age") : {}
|
265
|
+
Ppl::Format::Contact::Age.new(colors)
|
266
|
+
end
|
267
|
+
|
268
|
+
register :format_contact_birthday do
|
269
|
+
config = configuration
|
270
|
+
colors = config.color_enabled("bday") ? config.command_colors("bday") : {}
|
271
|
+
Ppl::Format::Contact::Birthday.new(colors)
|
272
|
+
end
|
273
|
+
|
274
|
+
register :format_contact_email_addresses do
|
275
|
+
config = configuration
|
276
|
+
colors = config.color_enabled("email") ? config.command_colors("email") : {}
|
277
|
+
Ppl::Format::Contact::EmailAddresses.new(colors)
|
278
|
+
end
|
279
|
+
|
280
|
+
register :format_contact_name do
|
281
|
+
config = configuration
|
282
|
+
colors = config.color_enabled("name") ? config.command_colors("name") : {}
|
283
|
+
Ppl::Format::Contact::Name.new(colors)
|
284
|
+
end
|
285
|
+
|
286
|
+
register :format_contact_nicknames do
|
287
|
+
config = configuration
|
288
|
+
colors = config.color_enabled("nick") ? config.command_colors("nick") : {}
|
289
|
+
Ppl::Format::Contact::Nicknames.new(colors)
|
59
290
|
end
|
60
291
|
|
61
|
-
|
62
|
-
|
63
|
-
|
292
|
+
register :format_contact_organizations do
|
293
|
+
config = configuration
|
294
|
+
colors = config.color_enabled("org") ? config.command_colors("org") : {}
|
295
|
+
Ppl::Format::Contact::Organization.new(colors)
|
296
|
+
end
|
297
|
+
|
298
|
+
register :format_contact_phone_numbers do
|
299
|
+
config = configuration
|
300
|
+
colors = config.color_enabled("phone") ? config.command_colors("phone") : {}
|
301
|
+
Ppl::Format::Contact::PhoneNumber.new(colors)
|
64
302
|
end
|
65
303
|
|
66
|
-
|
67
|
-
|
68
|
-
|
304
|
+
register :format_contact_postal_addresses do
|
305
|
+
Ppl::Format::Contact::PostalAddress.new
|
306
|
+
end
|
307
|
+
|
308
|
+
register :format_contact_urls do
|
309
|
+
config = configuration
|
310
|
+
colors = config.color_enabled("url") ? config.command_colors("url") : {}
|
311
|
+
Ppl::Format::Contact::Urls.new(colors)
|
69
312
|
end
|
70
313
|
|
71
|
-
|
314
|
+
register :input do
|
315
|
+
Ppl::Application::Input.new(ARGV.dup)
|
316
|
+
end
|
317
|
+
|
318
|
+
register :output do
|
319
|
+
Ppl::Application::Output.new($stdout, $stderr)
|
320
|
+
end
|
321
|
+
|
322
|
+
register :router do
|
72
323
|
router = Ppl::Application::Router.new(command_suite)
|
73
324
|
router.aliases = configuration.aliases
|
74
325
|
router.default = "help"
|
75
326
|
router.execute_command = execute_command
|
76
|
-
|
327
|
+
router
|
77
328
|
end
|
78
329
|
|
79
|
-
|
330
|
+
register :shell do
|
80
331
|
shell = Ppl::Application::Shell.new
|
81
332
|
shell.router = router
|
82
|
-
|
333
|
+
shell
|
83
334
|
end
|
84
335
|
|
85
|
-
|
336
|
+
register :storage_adapter do
|
86
337
|
config = configuration
|
87
|
-
|
88
338
|
directory = Dir.new(config.address_book_path)
|
89
339
|
factory = Ppl::Adapter::Storage::Factory.new(vcard_adapter)
|
90
340
|
storage = factory.load_adapter(directory)
|
91
|
-
|
92
341
|
storage.vcard_adapter = vcard_adapter
|
93
|
-
|
342
|
+
storage
|
94
343
|
end
|
95
344
|
|
96
|
-
|
97
|
-
|
98
|
-
return vcard
|
345
|
+
register :vcard_adapter do
|
346
|
+
Ppl::Adapter::Vcard::Vpim.new
|
99
347
|
end
|
100
348
|
|
101
349
|
end
|
@@ -28,6 +28,21 @@ class Ppl::Application::Configuration
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def color_enabled(command_name)
|
32
|
+
config = user_configuration
|
33
|
+
if !config["color"].nil? && config["color"][command_name] == "true"
|
34
|
+
true
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def command_colors(command_name)
|
41
|
+
config = user_configuration
|
42
|
+
search = "color \"#{command_name}\""
|
43
|
+
result = config[search]
|
44
|
+
end
|
45
|
+
|
31
46
|
private
|
32
47
|
|
33
48
|
def default_configuration
|
data/lib/ppl/command/age.rb
CHANGED
@@ -7,11 +7,6 @@ class Ppl::Command::Age < Ppl::Application::Command
|
|
7
7
|
attr_writer :list_format
|
8
8
|
attr_writer :show_format
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@list_format = Ppl::Format::AddressBook::Ages.new
|
12
|
-
@show_format = Ppl::Format::Contact::Age.new
|
13
|
-
end
|
14
|
-
|
15
10
|
def options(parser, options)
|
16
11
|
parser.banner = "usage: ppl age"
|
17
12
|
end
|
data/lib/ppl/command/bday.rb
CHANGED
@@ -7,11 +7,6 @@ class Ppl::Command::Bday < Ppl::Application::Command
|
|
7
7
|
attr_writer :list_format
|
8
8
|
attr_writer :show_format
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@list_format = Ppl::Format::AddressBook::Birthdays.new
|
12
|
-
@show_format = Ppl::Format::Contact::Birthday.new
|
13
|
-
end
|
14
|
-
|
15
10
|
def options(parser, options)
|
16
11
|
parser.banner = "usage: ppl birthday <contact> [<date>]"
|
17
12
|
end
|
data/lib/ppl/command/email.rb
CHANGED
@@ -5,9 +5,7 @@ class Ppl::Command::Email < Ppl::Command::Attribute
|
|
5
5
|
description "Show or change a contact's email address"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@attribute
|
9
|
-
@show_format = Ppl::Format::Contact::EmailAddresses.new
|
10
|
-
@list_format = Ppl::Format::AddressBook::EmailAddresses.new
|
8
|
+
@attribute = :email_addresses
|
11
9
|
end
|
12
10
|
|
13
11
|
def options(parser, options)
|
data/lib/ppl/command/ls.rb
CHANGED
@@ -6,10 +6,6 @@ class Ppl::Command::Ls < Ppl::Application::Command
|
|
6
6
|
|
7
7
|
attr_writer :format
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
@format = Ppl::Format::AddressBook::OneLine.new
|
11
|
-
end
|
12
|
-
|
13
9
|
def options(parser, options)
|
14
10
|
parser.banner = "usage: ppl ls"
|
15
11
|
end
|
@@ -17,7 +13,6 @@ class Ppl::Command::Ls < Ppl::Application::Command
|
|
17
13
|
def execute(input, output)
|
18
14
|
address_book = @storage.load_address_book
|
19
15
|
formatted = @format.process(address_book)
|
20
|
-
|
21
16
|
output.line(formatted)
|
22
17
|
return true
|
23
18
|
end
|
data/lib/ppl/command/mutt.rb
CHANGED
data/lib/ppl/command/name.rb
CHANGED
@@ -7,11 +7,6 @@ class Ppl::Command::Name < Ppl::Application::Command
|
|
7
7
|
attr_writer :show_format
|
8
8
|
attr_writer :list_format
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@show_format = Ppl::Format::Contact::Name.new
|
12
|
-
@list_format = Ppl::Format::AddressBook::Names.new
|
13
|
-
end
|
14
|
-
|
15
10
|
def options(parser, options)
|
16
11
|
parser.banner = "usage: ppl name <contact> [<name>]"
|
17
12
|
end
|
data/lib/ppl/command/nick.rb
CHANGED
@@ -5,9 +5,7 @@ class Ppl::Command::Nick < Ppl::Command::Attribute
|
|
5
5
|
description "List, show or change nicknames"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@attribute
|
9
|
-
@show_format = Ppl::Format::Contact::Nicknames.new
|
10
|
-
@list_format = Ppl::Format::AddressBook::Nicknames.new
|
8
|
+
@attribute = :nicknames
|
11
9
|
end
|
12
10
|
|
13
11
|
def options(parser, options)
|
data/lib/ppl/command/org.rb
CHANGED
@@ -5,9 +5,7 @@ class Ppl::Command::Org < Ppl::Command::Attribute
|
|
5
5
|
description "List, show or change organizations"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@attribute
|
9
|
-
@show_format = Ppl::Format::Contact::Organization.new
|
10
|
-
@list_format = Ppl::Format::AddressBook::Organizations.new
|
8
|
+
@attribute = :organizations
|
11
9
|
end
|
12
10
|
|
13
11
|
def options(parser, options)
|
data/lib/ppl/command/phone.rb
CHANGED
@@ -5,9 +5,7 @@ class Ppl::Command::Phone < Ppl::Command::Attribute
|
|
5
5
|
description "List, show or change phone numbers"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@attribute
|
9
|
-
@show_format = Ppl::Format::Contact::PhoneNumber.new
|
10
|
-
@list_format = Ppl::Format::AddressBook::PhoneNumbers.new
|
8
|
+
@attribute = :phone_numbers
|
11
9
|
end
|
12
10
|
|
13
11
|
def options(parser, options)
|
data/lib/ppl/command/post.rb
CHANGED
@@ -7,11 +7,6 @@ class Ppl::Command::Post < Ppl::Application::Command
|
|
7
7
|
attr_writer :show_format
|
8
8
|
attr_writer :list_format
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@show_format = Ppl::Format::Contact::PostalAddress.new
|
12
|
-
@list_format = Ppl::Format::AddressBook::PostalAddresses.new
|
13
|
-
end
|
14
|
-
|
15
10
|
def options(parser, options)
|
16
11
|
parser.banner = "usage: ppl post <contact> [address]"
|
17
12
|
|
data/lib/ppl/command/url.rb
CHANGED
@@ -5,9 +5,7 @@ class Ppl::Command::Url < Ppl::Command::Attribute
|
|
5
5
|
description "List, show or change URLs"
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@attribute
|
9
|
-
@show_format = Ppl::Format::Contact::Urls.new
|
10
|
-
@list_format = Ppl::Format::AddressBook::Urls.new
|
8
|
+
@attribute = :urls
|
11
9
|
end
|
12
10
|
|
13
11
|
def options(parser, options)
|
@@ -4,8 +4,8 @@ class Ppl::Format::AddressBook::Ages < Ppl::Format::AddressBook
|
|
4
4
|
attr_writer :table
|
5
5
|
attr_writer :date
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
@table = Ppl::Format::Table.new([:id, :age])
|
7
|
+
def initialize(colors={})
|
8
|
+
@table = Ppl::Format::Table.new([:id, :age], colors)
|
9
9
|
@date = Date.today
|
10
10
|
end
|
11
11
|
|
@@ -14,7 +14,6 @@ class Ppl::Format::AddressBook::Ages < Ppl::Format::AddressBook
|
|
14
14
|
@table.to_s
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
private
|
19
18
|
|
20
19
|
def add_row(contact)
|
@@ -24,6 +23,5 @@ class Ppl::Format::AddressBook::Ages < Ppl::Format::AddressBook
|
|
24
23
|
})
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
26
|
end
|
29
27
|
|
@@ -3,8 +3,8 @@ class Ppl::Format::AddressBook::Birthdays < Ppl::Format::AddressBook
|
|
3
3
|
|
4
4
|
attr_writer :table
|
5
5
|
|
6
|
-
def initialize
|
7
|
-
@table = Ppl::Format::Table.new([:id, :birthday])
|
6
|
+
def initialize(colors={})
|
7
|
+
@table = Ppl::Format::Table.new([:id, :birthday], colors)
|
8
8
|
end
|
9
9
|
|
10
10
|
def process(address_book)
|