alephant-logger-json 0.1.0 → 0.1.1

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: 84eb3ae131800ea10978a1bef31ae0a51bde66c4
4
- data.tar.gz: d7eda923aa0c8a7fb348840675f040185b6f295a
3
+ metadata.gz: 0154daa470efe5ef12b3e19a2bb11893cdf4b686
4
+ data.tar.gz: c5324b5beaef4b5becf02d4dcd7920d81ae7d154
5
5
  SHA512:
6
- metadata.gz: 1941155f17fc7b8d0795a98550ed9ce743eaea9c84799cd78c00d8588b747a3ed241247c070390469be85148c276df0e6936391e18d91343287287a6c6174eac
7
- data.tar.gz: 16962fa4fc1344968f6ed9546d921e38effe01a6fb375bdbdfa17ed40ffd13c4a406fa4075d66c7cf4ddffbe965f2a9346537d79d583f3c919d066f66beb9637
6
+ metadata.gz: 219d526f9be1c043f4c83978178c4552f0f950fd0df109bcc675885dc9aa67ff1f4e7f25d581a619cdaca9ce8170cf440ef87972ef13470cb6cb2979bea025be
7
+ data.tar.gz: fddbc2a85c4d059daf439a8724999e4c048dd9a1f048eda9b82fb1cf7f22bf9fde40c1cba4d09b2a06e7891c58b69f840067097196cdf6abf0fce2afe6a33aad
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/rspec"
2
3
 
4
+ task :default => :spec
@@ -1,15 +1,15 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'alephant/logger/json/version'
4
+ require "alephant/logger/json/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "alephant-logger-json"
8
8
  spec.version = Alephant::Logger::JSON::VERSION
9
9
  spec.authors = ["Dan Arnould"]
10
10
  spec.email = ["dan@arnould.co.uk"]
11
- spec.summary = %q{alephant-logger driver enabling structured logging in JSON}
12
- spec.description = %q{alephant-logger driver enabling structured logging in JSON}
11
+ spec.summary = "alephant-logger driver enabling structured logging in JSON"
12
+ spec.description = "alephant-logger driver enabling structured logging in JSON"
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3"
24
+ spec.add_development_dependency "rspec-nc"
25
+ spec.add_development_dependency "rake-rspec"
24
26
  end
@@ -1,7 +1,7 @@
1
1
  module Alephant
2
2
  module Logger
3
3
  class JSON
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -9,24 +9,20 @@ module Alephant
9
9
  @nesting = options.fetch(:nesting, false)
10
10
  end
11
11
 
12
- private
13
-
14
- def flatten_values_to_s(hash)
15
- Hash[hash.map { |k, v| [k, v.to_s] }]
16
- end
17
-
18
- public
19
-
20
12
  [:debug, :info, :warn, :error].each do |level|
21
13
  define_method(level) do |hash|
14
+ return if hash.is_a? String
22
15
  hash["level"] = level.to_s
23
-
24
- hash = flatten_values_to_s hash if not @nesting
25
-
16
+ hash = flatten_values_to_s hash unless @nesting
26
17
  @log_file.write(::JSON.generate(hash) + "\n")
27
18
  end
28
19
  end
20
+
21
+ private
22
+
23
+ def flatten_values_to_s(hash)
24
+ Hash[hash.map { |k, v| [k, v.to_s] }]
25
+ end
29
26
  end
30
27
  end
31
28
  end
32
-
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
-
3
2
  require "alephant/logger/json"
4
3
 
5
4
  describe Alephant::Logger::JSON do
@@ -12,7 +11,7 @@ describe Alephant::Logger::JSON do
12
11
 
13
12
  before do
14
13
  allow(File).to receive(:open) { log_file }
15
- allow(log_file).to receive :sync=
14
+ allow(log_file).to receive :sync=
16
15
  end
17
16
 
18
17
  shared_examples "JSON logging" do
@@ -61,7 +60,16 @@ describe Alephant::Logger::JSON do
61
60
  end
62
61
  end
63
62
 
64
- %w[debug info warn error].each do |level|
63
+ shared_examples "gracefully fail with string arg" do
64
+ let(:log_message) { "Unable to connect to server" }
65
+
66
+ specify { expect(log_file).not_to receive(:write) }
67
+ specify do
68
+ expect { subject.debug log_message }.not_to raise_error
69
+ end
70
+ end
71
+
72
+ %w(debug info warn error).each do |level|
65
73
  describe "##{level}" do
66
74
  let(:level) { level }
67
75
 
@@ -69,6 +77,8 @@ describe Alephant::Logger::JSON do
69
77
 
70
78
  it_behaves_like "nests flattened to strings"
71
79
 
80
+ it_behaves_like "gracefully fail with string arg"
81
+
72
82
  context "with nesting allowed" do
73
83
  subject do
74
84
  described_class.new(log_path, :nesting => true)
@@ -79,4 +89,3 @@ describe Alephant::Logger::JSON do
79
89
  end
80
90
  end
81
91
  end
82
-
data/spec/spec_helper.rb CHANGED
@@ -1,89 +1,9 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
- # file to always be loaded, without a need to explicitly require it in any files.
5
- #
6
- # Given that it is always loaded, you are encouraged to keep this file as
7
- # light-weight as possible. Requiring heavyweight dependencies from this file
8
- # will add to the boot time of your test suite on EVERY test run, even for an
9
- # individual file that may not need all of that loaded. Instead, consider making
10
- # a separate helper file that requires the additional dependencies and performs
11
- # the additional setup, and require it from the spec files that actually need it.
12
- #
13
- # The `.rspec` file also contains a few flags that are not defaults but that
14
- # users commonly want.
15
- #
16
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
1
  RSpec.configure do |config|
18
- # rspec-expectations config goes here. You can use an alternate
19
- # assertion/expectation library such as wrong or the stdlib/minitest
20
- # assertions if you prefer.
21
2
  config.expect_with :rspec do |expectations|
22
- # This option will default to `true` in RSpec 4. It makes the `description`
23
- # and `failure_message` of custom matchers include text for helper methods
24
- # defined using `chain`, e.g.:
25
- # be_bigger_than(2).and_smaller_than(4).description
26
- # # => "be bigger than 2 and smaller than 4"
27
- # ...rather than:
28
- # # => "be bigger than 2"
29
3
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
4
  end
31
5
 
32
- # rspec-mocks config goes here. You can use an alternate test double
33
- # library (such as bogus or mocha) by changing the `mock_with` option here.
34
6
  config.mock_with :rspec do |mocks|
35
- # Prevents you from mocking or stubbing a method that does not exist on
36
- # a real object. This is generally recommended, and will default to
37
- # `true` in RSpec 4.
38
7
  mocks.verify_partial_doubles = true
39
8
  end
40
-
41
- # The settings below are suggested to provide a good initial experience
42
- # with RSpec, but feel free to customize to your heart's content.
43
- =begin
44
- # These two settings work together to allow you to limit a spec run
45
- # to individual examples or groups you care about by tagging them with
46
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
- # get run.
48
- config.filter_run :focus
49
- config.run_all_when_everything_filtered = true
50
-
51
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
- # For more details, see:
53
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
- config.disable_monkey_patching!
57
-
58
- # This setting enables warnings. It's recommended, but in some cases may
59
- # be too noisy due to issues in dependencies.
60
- config.warnings = true
61
-
62
- # Many RSpec users commonly either run the entire suite or an individual
63
- # file, and it's useful to allow more verbose output when running an
64
- # individual spec file.
65
- if config.files_to_run.one?
66
- # Use the documentation formatter for detailed output,
67
- # unless a formatter has already been configured
68
- # (e.g. via a command-line flag).
69
- config.default_formatter = 'doc'
70
- end
71
-
72
- # Print the 10 slowest examples and example groups at the
73
- # end of the spec run, to help surface which specs are running
74
- # particularly slow.
75
- config.profile_examples = 10
76
-
77
- # Run specs in random order to surface order dependencies. If you find an
78
- # order dependency and want to debug it, you can fix the order by providing
79
- # the seed, which is printed after each run.
80
- # --seed 1234
81
- config.order = :random
82
-
83
- # Seed global randomization in this process using the `--seed` CLI option.
84
- # Setting this allows you to use `--seed` to deterministically reproduce
85
- # test failures related to randomization by passing the same `--seed` value
86
- # as the one that triggered the failure.
87
- Kernel.srand config.seed
88
- =end
89
9
  end
metadata CHANGED
@@ -1,57 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-logger-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Arnould
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: bundler
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - ~>
17
18
  - !ruby/object:Gem::Version
18
19
  version: '1.7'
19
- name: bundler
20
- prerelease: false
21
20
  type: :development
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: rake
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: '10.0'
33
- name: rake
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: rspec
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ~>
45
46
  - !ruby/object:Gem::Version
46
47
  version: '3'
47
- name: rspec
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-nc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: alephant-logger driver enabling structured logging in JSON
56
84
  email:
57
85
  - dan@arnould.co.uk
@@ -74,7 +102,7 @@ homepage: ''
74
102
  licenses:
75
103
  - MIT
76
104
  metadata: {}
77
- post_install_message:
105
+ post_install_message:
78
106
  rdoc_options: []
79
107
  require_paths:
80
108
  - lib
@@ -89,9 +117,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
117
  - !ruby/object:Gem::Version
90
118
  version: '0'
91
119
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.1.9
94
- signing_key:
120
+ rubyforge_project:
121
+ rubygems_version: 2.0.14
122
+ signing_key:
95
123
  specification_version: 4
96
124
  summary: alephant-logger driver enabling structured logging in JSON
97
125
  test_files: