yell 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -1
  3. data/.travis.yml +1 -2
  4. data/Gemfile +5 -1
  5. data/README.md +67 -14
  6. data/examples/004.1-colorizing-the-log-output.rb +4 -4
  7. data/lib/yell.rb +19 -10
  8. data/lib/yell/adapters.rb +23 -26
  9. data/lib/yell/adapters/base.rb +8 -2
  10. data/lib/yell/adapters/datefile.rb +45 -42
  11. data/lib/yell/adapters/file.rb +10 -5
  12. data/lib/yell/adapters/io.rb +52 -48
  13. data/lib/yell/adapters/streams.rb +10 -2
  14. data/lib/yell/configuration.rb +1 -1
  15. data/lib/yell/event.rb +4 -4
  16. data/lib/yell/formatter.rb +11 -25
  17. data/lib/yell/helpers/adapters.rb +51 -0
  18. data/lib/yell/helpers/base.rb +19 -0
  19. data/lib/yell/helpers/formatter.rb +31 -0
  20. data/lib/yell/helpers/level.rb +36 -0
  21. data/lib/yell/helpers/silencer.rb +32 -0
  22. data/lib/yell/helpers/tracer.rb +48 -0
  23. data/lib/yell/level.rb +38 -47
  24. data/lib/yell/logger.rb +53 -73
  25. data/lib/yell/repository.rb +31 -29
  26. data/lib/yell/silencer.rb +69 -0
  27. data/lib/yell/version.rb +1 -1
  28. data/spec/spec_helper.rb +21 -9
  29. data/spec/yell/adapters/base_spec.rb +17 -34
  30. data/spec/yell/adapters/datefile_spec.rb +109 -66
  31. data/spec/yell/adapters/file_spec.rb +18 -18
  32. data/spec/yell/adapters/io_spec.rb +17 -13
  33. data/spec/yell/adapters/streams_spec.rb +7 -7
  34. data/spec/yell/adapters_spec.rb +18 -23
  35. data/spec/yell/configuration_spec.rb +7 -7
  36. data/spec/yell/event_spec.rb +25 -27
  37. data/spec/yell/formatter_spec.rb +89 -82
  38. data/spec/yell/level_spec.rb +119 -94
  39. data/spec/yell/loggable_spec.rb +6 -5
  40. data/spec/yell/logger_spec.rb +106 -66
  41. data/spec/yell/repository_spec.rb +23 -38
  42. data/spec/yell/silencer_spec.rb +49 -0
  43. data/spec/yell_spec.rb +24 -27
  44. metadata +16 -9
@@ -2,83 +2,68 @@ require 'spec_helper'
2
2
 
3
3
  describe Yell::Repository do
4
4
  let(:name) { 'test' }
5
- let(:logger) { Yell.new :stdout }
5
+ let(:logger) { Yell.new(:stdout) }
6
6
 
7
7
  subject { Yell::Repository[name] }
8
8
 
9
-
10
9
  context ".[]" do
11
10
  it "should raise when not set" do
12
- lambda { subject }.should raise_error( Yell::LoggerNotFound )
11
+ expect { subject }.to raise_error(Yell::LoggerNotFound)
13
12
  end
14
13
 
15
- it "should return the logger when set" do
16
- Yell::Repository[ name ] = logger
14
+ context "when logger with :name exists" do
15
+ let!(:logger) { Yell.new(:stdout, :name => name) }
17
16
 
18
- subject.should == logger
17
+ it { should eq(logger) }
19
18
  end
20
19
 
21
20
  context "given a Class" do
22
- before do
23
- @logger = Yell.new :stdout, :name => "Numeric"
24
- end
21
+ let!(:logger) { Yell.new(:stdout, :name => "Numeric") }
25
22
 
26
23
  it "should raise with the correct :name when logger not found" do
27
- mock.proxy( Yell::LoggerNotFound ).new( String )
28
-
29
- lambda { Yell::Repository[ String ] }.should raise_error( Yell::LoggerNotFound )
24
+ mock.proxy(Yell::LoggerNotFound).new(String)
25
+ lambda { Yell::Repository[String] }.should raise_error(Yell::LoggerNotFound)
30
26
  end
31
27
 
32
28
  it "should return the logger" do
33
- Yell::Repository[ Numeric ].should == @logger
29
+ Yell::Repository[Numeric].should eq(logger)
34
30
  end
35
31
 
36
32
  it "should return the logger when superclass has it defined" do
37
- Yell::Repository[ Integer ].should == @logger
33
+ Yell::Repository[Integer].should eq(logger)
38
34
  end
39
35
  end
40
36
  end
41
37
 
42
38
  context ".[]=" do
43
- before do
44
- Yell::Repository[ name ] = logger
45
- end
46
-
47
- it { should == logger }
39
+ before { Yell::Repository[name] = logger }
40
+ it { should eq(logger) }
48
41
  end
49
42
 
50
- context "[]= with a named logger" do
51
- before do
52
- Yell::Repository[ name ] = Yell.new :stdout, :name => name
53
- end
43
+ context ".[]= with a named logger" do
44
+ let!(:logger) { Yell.new(:stdout, :name => name) }
45
+ before { Yell::Repository[name] = logger }
54
46
 
55
- it { should_not be_nil }
47
+ it { should eq(logger) }
56
48
  end
57
49
 
58
- context "[]= with a named logger of other name" do
50
+ context ".[]= with a named logger of a different name" do
59
51
  let(:other) { 'other' }
60
- let(:logger) { Yell.new :stdout, :name => other }
61
-
62
- before do
63
- Yell::Repository[ name ] = logger
64
- end
52
+ let(:logger) { Yell.new(:stdout, :name => other) }
53
+ before { Yell::Repository[name] = logger }
65
54
 
66
55
  it "should add logger to both repositories" do
67
- Yell::Repository[name].should == logger
68
- Yell::Repository[other].should == logger
56
+ Yell::Repository[name].should eq(logger)
57
+ Yell::Repository[other].should eq(logger)
69
58
  end
70
59
  end
71
60
 
72
61
  context "loggers" do
73
62
  let(:loggers) { { name => logger } }
74
-
75
63
  subject { Yell::Repository.loggers }
64
+ before { Yell::Repository[name] = logger }
76
65
 
77
- before do
78
- Yell::Repository[ name ] = logger
79
- end
80
-
81
- it { should == loggers }
66
+ it { should eq(loggers) }
82
67
  end
83
68
 
84
69
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yell::Silencer do
4
+
5
+ context "initialize with #patterns" do
6
+ subject { Yell::Silencer.new(/this/) }
7
+
8
+ its(:patterns) { should eq([/this/]) }
9
+ end
10
+
11
+ context "#add" do
12
+ let(:silencer) { Yell::Silencer.new }
13
+
14
+ it "should add patterns" do
15
+ silencer.add /this/, /that/
16
+
17
+ expect(silencer.patterns).to eq([/this/, /that/])
18
+ end
19
+
20
+ it "should ignore duplicate patterns" do
21
+ silencer.add /this/, /that/, /this/
22
+
23
+ expect(silencer.patterns).to eq([/this/, /that/])
24
+ end
25
+ end
26
+
27
+ context "#silence?" do
28
+ let(:silencer) { Yell::Silencer.new }
29
+
30
+ it "should be false when no patterns present" do
31
+ expect(silencer.silence?).to be_false
32
+ end
33
+
34
+ it "should be true when patterns present" do
35
+ silencer.add /this/
36
+
37
+ expect(silencer.silence?).to be_true
38
+ end
39
+ end
40
+
41
+ context "#silence" do
42
+ let(:silencer) { Yell::Silencer.new(/this/) }
43
+
44
+ it "should reject messages that match any pattern" do
45
+ expect(silencer.silence("this", "that")).to eq(["that"])
46
+ end
47
+ end
48
+
49
+ end
@@ -8,52 +8,52 @@ describe Yell do
8
8
  it { should be_kind_of Yell::Logger }
9
9
 
10
10
  it "should raise AdapterNotFound when adapter cant be loaded" do
11
- lambda { Yell.new :unknownadapter }.should raise_error( Yell::AdapterNotFound )
11
+ expect {
12
+ Yell.new :unknownadapter
13
+ }.to raise_error(Yell::AdapterNotFound)
12
14
  end
13
15
 
14
- context :level do
16
+ context ".level" do
15
17
  subject { Yell.level }
16
-
17
18
  it { should be_kind_of Yell::Level }
18
19
  end
19
20
 
20
- context :format do
21
+ context ".format" do
21
22
  subject { Yell.format( "%m" ) }
22
-
23
23
  it { should be_kind_of Yell::Formatter }
24
24
  end
25
25
 
26
- context :load! do
26
+ context ".load!" do
27
27
  subject { Yell.load!( 'yell.yml' ) }
28
28
 
29
29
  before do
30
- mock( Yell::Configuration ).load!( 'yell.yml' ) { {} }
30
+ mock(Yell::Configuration).load!('yell.yml') { {} }
31
31
  end
32
32
 
33
33
  it { should be_kind_of Yell::Logger }
34
34
  end
35
35
 
36
- context :[] do
37
- let( :name ) { 'test' }
36
+ context ".[]" do
37
+ let(:name) { 'test' }
38
38
 
39
39
  it "should delegate to the repository" do
40
- mock( Yell::Repository )[ name ]
40
+ mock(Yell::Repository)[name]
41
41
 
42
- Yell[ name ]
42
+ Yell[name]
43
43
  end
44
44
  end
45
45
 
46
- context :[]= do
47
- let( :name ) { 'test' }
46
+ context ".[]=" do
47
+ let(:name) { 'test' }
48
48
 
49
49
  it "should delegate to the repository" do
50
- mock.proxy( Yell::Repository )[name] = logger
50
+ mock.proxy(Yell::Repository)[name] = logger
51
51
 
52
- Yell[ name ] = logger
52
+ Yell[name] = logger
53
53
  end
54
54
  end
55
55
 
56
- context :env do
56
+ context ".env" do
57
57
  subject { Yell.env }
58
58
 
59
59
  it "should default to YELL_ENV" do
@@ -62,8 +62,8 @@ describe Yell do
62
62
 
63
63
  context "fallback to RACK_ENV" do
64
64
  before do
65
- stub( ENV ).key?( 'YELL_ENV' ) { false }
66
- mock( ENV ).key?( 'RACK_ENV' ) { true }
65
+ stub(ENV).key?('YELL_ENV') { false }
66
+ mock(ENV).key?('RACK_ENV') { true }
67
67
 
68
68
  ENV['RACK_ENV'] = 'rack'
69
69
  end
@@ -75,9 +75,9 @@ describe Yell do
75
75
 
76
76
  context "fallback to RAILS_ENV" do
77
77
  before do
78
- stub( ENV ).key?( 'YELL_ENV' ) { false }
79
- stub( ENV ).key?( 'RACK_ENV' ) { false }
80
- mock( ENV ).key?( 'RAILS_ENV' ) { true }
78
+ stub(ENV).key?('YELL_ENV') { false }
79
+ stub(ENV).key?('RACK_ENV') { false }
80
+ mock(ENV).key?('RAILS_ENV') { true }
81
81
 
82
82
  ENV['RAILS_ENV'] = 'rails'
83
83
  end
@@ -87,14 +87,11 @@ describe Yell do
87
87
  it { should == 'rails' }
88
88
  end
89
89
 
90
- it "should fallback to Rails.env" do
91
- end
92
-
93
90
  context "fallback to development" do
94
91
  before do
95
- stub( ENV ).key?( 'YELL_ENV' ) { false }
96
- stub( ENV ).key?( 'RACK_ENV' ) { false }
97
- stub( ENV ).key?( 'RAILS_ENV' ) { false }
92
+ stub(ENV).key?('YELL_ENV') { false }
93
+ stub(ENV).key?('RACK_ENV') { false }
94
+ stub(ENV).key?('RAILS_ENV') { false }
98
95
  end
99
96
 
100
97
  it { should == 'development' }
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yell
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
5
- prerelease:
4
+ version: 1.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rudolf Schmidt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
11
+ date: 2013-06-20 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Yell - Your Extensible Logging Library. Define multiple adapters, various
15
14
  log level combinations or message formatting options like you've never done before
@@ -46,10 +45,17 @@ files:
46
45
  - lib/yell/configuration.rb
47
46
  - lib/yell/event.rb
48
47
  - lib/yell/formatter.rb
48
+ - lib/yell/helpers/adapters.rb
49
+ - lib/yell/helpers/base.rb
50
+ - lib/yell/helpers/formatter.rb
51
+ - lib/yell/helpers/level.rb
52
+ - lib/yell/helpers/silencer.rb
53
+ - lib/yell/helpers/tracer.rb
49
54
  - lib/yell/level.rb
50
55
  - lib/yell/loggable.rb
51
56
  - lib/yell/logger.rb
52
57
  - lib/yell/repository.rb
58
+ - lib/yell/silencer.rb
53
59
  - lib/yell/version.rb
54
60
  - spec/fixtures/yell.yml
55
61
  - spec/spec_helper.rb
@@ -67,31 +73,31 @@ files:
67
73
  - spec/yell/loggable_spec.rb
68
74
  - spec/yell/logger_spec.rb
69
75
  - spec/yell/repository_spec.rb
76
+ - spec/yell/silencer_spec.rb
70
77
  - spec/yell_spec.rb
71
78
  - yell.gemspec
72
79
  homepage: http://rudionrails.github.com/yell
73
80
  licenses: []
81
+ metadata: {}
74
82
  post_install_message:
75
83
  rdoc_options: []
76
84
  require_paths:
77
85
  - lib
78
86
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
87
  requirements:
81
- - - ! '>='
88
+ - - '>='
82
89
  - !ruby/object:Gem::Version
83
90
  version: '0'
84
91
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
92
  requirements:
87
- - - ! '>='
93
+ - - '>='
88
94
  - !ruby/object:Gem::Version
89
95
  version: '0'
90
96
  requirements: []
91
97
  rubyforge_project: yell
92
- rubygems_version: 1.8.25
98
+ rubygems_version: 2.0.0
93
99
  signing_key:
94
- specification_version: 3
100
+ specification_version: 4
95
101
  summary: Yell - Your Extensible Logging Library
96
102
  test_files:
97
103
  - spec/fixtures/yell.yml
@@ -110,4 +116,5 @@ test_files:
110
116
  - spec/yell/loggable_spec.rb
111
117
  - spec/yell/logger_spec.rb
112
118
  - spec/yell/repository_spec.rb
119
+ - spec/yell/silencer_spec.rb
113
120
  - spec/yell_spec.rb