cputs 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 +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +121 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/cputs.gemspec +34 -0
- data/lib/cputs/functions.rb +31 -0
- data/lib/cputs/override.rb +13 -0
- data/lib/cputs/version.rb +3 -0
- data/lib/cputs.rb +49 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e1d3d28e41a68ab5b79a4fb79956e44902089640
|
4
|
+
data.tar.gz: 79f53672bdaa44c29c4335f20f1b2a956d559dd1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0771ec3cbe339855f85f4940e56a49182080534a8b50120637a3faf86b79b1459583179e927824f9066276bba283956958511a38bb817a54660616addaaf537a
|
7
|
+
data.tar.gz: 50d78a19a1b1ec73273a33573d27d52361fdfce52a319220801efe78dc0a4e4921ad7996b659b2d1feb12d89bb58ccf4d4fbd1d4520d5bd58362bc91c4ca5023
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 JGutierrezC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Cputs - Custom Puts
|
2
|
+
|
3
|
+
##Description
|
4
|
+
|
5
|
+
*Custom Puts* is as it's name says, a customized puts command that will always remember you where is the following message coming from:
|
6
|
+
|
7
|
+
```
|
8
|
+
Firm Load (0.2ms) SELECT `table2`.* FROM `table2` INNER JOIN `table1` ON `table2`.`id` = `table2`.`table2_id` WHERE `table2`.`foreign_key_id` = 509122938901 AND (table1.update_at is null)
|
9
|
+
Firm Load (0.2ms) SELECT `table2`.* FROM `table2` INNER JOIN `table1` ON `table2`.`id` = `table2`.`table2_id` WHERE `table1`.`user_id` = 668972 [["user_id", 668972]]
|
10
|
+
Project4 - The name is still to decide. user jgutierrezc
|
11
|
+
(0.3ms) SELECT COUNT(*) FROM `table1` WHERE `table1`.`id` = 166561 AND `table1`.`field_x` = 1
|
12
|
+
(0.2ms) SELECT COUNT(*) FROM `table1` WHERE `table1`.`id` = 166561 AND `table1`.`field_x` = 1 AND `table1`.`field2` = 0
|
13
|
+
```
|
14
|
+
|
15
|
+
As you can see, the message `Project4 - The name is still to decide. user jgutierrezc` is a puts message coming from who knows what file.
|
16
|
+
|
17
|
+
With **cputs** this message can be changed to this:
|
18
|
+
|
19
|
+
```
|
20
|
+
/Users/JGutierrezC/AwesomeProjects/the_best/app/controllers/randoms_controller at line 2: Project4 - The name is still to decide. user jgutierrezc
|
21
|
+
```
|
22
|
+
|
23
|
+
Or using a preffix and/or suffix to make the output more noticeable:
|
24
|
+
|
25
|
+
```
|
26
|
+
---------------------------->
|
27
|
+
/Users/JGutierrezC/AwesomeProjects/the_best/app/controllers/randoms_controller at line 2: Project4 - The name is still to decide. user jgutierrezc
|
28
|
+
<----------------------------
|
29
|
+
```
|
30
|
+
|
31
|
+
This way, you'll **NEVER** lose your output messages and hopefully they won't make it to production.
|
32
|
+
###Sometimes even the Gems are printing to your console. Find out which gem is doing that by using `CPuts.override_puts` :)
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
|
36
|
+
Add this line to your application's Gemfile:
|
37
|
+
|
38
|
+
```
|
39
|
+
gem 'cputs'
|
40
|
+
```
|
41
|
+
|
42
|
+
And then execute:
|
43
|
+
|
44
|
+
$ bundle
|
45
|
+
|
46
|
+
Or install it yourself as:
|
47
|
+
|
48
|
+
$ gem install cputs
|
49
|
+
|
50
|
+
## Usage
|
51
|
+
|
52
|
+
To use this gem you need to require 'cputs' and configure it as you want to:
|
53
|
+
|
54
|
+
```
|
55
|
+
require 'cputs'
|
56
|
+
|
57
|
+
# to set a message preffix for every output:
|
58
|
+
CPuts.set_preffix('<---------')
|
59
|
+
|
60
|
+
# to set a message suffix for every output:
|
61
|
+
CPuts.set_suffix('--------->')
|
62
|
+
|
63
|
+
# to set the same preffix and suffix for every output:
|
64
|
+
CPuts.set_preffix_and_suffix('-----------------')
|
65
|
+
|
66
|
+
# to set different preffix and suffix in a single method for every output:
|
67
|
+
CPuts.set_preffix_and_suffix('----------->', '<-----------')
|
68
|
+
|
69
|
+
|
70
|
+
```
|
71
|
+
|
72
|
+
And use cputs command to output your message:
|
73
|
+
|
74
|
+
```
|
75
|
+
cputs 'Project4 - The name is still to decide. user jgutierrezc'
|
76
|
+
```
|
77
|
+
|
78
|
+
Or if you want to replace the usual `puts` command for `cputs` functionality:
|
79
|
+
|
80
|
+
```
|
81
|
+
CPuts.override_puts
|
82
|
+
```
|
83
|
+
|
84
|
+
And then use puts:
|
85
|
+
|
86
|
+
```
|
87
|
+
puts 'Project4 - The name is still to decide. user jgutierrezc'
|
88
|
+
```
|
89
|
+
|
90
|
+
The output will be as follows (previously defined preffix and suffix):
|
91
|
+
|
92
|
+
```
|
93
|
+
----------------------------> /Users/JGutierrezC/AwesomeProjects/the_best/app/controllers/randoms_controller at line 2: Project4 - The name is still to decide. user jgutierrezc <----------------------------
|
94
|
+
```
|
95
|
+
|
96
|
+
### When using rails
|
97
|
+
|
98
|
+
Add `puts` to your Gemfile and then add a cputs initializer:
|
99
|
+
|
100
|
+
```
|
101
|
+
# config/initializers/cputs.rb
|
102
|
+
|
103
|
+
require 'cputs'
|
104
|
+
|
105
|
+
CPuts.override_puts
|
106
|
+
CPuts.set_preffix_and_suffix("----------------->\n", "\n<-----------------")
|
107
|
+
|
108
|
+
```
|
109
|
+
|
110
|
+
Restart your console...
|
111
|
+
Done!
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JGutierrezC/cputs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct. Remember to test with rspec before :)
|
116
|
+
|
117
|
+
|
118
|
+
## License
|
119
|
+
|
120
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
121
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cputs"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/cputs.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cputs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cputs"
|
8
|
+
spec.version = Cputs::VERSION
|
9
|
+
spec.authors = ["JGutierrezC"]
|
10
|
+
spec.email = ["jegut87@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{CPuts - CustomPuts}
|
13
|
+
spec.description = %q{Custom Puts is as it's name says, a customized puts command that will always remember you where are those weird console messages coming from. Sometimes even the Gems are printing to your console, find out which gem(s) is doing that by using `CPuts.override_puts` :)}
|
14
|
+
spec.homepage = "https://github.com/JGutierrezC/cputs"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "minitest"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CPuts
|
2
|
+
module Functions
|
3
|
+
attr :preffix, :suffix
|
4
|
+
|
5
|
+
def self.cputs(message, caller)
|
6
|
+
matcher = caller.first.match(/^(.*)\:(\d+)/)
|
7
|
+
file, line = matcher.captures[0..1] unless matcher.nil?
|
8
|
+
default_puts "#{@preffix}#{file} at line #{line}: #{message}#{@suffix}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.preffix(preffix)
|
12
|
+
@preffix = preffix
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.suffix(suffix)
|
16
|
+
@suffix = suffix
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.preffix_and_suffix(*args)
|
20
|
+
case args.length
|
21
|
+
when 1
|
22
|
+
@preffix = args[0]
|
23
|
+
@suffix = args[0]
|
24
|
+
when 2
|
25
|
+
@preffix = args[0]
|
26
|
+
@suffix = args[1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/cputs.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'cputs/version.rb'
|
2
|
+
require_relative 'cputs/functions.rb'
|
3
|
+
##
|
4
|
+
# This module represents the bridge between CPuts functionality and the user
|
5
|
+
|
6
|
+
module CPuts
|
7
|
+
|
8
|
+
##
|
9
|
+
# The main method to print (puts) a message with the *preffix* (if set) *File* (that's making the call) *Line* (of the file) and *Suffix* (if set)
|
10
|
+
# :args: message
|
11
|
+
|
12
|
+
def cputs(message)
|
13
|
+
CPuts::Functions.cputs(message, caller)
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Override the usual *puts* method to always use
|
18
|
+
# cputs instead.
|
19
|
+
|
20
|
+
def self.override_puts
|
21
|
+
require_relative 'cputs/override.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Sets the preffix for the output
|
26
|
+
|
27
|
+
def CPuts.set_preffix(preffix)
|
28
|
+
CPuts::Functions.preffix preffix
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Sets the suffix for the output
|
33
|
+
|
34
|
+
def CPuts.set_suffix(suffix)
|
35
|
+
CPuts::Functions.suffix suffix
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Sets both the preffix and suffix for the output
|
40
|
+
|
41
|
+
def CPuts.set_preffix_and_suffix(*args)
|
42
|
+
CPuts::Functions.preffix_and_suffix *args
|
43
|
+
end
|
44
|
+
|
45
|
+
alias :default_puts :puts
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
include CPuts
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cputs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JGutierrezC
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Custom Puts is as it's name says, a customized puts command that will
|
70
|
+
always remember you where are those weird console messages coming from. Sometimes
|
71
|
+
even the Gems are printing to your console, find out which gem(s) is doing that
|
72
|
+
by using `CPuts.override_puts` :)
|
73
|
+
email:
|
74
|
+
- jegut87@gmail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- .gitignore
|
80
|
+
- .travis.yml
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- cputs.gemspec
|
89
|
+
- lib/cputs.rb
|
90
|
+
- lib/cputs/functions.rb
|
91
|
+
- lib/cputs/override.rb
|
92
|
+
- lib/cputs/version.rb
|
93
|
+
homepage: https://github.com/JGutierrezC/cputs
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata:
|
97
|
+
allowed_push_host: https://rubygems.org
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.6
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: CPuts - CustomPuts
|
118
|
+
test_files: []
|