nasty 0.0.1388162472 → 0.0.1388163140

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: 642033e0d0fe0194dbac76d15ea61ff8f4392445
4
- data.tar.gz: 9bef2d7c6d40c6ffec26c1356ce0eff7db1996b7
3
+ metadata.gz: f68abe673beec967c3cfcc12dfa14d741394ecf4
4
+ data.tar.gz: 4a1df0f3a74efbaf19334f832f7beac2df6fdaad
5
5
  SHA512:
6
- metadata.gz: ef743b56cfb87efac47b67e2d0074f53354fe5be971f233a8c6ab9d442409edc8e972801edc0268fbd4352d711533ec15223460f721abc436e709365e79b45e3
7
- data.tar.gz: f1304112fd741f6ea08d74d519374edf556b153654c70728c21a475143ff0ca73ab724e9ac2c1068beb36c78dfd4a69b511bfe01b26ec5879de6a74ae1063145
6
+ metadata.gz: f5ae34b0386a7dcfd1a090d5d06ff5f4e252dd99d54d28507e8e538d9369d5a54a63b8bfe823e3620525d99a363f4dd22100aeda218a62495b9b48c81f69a4d4
7
+ data.tar.gz: 5566667b068f370d6290ca59bf22d2a90301ff3cd01cb2a3208849e13e7e31fe7df424e9f2c0f3d8482fe76f2f7102a71d0e883368f3e00beb775abb95ccdc51
data/lib/nasty.rb CHANGED
@@ -2,6 +2,7 @@ require "nasty/background_job"
2
2
  require "nasty/command"
3
3
  require "nasty/composite_command"
4
4
  require "nasty/kernel"
5
+ require "nasty/log"
5
6
  require "nasty/lambda_behaviours"
6
7
  require "nasty/version"
7
8
 
data/lib/nasty/log.rb ADDED
@@ -0,0 +1,27 @@
1
+ require "logger"
2
+
3
+ module Nasty
4
+ class Log
5
+ class << self
6
+ def bind_to(log_factory)
7
+ @@log_factory = log_factory
8
+ end
9
+
10
+ def for(target)
11
+ @@log_factory || ConsoleLogFactory.new
12
+ @@log_factory.create_for(target)
13
+ end
14
+ end
15
+ end
16
+
17
+ class ConsoleLogFactory
18
+ def initialize(logger = Logger.new(STDOUT), level = Logger::DEBUG)
19
+ @logger = logger
20
+ @logger.level = level
21
+ end
22
+
23
+ def create_for(target)
24
+ @logger
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Logger do
4
+ context "playtime" do
5
+ it "should log stuff" do
6
+ logger = Logger.new(STDOUT)
7
+ logger.level = Logger::DEBUG
8
+
9
+ #logger.debug("i am logged")
10
+ #logger.close
11
+ end
12
+ end
13
+ end
14
+
15
+ module Nasty
16
+ describe Log do
17
+ context "when logging stuff" do
18
+ let(:logger) { double("", debug: true) }
19
+ let(:log_factory) { double }
20
+
21
+ before :each do
22
+ log_factory.stub(:create_for).with(self).and_return(logger)
23
+ Log.bind_to(log_factory)
24
+ Log.for(self).debug("hi there")
25
+ end
26
+
27
+ it "should log to the bound logger" do
28
+ logger.should have_received(:debug).with("hi there")
29
+ end
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nasty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1388162472
4
+ version: 0.0.1388163140
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
@@ -85,11 +85,13 @@ files:
85
85
  - lib/nasty/composite_command.rb
86
86
  - lib/nasty/kernel.rb
87
87
  - lib/nasty/lambda_behaviours.rb
88
+ - lib/nasty/log.rb
88
89
  - lib/nasty/version.rb
89
90
  - nasty.gemspec
90
91
  - spec/spec_helper.rb
91
92
  - spec/unit/command_spec.rb
92
93
  - spec/unit/lambda_behaviours_spec.rb
94
+ - spec/unit/log_spec.rb
93
95
  - spec/unit/using_spec.rb
94
96
  homepage: http://github.com/mokhan/nasty
95
97
  licenses:
@@ -119,4 +121,5 @@ test_files:
119
121
  - spec/spec_helper.rb
120
122
  - spec/unit/command_spec.rb
121
123
  - spec/unit/lambda_behaviours_spec.rb
124
+ - spec/unit/log_spec.rb
122
125
  - spec/unit/using_spec.rb