quicklog 0.0.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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +9 -0
- data/lib/quicklog/version.rb +3 -0
- data/lib/quicklog.rb +18 -0
- data/quicklog.gemspec +24 -0
- data/test/test_quicklog.rb +17 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 540c01430363a89c339bf55b650a5563f0dc229b
|
4
|
+
data.tar.gz: e3509431bcd34d3be8aaff11f1cce7fd6f9aec7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 89eaaef654497b4d3c705a0df98cb1e1c02f3de6607204b419208abe1437aadf0838e89b039db50a69078a4b7b84129232951ce1242f1a6a2b982a726c963901
|
7
|
+
data.tar.gz: 6622a0d6323bd05a6aaa6fc529243ad4cb8226ee6b3a7d54db0ff1a31004a06ec741be07de4e8c4d8fcf1ad7543b78b500a3956f5220ebfba18d0014df26f3b5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Florent Guilleux
|
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,55 @@
|
|
1
|
+
# Quicklog
|
2
|
+
|
3
|
+
Provides an easy way to log a variable value with its label.
|
4
|
+
|
5
|
+
Instead of doing
|
6
|
+
|
7
|
+
puts "my_var = #{my_var}"
|
8
|
+
|
9
|
+
write
|
10
|
+
|
11
|
+
ql :my_var
|
12
|
+
|
13
|
+
For Ruby 2+ only.
|
14
|
+
|
15
|
+
## Examples
|
16
|
+
|
17
|
+
* logging an object attribute: `ql :"@user.name"`
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
gem 'quicklog'
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install quicklog
|
32
|
+
|
33
|
+
## Credits
|
34
|
+
|
35
|
+
I wanted the same kind of functionality that the [lll gem](http://rubygems.org/gems/lll) offers, but with a shorter syntax.
|
36
|
+
|
37
|
+
I found the solution I needed in this [stackoverflow answer](http://stackoverflow.com/a/1385047/117704).
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
46
|
+
|
47
|
+
## TODO
|
48
|
+
|
49
|
+
* display in reverse video
|
50
|
+
* allow logging of strings, ie `ql "hi!"`
|
51
|
+
* use inspect to output the expression
|
52
|
+
* use Awesome Print if available
|
53
|
+
* allow logging of string + variable: `ql "hi!", :my_var`
|
54
|
+
* allow logging of several variables: `ql :my_var1, :my_var2, :my_var3`
|
55
|
+
* logs through Rails.logger if available
|
data/Rakefile
ADDED
data/lib/quicklog.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "quicklog/version"
|
2
|
+
require 'debug_inspector'
|
3
|
+
|
4
|
+
module Quicklog
|
5
|
+
def self.ql var_symbol
|
6
|
+
RubyVM::DebugInspector.open do |inspector|
|
7
|
+
value = eval var_symbol.to_s, inspector.frame_binding(3)
|
8
|
+
puts "#{var_symbol} = #{value}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Kernel
|
14
|
+
def ql var_symbol
|
15
|
+
Quicklog.ql var_symbol
|
16
|
+
end
|
17
|
+
module_function :ql
|
18
|
+
end
|
data/quicklog.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quicklog/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "quicklog"
|
8
|
+
spec.version = Quicklog::VERSION
|
9
|
+
spec.authors = ["Florent Guilleux"]
|
10
|
+
spec.email = ["florent2@gmail.com"]
|
11
|
+
spec.description = %q{easy logging of a variable value with its label}
|
12
|
+
spec.summary = %q{easy logging of a variable value with its label}
|
13
|
+
spec.homepage = "http://github.com/Florent2/quicklog"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.4"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "mocha"
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "mocha/setup"
|
3
|
+
require "quicklog"
|
4
|
+
|
5
|
+
class QuicklogTest < Minitest::Test
|
6
|
+
def test_log_variable_label_and_value
|
7
|
+
my_var = 2
|
8
|
+
$stdout.expects(:puts).with("my_var = 2")
|
9
|
+
ql :my_var
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_log_object_attribute
|
13
|
+
person = Struct.new(:name).new "David"
|
14
|
+
$stdout.expects(:puts).with("person.name = David")
|
15
|
+
ql :"person.name"
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quicklog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florent Guilleux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-09 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.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
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
|
+
description: easy logging of a variable value with its label
|
56
|
+
email:
|
57
|
+
- florent2@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/quicklog.rb
|
68
|
+
- lib/quicklog/version.rb
|
69
|
+
- quicklog.gemspec
|
70
|
+
- test/test_quicklog.rb
|
71
|
+
homepage: http://github.com/Florent2/quicklog
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.1.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: easy logging of a variable value with its label
|
95
|
+
test_files:
|
96
|
+
- test/test_quicklog.rb
|