tel_search 0.1.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 +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +8 -0
- data/bin/check_linters +1 -0
- data/bin/console +15 -0
- data/bin/format +1 -0
- data/bin/setup +6 -0
- data/lib/tel_search/client.rb +47 -0
- data/lib/tel_search/entry.rb +38 -0
- data/lib/tel_search/param_parser.rb +46 -0
- data/lib/tel_search/query.rb +33 -0
- data/lib/tel_search/response.rb +35 -0
- data/lib/tel_search/version.rb +5 -0
- data/lib/tel_search.rb +13 -0
- data/tel_search.gemspec +30 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 953a443aa4a2926232a53e25d542748579661ffd147676c29cbc543507e87d45
|
4
|
+
data.tar.gz: 3b415da4ab4f7ed80a0cf3c2c2fb088cdad9ea8676327446b57a0448e6f59991
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb9e0d06e9e7ad23f66b83901620daccaea662fe82ebeb90964b1efd8d25b55c54c2298632941fe689bf8828a116c5cd67f3c2ec61181eaec4c6cdeebea07585
|
7
|
+
data.tar.gz: e3dd6bce4cc659f86f5c7be7e4f24c0f75970477e5e2c0bb97acba3494783322ba2b5c2d3ae74c71ba0738273c214316bc6f1867c52dce7d7301a95a718f3b56
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.2
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
17
|
+
env:
|
18
|
+
TEL_KEY: 'find-me-in-your-password-manager'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at nick.flueckiger@renuo.ch. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in tel_search.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "nokogiri"
|
11
|
+
|
12
|
+
group :test, :development do
|
13
|
+
gem "standard"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "vcr"
|
18
|
+
gem "webmock"
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tel_search (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.8.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
ast (2.4.2)
|
12
|
+
crack (0.4.5)
|
13
|
+
rexml
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
hashdiff (1.0.1)
|
16
|
+
nokogiri (1.12.5-x86_64-darwin)
|
17
|
+
racc (~> 1.4)
|
18
|
+
nokogiri (1.12.5-x86_64-linux)
|
19
|
+
racc (~> 1.4)
|
20
|
+
parallel (1.21.0)
|
21
|
+
parser (3.0.2.0)
|
22
|
+
ast (~> 2.4.1)
|
23
|
+
public_suffix (4.0.6)
|
24
|
+
racc (1.6.0)
|
25
|
+
rainbow (3.0.0)
|
26
|
+
rake (13.0.6)
|
27
|
+
regexp_parser (2.1.1)
|
28
|
+
rexml (3.2.5)
|
29
|
+
rspec (3.10.0)
|
30
|
+
rspec-core (~> 3.10.0)
|
31
|
+
rspec-expectations (~> 3.10.0)
|
32
|
+
rspec-mocks (~> 3.10.0)
|
33
|
+
rspec-core (3.10.1)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-expectations (3.10.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-mocks (3.10.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-support (3.10.2)
|
42
|
+
rubocop (1.20.0)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.0.0.0)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.12.0)
|
52
|
+
parser (>= 3.0.1.1)
|
53
|
+
rubocop-performance (1.11.5)
|
54
|
+
rubocop (>= 1.7.0, < 2.0)
|
55
|
+
rubocop-ast (>= 0.4.0)
|
56
|
+
ruby-progressbar (1.11.0)
|
57
|
+
standard (1.3.0)
|
58
|
+
rubocop (= 1.20.0)
|
59
|
+
rubocop-performance (= 1.11.5)
|
60
|
+
unicode-display_width (2.1.0)
|
61
|
+
vcr (6.0.0)
|
62
|
+
webmock (3.14.0)
|
63
|
+
addressable (>= 2.8.0)
|
64
|
+
crack (>= 0.3.2)
|
65
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
x86_64-darwin-19
|
69
|
+
x86_64-linux
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
nokogiri
|
73
|
+
rake (~> 13.0)
|
74
|
+
rspec (~> 3.0)
|
75
|
+
standard
|
76
|
+
tel_search!
|
77
|
+
vcr
|
78
|
+
webmock
|
79
|
+
|
80
|
+
BUNDLED WITH
|
81
|
+
2.2.22
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Renuo AG
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# TelSearch
|
2
|
+
|
3
|
+
A ruby client for the tel.search.ch api. [Docs](https://tel.search.ch/api/help.en.html)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'tel_search'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tel_search
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
```ruby
|
23
|
+
client = TelSearch::Client.new(ENV['TEL_API_KEY'])
|
24
|
+
query = TelSearch::Query.new(where: 'Wallisellen', what: 'Renuo AG', language: :de)
|
25
|
+
|
26
|
+
response = client.execute(query)
|
27
|
+
|
28
|
+
response.entries.first.name == 'Renuo AG'
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
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
|
+
|
35
|
+
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
|
+
|
37
|
+
## Contributing
|
38
|
+
|
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/master/CODE_OF_CONDUCT.md).
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
44
|
+
|
45
|
+
## Code of Conduct
|
46
|
+
|
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/master/CODE_OF_CONDUCT.md).
|
48
|
+
|
49
|
+
## Copyright
|
50
|
+
|
51
|
+
Copyright 2021 [Renuo AG](https://www.renuo.ch/).
|
data/Rakefile
ADDED
data/bin/check_linters
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bundle exec standardrb
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "tel_search"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/format
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bundle exec standardrb --fix
|
data/bin/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
|
4
|
+
module TelSearch
|
5
|
+
class Client
|
6
|
+
BASE_URL = "https://tel.search.ch"
|
7
|
+
API_KEY_NAME = :key
|
8
|
+
BASE_PATH = "api/"
|
9
|
+
|
10
|
+
def initialize(api_key, base_path: BASE_URL)
|
11
|
+
@api_key = api_key
|
12
|
+
@base_uri = base_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute(query)
|
16
|
+
params_for_request = request_params(query.to_h)
|
17
|
+
parse_response(send_request(params_for_request))
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def request_params(parameters)
|
23
|
+
TelSearch::ParamParser.new(parameters.to_h).parse.compact.merge(
|
24
|
+
API_KEY_NAME => @api_key
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def send_request(params)
|
29
|
+
url = build_url
|
30
|
+
url.query = URI.encode_www_form(params)
|
31
|
+
req = Net::HTTP::Get.new(url)
|
32
|
+
Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http|
|
33
|
+
http.request(req)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_url
|
38
|
+
uri = @base_uri.dup
|
39
|
+
uri << "/" unless uri.end_with? "/"
|
40
|
+
URI.join(URI.parse(uri), BASE_PATH)
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_response(response)
|
44
|
+
TelSearch::Response.build_from_response(response)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TelSearch
|
2
|
+
class Entry
|
3
|
+
ATTRIBUTES = %i[title type name first_name last_name street street_number zip city canton phone]
|
4
|
+
|
5
|
+
ATTRIBUTE_MAPPING = {
|
6
|
+
streetno: :street_number
|
7
|
+
}
|
8
|
+
|
9
|
+
attr_accessor(*ATTRIBUTES)
|
10
|
+
|
11
|
+
def from_rss(feed_entry)
|
12
|
+
attributes = collect_tel_information(feed_entry)
|
13
|
+
set_attributes(attributes)
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_attributes(attributes)
|
21
|
+
ATTRIBUTES.each do |attribute_name|
|
22
|
+
set_property(attribute_name, attributes[attribute_name])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def collect_tel_information(feed_entry)
|
27
|
+
feed_entry.xpath("./tel:*").each_with_object(Hash.new { |h, k| h[k] = [] }) do |node, hash|
|
28
|
+
custom_key = ATTRIBUTE_MAPPING[node.name.to_sym]
|
29
|
+
node_name = custom_key || node.name.to_sym
|
30
|
+
hash[node_name] << node.text
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_property(prop_name, prop_value)
|
35
|
+
send("#{prop_name}=", prop_value.count > 1 ? prop_value : prop_value.first)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module TelSearch
|
2
|
+
class ParamParser
|
3
|
+
ALLOWED_PARAMETERS = {
|
4
|
+
what: "was",
|
5
|
+
where: "wo",
|
6
|
+
query: "q",
|
7
|
+
priv: "privat",
|
8
|
+
company: "firma",
|
9
|
+
position: "pos",
|
10
|
+
max_results: "maxnum",
|
11
|
+
language: "lang",
|
12
|
+
count_only: "count_only"
|
13
|
+
}
|
14
|
+
|
15
|
+
REQUIRED_PARAM = %i[what where]
|
16
|
+
|
17
|
+
def initialize(params)
|
18
|
+
@params = params
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse
|
22
|
+
fetch_valid_params
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def fetch_valid_params
|
28
|
+
ALLOWED_PARAMETERS.keys.each_with_object({}) do |key, hash|
|
29
|
+
hash[ALLOWED_PARAMETERS[key]] = if @params[key.to_s] || REQUIRED_PARAM.include?(key)
|
30
|
+
transform_value(@params[key.to_s] || "")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def transform_value(value)
|
36
|
+
case value
|
37
|
+
when true
|
38
|
+
"1"
|
39
|
+
when false
|
40
|
+
"0"
|
41
|
+
else
|
42
|
+
value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module TelSearch
|
2
|
+
class Query
|
3
|
+
def initialize(
|
4
|
+
where: nil,
|
5
|
+
what: nil,
|
6
|
+
query: nil,
|
7
|
+
priv: true,
|
8
|
+
company: true,
|
9
|
+
position: nil,
|
10
|
+
max_results: 200,
|
11
|
+
language: :en,
|
12
|
+
count_only: false
|
13
|
+
)
|
14
|
+
|
15
|
+
@where = where
|
16
|
+
@what = what
|
17
|
+
@query = query
|
18
|
+
@priv = priv
|
19
|
+
@company = company
|
20
|
+
@position = position
|
21
|
+
@max_results = max_results
|
22
|
+
@language = language
|
23
|
+
@count_only = count_only
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_h
|
27
|
+
instance_variables.each_with_object({}) do |method, hash|
|
28
|
+
method_name = method[1..]
|
29
|
+
hash[method_name] = instance_variable_get(method)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module TelSearch
|
4
|
+
class Response
|
5
|
+
attr_accessor :entries
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
|
+
@entries = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.build_from_response(response)
|
13
|
+
tel_response = new(response)
|
14
|
+
tel_response.parse
|
15
|
+
tel_response
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse
|
19
|
+
feed = parse_rss
|
20
|
+
self.entries = convert_to_entries(feed)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def convert_to_entries(feed)
|
26
|
+
feed.search("entry").map do |entry|
|
27
|
+
Entry.new.from_rss(entry)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_rss
|
32
|
+
Nokogiri.XML(@response.body)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/tel_search.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "tel_search/client"
|
4
|
+
require_relative "tel_search/entry"
|
5
|
+
require_relative "tel_search/param_parser"
|
6
|
+
require_relative "tel_search/query"
|
7
|
+
require_relative "tel_search/response"
|
8
|
+
require_relative "tel_search/version"
|
9
|
+
|
10
|
+
module TelSearch
|
11
|
+
class Error < StandardError; end
|
12
|
+
# Your code goes here...
|
13
|
+
end
|
data/tel_search.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/tel_search/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "tel_search"
|
7
|
+
spec.version = TelSearch::VERSION
|
8
|
+
spec.authors = ["Liberatys"]
|
9
|
+
spec.email = ["nick.flueckiger@renuo.ch"]
|
10
|
+
|
11
|
+
spec.summary = "A ruby wrapper for the tel.search.ch/api endpoint"
|
12
|
+
spec.description = "A ruby wrapper for the tel.search.ch/api endpoint"
|
13
|
+
spec.homepage = "https://github.com/renuo/tel_search"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
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"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tel_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Liberatys
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A ruby wrapper for the tel.search.ch/api endpoint
|
14
|
+
email:
|
15
|
+
- nick.flueckiger@renuo.ch
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".github/workflows/main.yml"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- CHANGELOG.md
|
24
|
+
- CODE_OF_CONDUCT.md
|
25
|
+
- Gemfile
|
26
|
+
- Gemfile.lock
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- bin/check_linters
|
31
|
+
- bin/console
|
32
|
+
- bin/format
|
33
|
+
- bin/setup
|
34
|
+
- lib/tel_search.rb
|
35
|
+
- lib/tel_search/client.rb
|
36
|
+
- lib/tel_search/entry.rb
|
37
|
+
- lib/tel_search/param_parser.rb
|
38
|
+
- lib/tel_search/query.rb
|
39
|
+
- lib/tel_search/response.rb
|
40
|
+
- lib/tel_search/version.rb
|
41
|
+
- tel_search.gemspec
|
42
|
+
homepage: https://github.com/renuo/tel_search
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/renuo/tel_search
|
47
|
+
source_code_uri: https://github.com/renuo/tel_search
|
48
|
+
changelog_uri: https://github.com/renuo/tel_search/CHANGELOG.md
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.6.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.2.22
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: A ruby wrapper for the tel.search.ch/api endpoint
|
68
|
+
test_files: []
|