primo_central_counter 0.2.0 → 0.3.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/README.md +3 -3
- data/exe/primo_central_counter +0 -1
- data/lib/primo_central_counter/cli.rb +19 -7
- data/lib/primo_central_counter/connection_checker.rb +27 -0
- data/lib/primo_central_counter/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eedacf0ca23e92ecd8f1254d0193d8a21059c302
|
4
|
+
data.tar.gz: f63fadf9400ec532277d29e0e93212f2aa9c8e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56477fbd5f7c599564334676eb677e6d039d03f2594559766d9b7e819c04924e98c78ffd5ee5a139ea6c573e41f39db7a09ddd479d8ad1d8b718c099ddfc240
|
7
|
+
data.tar.gz: 739846bdcdebab65e7432b26bbfda7582ccf62458e183254bb9f6f22be79acf73bd2a5e2f6bb49355d2f3f3a2e7b6c104a20156d556b8966e57e8c216aa93e31
|
data/README.md
CHANGED
@@ -20,16 +20,16 @@ Usage: primo_central_counter [options]
|
|
20
20
|
-h, --help Display usage informations
|
21
21
|
```
|
22
22
|
|
23
|
-
The output is
|
23
|
+
The output is total record cound on STDOUT. If you enable logging, this will be outputted on STDERR.
|
24
24
|
|
25
25
|
### Examples
|
26
26
|
|
27
27
|
```
|
28
|
-
primo_central_counter -u http://primo.kobv.de -i PAD
|
28
|
+
primo_central_counter -u http://primo.kobv.de -i PAD
|
29
29
|
```
|
30
30
|
|
31
31
|
```
|
32
|
-
primo_central_counter -u http://primo.kobv.de -i PAD -l info 1> ./
|
32
|
+
primo_central_counter -u http://primo.kobv.de -i PAD -l info 1> ./sum.txt 2> ./messages.txt
|
33
33
|
```
|
34
34
|
|
35
35
|
## Development
|
data/exe/primo_central_counter
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "logger"
|
2
2
|
require_relative "../primo_central_counter"
|
3
|
+
require_relative "./connection_checker"
|
3
4
|
require_relative "./counter"
|
4
5
|
require_relative "./option_parser"
|
5
6
|
require_relative "./soap_discoverer"
|
@@ -28,19 +29,30 @@ class PrimoCentralCounter::Cli
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def call
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
_sum
|
36
|
-
|
32
|
+
if PrimoCentralCounter::ConnectionChecker.call(@options[:base_url], logger: @logger)
|
33
|
+
searcher_url = PrimoCentralCounter::SoapDiscoverer.call(@options[:base_url], logger: @logger)
|
34
|
+
queries = [("a".."z").to_a, (0..9).to_a.map(&:to_s)].flatten(1).map { |_char| "#{_char}*" }
|
35
|
+
result = PrimoCentralCounter::Counter.call(searcher_url, queries, @options.merge(logger: @logger))
|
36
|
+
sum = result.inject(0) do |_sum, (_query, _count)|
|
37
|
+
_sum + _count
|
38
|
+
end
|
37
39
|
|
38
|
-
|
40
|
+
puts sum
|
41
|
+
else
|
42
|
+
log_error(@logger, "Cannot connect to Primo Central! Please check the given url and if you are allowed to access the API.")
|
43
|
+
log_error(@logger, "The following primo backoffice settings control the API access privileges:")
|
44
|
+
log_error(@logger, "- Advanced Configuration > All Mapping Tables > WS and XS IP")
|
45
|
+
log_error(@logger, "- Deploy All > All Client IP Ranges (WS and XS IP mapping table)")
|
46
|
+
end
|
39
47
|
end
|
40
48
|
|
41
49
|
#
|
42
50
|
private
|
43
51
|
#
|
52
|
+
def log_error(logger, message)
|
53
|
+
logger.error(message) if logger
|
54
|
+
end
|
55
|
+
|
44
56
|
def option_parser(result = {})
|
45
57
|
PrimoCentralCounter::OptionParser.new(nil, 38) do |_option_parser|
|
46
58
|
_option_parser.banner = "Usage: primo_central_counter [options]\n\n"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
require_relative "../primo_central_counter"
|
4
|
+
|
5
|
+
class PrimoCentralCounter::ConnectionChecker
|
6
|
+
def self.call(primo_base_url, options = {})
|
7
|
+
logger = options[:logger]
|
8
|
+
|
9
|
+
log_info(logger, "Checking connection to Primo Central")
|
10
|
+
url = URI.parse("#{primo_base_url}/PrimoWebServices/services/searcher")
|
11
|
+
response = Net::HTTP.get_response(url)
|
12
|
+
|
13
|
+
if response.body[/IP address rejected/]
|
14
|
+
false
|
15
|
+
else
|
16
|
+
true
|
17
|
+
end
|
18
|
+
rescue Errno::ECONNREFUSED
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.log_info(logger, message)
|
25
|
+
logger.info(message) if logger
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primo_central_counter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Sievers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- exe/primo_central_counter
|
58
58
|
- lib/primo_central_counter.rb
|
59
59
|
- lib/primo_central_counter/cli.rb
|
60
|
+
- lib/primo_central_counter/connection_checker.rb
|
60
61
|
- lib/primo_central_counter/counter.rb
|
61
62
|
- lib/primo_central_counter/option_parser.rb
|
62
63
|
- lib/primo_central_counter/soap_discoverer.rb
|