syc-ontact 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. checksums.yaml +4 -4
  2. metadata +2 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe93582cead2b2ccc48d60fcaa54a8d602baec10
4
- data.tar.gz: 501cacb2bc96c5fb42e65226012da13859a0ce97
3
+ metadata.gz: 80e73e81f14547f26d98fe5b679b99f01ead7983
4
+ data.tar.gz: f45271ffbf6dd223f03b3d93fce00be6e953a192
5
5
  SHA512:
6
- metadata.gz: 4fb3c6fb9ed8d190de1a2f8e4525d99b5573b633abd5d4fe88c2ad44ebeda43036c587aa1c249fd7e964b14b021acd01cb9dec4ad42f15fd31b16f43ec21aa80
7
- data.tar.gz: 1409a116127b05967202549f873093b370994d20d297b97d5041c5dfc4dd1a764a6e674f896619a5ab1488230c6f013a807da37005b691a5a4050f9ab6b95221
6
+ metadata.gz: 8bc9da0fa153b04b30783d8237dc6ace3af4d5a697318815bed2e469e41ac54965a56ebdcd5acbf76ceebed83166ce9efe0deeb3830df7ff5debacd32e5d809c
7
+ data.tar.gz: ec13459becd9acf3d567cbe8f661e67f3ad78754817e26c4652a19da4fd84232793ced15ae702916b2c99169ce4e31e9a0c07976b2d1ffa59caa2533601918f2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syc-ontact
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Sugar
@@ -24,81 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: "sycontact\n=========\n`syc-ontact` is a command line interface for looking
28
- up contacts from any source that is providing contact information.\n\nInstallation\n============\n`gem
29
- install sycontact`\n\nSetup\n=====\nTo use `sycontact` a source-file has to be provided.
30
- The source-file is Ruby script retrieving the data from the source. A source can
31
- be anything that can be read from the Ruby script, e.g. a web site, an LDAP server,
32
- a file with contact data.\n\n**Note:** Without a user defined Ruby script file (a
33
- Ruby module) `sycontact` will do nothing but \n creating a configuration
34
- file, a source directory and displaying the help page.\n\nTo get `sycontact` to
35
- life you have to follow these setup steps:\n\n1. start `sycontact` once. This will
36
- create the configuration file and the working directory\n2. provide a Ruby module
37
- describing how to retrieve the data from the source. The module name has\n to
38
- be `some_name_source.rb`.\n\nThe Ruby source code below describes a source-file
39
- that is retrieving contact data from a contact directory with the name *test-contacts*
40
- below the module's directory.\n\n\n```\nmodule AddressSource\n\n # Where to find
41
- the contact files\n URL = File.join(File.dirname(__FILE__), \"test-contacts\")\n\n
42
- \ # Regex to extract contact data from the contact files\n REGEX = { cn: /(?<=<common_name>)[\\w
43
- -]*(?=<\\common_name>)/,\n sn: /(?<=<surname>)[\\w -]*(?=<\\/surname>)/,\n
44
- \ gn: /(?<=<given_name>)[\\w -]*(?=<\\/given_name>)/,\n c:
45
- /(?<=<country>)[\\w]*(?=<\\/country>)/,\n l: /(?<=<location>)[\\w]*(?=<\\/location>)/,\n
46
- \ st: /(?<=<state>)[\\w]*(?=<\\/state>)/,\n street: /(?<=<street>)[\\w
47
- .]*(?=<\\/street>)/,\n o: /(?<=<organization>)[\\w -]*(?=<\\/organization>)/,\n
48
- \ ou: /(?<=<department>)[\\w -]*(?=<\\/department>)/,\n title:
49
- /(?<=<title>)[\\w .-]*(?=<\\/title>)/,\n description: /(?<=<description>)[\\w
50
- -+]*(?=<\\/description>)/,\n telephone: /(?<=<telephone>)[\\w +()-]*(?=<\\/telephone>)/,\n
51
- \ mobile: /(?<=<mobile>)[\\w +()-]*(?=<\\/mobile>)/,\n mail:
52
- /(?<=<email>)[\\w @.-]*(?=<\\/email>)/\n }\n\n # Mandatory method! Will
53
- be invoked by `sycontact`.\n # Will lookup the contact based on the pattern provided\n
54
- \ def lookup(pattern = {})\n contacts = []\n create_source_files(pattern).each
55
- do |source_file|\n\n next unless File.exist? source_file\n\n source =
56
- File.read(source_file)\n\n next if source.empty?\n\n values = {}\n\n REGEX.each
57
- do |key, regex|\n value = source.scan(regex)[0]\n values[key] = value
58
- if value\n end\n\n contacts << values\n end\n\n contacts.keep_if
59
- do |contact|\n pattern.each.reduce(true) do |match, pattern| \n contact_does_not_have_key
60
- = contact[pattern[0]].nil?\n regex = Regexp.new(pattern[1].strip.downcase)\n
61
- \ pos = regex =~ contact[pattern[0]].strip.downcase unless contact_does_not_have_key\n
62
- \ match and (not pos.nil? or contact_does_not_have_key)\n end\n end\n
63
- \ end\n\n private\n\n # Creates the contact file name. In this case the contact
64
- files have to be in the form\n # firstname_lastname.contact or lastname_firstname.contact.
65
- If neather is given all *_*.contact\n # files are retrieved\n def create_source_files(pattern)\n
66
- \ source_files = []\n if pattern[:cn]\n names = pattern[:cn].scan(/(^[a-zA-Z]*)[^a-zA-Z]*([a-zA-Z]*)/).flatten\n
67
- \ names[0] = '*' if names[0].empty?\n names[1] = '*' if names[1].empty?\n
68
- \ names.permutation do |names|\n file = File.join(URL, \"#{names.join('_').downcase}.contact\")\n
69
- \ Dir.glob(file).each { |file| source_files << file }\n end\n elsif
70
- pattern[:sn] or pattern[:gn]\n sn = pattern[:sn] ? pattern[:sn].strip.downcase
71
- : '*'\n gn = pattern[:gn] ? pattern[:gn].strip.downcase : '*'\n Dir.glob(File.join(URL,
72
- \"#{gn}_#{sn}.contact\")).each do |file|\n source_files << file\n end\n
73
- \ else\n Dir.glob(File.join(URL, \"*_*.contact\")).each do |file|\n source_files
74
- << file\n end\n end\n source_files\n end\nend\n```\n\n**Listing
75
- 1: Source-file to provide information about how to retrieve contact information**\n\nBelow
76
- a contact file that can be read by the above source module.\n\n```\n<common_name>Sugar
77
- Pierre</common_name>\n<given_name>Pierre</given_name>\n<surname>Sugar</surname>\n<country>CA</country>\n<location>Vancouver</location>\n<state>BC</state>\n<street>Robson
78
- Street</street>\n<organization>SugarYourCoffee</organization>\n<department>DevOps</department>\n<telephone>+001
79
- (123) 4567</telephone>\n<mobile>+001 (765) 4321</mobile>\n<email>pierre@sugaryourcoffee.de</email>\n```\n\n**Listing
80
- 2: Contact file that can be read by the `AddressSource` module**\n\nUsage\n=====\n\nGet
81
- help for sycontact\n\n $ sycontact -h\n\n```\nUsage: sycontact [options]\n -p,
82
- --print RAW|SUMMARY|ALL Print contact attributes\n SUMMARY
83
- (default)\n --cn COMMON_NAME Common name e.g. 'Jane Doe' or 'Doe,
84
- Jane'\n --sn SURNAME Surname e.g. 'Doe'\n --gn GIVEN_NAME
85
- \ Given name e.g. 'Jane'\n --uid USER_ID User
86
- ID\n -c COUNTRY Country in ISO 3166 e.g. 'CA' for Canada\n
87
- \ -l LOCATION City e.g. 'Vancouver'\n --st STATE State
88
- e.g. 'British Columbia'\n --street STREET Street e.g. 'Robson
89
- Street'\n -o ORGANIZATION Organization e.g. 'Northstar'\n --ou
90
- ORGANIZATIONAL_UNIT Department e.g. 'R&D'\n --title TITLE Title
91
- e.g. 'Dr.'\n --description DESCRIPTION Description e.g. 'Head of R&D'\n
92
- \ --telephone TELEPHONE Telephone number e.g. '+001 (252) 4354'\n --mobile
93
- MOBILE_PHONE Mobile number e.g. '+001 (252) 4345'\n --mail E-MAIL
94
- \ E-Mail address e.g. 'jane@northstart.ca'\n -h, --help Show
95
- his message\n```\n\nLookup a contact with summary output\n\n $ sycontact --cn
96
- sugar\n $ sycontact --cn \"sugar, pierre\"\n $ sycontact --cn \"pierre sugar\"\n\nAny
97
- of the above commands result in the following output\n\n```\nAddressSource\n\nCN..................Sugar
98
- Pierre\nC...................DE\nL...................Vancouver\nO...................SugarYourCoffee\nOU..................DevOps\nTELEPHONE...........+001
99
- (123) 4567\nMOBILE..............+001 (765) 4321\nMAIL................pierre@sugaryourcoffee.de\n```\nSources\n=======\nHome
100
- page: <http://syc.dyndns.org/drupal/wiki/sycontact-lookup-contacts-any-source>\n\nSource:
101
- <https://github.com/sugaryourcoffee/syc-ontact>\n\nContact\n=======\n\n<pierre@sugaryourcoffee.de>\n"
27
+ description:
102
28
  email: pierre@sugaryourcoffee.de
103
29
  executables:
104
30
  - sycontact