logging_factory 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTVhM2Q5M2M2ZmU0NjI4OTliM2RjNjQxMWM2YzMyZDQyMDFhOGQ2Mg==
4
+ ZWE2YzJkOTk1NjQwOTdjMDU4MjAyNWQ1N2JmMmM0ZjM0M2JiYjM1Yw==
5
5
  data.tar.gz: !binary |-
6
- ZmE1MjNhZjY3NGE1NWUwMTI1YTQ2ZjQyZGRlYjQzZDFmYWE3MTNkZA==
6
+ MzhjMzQzNDYzZWQzNGZkMDVhZmU0MWJkOWIwMzNlYzUwYWI1YWY3NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWU0YjI1MDI4ZWY1YzdlNGU0NGQxM2YyNDg2NDZiODVmMTUzZmRkZDFjYmM1
10
- ODVhZmRjNDZhZWMzZGM5NTk0MDU1YjU2NGQ3NjgyNzk4MjM4YmQzOWE5ZWVl
11
- NjJjZGMzOWYwODY1NGJlZTExMGQyNmMyYWM2OThlZjFjNjU3NmM=
9
+ OGZhOGQ0MWQ5NGNkZjY0NWY1NGUyMDZjNDU1YmU5MWEwOGFlYzgxMDQ2Mjk1
10
+ NjlkNWM2OWI3ZDkxOGM3NTE4OWFjYmVmM2Q4N2JiMDAwNWEwYzBjYjk3ZWVi
11
+ ODc4NTczOTM1ODI2ZGRkMGU0NjRmMTQxODY0MGMzOGJiMGY4NGI=
12
12
  data.tar.gz: !binary |-
13
- NTQ0NDMwOTQwNjEyZTY5YjIzOWIwODUwYWNjNjc0OGI1MmM0Y2FmMWQ4ODcy
14
- ODJkNGRhYTA1OTBmNjQwMmVkYjg2ZjJiZDI3NTI4YmNmNGEyNTI0YTg1ZGQ5
15
- Mjc0NWMwMmE2MTJlYTAwMGIzZjc5NmFiNzc3NmU3NzZkYjBkNTA=
13
+ ZDRkNjZiODgzMGI1YTU3NzlkNmEzMTY2ZjcxNmE1NjQ2NmMyYzdkZTlhOTM5
14
+ MGU1MTJkOWExZmMyZjQxZTRjMmZlNmQzMGM0OTFkZTA1Y2VmNzdhNDViODg3
15
+ MzIzZDQ3ZTVjZWZkNWE1NDRjMDk5MWUxNTYyYmY3MDQ0ZGE3ODc=
@@ -0,0 +1,4 @@
1
+ Style/MethodLength:
2
+ Enabled: false
3
+ Style/LineLength:
4
+ Max: 180
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script:
5
+ - bundle exec rake rubocop
6
+ - bundle exec rake spec
7
+ - bundle exec rake build
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
+ # encoding: UTF-8
2
+ # encoding: UTF-8
1
3
  require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new(:rubocop)
9
+
10
+ desc 'Main task for this project to ensure the project passes build'
11
+ task default: [:rubocop, :spec, :build]
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'version'
2
3
  require 'preconditions'
3
4
  require 'logging'
@@ -16,12 +17,11 @@ end
16
17
 
17
18
  # Logging factory for logs
18
19
  module LoggingFactory
19
-
20
20
  DEFAULT_LOG_CONFIGURATION = {
21
- output: 'STDOUT',
22
- truncate: false,
23
- level: :debug,
24
- format: '[%d] %-5l [%c] %m\n'
21
+ output: 'STDOUT',
22
+ truncate: false,
23
+ level: :debug,
24
+ format: '[%d] %-5l [%c] %m\n'
25
25
  }
26
26
 
27
27
  # Create a new logging factory
@@ -36,12 +36,12 @@ module LoggingFactory
36
36
  attr_reader :log_configuration
37
37
 
38
38
  # Initializes this logger instance with teh format specified
39
- def initialize(config={})
39
+ def initialize(config = {})
40
40
  @log_configuration = DEFAULT_LOG_CONFIGURATION.merge(config)
41
41
  end
42
42
 
43
43
  # Returns a new log for the calling class with the supplied configuration
44
- def log(caller, config={})
44
+ def log(caller, config = {})
45
45
  log_configuration = @log_configuration.merge(config)
46
46
  log = Logging.logger[caller]
47
47
  add_appenders(log, log_configuration)
@@ -49,6 +49,7 @@ module LoggingFactory
49
49
  end
50
50
 
51
51
  private
52
+
52
53
  def add_appenders(log, log_configuration)
53
54
  destination = log_configuration[:output]
54
55
  truncate = log_configuration[:truncate]
@@ -71,38 +72,32 @@ module LoggingFactory
71
72
  log
72
73
  end
73
74
 
74
- def append_file_format(log, destination, fmt, truncate=false)
75
+ def append_file_format(log, destination, fmt, truncate = false)
75
76
  Logging.appenders.file(destination,
76
- {
77
- file_name: destination,
78
- truncate: truncate ? true : false,
79
- layout: Logging.layouts.pattern(pattern: fmt)
80
- })
77
+ file_name: destination,
78
+ truncate: truncate ? true : false,
79
+ layout: Logging.layouts.pattern(pattern: fmt)
80
+ )
81
81
  log.add_appenders(destination)
82
82
  end
83
83
 
84
84
  def append_stdout_format(log, fmt)
85
85
  Logging.color_scheme('bright',
86
86
  levels: {
87
- debug: :magenta,
88
- info: :green,
89
- warn: :yellow,
90
- error: :red, fatal: [:white, :on_red]
87
+ debug: :magenta,
88
+ info: :green,
89
+ warn: :yellow,
90
+ error: :red, fatal: [:white, :on_red]
91
91
  },
92
92
  date: :blue, logger: :cyan)
93
93
  Logging.appenders.stdout(
94
- 'stdout',
95
- layout: Logging.layouts.pattern(
96
- pattern: fmt,
97
- color_scheme: 'bright'))
94
+ 'stdout',
95
+ layout: Logging.layouts.pattern(
96
+ pattern: fmt,
97
+ color_scheme: 'bright'))
98
98
  log.add_appenders 'stdout'
99
99
  end
100
100
  end
101
101
 
102
102
  DEFAULT_FACTORY = LoggingFactory.create
103
103
  end
104
-
105
-
106
-
107
-
108
-
@@ -1,4 +1,5 @@
1
+ # encoding: UTF-8
2
+ # Top level module
1
3
  module LoggingFactory
2
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
3
5
  end
4
-
@@ -8,13 +8,19 @@ Gem::Specification.new do |gem|
8
8
  gem.version = LoggingFactory::VERSION
9
9
  gem.authors = ['Nayyara Samuel']
10
10
  gem.email = ['nayyara.samuel@opower.com']
11
- gem.description = %q{A wrapper around logging gem}
12
- gem.summary = %q{A wrapper around logging gem}
11
+ gem.description = %q(A wrapper around logging gem)
12
+ gem.summary = %q(A wrapper around logging gem)
13
13
 
14
- gem.files = `git ls-files`.split($/)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(spec|spec|features)/})
17
- gem.require_paths = ["lib"]
14
+ gem.files = `git ls-files -z`.split("\x0")
15
+ gem.executables = gem.files.grep(/^bin\//) { |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(/^(test|spec|features)\//)
17
+ gem.require_paths = ['lib']
18
+
19
+ gem.add_development_dependency 'bundler', '~> 1.6'
20
+ gem.add_development_dependency 'rake', '~> 10.3.2'
21
+ gem.add_development_dependency 'rspec', '~> 3.0.0'
22
+ gem.add_development_dependency 'rubocop', '~> 0.23.0'
23
+ gem.add_development_dependency 'simplecov', '~> 0.6.4'
18
24
 
19
25
  gem.add_dependency 'logging', '~> 1.8.1'
20
26
  gem.add_dependency 'preconditions', '~> 0.3.0'
@@ -1,4 +1,5 @@
1
- require 'spec_helper'
1
+ # encoding: UTF-8
2
+ require_relative './spec_helper'
2
3
 
3
4
  describe LoggingFactory::Logger do
4
5
 
@@ -34,5 +35,3 @@ describe LoggingFactory::Logger do
34
35
 
35
36
  end
36
37
  end
37
-
38
-
@@ -1,3 +1,13 @@
1
+ # encoding: UTF-8
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_filter 'spec/'
6
+ add_filter 'rdoc/'
7
+ add_filter 'results/'
8
+ add_filter 'coverage/'
9
+ end
10
+
1
11
  require 'rspec'
2
12
  require 'rspec/mocks'
3
13
  require_relative '../lib/logging_factory'
@@ -8,7 +18,7 @@ class FileAccessor
8
18
 
9
19
  # Options should have a list of parts which will be appended together to give the base path
10
20
  def initialize(*options)
11
- @base_path = File.join(options.map {|f| f.to_s})
21
+ @base_path = File.join(options.map { |f| f.to_s })
12
22
  end
13
23
 
14
24
  # Access specific file in the base path
@@ -22,7 +32,7 @@ class FileAccessor
22
32
  end
23
33
 
24
34
  # Delete all files in the directory
25
- def delete_files(pattern='*.log')
35
+ def delete_files(pattern = '*.log')
26
36
  FileUtils.rm_rf Dir.glob(File.join(base_path, pattern))
27
37
  end
28
38
  end
@@ -34,4 +44,4 @@ RSpec.configure do |config|
34
44
  file_accessor.delete_files
35
45
  end
36
46
 
37
- end
47
+ end
metadata CHANGED
@@ -1,15 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nayyara Samuel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 10.3.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 10.3.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.23.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.23.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.4
13
83
  - !ruby/object:Gem::Dependency
14
84
  name: logging
15
85
  requirement: !ruby/object:Gem::Requirement
@@ -46,6 +116,8 @@ extensions: []
46
116
  extra_rdoc_files: []
47
117
  files:
48
118
  - .gitignore
119
+ - .rubocop.yml
120
+ - .travis.yml
49
121
  - Gemfile
50
122
  - README.md
51
123
  - Rakefile