yajl 0.2.2 → 0.3.2

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: 9fdfad3b5149928729686a23f0951a7daedd3fcb
4
- data.tar.gz: 4aa1bf76f6f5a80853a351d542def1d3d279bf97
3
+ metadata.gz: f16a11b1d6b326240447f36ba5b6396c9a5fe927
4
+ data.tar.gz: 080e4b796b36836db9ef1eab90f9712103bc8b67
5
5
  SHA512:
6
- metadata.gz: 79769d884f5a0a663f0ad4ce8b6b3a4fb776ae828f59d4f272ee55cda3f5baf5f38c805c462c97158319fe2eadccfae8f5f67945464234af7d2c64b50c097f24
7
- data.tar.gz: a2e6d2141af656d674a40b132e750592013502c458045cc67929c4d3e6dcb87aac9ad0a5fd0b8361ec58bab3028d1624c729b42ac06e5fe8f43121af0d924e6e
6
+ metadata.gz: db297ea29f8ce8fe70d01b0ddff9496748f20f7bd708315bc06842878c65f5533e29c2703383d1766532998eefe9e6615452f94ceb3ad32eb71ee81a128e9633
7
+ data.tar.gz: a810f693150d64d27ad6c9b593ba84c4e1418bc08fc3b7d103e5d8f741f869739c20535a96b220ca24e5bf5be008170d1cc8eaf5e4d2f7c7675223434a90dad4
data/README.markdown CHANGED
@@ -9,6 +9,7 @@ without screwing around, and I want to be able to easily log text.
9
9
 
10
10
  1. Tests. I guess. Maybe.
11
11
  2. Maybe rewrite this in [Nim](http://nim-lang.org/) and wrap it in the Ruby FFI. I'd have to be logging a *lot* to justify it though.
12
+ 3. Maybe make it Windows friendly. (Not sure how to handle newlines for Windows).
12
13
 
13
14
  ## Installation
14
15
 
@@ -101,7 +102,8 @@ Which sets the `progname` attribute.
101
102
  By default logs are stored in `~/logs` with a very sensible
102
103
  logger name. If even one person wants the ability to change the
103
104
  filename that is set I'll add the support to do so. Right now it
104
- looks like this:
105
+ looks like this (Where `yajl` would be the name of whatever git
106
+ repo you are using):
105
107
 
106
108
  `/home/zach/logs/zach@Lux.yajl.log`
107
109
 
@@ -110,7 +112,7 @@ or like this:
110
112
  `/home/zach/logs/zach@Lux.yajl.log.1`
111
113
 
112
114
  If there are multiple running processes (just like the normal Ruby
113
- processor.
115
+ logger).
114
116
 
115
117
  Note, it gets the name of the project from your Git project name.
116
118
  If you don't use Git let me know and I'll make this toggleable too.
data/lib/yajl.rb CHANGED
@@ -4,9 +4,36 @@ require "securerandom"
4
4
 
5
5
  require "yajl/version"
6
6
 
7
- class Logger::LogDevice
7
+ def project
8
+ result = `git rev-parse --show-toplevel`.chomp
9
+ message = "logger only works within a git project"
10
+ raise message if result == ""
11
+
12
+ result
13
+ end
14
+
15
+ class YajlLogger < Logger
16
+
17
+ %w{ warn info debug fatal error unknown }
18
+ .each do |method_name|
19
+ define_method(method_name) do |message|
20
+ sender = caller[0].split(":")[0]
21
+ path = sender.split("/")
22
+ project_depth = project.split("/").size
23
+
24
+ if path[0..project_depth-1].join("/") == project
25
+ path = path[project_depth..-1]
26
+ end
27
+
28
+ progname = path.join("/")
29
+ super(progname) { message }
30
+ end
31
+ end
32
+
33
+ # I don't want header lines
8
34
  def add_log_header(file)
9
35
  end
36
+
10
37
  end
11
38
 
12
39
  module Yajl
@@ -18,16 +45,11 @@ module Yajl
18
45
  user = `whoami`.chomp
19
46
  hostname = `hostname`.chomp
20
47
 
21
- project = `git rev-parse --show-toplevel`.chomp
22
- message = "logger only works within a git project"
23
- raise message if project == ""
24
-
25
48
  `mkdir -p #{log_directory}`
49
+ project_name = project.split("/")[-1]
26
50
 
27
- project = project.split("/")[-1]
28
-
29
- filename = File.expand_path("~/logs/#{user}@#{hostname}.#{project}.log")
30
- logger = Logger.new(filename)
51
+ filename = File.expand_path("#{log_directory}/#{user}@#{hostname}.#{project_name}.log")
52
+ logger = YajlLogger.new(filename)
31
53
 
32
54
  logger.level = Logger::INFO
33
55
  logger.formatter = proc do |severity, datetime, progname, message|
data/lib/yajl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yajl
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yajl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Aysan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler