whowas 0.2.0 → 0.2.1
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/lib/adapters/splunk.rb +7 -3
- data/lib/whowas.rb +12 -4
- data/lib/whowas/errors.rb +4 -0
- data/lib/whowas/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f18c072668284649883a05ad1bbebe28c610a3b
|
4
|
+
data.tar.gz: 8f9e494556ac732fafbc724f3e2c4c1365733bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9446751954db0d0894d12f15ebd33fe07a9894f0283d482c49f9bac472ea6590c81bb16769d9d3d497032b885893608542a32ddaa8845d379c731636fb09a1f3
|
7
|
+
data.tar.gz: f8f7fdda8c3b564c8ddcc8d6b68f128d883fb80ecb069e8fed6076688f5fdebab31b75372f87d68a165bfa22715940ead1c139b8427c1e9a32d218391de4ba6b
|
data/lib/adapters/splunk.rb
CHANGED
@@ -11,8 +11,12 @@ module Whowas
|
|
11
11
|
# Whowas.splunk_config is configured via define_setting in the initializer.
|
12
12
|
# See configuration.rb for more information.
|
13
13
|
def self.connection(config: Whowas.splunk_config)
|
14
|
-
@@connection
|
15
|
-
|
14
|
+
if @@connection && @@connection.token
|
15
|
+
@@connection = ::Splunk::Service.new(config.merge(token: @@connection.token))
|
16
|
+
else
|
17
|
+
@@connection = ::Splunk::connect(config)
|
18
|
+
end
|
19
|
+
rescue StandardError => e
|
16
20
|
raise Whowas::Errors::ServiceUnavailable, "#{self.class.name}: #{e}"
|
17
21
|
end
|
18
22
|
|
@@ -47,6 +51,6 @@ module Whowas
|
|
47
51
|
else
|
48
52
|
""
|
49
53
|
end
|
50
|
-
end
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
data/lib/whowas.rb
CHANGED
@@ -40,17 +40,16 @@ module Whowas
|
|
40
40
|
define_setting :recipe_class, Whowas::Recipes
|
41
41
|
|
42
42
|
# configuration defaults
|
43
|
-
define_setting :splunk_config, nil
|
43
|
+
define_setting :splunk_config, nil
|
44
44
|
|
45
45
|
def self.search(input)
|
46
|
+
validate_configuration
|
46
47
|
recipe = recipe_class.select(input) || Whowas.recipe_table[:default]
|
47
48
|
env = {input: input, results: []}
|
48
49
|
self.send(recipe).call(env)
|
49
50
|
env
|
50
51
|
end
|
51
52
|
|
52
|
-
private
|
53
|
-
|
54
53
|
# Uses the recipe_table hash to match up the input to the correct recipe type.
|
55
54
|
# If there is an IP address in the input, it tries to match the IP address
|
56
55
|
# against any keys that are valid CIDR blocks.
|
@@ -58,5 +57,14 @@ module Whowas
|
|
58
57
|
# Otherwise, it falls back to :default.
|
59
58
|
def select_recipe(input)
|
60
59
|
end
|
61
|
-
|
60
|
+
|
61
|
+
# Ensure that the user has configured the recipe table and initialized the whowas
|
62
|
+
# directory in the overarching app.
|
63
|
+
# Does not prove the app is properly configured -- this is the bare minimum, meant to
|
64
|
+
# be an alert for users who don't realize they have to configure anything at all.
|
65
|
+
def self.validate_configuration
|
66
|
+
if recipe_table == {} || !recipe_table.include?(:default)
|
67
|
+
raise Whowas::Errors::ConfigurationError, "Please configure Whowas as described at https://github.com/TuftsUniversity/whowas"
|
68
|
+
end
|
69
|
+
end
|
62
70
|
end
|
data/lib/whowas/errors.rb
CHANGED
data/lib/whowas/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whowas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jess Frisch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleware
|