ppl 3.0.0 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +16 -0
- data/.eleventy.js +86 -0
- data/.eleventyignore +1 -0
- data/.github/workflows/build.yml +61 -0
- data/.gitignore +3 -1
- data/Rakefile +1 -18
- data/{CODE_OF_CONDUCT.md → code_of_conduct.md} +1 -1
- data/features/step_definitions/ppl_steps.rb +27 -27
- data/gh-pages/Gemfile +2 -0
- data/gh-pages/_config.yml +5 -0
- data/gh-pages/_includes/changelog.html +23 -0
- data/gh-pages/_includes/development-sidebar.html +25 -0
- data/gh-pages/_includes/footer.html +22 -0
- data/gh-pages/_includes/header.html +43 -0
- data/gh-pages/_includes/news.html +36 -0
- data/gh-pages/_includes/tip.html +54 -0
- data/gh-pages/_layouts/changelog.html +1 -0
- data/gh-pages/_layouts/command.html +104 -0
- data/gh-pages/_layouts/configuration.html +71 -0
- data/gh-pages/_layouts/development.html +20 -0
- data/gh-pages/_layouts/frontpage.html +6 -0
- data/gh-pages/_layouts/integration.html +44 -0
- data/gh-pages/_layouts/news.html +2 -0
- data/gh-pages/_layouts/page.html +6 -0
- data/gh-pages/_layouts/tip.html +2 -0
- data/gh-pages/_posts/2012-01-15-first-post.md +16 -0
- data/gh-pages/_posts/2012-12-20-1.0.0.md +19 -0
- data/gh-pages/_posts/2012-12-20-1.1.0.md +28 -0
- data/gh-pages/_posts/2012-12-20-1.2.0.md +18 -0
- data/gh-pages/_posts/2012-12-21-1.3.0.md +20 -0
- data/gh-pages/_posts/2012-12-21-thank-you-for-your-all-your-feedback.md +26 -0
- data/gh-pages/_posts/2012-12-22-1.4.1.md +21 -0
- data/gh-pages/_posts/2012-12-22-1.5.0.md +17 -0
- data/gh-pages/_posts/2012-12-23-1.5.1.md +13 -0
- data/gh-pages/_posts/2012-12-23-1.5.2.md +15 -0
- data/gh-pages/_posts/2012-12-26-1.5.3.md +19 -0
- data/gh-pages/_posts/2012-12-27-1.6.0.md +18 -0
- data/gh-pages/_posts/2012-12-29-1.7.0.md +18 -0
- data/gh-pages/_posts/2013-01-05-1.8.0.md +18 -0
- data/gh-pages/_posts/2013-01-06-1.9.0.md +20 -0
- data/gh-pages/_posts/2013-01-10-1.10.0.md +18 -0
- data/gh-pages/_posts/2013-01-20-1.11.0.md +14 -0
- data/gh-pages/_posts/2013-02-16-1.12.0.md +14 -0
- data/gh-pages/_posts/2013-02-17-1.13.0.md +29 -0
- data/gh-pages/_posts/2013-02-17-1.14.0.md +15 -0
- data/gh-pages/_posts/2013-02-17-1.14.1.md +18 -0
- data/gh-pages/_posts/2013-02-17-two-months-in.md +27 -0
- data/gh-pages/_posts/2013-03-16-1.15.0.md +28 -0
- data/gh-pages/_posts/2013-03-16-coloured-output-released.md +27 -0
- data/gh-pages/_posts/2013-04-10-ruby-2.0-compatibility.md +28 -0
- data/gh-pages/_posts/2013-04-11-1.15.1.md +13 -0
- data/gh-pages/_posts/2013-04-12-1.16.0.md +22 -0
- data/gh-pages/_posts/2013-04-14-1.17.0.md +15 -0
- data/gh-pages/_posts/2013-04-14-1.17.1.md +20 -0
- data/gh-pages/_posts/2013-04-14-1.17.2.md +13 -0
- data/gh-pages/_posts/2013-04-15-sync-alias.md +31 -0
- data/gh-pages/_posts/2013-04-15-utf8-fixed-and-more.md +37 -0
- data/gh-pages/_posts/2013-04-16-1.18.0.md +15 -0
- data/gh-pages/_posts/2013-04-16-set-up-color-output.md +47 -0
- data/gh-pages/_posts/2013-04-19-1.19.0.md +13 -0
- data/gh-pages/_posts/2013-04-19-1.20.0.md +15 -0
- data/gh-pages/_posts/2013-04-20-1.21.0.md +16 -0
- data/gh-pages/_posts/2013-04-20-1.22.0.md +14 -0
- data/gh-pages/_posts/2013-04-20-1.22.1.md +13 -0
- data/gh-pages/_posts/2013-04-21-1.22.2.md +15 -0
- data/gh-pages/_posts/2013-04-21-1.23.0.md +35 -0
- data/gh-pages/_posts/2013-04-23-1.24.0.md +16 -0
- data/gh-pages/_posts/2013-04-24-1.25.0.md +21 -0
- data/gh-pages/_posts/2013-05-09-2.0.0.md +33 -0
- data/gh-pages/_posts/2013-05-09-version-2.0.0-released.md +32 -0
- data/gh-pages/_posts/2013-07-20-2.1.0.md +36 -0
- data/gh-pages/_posts/2013-07-20-2.2.0.md +20 -0
- data/gh-pages/_posts/2013-10-12-2.3.0.md +19 -0
- data/gh-pages/_posts/2014-03-30-2.3.1.md +25 -0
- data/gh-pages/_posts/2015-01-05-2.3.2.md +18 -0
- data/gh-pages/_posts/2015-12-03-get-involved.md +29 -0
- data/gh-pages/_posts/2015-12-05-2.3.3.md +16 -0
- data/gh-pages/_posts/2016-01-02-2.4.0.md +19 -0
- data/gh-pages/_posts/2017-05-01-2.4.1.md +12 -0
- data/gh-pages/_posts/2017-10-23-sleep-mode.md +18 -0
- data/gh-pages/_posts/2018-01-03-3.0.1.md +12 -0
- data/gh-pages/_stylesheets/ppl/color.less +119 -0
- data/gh-pages/_stylesheets/ppl/layout.less +54 -0
- data/gh-pages/_stylesheets/ppl/style.less +185 -0
- data/gh-pages/_stylesheets/ppl/typography.less +59 -0
- data/gh-pages/development/changelog/index.md +18 -0
- data/gh-pages/development/changelog/split.rb +51 -0
- data/gh-pages/development/index.html +32 -0
- data/gh-pages/development/roadmap/index.md +15 -0
- data/gh-pages/documentation/about/index.html +63 -0
- data/gh-pages/documentation/commands/add/index.md +43 -0
- data/gh-pages/documentation/commands/age/add/index.md +40 -0
- data/gh-pages/documentation/commands/age/index.md +38 -0
- data/gh-pages/documentation/commands/bday/index.md +44 -0
- data/gh-pages/documentation/commands/completion/index.md +38 -0
- data/gh-pages/documentation/commands/email/index.md +64 -0
- data/gh-pages/documentation/commands/grep/index.md +32 -0
- data/gh-pages/documentation/commands/init/index.md +28 -0
- data/gh-pages/documentation/commands/ls/index.md +55 -0
- data/gh-pages/documentation/commands/mutt/index.md +36 -0
- data/gh-pages/documentation/commands/mv/index.md +26 -0
- data/gh-pages/documentation/commands/name/index.md +45 -0
- data/gh-pages/documentation/commands/nick/index.md +44 -0
- data/gh-pages/documentation/commands/org/index.md +45 -0
- data/gh-pages/documentation/commands/phone/index.md +56 -0
- data/gh-pages/documentation/commands/post/index.md +61 -0
- data/gh-pages/documentation/commands/pull/index.md +39 -0
- data/gh-pages/documentation/commands/push/index.md +36 -0
- data/gh-pages/documentation/commands/remote/index.md +40 -0
- data/gh-pages/documentation/commands/rm/index.md +23 -0
- data/gh-pages/documentation/commands/scrape/index.md +38 -0
- data/gh-pages/documentation/commands/shell/index.md +39 -0
- data/gh-pages/documentation/commands/show/index.md +33 -0
- data/gh-pages/documentation/commands/url/index.md +44 -0
- data/gh-pages/documentation/commands/version/index.md +27 -0
- data/gh-pages/documentation/configuration/address_book/index.md +22 -0
- data/gh-pages/documentation/configuration/alias/index.md +45 -0
- data/gh-pages/documentation/configuration/color/index.md +47 -0
- data/gh-pages/documentation/configuration/color_age/index.md +20 -0
- data/gh-pages/documentation/configuration/color_bday/index.md +20 -0
- data/gh-pages/documentation/configuration/color_email/index.md +21 -0
- data/gh-pages/documentation/configuration/color_ls/index.md +21 -0
- data/gh-pages/documentation/configuration/color_name/index.md +20 -0
- data/gh-pages/documentation/configuration/color_nick/index.md +20 -0
- data/gh-pages/documentation/configuration/color_org/index.md +20 -0
- data/gh-pages/documentation/configuration/color_phone/index.md +22 -0
- data/gh-pages/documentation/configuration/color_post/index.md +20 -0
- data/gh-pages/documentation/configuration/color_url/index.md +20 -0
- data/gh-pages/documentation/configuration/index.html +8 -0
- data/gh-pages/documentation/index.html +183 -0
- data/gh-pages/documentation/integration/bash/index.md +23 -0
- data/gh-pages/documentation/integration/google/index.md +26 -0
- data/gh-pages/documentation/integration/index.html +8 -0
- data/gh-pages/documentation/integration/mutt/index.md +35 -0
- data/gh-pages/documentation/integration/zsh/index.md +19 -0
- data/gh-pages/documentation/quick-start/index.html +88 -0
- data/gh-pages/documentation/tips/index.html +9 -0
- data/gh-pages/index.html +108 -0
- data/gh-pages/news/index.html +9 -0
- data/gh-pages/robots.txt +3 -0
- data/gh-pages/stylesheets/flatstrap.css +10 -0
- data/gh-pages/stylesheets/ppl.scss +235 -0
- data/gh-pages/wiki.png +0 -0
- data/lib/ppl.rb +4 -1
- data/lib/ppl/adapter/color.rb +0 -1
- data/lib/ppl/adapter/color/colored.rb +0 -1
- data/lib/ppl/adapter/email_scraper.rb +0 -1
- data/lib/ppl/adapter/email_scraper/mail.rb +4 -5
- data/lib/ppl/adapter/storage.rb +0 -1
- data/lib/ppl/adapter/storage/disk.rb +0 -1
- data/lib/ppl/adapter/storage/factory.rb +0 -1
- data/lib/ppl/adapter/vcard.rb +0 -1
- data/lib/ppl/adapter/vcard/vpim.rb +5 -1
- data/lib/ppl/application/bootstrap.rb +0 -1
- data/lib/ppl/application/command.rb +0 -1
- data/lib/ppl/application/command_suite.rb +0 -1
- data/lib/ppl/application/configuration.rb +0 -1
- data/lib/ppl/application/input.rb +0 -1
- data/lib/ppl/application/output.rb +0 -1
- data/lib/ppl/application/router.rb +0 -1
- data/lib/ppl/application/shell.rb +0 -1
- data/lib/ppl/command/add.rb +0 -1
- data/lib/ppl/command/age.rb +0 -1
- data/lib/ppl/command/attribute.rb +0 -1
- data/lib/ppl/command/bday.rb +0 -1
- data/lib/ppl/command/completion.rb +0 -1
- data/lib/ppl/command/email.rb +0 -1
- data/lib/ppl/command/external.rb +0 -1
- data/lib/ppl/command/help.rb +0 -1
- data/lib/ppl/command/init.rb +0 -1
- data/lib/ppl/command/ls.rb +0 -1
- data/lib/ppl/command/mutt.rb +0 -1
- data/lib/ppl/command/mv.rb +0 -1
- data/lib/ppl/command/name.rb +0 -1
- data/lib/ppl/command/nick.rb +0 -1
- data/lib/ppl/command/org.rb +0 -1
- data/lib/ppl/command/phone.rb +0 -1
- data/lib/ppl/command/post.rb +0 -1
- data/lib/ppl/command/rm.rb +0 -1
- data/lib/ppl/command/scrape.rb +0 -1
- data/lib/ppl/command/shell.rb +0 -1
- data/lib/ppl/command/show.rb +0 -1
- data/lib/ppl/command/url.rb +0 -1
- data/lib/ppl/command/version.rb +0 -1
- data/lib/ppl/entity/address_book.rb +0 -1
- data/lib/ppl/entity/contact.rb +0 -1
- data/lib/ppl/entity/email_address.rb +0 -1
- data/lib/ppl/entity/name.rb +0 -1
- data/lib/ppl/entity/phone_number.rb +0 -1
- data/lib/ppl/entity/postal_address.rb +0 -1
- data/lib/ppl/error/completion_not_found.rb +0 -1
- data/lib/ppl/error/contact_not_found.rb +0 -1
- data/lib/ppl/error/incorrect_usage.rb +0 -1
- data/lib/ppl/error/invalid_vcard.rb +1 -0
- data/lib/ppl/error/postal_address_not_found.rb +0 -1
- data/lib/ppl/format/address_book.rb +0 -1
- data/lib/ppl/format/address_book/ages.rb +0 -1
- data/lib/ppl/format/address_book/birthdays.rb +0 -1
- data/lib/ppl/format/address_book/email_addresses.rb +0 -1
- data/lib/ppl/format/address_book/mutt_query.rb +0 -1
- data/lib/ppl/format/address_book/names.rb +0 -1
- data/lib/ppl/format/address_book/nicknames.rb +0 -1
- data/lib/ppl/format/address_book/one_line.rb +0 -1
- data/lib/ppl/format/address_book/organizations.rb +0 -1
- data/lib/ppl/format/address_book/phone_numbers.rb +0 -1
- data/lib/ppl/format/address_book/postal_addresses.rb +0 -1
- data/lib/ppl/format/address_book/urls.rb +0 -1
- data/lib/ppl/format/contact.rb +0 -1
- data/lib/ppl/format/contact/age.rb +0 -1
- data/lib/ppl/format/contact/birthday.rb +0 -1
- data/lib/ppl/format/contact/email_addresses.rb +0 -1
- data/lib/ppl/format/contact/full.rb +0 -1
- data/lib/ppl/format/contact/nicknames.rb +0 -1
- data/lib/ppl/format/contact/organization.rb +0 -1
- data/lib/ppl/format/contact/phone_number.rb +0 -1
- data/lib/ppl/format/contact/postal_address.rb +0 -1
- data/lib/ppl/format/contact/postal_addresses.rb +0 -1
- data/lib/ppl/format/contact/urls.rb +0 -1
- data/lib/ppl/format/custom.rb +0 -1
- data/lib/ppl/format/custom/contact.rb +0 -1
- data/lib/ppl/format/custom/email_address.rb +0 -1
- data/lib/ppl/format/custom/phone_number.rb +0 -1
- data/lib/ppl/format/name.rb +0 -1
- data/lib/ppl/format/name/full_only.rb +0 -1
- data/lib/ppl/format/postal_address.rb +0 -1
- data/lib/ppl/format/postal_address/multi_line.rb +0 -1
- data/lib/ppl/format/postal_address/one_line.rb +0 -1
- data/lib/ppl/format/table.rb +0 -1
- data/lib/ppl/service/email_address.rb +0 -1
- data/lib/ppl/service/name.rb +0 -1
- data/lib/ppl/service/phone_number.rb +0 -1
- data/lib/ppl/service/postal_address.rb +0 -1
- data/{LICENSE → license} +0 -0
- data/makefile +18 -0
- data/package.json +23 -0
- data/ppl.gemspec +15 -13
- data/{README.md → readme.md} +12 -9
- data/site/_data/url.js +4 -0
- data/site/casts/hero.cast +189 -0
- data/site/development.njk +6 -0
- data/site/documentation.njk +6 -0
- data/site/index.njk +75 -0
- data/site/news.njk +6 -0
- data/site/style.scss +140 -0
- data/spec/ppl/adapter/color/colored_spec.rb +3 -4
- data/spec/ppl/adapter/color_spec.rb +0 -1
- data/spec/ppl/adapter/email_scraper/mail_spec.rb +13 -13
- data/spec/ppl/adapter/email_scraper_spec.rb +0 -1
- data/spec/ppl/adapter/output_spec.rb +7 -8
- data/spec/ppl/adapter/storage/disk_spec.rb +18 -19
- data/spec/ppl/adapter/storage/factory_spec.rb +3 -4
- data/spec/ppl/adapter/storage/git_spec.rb +31 -32
- data/spec/ppl/adapter/storage_spec.rb +3 -4
- data/spec/ppl/adapter/vcard/greencard_spec.rb +45 -45
- data/spec/ppl/adapter/vcard_spec.rb +0 -1
- data/spec/ppl/application/bootstrap_spec.rb +128 -129
- data/spec/ppl/application/command_spec.rb +8 -9
- data/spec/ppl/application/command_suite_spec.rb +7 -8
- data/spec/ppl/application/configuration_spec.rb +16 -17
- data/spec/ppl/application/input_spec.rb +2 -3
- data/spec/ppl/application/router_spec.rb +8 -9
- data/spec/ppl/application/shell_spec.rb +39 -40
- data/spec/ppl/command/add_spec.rb +6 -7
- data/spec/ppl/command/age_spec.rb +7 -8
- data/spec/ppl/command/attribute_spec.rb +22 -23
- data/spec/ppl/command/bday_spec.rb +11 -12
- data/spec/ppl/command/completion_spec.rb +7 -8
- data/spec/ppl/command/email_spec.rb +19 -20
- data/spec/ppl/command/external_spec.rb +7 -8
- data/spec/ppl/command/help_spec.rb +15 -16
- data/spec/ppl/command/init_spec.rb +5 -6
- data/spec/ppl/command/ls_spec.rb +12 -13
- data/spec/ppl/command/mutt_spec.rb +33 -34
- data/spec/ppl/command/mv_spec.rb +11 -12
- data/spec/ppl/command/name_spec.rb +17 -18
- data/spec/ppl/command/nick_spec.rb +1 -2
- data/spec/ppl/command/org_spec.rb +1 -2
- data/spec/ppl/command/phone_spec.rb +15 -16
- data/spec/ppl/command/post_spec.rb +29 -30
- data/spec/ppl/command/rm_spec.rb +3 -4
- data/spec/ppl/command/scrape_spec.rb +24 -25
- data/spec/ppl/command/shell_spec.rb +41 -42
- data/spec/ppl/command/show_spec.rb +4 -5
- data/spec/ppl/command/url_spec.rb +1 -2
- data/spec/ppl/command/version_spec.rb +4 -5
- data/spec/ppl/entity/address_book_spec.rb +1 -2
- data/spec/ppl/entity/contact_spec.rb +16 -17
- data/spec/ppl/entity/email_address_spec.rb +3 -4
- data/spec/ppl/entity/name_spec.rb +1 -2
- data/spec/ppl/entity/phone_number_spec.rb +5 -6
- data/spec/ppl/entity/postal_address_spec.rb +2 -3
- data/spec/ppl/format/address_book/ages_spec.rb +3 -4
- data/spec/ppl/format/address_book/birthdays_spec.rb +3 -4
- data/spec/ppl/format/address_book/email_addresses_spec.rb +3 -4
- data/spec/ppl/format/address_book/mutt_query_spec.rb +3 -4
- data/spec/ppl/format/address_book/names_spec.rb +3 -4
- data/spec/ppl/format/address_book/nicknames_spec.rb +4 -5
- data/spec/ppl/format/address_book/one_line_spec.rb +5 -6
- data/spec/ppl/format/address_book/organizations_spec.rb +3 -4
- data/spec/ppl/format/address_book/phone_numbers_spec.rb +3 -4
- data/spec/ppl/format/address_book/postal_addresses_spec.rb +2 -3
- data/spec/ppl/format/address_book/urls_spec.rb +3 -4
- data/spec/ppl/format/address_book_spec.rb +0 -1
- data/spec/ppl/format/contact/age_spec.rb +8 -9
- data/spec/ppl/format/contact/birthday_spec.rb +4 -5
- data/spec/ppl/format/contact/email_addresses_spec.rb +3 -4
- data/spec/ppl/format/contact/full_spec.rb +11 -12
- data/spec/ppl/format/contact/nicknames_spec.rb +4 -5
- data/spec/ppl/format/contact/organization_spec.rb +4 -5
- data/spec/ppl/format/contact/phone_number_spec.rb +4 -5
- data/spec/ppl/format/contact/postal_address_spec.rb +1 -2
- data/spec/ppl/format/contact/postal_addresses_spec.rb +3 -4
- data/spec/ppl/format/contact/urls_spec.rb +4 -5
- data/spec/ppl/format/contact_spec.rb +0 -1
- data/spec/ppl/format/custom/contact_spec.rb +13 -14
- data/spec/ppl/format/custom/email_address_spec.rb +3 -4
- data/spec/ppl/format/custom/phone_number_spec.rb +4 -5
- data/spec/ppl/format/custom_spec.rb +6 -7
- data/spec/ppl/format/name/full_only_spec.rb +4 -5
- data/spec/ppl/format/name_spec.rb +0 -1
- data/spec/ppl/format/postal_address/multi_line_spec.rb +10 -11
- data/spec/ppl/format/postal_address/one_line_spec.rb +9 -10
- data/spec/ppl/format/postal_address_spec.rb +0 -1
- data/spec/ppl/format/table_spec.rb +11 -11
- data/spec/ppl/service/email_address_spec.rb +13 -14
- data/spec/ppl/service/name_spec.rb +9 -10
- data/spec/ppl/service/phone_number_spec.rb +11 -12
- data/spec/ppl/service/postal_address_spec.rb +20 -21
- data/spec/spec_helper.rb +4 -0
- data/yarn.lock +3605 -0
- metadata +183 -22
- data/.travis.yml +0 -11
- data/COPYING +0 -339
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
describe Ppl::Adapter::Color::Colored do
|
3
2
|
|
4
3
|
before(:each) do
|
@@ -9,13 +8,13 @@ describe Ppl::Adapter::Color::Colored do
|
|
9
8
|
|
10
9
|
it "should colorize the string using the monkeypatched String method" do
|
11
10
|
string = "example"
|
12
|
-
string.
|
13
|
-
@adapter.colorize(string, "red").
|
11
|
+
expect(string).to receive(:red).and_return("red example")
|
12
|
+
expect(@adapter.colorize(string, "red")).to eq "red example"
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should only attempt to colorize the string if the color exists" do
|
17
16
|
string = "example"
|
18
|
-
@adapter.colorize(string, "neon").
|
17
|
+
expect(@adapter.colorize(string, "neon")).to eq "example"
|
19
18
|
end
|
20
19
|
|
21
20
|
end
|
@@ -11,7 +11,7 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
11
11
|
describe "#scrape_contacts" do
|
12
12
|
|
13
13
|
it "should return an array" do
|
14
|
-
@adapter.scrape_contacts("").
|
14
|
+
expect(@adapter.scrape_contacts("")).to eq []
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should scrape the sender's name" do
|
@@ -26,9 +26,9 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
26
26
|
"This is a test email.",
|
27
27
|
"Bye!",
|
28
28
|
].join("\n")
|
29
|
-
@storage.
|
29
|
+
expect(@storage).to receive(:load_contact).and_return(nil)
|
30
30
|
contacts = @adapter.scrape_contacts(email)
|
31
|
-
contacts.first.name.full.
|
31
|
+
expect(contacts.first.name.full).to eq "Test User"
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should scrape the sender's email address" do
|
@@ -43,9 +43,9 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
43
43
|
"This is a test email.",
|
44
44
|
"Bye!",
|
45
45
|
].join("\n")
|
46
|
-
@storage.
|
46
|
+
expect(@storage).to receive(:load_contact).and_return(nil)
|
47
47
|
contacts = @adapter.scrape_contacts(email)
|
48
|
-
contacts.first.email_addresses.first.address.
|
48
|
+
expect(contacts.first.email_addresses.first.address).to eq "test@example.org"
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should generate an ID for the sender based on their name" do
|
@@ -60,9 +60,9 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
60
60
|
"This is a test email.",
|
61
61
|
"Bye!",
|
62
62
|
].join("\n")
|
63
|
-
@storage.
|
63
|
+
expect(@storage).to receive(:load_contact).and_return(nil)
|
64
64
|
contacts = @adapter.scrape_contacts(email)
|
65
|
-
contacts.first.id.
|
65
|
+
expect(contacts.first.id).to eq "test_user"
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should generate a sender ID based on email address if there's no name" do
|
@@ -78,7 +78,7 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
78
78
|
"Bye!",
|
79
79
|
].join("\n")
|
80
80
|
contacts = @adapter.scrape_contacts(email)
|
81
|
-
contacts.first.id.
|
81
|
+
expect(contacts.first.id).to eq "test@example.org"
|
82
82
|
end
|
83
83
|
|
84
84
|
it "avoids overwriting an existing contact ID" do
|
@@ -93,10 +93,10 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
93
93
|
"This is a test email.",
|
94
94
|
"Bye!",
|
95
95
|
].join("\n")
|
96
|
-
@storage.
|
97
|
-
@storage.
|
96
|
+
expect(@storage).to receive(:load_contact).with("test_user").and_return(Ppl::Entity::Contact.new)
|
97
|
+
expect(@storage).to receive(:load_contact).with("test_user_1").and_return(nil)
|
98
98
|
contacts = @adapter.scrape_contacts(email)
|
99
|
-
contacts.first.id.
|
99
|
+
expect(contacts.first.id).to eq "test_user_1"
|
100
100
|
end
|
101
101
|
|
102
102
|
it "allows non-ASCII sender names" do
|
@@ -112,10 +112,10 @@ describe Ppl::Adapter::EmailScraper::Mail do
|
|
112
112
|
"Bye!",
|
113
113
|
].join("\n")
|
114
114
|
|
115
|
-
@storage.
|
115
|
+
expect(@storage).to receive(:load_contact).and_return(nil)
|
116
116
|
contacts = @adapter.scrape_contacts(email)
|
117
117
|
|
118
|
-
contacts.first.name.full.
|
118
|
+
expect(contacts.first.name.full).to eq "Александр"
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
@@ -1,16 +1,15 @@
|
|
1
|
-
|
2
1
|
describe Ppl::Application::Output, "#initialize" do
|
3
2
|
|
4
3
|
it "should accept stdout" do
|
5
4
|
stdout = Object.new
|
6
5
|
@output = Ppl::Application::Output.new(stdout, nil)
|
7
|
-
@output.stdout.
|
6
|
+
expect(@output.stdout).to be stdout
|
8
7
|
end
|
9
8
|
|
10
9
|
it "should accept stderr" do
|
11
10
|
stderr = Object.new
|
12
11
|
@output = Ppl::Application::Output.new(nil, stderr)
|
13
|
-
@output.stderr.
|
12
|
+
expect(@output.stderr).to be stderr
|
14
13
|
end
|
15
14
|
|
16
15
|
end
|
@@ -26,7 +25,7 @@ describe Ppl::Application::Output do
|
|
26
25
|
describe "#error" do
|
27
26
|
it "should delegate to stderr's puts method" do
|
28
27
|
string = "COMPUTER OVER. VIRUS = VERY YES"
|
29
|
-
@stderr.
|
28
|
+
expect(@stderr).to receive(:puts).with(string)
|
30
29
|
@output.error(string)
|
31
30
|
end
|
32
31
|
end
|
@@ -34,25 +33,25 @@ describe Ppl::Application::Output do
|
|
34
33
|
describe "#line" do
|
35
34
|
it "should delegate to stdout's puts method" do
|
36
35
|
string = "The quick brown fox"
|
37
|
-
@stdout.
|
36
|
+
expect(@stdout).to receive(:puts).with(string)
|
38
37
|
@output.line(string)
|
39
38
|
end
|
40
39
|
|
41
40
|
it "should not send carriage returns to stdout" do
|
42
41
|
string = "The quick brown fox
|
43
|
-
@stdout.
|
42
|
+
expect(@stdout).to receive(:puts).with("The quick brown fox")
|
44
43
|
@output.line(string)
|
45
44
|
end
|
46
45
|
|
47
46
|
it "should not send carriage returns to stderr" do
|
48
47
|
string = "The quick brown fox
|
49
|
-
@stderr.
|
48
|
+
expect(@stderr).to receive(:puts).with("The quick brown fox")
|
50
49
|
@output.error(string)
|
51
50
|
end
|
52
51
|
|
53
52
|
it "should not sanitise output if nil" do
|
54
53
|
string = nil
|
55
|
-
@stdout.
|
54
|
+
expect(@stdout).to receive(:puts).with(nil)
|
56
55
|
@output.line(string)
|
57
56
|
end
|
58
57
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
describe Ppl::Adapter::Storage::Disk, "#create_address_book" do
|
3
2
|
|
4
3
|
before(:each) do
|
@@ -12,13 +11,13 @@ describe Ppl::Adapter::Storage::Disk, "#create_address_book" do
|
|
12
11
|
describe "#create_address_book" do
|
13
12
|
it "should create the directory if it doesn't exist yet" do
|
14
13
|
Ppl::Adapter::Storage::Disk.create_address_book("/contacts")
|
15
|
-
Dir.exists?("/contacts").
|
14
|
+
expect(Dir.exists?("/contacts")).to eq true
|
16
15
|
FileUtils.rm_rf("/contacts")
|
17
16
|
end
|
18
17
|
it "should return a Ppl::Adapter::Storage::Disk" do
|
19
18
|
disk = Ppl::Adapter::Storage::Disk.create_address_book("/contacts")
|
20
19
|
FileUtils.rm_rf("/contacts")
|
21
|
-
disk.
|
20
|
+
expect(disk).to be_a(Ppl::Adapter::Storage::Disk)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -29,7 +28,7 @@ describe Ppl::Adapter::Storage::Disk, "#initialize" do
|
|
29
28
|
it "should accept a Dir object" do
|
30
29
|
directory = Dir.new("/tmp")
|
31
30
|
@storage = Ppl::Adapter::Storage::Disk.new(directory)
|
32
|
-
@storage.directory.
|
31
|
+
expect(@storage.directory).to be directory
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
@@ -44,7 +43,7 @@ describe Ppl::Adapter::Storage::Disk do
|
|
44
43
|
it "should accept a vcard adapter" do
|
45
44
|
adapter = double(Ppl::Adapter::Vcard)
|
46
45
|
@storage.vcard_adapter = adapter
|
47
|
-
@storage.vcard_adapter.
|
46
|
+
expect(@storage.vcard_adapter).to be adapter
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -71,24 +70,24 @@ describe Ppl::Adapter::Storage::Disk do
|
|
71
70
|
|
72
71
|
describe "#path" do
|
73
72
|
it "should return the path of the directory" do
|
74
|
-
@storage.path.
|
73
|
+
expect(@storage.path).to eq "/contacts"
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
77
|
describe "#load_address_book" do
|
79
78
|
|
80
79
|
it "should return a Ppl::Entity::AddressBook" do
|
81
|
-
@storage.load_address_book.
|
80
|
+
expect(@storage.load_address_book).to be_a(Ppl::Entity::AddressBook)
|
82
81
|
end
|
83
82
|
|
84
83
|
it "should fill the address book with the contacts in the directory" do
|
85
84
|
FileUtils.touch "/contacts/one.vcf"
|
86
85
|
FileUtils.touch "/contacts/two.vcf"
|
87
86
|
|
88
|
-
@adapter.
|
87
|
+
expect(@adapter).to receive(:decode).twice
|
89
88
|
|
90
89
|
address_book = @storage.load_address_book
|
91
|
-
address_book.contacts.count.
|
90
|
+
expect(address_book.contacts.count).to eq 2
|
92
91
|
end
|
93
92
|
|
94
93
|
end
|
@@ -96,19 +95,19 @@ describe Ppl::Adapter::Storage::Disk do
|
|
96
95
|
describe "#load_contact" do
|
97
96
|
|
98
97
|
it "should return nil if the given contact doesn't exist" do
|
99
|
-
@storage.load_contact("xyz").
|
98
|
+
expect(@storage.load_contact("xyz")).to be nil
|
100
99
|
end
|
101
100
|
|
102
101
|
it "should return a Ppl::Entity::Contact" do
|
103
102
|
FileUtils.touch "/contacts/one.vcf"
|
104
|
-
@adapter.
|
105
|
-
@storage.load_contact("one").
|
103
|
+
expect(@adapter).to receive(:decode).once.and_return(@contact)
|
104
|
+
expect(@storage.load_contact("one")).to be_a(Ppl::Entity::Contact)
|
106
105
|
end
|
107
106
|
|
108
107
|
it "should populate the contact's id" do
|
109
108
|
FileUtils.touch "/contacts/one.vcf"
|
110
|
-
@adapter.
|
111
|
-
@storage.load_contact("one").id.
|
109
|
+
expect(@adapter).to receive(:decode).once.and_return(@contact)
|
110
|
+
expect(@storage.load_contact("one").id).to eq "one"
|
112
111
|
end
|
113
112
|
|
114
113
|
end
|
@@ -116,12 +115,12 @@ describe Ppl::Adapter::Storage::Disk do
|
|
116
115
|
describe "#save_contact" do
|
117
116
|
|
118
117
|
it "should write the contact to disk" do
|
119
|
-
@adapter.
|
118
|
+
expect(@adapter).to receive(:encode).with(@contact).and_return("asdfg")
|
120
119
|
|
121
120
|
@contact.id = "test"
|
122
121
|
@storage.save_contact(@contact)
|
123
122
|
|
124
|
-
File.read("/contacts/test.vcf").
|
123
|
+
expect(File.read("/contacts/test.vcf")).to eq "asdfg"
|
125
124
|
end
|
126
125
|
|
127
126
|
end
|
@@ -131,20 +130,20 @@ describe Ppl::Adapter::Storage::Disk do
|
|
131
130
|
FileUtils.touch "/contacts/test.vcf"
|
132
131
|
@contact.id = "test"
|
133
132
|
@storage.delete_contact(@contact)
|
134
|
-
File.exists?("/contacts/test.vcf").
|
133
|
+
expect(File.exists?("/contacts/test.vcf")).to eq false
|
135
134
|
end
|
136
135
|
end
|
137
136
|
|
138
137
|
describe "#filename_for_contact" do
|
139
138
|
it "should base the filename on the contact's id" do
|
140
139
|
@contact.id = "test"
|
141
|
-
@storage.filename_for_contact(@contact).
|
140
|
+
expect(@storage.filename_for_contact(@contact)).to eq "/contacts/test.vcf"
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
145
144
|
describe "#filename_for_contact_id" do
|
146
145
|
it "should base the filename on the directory path" do
|
147
|
-
@storage.filename_for_contact_id("test").
|
146
|
+
expect(@storage.filename_for_contact_id("test")).to eq "/contacts/test.vcf"
|
148
147
|
end
|
149
148
|
end
|
150
149
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
describe Ppl::Adapter::Storage::Factory do
|
3
2
|
|
4
3
|
before(:each) do
|
@@ -9,7 +8,7 @@ describe Ppl::Adapter::Storage::Factory do
|
|
9
8
|
@directory = Dir.new("/contacts")
|
10
9
|
@repo = double(Rugged::Repository)
|
11
10
|
|
12
|
-
Rugged::Repository.
|
11
|
+
allow(Rugged::Repository).to receive(:new).and_return(@repo)
|
13
12
|
end
|
14
13
|
|
15
14
|
after(:each) do
|
@@ -20,12 +19,12 @@ describe Ppl::Adapter::Storage::Factory do
|
|
20
19
|
describe "#load_adapter" do
|
21
20
|
|
22
21
|
it "should return a disk adapter by default" do
|
23
|
-
@factory.load_adapter(@directory).
|
22
|
+
expect(@factory.load_adapter(@directory)).to be_a(Ppl::Adapter::Storage::Disk)
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should return a git adapter if the directory is a git repository" do
|
27
26
|
Dir.mkdir "/contacts/.git"
|
28
|
-
@factory.load_adapter(@directory).
|
27
|
+
expect(@factory.load_adapter(@directory)).to be_a(Ppl::Adapter::Storage::Git)
|
29
28
|
end
|
30
29
|
|
31
30
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require "ostruct"
|
3
2
|
|
4
3
|
describe Ppl::Adapter::Storage::Git do
|
@@ -14,11 +13,11 @@ describe Ppl::Adapter::Storage::Git do
|
|
14
13
|
@vcard = double(Ppl::Adapter::Vcard)
|
15
14
|
@target = double(Rugged::Commit)
|
16
15
|
|
17
|
-
Rugged::Repository.
|
16
|
+
allow(Rugged::Repository).to receive(:new).and_return(@repo)
|
18
17
|
|
19
|
-
@disk.
|
20
|
-
@disk.
|
21
|
-
@contact.
|
18
|
+
allow(@disk).to receive(:directory).and_return(Dir.new("/contacts"))
|
19
|
+
allow(@disk).to receive(:path).and_return("/contacts")
|
20
|
+
allow(@contact).to receive(:id).and_return("test")
|
22
21
|
|
23
22
|
@git = Ppl::Adapter::Storage::Git.new(@disk)
|
24
23
|
@git.vcard_adapter = @vcard
|
@@ -31,16 +30,16 @@ describe Ppl::Adapter::Storage::Git do
|
|
31
30
|
|
32
31
|
describe "#path" do
|
33
32
|
it "should return the path of the repository" do
|
34
|
-
@git.path.
|
33
|
+
expect(@git.path).to eq "/contacts"
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
describe "#initialize" do
|
39
38
|
it "should accept a disk storage adapter" do
|
40
|
-
@git.disk.
|
39
|
+
expect(@git.disk).to be @disk
|
41
40
|
end
|
42
41
|
it "should instantiate rugged" do
|
43
|
-
@git.repository.
|
42
|
+
expect(@git.repository).to be @repo
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -51,12 +50,12 @@ describe Ppl::Adapter::Storage::Git do
|
|
51
50
|
|
52
51
|
@files = [{:name => "test.vcf"}]
|
53
52
|
|
54
|
-
@commit.
|
55
|
-
@target.
|
56
|
-
@repo.
|
57
|
-
@repo.
|
53
|
+
expect(@commit).to receive(:target).and_return(@target)
|
54
|
+
expect(@target).to receive(:oid)
|
55
|
+
expect(@repo).to receive(:lookup).and_return(@head)
|
56
|
+
expect(@repo).to receive(:head).and_return(@commit)
|
58
57
|
|
59
|
-
@git.
|
58
|
+
allow(@git).to receive(:load_contact) do |id|
|
60
59
|
contact = Ppl::Entity::Contact.new
|
61
60
|
contact.id = id
|
62
61
|
contact
|
@@ -65,17 +64,17 @@ describe Ppl::Adapter::Storage::Git do
|
|
65
64
|
end
|
66
65
|
|
67
66
|
it "should return an address book" do
|
68
|
-
@head.
|
69
|
-
@git.load_address_book.
|
67
|
+
expect(@head).to receive(:tree).and_return(@files)
|
68
|
+
expect(@git.load_address_book).to be_a(Ppl::Entity::AddressBook)
|
70
69
|
end
|
71
70
|
|
72
71
|
it "should not put anything except contacts in the address book" do
|
73
72
|
@files = [{:name => "poop.vcf"}, {:name => ".ppl"}]
|
74
|
-
@head.
|
73
|
+
expect(@head).to receive(:tree).and_return(@files)
|
75
74
|
|
76
75
|
address_book = @git.load_address_book
|
77
76
|
address_book.contacts.each do |contact|
|
78
|
-
contact.
|
77
|
+
expect(contact).to be_a(Ppl::Entity::Contact)
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -92,10 +91,10 @@ describe Ppl::Adapter::Storage::Git do
|
|
92
91
|
blob = OpenStruct.new
|
93
92
|
blob.content = 'vcard contents'
|
94
93
|
|
95
|
-
@repo.
|
96
|
-
@repo.
|
97
|
-
@vcard.
|
98
|
-
@contact.
|
94
|
+
expect(@repo).to receive(:head).and_return(head)
|
95
|
+
expect(@repo).to receive(:blob_at).and_return(blob)
|
96
|
+
expect(@vcard).to receive(:decode).and_return(@contact)
|
97
|
+
expect(@contact).to receive(:id=).with("test")
|
99
98
|
|
100
99
|
contact = @git.load_contact("test")
|
101
100
|
end
|
@@ -109,9 +108,9 @@ describe Ppl::Adapter::Storage::Git do
|
|
109
108
|
blob = OpenStruct.new
|
110
109
|
blob.content = 'vcard contents'
|
111
110
|
|
112
|
-
@repo.
|
113
|
-
@repo.
|
114
|
-
@vcard.
|
111
|
+
expect(@repo).to receive(:head).and_return(head)
|
112
|
+
expect(@repo).to receive(:blob_at).and_return(blob)
|
113
|
+
expect(@vcard).to receive(:decode).and_raise(Vpim::InvalidEncodingError)
|
115
114
|
expect{ @git.load_contact("test") }.to raise_error(Ppl::Error::InvalidVcard)
|
116
115
|
end
|
117
116
|
|
@@ -120,19 +119,19 @@ describe Ppl::Adapter::Storage::Git do
|
|
120
119
|
describe "#save_contact" do
|
121
120
|
|
122
121
|
it "should save the contact to disk" do
|
123
|
-
@disk.
|
124
|
-
@git.
|
125
|
-
@git.
|
122
|
+
expect(@disk).to receive(:save_contact).with(@contact)
|
123
|
+
allow(@git).to receive(:add)
|
124
|
+
allow(@git).to receive(:commit)
|
126
125
|
@git.save_contact(@contact)
|
127
126
|
end
|
128
127
|
|
129
128
|
it "should commit the changes" do
|
130
|
-
@disk.
|
131
|
-
@git.
|
132
|
-
file.
|
129
|
+
expect(@disk).to receive(:save_contact)
|
130
|
+
allow(@git).to receive(:add) do |file|
|
131
|
+
expect(file).to eq "test.vcf"
|
133
132
|
end
|
134
|
-
@git.
|
135
|
-
message.
|
133
|
+
allow(@git).to receive(:commit) do |message|
|
134
|
+
expect(message).to eq "save_contact(test)"
|
136
135
|
end
|
137
136
|
@git.save_contact(@contact)
|
138
137
|
end
|