huck 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/huck.rb +6 -1
- data/lib/huck/generator.rb +12 -10
- data/lib/huck/generators/basic.rb +25 -0
- data/lib/huck/generators/facter.rb +3 -2
- data/lib/huck/generators/json.rb +2 -1
- data/lib/huck/generators/ohai.rb +3 -2
- data/lib/huck/generators/yaml.rb +2 -1
- data/lib/huck/handlers/echo.rb +5 -0
- data/lib/huck/handlers/exec.rb +6 -1
- data/lib/huck/receivers/sqs.rb +1 -1
- data/lib/huck/senders/sqs.rb +2 -2
- data/lib/huck/util.rb +14 -0
- data/lib/huck/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a79a3c9c263d302401491186d5ab0bd97a3ce51c
|
4
|
+
data.tar.gz: 600ea4d99d5c905796abbe425060e27e43cba421
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96f236417d31c5af714c20814cf95f3a11a8b266b68f8f879464218af21df3957fd3af53dab536079ff2865d023da3e9f6489f5b1525064c63569e82bb69379
|
7
|
+
data.tar.gz: ca82f5ca5ddd75d8c4a67e6cb45e9e059a01e9ad5055bcd4d562183889a81f02824e942c198f86e8de891a7c802fe53468c500450920c06e76a7e8bf76791533
|
data/lib/huck.rb
CHANGED
@@ -4,6 +4,7 @@ require 'yaml'
|
|
4
4
|
require 'huck/version'
|
5
5
|
require 'huck/util'
|
6
6
|
require 'huck/generator'
|
7
|
+
require 'huck/generators/basic'
|
7
8
|
require 'huck/generators/facter'
|
8
9
|
require 'huck/generators/ohai'
|
9
10
|
require 'huck/generators/yaml'
|
@@ -21,8 +22,12 @@ module Huck
|
|
21
22
|
# Main method to run Huck and dump info
|
22
23
|
#
|
23
24
|
# == Parameters:
|
25
|
+
# config::
|
26
|
+
# Configuration file path
|
24
27
|
# generator::
|
25
|
-
# The name of the generator to use
|
28
|
+
# The name of the generator to use
|
29
|
+
# sender::
|
30
|
+
# The name of the sender to use
|
26
31
|
#
|
27
32
|
def self.run kwargs = {}
|
28
33
|
conf_file = Huck::getarg kwargs, :config, nil
|
data/lib/huck/generator.rb
CHANGED
@@ -6,6 +6,14 @@ module Huck
|
|
6
6
|
|
7
7
|
# This method will call the generation method, and return the data in the
|
8
8
|
# desired format.
|
9
|
+
#
|
10
|
+
# == Parameters:
|
11
|
+
# format::
|
12
|
+
# The serialization format (json or yaml)
|
13
|
+
#
|
14
|
+
# == Returns:
|
15
|
+
# A string of serialized text
|
16
|
+
#
|
9
17
|
def dump kwargs = {}
|
10
18
|
format = Huck::getarg kwargs, :format, 'json'
|
11
19
|
data = generate
|
@@ -27,7 +35,7 @@ module Huck
|
|
27
35
|
#
|
28
36
|
# == Parameters:
|
29
37
|
# name::
|
30
|
-
# The name of the generator
|
38
|
+
# The name of the generator
|
31
39
|
# config::
|
32
40
|
# A configuration hash
|
33
41
|
#
|
@@ -38,17 +46,11 @@ module Huck
|
|
38
46
|
name = Huck::getarg kwargs, :name, nil
|
39
47
|
config = Huck::getarg kwargs, :config, nil
|
40
48
|
|
41
|
-
if name.nil?
|
42
|
-
if Huck::try_load 'facter'
|
43
|
-
name = 'facter'
|
44
|
-
elsif Huck::try_load 'ohai'
|
45
|
-
name = 'ohai'
|
46
|
-
else
|
47
|
-
raise RuntimeError, 'unable to load any generators'
|
48
|
-
end
|
49
|
-
end
|
49
|
+
name = 'basic' if name.nil?
|
50
50
|
|
51
51
|
case name
|
52
|
+
when 'basic'
|
53
|
+
g = Generators::BasicGenerator.new
|
52
54
|
when 'facter'
|
53
55
|
g = Generators::FacterGenerator.new
|
54
56
|
when 'ohai'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Huck
|
2
|
+
|
3
|
+
module Generators
|
4
|
+
|
5
|
+
# A very basic host info generator
|
6
|
+
class BasicGenerator < Generator
|
7
|
+
|
8
|
+
# Include required modules
|
9
|
+
def initialize
|
10
|
+
Huck::must_load 'socket'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Generates bare minimum useful information
|
14
|
+
#
|
15
|
+
# == Returns:
|
16
|
+
# A hash of host information
|
17
|
+
#
|
18
|
+
def generate
|
19
|
+
{'hostname' => Socket.gethostname,
|
20
|
+
'platform' => RUBY_PLATFORM}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -7,13 +7,14 @@ module Huck
|
|
7
7
|
|
8
8
|
# Load required modules for facter generator
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
Huck::must_load 'facter'
|
11
11
|
end
|
12
12
|
|
13
|
-
#
|
13
|
+
# Generate data using facter
|
14
14
|
#
|
15
15
|
# == Returns:
|
16
16
|
# A hash of facts as returned by facter
|
17
|
+
#
|
17
18
|
def generate
|
18
19
|
Facter.to_hash
|
19
20
|
end
|
data/lib/huck/generators/json.rb
CHANGED
@@ -7,7 +7,7 @@ module Huck
|
|
7
7
|
|
8
8
|
# Load required modules for json generator
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
Huck::must_load 'json'
|
11
11
|
end
|
12
12
|
|
13
13
|
# Ensure that all JSON config items are properly set
|
@@ -24,6 +24,7 @@ module Huck
|
|
24
24
|
#
|
25
25
|
# == Returns:
|
26
26
|
# A hash of facts read from the JSON file
|
27
|
+
#
|
27
28
|
def generate
|
28
29
|
verify_config
|
29
30
|
JSON.load IO.read(@config['json']['file'])
|
data/lib/huck/generators/ohai.rb
CHANGED
@@ -7,13 +7,14 @@ module Huck
|
|
7
7
|
|
8
8
|
# Load required modules for ohai generator
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
Huck::must_load 'ohai/system'
|
11
11
|
end
|
12
12
|
|
13
|
-
#
|
13
|
+
# Generate data using ohai
|
14
14
|
#
|
15
15
|
# == Returns
|
16
16
|
# A hash of hints as returned by ohai
|
17
|
+
#
|
17
18
|
def generate
|
18
19
|
ohai = Ohai::System.new
|
19
20
|
ohai.all_plugins
|
data/lib/huck/generators/yaml.rb
CHANGED
@@ -7,7 +7,7 @@ module Huck
|
|
7
7
|
|
8
8
|
# Load required modules for yaml generator
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
Huck::must_load 'yaml'
|
11
11
|
end
|
12
12
|
|
13
13
|
# Ensure that all YAML config items are properly set
|
@@ -24,6 +24,7 @@ module Huck
|
|
24
24
|
#
|
25
25
|
# == Returns:
|
26
26
|
# A hash of facts read from the YAML file
|
27
|
+
#
|
27
28
|
def generate
|
28
29
|
verify_config
|
29
30
|
YAML.load_file @config['yaml']['file']
|
data/lib/huck/handlers/echo.rb
CHANGED
data/lib/huck/handlers/exec.rb
CHANGED
@@ -8,7 +8,7 @@ module Huck
|
|
8
8
|
|
9
9
|
# Includes all required modules
|
10
10
|
def initialize
|
11
|
-
|
11
|
+
Huck::must_load 'open3'
|
12
12
|
end
|
13
13
|
|
14
14
|
# Ensures that configuration is set properly before executing
|
@@ -23,6 +23,11 @@ module Huck
|
|
23
23
|
|
24
24
|
# Handle an individual message by running an executable, passing in the
|
25
25
|
# gathered data via stdin.
|
26
|
+
#
|
27
|
+
# == Parameters:
|
28
|
+
# msg::
|
29
|
+
# The message to process
|
30
|
+
#
|
26
31
|
def handle msg
|
27
32
|
verify_config
|
28
33
|
|
data/lib/huck/receivers/sqs.rb
CHANGED
data/lib/huck/senders/sqs.rb
CHANGED
@@ -7,7 +7,7 @@ module Huck
|
|
7
7
|
|
8
8
|
# Includes all required modules for the SQS sender
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
Huck::must_load 'aws-sdk'
|
11
11
|
end
|
12
12
|
|
13
13
|
# Ensures that configuration is set properly before trying to use the
|
@@ -28,7 +28,7 @@ module Huck
|
|
28
28
|
#
|
29
29
|
# == Parameters:
|
30
30
|
# msg::
|
31
|
-
# The
|
31
|
+
# The message to process
|
32
32
|
#
|
33
33
|
def send msg
|
34
34
|
verify_config
|
data/lib/huck/util.rb
CHANGED
@@ -50,4 +50,18 @@ module Huck
|
|
50
50
|
true
|
51
51
|
end
|
52
52
|
|
53
|
+
# Try to load a module, and raise a RuntimeError if it is not
|
54
|
+
# loadable. This is useful for trying to load certain provider
|
55
|
+
# code at runtime without dealing with LoadError.
|
56
|
+
#
|
57
|
+
# == Parameters:
|
58
|
+
# name::
|
59
|
+
# The name of the module
|
60
|
+
#
|
61
|
+
def self.must_load name
|
62
|
+
if !self.try_load name
|
63
|
+
raise RuntimeError, "unable to load #{name}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
53
67
|
end
|
data/lib/huck/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huck
|
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
|
- Ryan Uber
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- lib/huck/generators/ohai.rb
|
63
63
|
- lib/huck/generators/facter.rb
|
64
|
+
- lib/huck/generators/basic.rb
|
64
65
|
- lib/huck/generators/yaml.rb
|
65
66
|
- lib/huck/generators/json.rb
|
66
67
|
- lib/huck/senders/sqs.rb
|