tel_search 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +22 -3
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +62 -44
- data/README.md +8 -3
- data/lib/tel_search/client.rb +4 -1
- data/lib/tel_search/entry.rb +58 -9
- data/lib/tel_search/param_parser.rb +6 -6
- data/lib/tel_search/version.rb +1 -1
- data/lib/tel_search.rb +8 -2
- data/tel_search.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785d7f800686e0b7c6472e1fac9246450079df424f9b55a9f362e8281df9b55b
|
4
|
+
data.tar.gz: 9b7f61745a4fbd67c8ded3760efa0e0e42ebcf2d584b4cf7f21847463c1f5d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81da868a8a5502933b408154358837eeee594e6f4346beb6a1c013cc76423665e33904279809573a45a9699f4853f3963be7575705746987ae51afd0ec30b50
|
7
|
+
data.tar.gz: dc58431b4804d6a1efefb3c31fdc1922d321bf0871a3101183268187a3ad970684068976590b7f08ca1fff2e012fb6a852ed87c9d62aba1512448ef60461d713
|
data/.github/workflows/main.yml
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
4
8
|
|
5
9
|
jobs:
|
6
|
-
|
10
|
+
lint:
|
11
|
+
runs-on: ubuntu-22.04
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v3
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '3.0'
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Run rubocop
|
20
|
+
run: bundle exec standardrb
|
21
|
+
|
22
|
+
test:
|
7
23
|
runs-on: ubuntu-latest
|
24
|
+
strategy:
|
25
|
+
matrix:
|
26
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
8
27
|
steps:
|
9
28
|
- uses: actions/checkout@v2
|
10
29
|
- name: Set up Ruby
|
11
30
|
uses: ruby/setup-ruby@v1
|
12
31
|
with:
|
13
|
-
ruby-version:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
14
33
|
bundler-cache: true
|
15
34
|
- name: Run the default task
|
16
35
|
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.0] - 2024-02-12
|
4
|
+
|
5
|
+
- Add mappings for `first_name`, `last_name` and `company`
|
6
|
+
- Raise error on bad requests
|
7
|
+
- Require Ruby > 3
|
8
|
+
|
3
9
|
## [0.1.0] - 2021-10-27
|
4
10
|
|
5
11
|
- Initial release
|
6
12
|
- Basic functionality of the api
|
13
|
+
|
14
|
+
[Unreleased]: https://github.com/renuo/tel_search/compare/v0.1.0..v0.2.0
|
15
|
+
[0.2.0]: https://github.com/renuo/tel_search/compare/v0.1.0..v0.2.0
|
16
|
+
[0.1.0]: https://github.com/renuo/tel_search/releases/tag/v0.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,70 +1,88 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tel_search (0.
|
4
|
+
tel_search (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
addressable (2.8.
|
10
|
-
public_suffix (>= 2.0.2, <
|
9
|
+
addressable (2.8.6)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
11
11
|
ast (2.4.2)
|
12
12
|
crack (0.4.5)
|
13
13
|
rexml
|
14
|
-
diff-lcs (1.
|
15
|
-
hashdiff (1.0
|
16
|
-
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
hashdiff (1.1.0)
|
16
|
+
json (2.7.1)
|
17
|
+
language_server-protocol (3.17.0.3)
|
18
|
+
lint_roller (1.1.0)
|
19
|
+
nokogiri (1.16.2-arm64-darwin)
|
17
20
|
racc (~> 1.4)
|
18
|
-
nokogiri (1.
|
21
|
+
nokogiri (1.16.2-x86_64-darwin)
|
19
22
|
racc (~> 1.4)
|
20
|
-
|
21
|
-
|
23
|
+
nokogiri (1.16.2-x86_64-linux)
|
24
|
+
racc (~> 1.4)
|
25
|
+
parallel (1.24.0)
|
26
|
+
parser (3.3.0.5)
|
22
27
|
ast (~> 2.4.1)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
rspec-
|
32
|
-
rspec-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
racc
|
29
|
+
public_suffix (5.0.4)
|
30
|
+
racc (1.7.3)
|
31
|
+
rainbow (3.1.1)
|
32
|
+
rake (13.1.0)
|
33
|
+
regexp_parser (2.9.0)
|
34
|
+
rexml (3.2.6)
|
35
|
+
rspec (3.12.0)
|
36
|
+
rspec-core (~> 3.12.0)
|
37
|
+
rspec-expectations (~> 3.12.0)
|
38
|
+
rspec-mocks (~> 3.12.0)
|
39
|
+
rspec-core (3.12.2)
|
40
|
+
rspec-support (~> 3.12.0)
|
41
|
+
rspec-expectations (3.12.3)
|
36
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-mocks (3.
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-mocks (3.12.6)
|
39
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-support (3.
|
42
|
-
rubocop (1.
|
46
|
+
rspec-support (~> 3.12.0)
|
47
|
+
rspec-support (3.12.1)
|
48
|
+
rubocop (1.59.0)
|
49
|
+
json (~> 2.3)
|
50
|
+
language_server-protocol (>= 3.17.0)
|
43
51
|
parallel (~> 1.10)
|
44
|
-
parser (>= 3.
|
52
|
+
parser (>= 3.2.2.4)
|
45
53
|
rainbow (>= 2.2.2, < 4.0)
|
46
54
|
regexp_parser (>= 1.8, < 3.0)
|
47
|
-
rexml
|
48
|
-
rubocop-ast (>= 1.
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
49
57
|
ruby-progressbar (~> 1.7)
|
50
|
-
unicode-display_width (>=
|
51
|
-
rubocop-ast (1.
|
52
|
-
parser (>= 3.
|
53
|
-
rubocop-performance (1.
|
54
|
-
rubocop (>= 1.
|
55
|
-
rubocop-ast (>=
|
56
|
-
ruby-progressbar (1.
|
57
|
-
standard (1.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
59
|
+
rubocop-ast (1.30.0)
|
60
|
+
parser (>= 3.2.1.0)
|
61
|
+
rubocop-performance (1.20.2)
|
62
|
+
rubocop (>= 1.48.1, < 2.0)
|
63
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
64
|
+
ruby-progressbar (1.13.0)
|
65
|
+
standard (1.33.0)
|
66
|
+
language_server-protocol (~> 3.17.0.2)
|
67
|
+
lint_roller (~> 1.0)
|
68
|
+
rubocop (~> 1.59.0)
|
69
|
+
standard-custom (~> 1.0.0)
|
70
|
+
standard-performance (~> 1.3)
|
71
|
+
standard-custom (1.0.2)
|
72
|
+
lint_roller (~> 1.0)
|
73
|
+
rubocop (~> 1.50)
|
74
|
+
standard-performance (1.3.1)
|
75
|
+
lint_roller (~> 1.1)
|
76
|
+
rubocop-performance (~> 1.20.2)
|
77
|
+
unicode-display_width (2.5.0)
|
78
|
+
vcr (6.2.0)
|
79
|
+
webmock (3.19.1)
|
63
80
|
addressable (>= 2.8.0)
|
64
81
|
crack (>= 0.3.2)
|
65
82
|
hashdiff (>= 0.4.0, < 2.0.0)
|
66
83
|
|
67
84
|
PLATFORMS
|
85
|
+
arm64-darwin-21
|
68
86
|
x86_64-darwin-19
|
69
87
|
x86_64-linux
|
70
88
|
|
@@ -78,4 +96,4 @@ DEPENDENCIES
|
|
78
96
|
webmock
|
79
97
|
|
80
98
|
BUNDLED WITH
|
81
|
-
2.2.
|
99
|
+
2.2.32
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# TelSearch
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/tel_search)
|
4
|
+
|
3
5
|
A ruby client for the tel.search.ch api. [Docs](https://tel.search.ch/api/help.en.html)
|
4
6
|
|
5
7
|
## Installation
|
@@ -19,6 +21,7 @@ Or install it yourself as:
|
|
19
21
|
$ gem install tel_search
|
20
22
|
|
21
23
|
## Usage
|
24
|
+
|
22
25
|
```ruby
|
23
26
|
client = TelSearch::Client.new(ENV['TEL_API_KEY'])
|
24
27
|
query = TelSearch::Query.new(where: 'Wallisellen', what: 'Renuo AG', language: :de)
|
@@ -30,13 +33,15 @@ response.entries.first.name == 'Renuo AG'
|
|
30
33
|
|
31
34
|
## Development
|
32
35
|
|
36
|
+
Set `TEL_KEY` in your environment.
|
37
|
+
|
33
38
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
39
|
|
35
40
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
41
|
|
37
42
|
## Contributing
|
38
43
|
|
39
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/renuo/tel_search. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tel_search/blob/
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/renuo/tel_search. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tel_search/blob/main/CODE_OF_CONDUCT.md).
|
40
45
|
|
41
46
|
## License
|
42
47
|
|
@@ -44,8 +49,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
44
49
|
|
45
50
|
## Code of Conduct
|
46
51
|
|
47
|
-
Everyone interacting in the TelSearch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[renuo]/tel_search/blob/
|
52
|
+
Everyone interacting in the TelSearch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[renuo]/tel_search/blob/main/CODE_OF_CONDUCT.md).
|
48
53
|
|
49
54
|
## Copyright
|
50
55
|
|
51
|
-
Copyright 2021 [Renuo AG](https://www.renuo.ch/).
|
56
|
+
Copyright 2021-2024 [Renuo AG](https://www.renuo.ch/).
|
data/lib/tel_search/client.rb
CHANGED
@@ -14,7 +14,10 @@ module TelSearch
|
|
14
14
|
|
15
15
|
def execute(query)
|
16
16
|
params_for_request = request_params(query.to_h)
|
17
|
-
|
17
|
+
response = send_request(params_for_request)
|
18
|
+
raise TelSearch::Error.new(response) unless response.is_a?(Net::HTTPSuccess)
|
19
|
+
|
20
|
+
parse_response(response)
|
18
21
|
end
|
19
22
|
|
20
23
|
private
|
data/lib/tel_search/entry.rb
CHANGED
@@ -1,38 +1,87 @@
|
|
1
1
|
module TelSearch
|
2
2
|
class Entry
|
3
|
-
|
3
|
+
TYPES = {
|
4
|
+
person: "Person",
|
5
|
+
company: "Organisation"
|
6
|
+
}
|
7
|
+
|
8
|
+
ATTRIBUTES = %i[
|
9
|
+
canton
|
10
|
+
city
|
11
|
+
company
|
12
|
+
first_name
|
13
|
+
last_name
|
14
|
+
name
|
15
|
+
phone
|
16
|
+
street
|
17
|
+
street_number
|
18
|
+
title
|
19
|
+
type
|
20
|
+
zip
|
21
|
+
].freeze
|
4
22
|
|
5
23
|
ATTRIBUTE_MAPPING = {
|
6
|
-
streetno: :street_number
|
7
|
-
|
24
|
+
streetno: [:street_number],
|
25
|
+
firstname: [:first_name],
|
26
|
+
name: [
|
27
|
+
{
|
28
|
+
target: :last_name,
|
29
|
+
condition: ->(attributes) { attributes[:type]&.first == TYPES[:person] }
|
30
|
+
},
|
31
|
+
{
|
32
|
+
target: :company,
|
33
|
+
condition: ->(attributes) { attributes[:type]&.first == TYPES[:company] }
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}.freeze
|
8
37
|
|
9
38
|
attr_accessor(*ATTRIBUTES)
|
10
39
|
|
11
40
|
def from_rss(feed_entry)
|
12
41
|
attributes = collect_tel_information(feed_entry)
|
13
42
|
set_attributes(attributes)
|
43
|
+
map_attributes(attributes)
|
14
44
|
|
15
45
|
self
|
16
46
|
end
|
17
47
|
|
18
48
|
private
|
19
49
|
|
50
|
+
def collect_tel_information(feed_entry)
|
51
|
+
feed_entry.xpath("./tel:*").each_with_object(Hash.new { |h, k| h[k] = [] }) do |node, hash|
|
52
|
+
hash[node.name.to_sym] << node.text
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
20
56
|
def set_attributes(attributes)
|
21
57
|
ATTRIBUTES.each do |attribute_name|
|
22
58
|
set_property(attribute_name, attributes[attribute_name])
|
23
59
|
end
|
24
60
|
end
|
25
61
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
62
|
+
def map_attributes(attributes)
|
63
|
+
ATTRIBUTE_MAPPING.each do |key, mappings|
|
64
|
+
next if key.nil? || mappings.nil?
|
65
|
+
|
66
|
+
node_value = attributes[key]
|
67
|
+
|
68
|
+
mappings.each do |mapping|
|
69
|
+
case mapping
|
70
|
+
when Symbol
|
71
|
+
set_property(mapping, node_value)
|
72
|
+
when Hash
|
73
|
+
condition = mapping[:condition]
|
74
|
+
|
75
|
+
set_property(mapping[:target], node_value) if condition.call(attributes)
|
76
|
+
end
|
77
|
+
end
|
31
78
|
end
|
32
79
|
end
|
33
80
|
|
34
81
|
def set_property(prop_name, prop_value)
|
35
|
-
|
82
|
+
return if prop_value.nil?
|
83
|
+
|
84
|
+
send(:"#{prop_name}=", (prop_value.count > 1) ? prop_value : prop_value.first)
|
36
85
|
end
|
37
86
|
end
|
38
87
|
end
|
data/lib/tel_search/version.rb
CHANGED
data/lib/tel_search.rb
CHANGED
@@ -8,6 +8,12 @@ require_relative "tel_search/response"
|
|
8
8
|
require_relative "tel_search/version"
|
9
9
|
|
10
10
|
module TelSearch
|
11
|
-
class Error < StandardError
|
12
|
-
|
11
|
+
class Error < StandardError
|
12
|
+
attr_reader :response
|
13
|
+
|
14
|
+
def initialize(response)
|
15
|
+
super(response.body)
|
16
|
+
@response = response
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
data/tel_search.gemspec
CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "A ruby wrapper for the tel.search.ch/api endpoint"
|
13
13
|
spec.homepage = "https://github.com/renuo/tel_search"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">=
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/renuo/tel_search"
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/renuo/tel_search/CHANGELOG.md"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/renuo/tel_search/blob/main/CHANGELOG.md"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tel_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liberatys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A ruby wrapper for the tel.search.ch/api endpoint
|
14
14
|
email:
|
@@ -45,7 +45,7 @@ licenses:
|
|
45
45
|
metadata:
|
46
46
|
homepage_uri: https://github.com/renuo/tel_search
|
47
47
|
source_code_uri: https://github.com/renuo/tel_search
|
48
|
-
changelog_uri: https://github.com/renuo/tel_search/CHANGELOG.md
|
48
|
+
changelog_uri: https://github.com/renuo/tel_search/blob/main/CHANGELOG.md
|
49
49
|
post_install_message:
|
50
50
|
rdoc_options: []
|
51
51
|
require_paths:
|
@@ -54,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 3.0.0
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.5.22
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: A ruby wrapper for the tel.search.ch/api endpoint
|