simple_speaker 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a36017aba38009246815b8f4612477e21f220b86
4
- data.tar.gz: 36af3c996e1a1a430ec51dcb21b0074f062ef41b
3
+ metadata.gz: a312e6b4c371d820e6d2707184e4c939652dd107
4
+ data.tar.gz: 6c7997f7dea6d0f4c41cc02afea0d68703775910
5
5
  SHA512:
6
- metadata.gz: afb0469d51d73f12ca79aebd8e91085f1d73bfe8c6cee88d77858e7ceac43feca3d10f9de13613a57e52456c57d21de5b4abea0d9c6d0e463362f382f196f129
7
- data.tar.gz: 1c93984e4b803a838c523f482a5bc3c3898d66445d175146b0dfdc911c41a83995e0e18ab4abea3be35d980d779fcdfe79392a1228b8144d4ec9d410b8c725f8
6
+ metadata.gz: 5df0066f8eb53d9f5436f884f8e74786e169d65299cee71d636e6ece312b166386cc59ab1436786ffab615e75f4f66bccbae1577f05e2a1e641e63bc4a07131f
7
+ data.tar.gz: f26e4cdba6ad2065dfcb9b9c9bb038b2a9582d0167d8b1c4eead859750417f23bb27bed3f069397dc3d0e2e97901ecf6a4a47b25d9c3d4eae18c8de0bdd1595e
@@ -1,3 +1,3 @@
1
1
  module SimpleSpeaker
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -9,10 +9,10 @@ module SimpleSpeaker
9
9
  @user_input = nil
10
10
  end
11
11
 
12
- def ask_if_needed(question, no_prompt = 0, default = 'y')
12
+ def ask_if_needed(question, no_prompt = 0, default = 'y', thread = Thread.current)
13
13
  ask_if_needed = default
14
14
  if no_prompt.to_i == 0
15
- self.speak_up(question, 0)
15
+ self.speak_up(question, 0, thread)
16
16
  if Daemon.is_daemon?
17
17
  wtime = 0
18
18
  while @user_input.nil?
@@ -32,14 +32,18 @@ module SimpleSpeaker
32
32
  Thread.current[:current_daemon].send_data "#{str}\n" if Thread.current[:current_daemon]
33
33
  end
34
34
 
35
- def speak_up(str, in_mail = 1)
35
+ def email_msg_add(str, in_mail, thread)
36
+ thread[:email_msg] += str + NEW_LINE if thread[:email_msg]
37
+ if in_mail.to_i > 0
38
+ thread[:send_email] = in_mail.to_i if thread[:send_email]
39
+ end
40
+ end
41
+
42
+ def speak_up(str, in_mail = 1, thread = Thread.current)
36
43
  puts str
37
44
  daemon_send(str)
38
45
  @logger.info(str) if @logger
39
- Thread.current[:email_msg] += str + NEW_LINE if Thread.current[:email_msg]
40
- if in_mail.to_i > 0
41
- Thread.current[:send_email] = in_mail.to_i if Thread.current[:send_email]
42
- end
46
+ email_msg_add(str, in_mail, thread)
43
47
  str
44
48
  end
45
49
 
@@ -47,18 +51,15 @@ module SimpleSpeaker
47
51
  @logger.info(str) if @logger
48
52
  end
49
53
 
50
- def tell_error(e, src, in_mail = 1)
54
+ def tell_error(e, src, in_mail = 1, thread = Thread.current)
51
55
  puts "In #{src}"
52
56
  daemon_send(src)
53
57
  puts e
54
58
  daemon_send(e)
55
59
  @logger_error.error("ERROR #{Time.now.utc.to_s} #{src}") if @logger_error
56
60
  @logger_error.error(e) if @logger_error
57
- Thread.current[:email_msg] += "ERROR #{Time.now.utc.to_s} #{src}" + NEW_LINE if Thread.current[:email_msg]
58
- Thread.current[:email_msg] += e.to_s + NEW_LINE if Thread.current[:email_msg]
59
- if in_mail.to_i > 0
60
- Thread.current[:send_email] = in_mail.to_i if Thread.current[:send_email]
61
- end
61
+ email_msg_add("ERROR #{Time.now.utc.to_s} #{src}" + NEW_LINE, in_mail, thread)
62
+ email_msg_add(e.to_s + NEW_LINE, in_mail, thread)
62
63
  end
63
64
 
64
65
  def user_input(input)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_speaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - R
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-19 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.6.12
94
+ rubygems_version: 2.6.14
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Ruby utilities to push to log files and various output.