rails_objects_logger 1.0.0

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.gpairrc ADDED
@@ -0,0 +1 @@
1
+ alone for github
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use 1.9.3@rails_objects_logger
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - ruby-head
3
+ - 1.9.3
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby_objects_logger.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+ gem "rspec"
8
+ gem "simplecov"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 zedtux
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Rails Objects Logger [![Build Status](https://secure.travis-ci.org/zedtux/rails_objects_logger.png)](http://travis-ci.org/zedtux/rails_objects_logger) [![Dependency Status](https://gemnasium.com/zedtux/rails_objects_logger.png)](http://gemnasium.com/zedtux/rails_objects_logger) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zedtux/rails_objects_logger) [![endorse](http://api.coderwall.com/zedtux/endorsecount.png)](http://coderwall.com/zedtux)
2
+
3
+ Implement debug, info, warn and error class methods to all Rails objects in order to log anything very easily. This gem is part of Citaskit.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails_objects_logger'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails_objects_logger
18
+
19
+ ## Usage
20
+
21
+ ````ruby
22
+ class MyObject
23
+ def initialize
24
+ MyObject.info "Initializing..."
25
+ end
26
+
27
+ def my_function_1
28
+ debug "Calling my_function_1"
29
+ end
30
+
31
+ def build_new_thing
32
+ self.error "You can't call this method!"
33
+ end
34
+ end
35
+ ````
36
+
37
+ Will produce those log lines in your Rails log/development.log file:
38
+
39
+ Info#MyObject: Initializing...
40
+ Debug#MyObject: Calling my_function_1
41
+ Error#MyObject: You can't call this method!
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new("spec")
4
+
5
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ class Object
2
+ def self.debug(message)
3
+ send_log(:debug, message)
4
+ end
5
+
6
+ def self.info(message)
7
+ send_log(:info, message)
8
+ end
9
+
10
+ def self.warn(message)
11
+ send_log(:warn, message)
12
+ end
13
+
14
+ def self.error(message)
15
+ send_log(:error, message)
16
+ end
17
+
18
+ private
19
+
20
+ def self.send_log(level, message)
21
+ RailsObjectsLogger.log(level, self.name, message)
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module RailsObjectsLogger
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "rails_objects_logger/version"
2
+
3
+ module RailsObjectsLogger
4
+ def self.log(level, class_name, message)
5
+ Rails.logger.send(level, "#{level.to_s.capitalize}##{class_name}: #{message}")
6
+ end
7
+ end
8
+
9
+ require "rails_objects_logger/object_extensions"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_objects_logger/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rails_objects_logger"
8
+ gem.version = RailsObjectsLogger::VERSION
9
+ gem.authors = ["zedtux"]
10
+ gem.email = ["zedtux@zedroot.org"]
11
+ gem.description = %q{Rails ojects logger helper}
12
+ gem.summary = %q{Implement debug, info, warn and error class methods to all objects in order to log anything very easily. This gem is part of Citaskit.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "activesupport"
21
+ end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ module Rails
4
+ # No need to put the methods debug, info, warn and error as RSpec will stub them
5
+ class LoggerTest; end
6
+
7
+ attr_accessor :logger
8
+ def self.logger
9
+ @logger ||= LoggerTest.new
10
+ end
11
+ end
12
+
13
+ describe RailsObjectsLogger do
14
+ describe "Class Methods" do
15
+ describe "#log" do
16
+ context "passing level debug, class name \"Citaskit\" and message \"My awesome debug message that will make me understand what is going wrong.\"" do
17
+ it "should call Rails.logger.debug and log \"Debug#Citaskit: My awesome debug message that will make me understand what is going wrong.\"" do
18
+ Rails.logger.should_receive(:debug).with("Debug#Citaskit: My awesome debug message that will make me understand what is going wrong.")
19
+ RailsObjectsLogger.log(
20
+ :debug,
21
+ "Citaskit",
22
+ "My awesome debug message that will make me understand what is going wrong."
23
+ )
24
+ end
25
+ end
26
+ context "passing level info, class name \"Citaskit\" and message \"This information message help to know the current state of the application.\"" do
27
+ it "should call Rails.logger.info and log \"Info#Citaskit: This information message help to know the current state of the application.\"" do
28
+ Rails.logger.should_receive(:info).with("Info#Citaskit: This information message help to know the current state of the application.")
29
+ RailsObjectsLogger.log(
30
+ :info,
31
+ "Citaskit",
32
+ "This information message help to know the current state of the application."
33
+ )
34
+ end
35
+ end
36
+ context "passing level warn, class name \"Citaskit\" and message \"Achtung! This message is important!\"" do
37
+ it "should call Rails.logger.warn and log \"Warn#Citaskit: Achtung! This message is important!\"" do
38
+ Rails.logger.should_receive(:warn).with("Warn#Citaskit: Achtung! This message is important!")
39
+ RailsObjectsLogger.log(
40
+ :warn,
41
+ "Citaskit",
42
+ "Achtung! This message is important!"
43
+ )
44
+ end
45
+ end
46
+ context "passing level error, class name \"Citaskit\" and message \"CRITICAL ERROR! YOUR APP IS DEAD!\"" do
47
+ it "should call Rails.logger.error and log \"Error#Citaskit: CRITICAL ERROR! YOUR APP IS DEAD!\"" do
48
+ Rails.logger.should_receive(:error).with("Error#Citaskit: CRITICAL ERROR! YOUR APP IS DEAD!")
49
+ RailsObjectsLogger.log(
50
+ :error,
51
+ "Citaskit",
52
+ "CRITICAL ERROR! YOUR APP IS DEAD!"
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "logging something from an object" do
60
+ it "should works" do
61
+ class MyObject; end
62
+ Rails.logger.should_receive(:info)
63
+ MyObject.info("It works!")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ if RUBY_VERSION[0, 3] == "1.9"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+ end
6
+
7
+ require "rubygems"
8
+ require "bundler/setup"
9
+ require "active_support"
10
+
11
+ # our gem
12
+ require "rails_objects_logger"
13
+
14
+ RSpec.configure do |config|
15
+
16
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_objects_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - zedtux
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Rails ojects logger helper
31
+ email:
32
+ - zedtux@zedroot.org
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - .gpairrc
39
+ - .rspec
40
+ - .rvmrc
41
+ - .travis.yml
42
+ - Gemfile
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - lib/rails_objects_logger.rb
47
+ - lib/rails_objects_logger/object_extensions.rb
48
+ - lib/rails_objects_logger/version.rb
49
+ - rails_objects_logger.gemspec
50
+ - spec/rails_objects_logger_spec.rb
51
+ - spec/spec_helper.rb
52
+ homepage: ''
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ segments:
65
+ - 0
66
+ hash: -2819341135527539488
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ segments:
74
+ - 0
75
+ hash: -2819341135527539488
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.24
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Implement debug, info, warn and error class methods to all objects in order
82
+ to log anything very easily. This gem is part of Citaskit.
83
+ test_files:
84
+ - spec/rails_objects_logger_spec.rb
85
+ - spec/spec_helper.rb