pps_commons 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5a18be028e38ab0bbd7cf0c6aac4123ffeb9aa6
4
- data.tar.gz: 72122f33cd7aa295d5175c60c56237f5bfddef97
3
+ metadata.gz: d8b150097ed1971d14a82d0a3d7c3c20beef5036
4
+ data.tar.gz: 9b6d1acd87d24b7da1fd5851a6e8097d23b41a5f
5
5
  SHA512:
6
- metadata.gz: cd91e52bea59c2c47850b7d48b6dbd0cb585fc10778dc9197f18455d23842df21ebf052dcfb82b9aeda7ca700db6dd0b361cc7b085aab4095fa4a167677462a1
7
- data.tar.gz: 46ed66bae46be0c6a30c4e20f92538785c9b1f846c9964434c404b32c78842d600d57d6048effc1eea12307d84a53edf6d2ba32235b9c589aad8af659def810b
6
+ metadata.gz: bd3d92e340ac590e4e6cb8e034eff74b34471648dbe846327aed59ba3d56d27afec5825f826b3afd499ed174bb804218e60f0604a5483493a7c58ec93010c97c
7
+ data.tar.gz: 49b079eb63bf431d5f15fffe68eba9013ff83a81da7026b23dee99e1a88e7b7ba14298bc89d82146075fa791b561a237b2da018a9b8703affa695a3985f9ec27
@@ -1,11 +1,13 @@
1
1
  require 'byebug'
2
2
  require 'dotenv'
3
+ require 'pps_commons'
4
+
3
5
  module WGU
4
6
  # The DelegationAgent class allows you to pass in a message and move on with
5
7
  # life. It does this by understanding the message and deferring the correct
6
8
  # methods for later. This class is called from the PPS agents in the work_loop.
7
9
  class DelegationAgent
8
- include ::PPSCommons
10
+ include WGU::PPSCommons
9
11
 
10
12
  attr_accessor :requester
11
13
  attr_reader :sentence
@@ -1,7 +1,9 @@
1
- require 'pps_commons/commons'
1
+ require 'pps_commons'
2
2
 
3
3
  module WGU
4
4
  class Sentence
5
+ include WGU::PPSCommons
6
+
5
7
  attr_reader :recipient
6
8
  attr_reader :message
7
9
 
@@ -1,3 +1,3 @@
1
1
  module PPSCommons
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/pps_commons.rb CHANGED
@@ -1,10 +1,51 @@
1
- require 'pps_commons/commons'
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'byebug'
2
4
 
3
- module PPSCommons
4
- include Commons
5
- extend Commons::ClassMethods
5
+ module WGU
6
+ module PPSCommons
7
+ def self.included(base)
8
+ base.send :include, InstanceMethods
9
+ end
10
+ # this tells EventMachine how many threads it can use. There is a lot of Deferrals
11
+ # in this project so it helps to run a higher number.
12
+ # EM defaults to '20', PPS defaults to '40'
13
+ def PPSCommons.unleash_the_fury_level
14
+ found = ENV['PPS_THREAD_COUNT'].to_i
15
+ found.eql?(0) ? 40 : found.to_i
16
+ end
17
+ # search through a hash's nested keys for crap
18
+ def PPSCommons.deep_find(key, object=self, found=nil)
19
+ if object.respond_to?(:key?) && object.key?(key)
20
+ object[key]
21
+ elsif object.respond_to?(:each)
22
+ object.find { |k,v| found = deep_find(key, v) }
23
+ found
24
+ end
25
+ end
6
26
 
7
- def self.included(base)
8
- base.send :include, Commons
27
+ # Common instance methods
28
+ module InstanceMethods
29
+ def logger(file = nil)
30
+ if @logger.nil?
31
+ log = ::File.expand_path(file)
32
+ unless ::File.exist?(log)
33
+ log_dir = File.dirname(log)
34
+ unless ::Dir.exist?(log_dir)
35
+ ::Dir.mkdir_p(log_dir)
36
+ end
37
+ ::File.new(log, 'a+')
38
+ end
39
+
40
+ Logger.new(log)
41
+ else
42
+ @logger
43
+ end
44
+ end
45
+ # instance version of +self.deep_find()+
46
+ def deep_find(key, object=self, found=nil)
47
+ WGU::PPSCommons.deep_find(key, object)
48
+ end
49
+ end
9
50
  end
10
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pps_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Phillipps
@@ -126,7 +126,6 @@ files:
126
126
  - bin/setup
127
127
  - lib/pps_commons.rb
128
128
  - lib/pps_commons/chef_comms.rb
129
- - lib/pps_commons/commons.rb
130
129
  - lib/pps_commons/delegation_agent.rb
131
130
  - lib/pps_commons/sentence.rb
132
131
  - lib/pps_commons/thycotic_comms.rb
@@ -1,48 +0,0 @@
1
- require 'rest-client'
2
- require 'json'
3
- require 'byebug'
4
-
5
- module Commons
6
- module ClassMethods
7
- # this tells EventMachine how many threads it can use. There is a lot of Deferrals
8
- # in this project so it helps to run a higher number.
9
- # EM defaults to '20', PPS defaults to '40'
10
- def unleash_the_fury_level
11
- found = ENV['PPS_THREAD_COUNT'].to_i
12
- found.eql?(0) ? 40 : found.to_i
13
- end
14
-
15
- # search through a hash's nested keys for crap
16
- def ClassMethods.deep_find(key, object=self, found=nil)
17
- if object.respond_to?(:key?) && object.key?(key)
18
- object[key]
19
- elsif object.respond_to?(:each)
20
- object.find { |k,v| found = deep_find(key, v) }
21
- found
22
- end
23
- end
24
- end
25
-
26
- # TODO: accept a file path instead of somewhere in the gems
27
- def logger(file = nil)
28
- if @logger.nil?
29
- log = ::File.expand_path(file)
30
- unless ::File.exist?(log)
31
- log_dir = File.dirname(log)
32
- unless ::Dir.exist?(log_dir)
33
- ::Dir.mkdir_p(log_dir)
34
- end
35
- ::File.new(log, 'a+')
36
- end
37
-
38
- Logger.new(log)
39
- else
40
- @logger
41
- end
42
- end
43
-
44
- # instance version of +self.deep_find()+
45
- def deep_find(key, object=self, found=nil)
46
- Commons::ClassMethods.deep_find(key, object)
47
- end
48
- end