logzomg 0.1.0.7 → 0.1.0.8

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: 38b7219a7f59823e05b79dc758b745f741d3dbca
4
- data.tar.gz: 1ec3ce8ca7aa6edab9b71373d272f9becd87083c
3
+ metadata.gz: 7d264f9491f0647d35cfa53b035197f7edfa2c7f
4
+ data.tar.gz: e05ec63bf2abd4251ae7af19a83665a2841f1a15
5
5
  SHA512:
6
- metadata.gz: a442301af1a91473bfb181896bb6644b9f0a0f3b5806e2d451b5f1949de6c2e694fa3c382a2d65f111db984f4e744b53e3a6fbff55effce0fc8d4b1dc38a4ee9
7
- data.tar.gz: 7c773b4cf69946baa366c587b24dba587052c4325eb9941bac01a45835a6d4dfc4a9f4760829f6702cd5702feb4072d03a417b73da84597e3e02f64450f96f33
6
+ metadata.gz: 17aef22ec720a4223cbb8b3bbf8244695114076c9febd0a0b4d12cb00f8fa11987bb70966aee9300d912217f5ed3e0d3f73e879ef585cbc483ab462d03dfd4db
7
+ data.tar.gz: c8e9f9438cf0ad8fb0516f1183fbcf7bb4aa5838912a54cd655d7abe918648f96739d1ee61cf09ca6d3eb4f0f80ebc0bf580d37ce2aa5975a7e79199faabe1d8
data/.gitignore CHANGED
@@ -7,6 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /logs/
10
+ /log/
11
11
 
12
12
  /*.gem
@@ -31,9 +31,10 @@ class TextFormatter
31
31
 
32
32
  s_msg.each do |n|
33
33
  str += count == 0 ? "#{add_log_level(str)}#{get_date} | " : "#{add_log_level(str)}"
34
- str += count == 0 ? "#{n}\n" : " " * (get_date.length) + " | #{n}\n" # Indent if 2nd+ iteration
34
+ str += count == 0 ? "#{n}\n" : " " * (get_date.length) + " | #{n}\n" # Indent if 2nd+ iteration
35
35
  count += 1
36
36
  end
37
+
37
38
  str
38
39
  end
39
40
 
@@ -76,6 +77,7 @@ class TextFormatter
76
77
  def split_msg(msg)
77
78
  sub_end = MAX_CHAR - 5
78
79
  # Goes back to start of word if matches inside a word. If it matches inside a coloured key go back to start of word before colour
79
- msg.scan(/.{0,#{Regexp.escape(sub_end.to_s)}}[\\033\[0-90-9m\]\w\\e\[0m](?:\ |$)/mi).each { |n| n.slice!(0) if n[0] == " "}
80
+ # Remove starting whitespace. Sometimes creates empty array indice so remove if length isn't long enough
81
+ arr = msg.scan(/.{0,#{Regexp.escape(sub_end.to_s)}}[\\033\[0-90-9m\w\\e\[0m\ ]{0}(?:\ |$)/mi).select { |s| s.length > 1 }.each { |n| n.slice!(0) if n[0] == " "}
80
82
  end
81
83
  end
@@ -12,7 +12,7 @@ module Logzomg
12
12
  attr_accessor :log_path
13
13
 
14
14
  def initialize(**args, &block)
15
- @log_path = File.expand_path(Rails.root.to_s + '/log/')
15
+ @log_path = get_log_path
16
16
  @level = args[:level] ? args[:level] : "warning"
17
17
  @formatter = args[:formatter] ? args[:formatter] : TextFormatter.new {|f| f.with_color = true}
18
18
  if block_given?
@@ -83,10 +83,11 @@ module Logzomg
83
83
  wild: true,
84
84
  msg: "Something has been spotted!",
85
85
  damn: "son",
86
- damn2: "son",
87
- damn3: "son",
88
- damn4: "son",
89
- damn5: "son",
86
+ damn2: "son",
87
+ damn3: "son",
88
+ object: Object.new,
89
+ damn4: "son",
90
+ damn5: "son",
90
91
  level: "info"
91
92
  })
92
93
  self.log({
@@ -114,18 +115,22 @@ module Logzomg
114
115
  File.open(@log_path + file, 'a') {|f| f.write(msg) }
115
116
  end
116
117
 
117
- def get_path
118
- Dir.pwd
119
- end
120
-
121
118
  # Checks if message is hash
122
119
  def valid_hash?(hash)
123
- return hash.class == Hash
120
+ return hash.is_a?(Hash)
124
121
  end
125
122
 
126
123
  # Checks if the level value is valid (part of LEVELS)
127
124
  def valid_level?(level)
128
125
  return !level.nil? && LEVELS.any? { |l| l == level.downcase }
129
126
  end
127
+
128
+ def get_log_path
129
+ if defined?(Rails)
130
+ File.expand_path(Rails.root.to_s + '/log/')
131
+ else
132
+ File.expand_path('log/')
133
+ end
134
+ end
130
135
  end
131
136
  end
@@ -1,3 +1,3 @@
1
1
  module Logzomg
2
- VERSION = "0.1.0.7"
2
+ VERSION = "0.1.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logzomg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.7
4
+ version: 0.1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rasmus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-01 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler