loba 0.3.1 → 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.
- checksums.yaml +5 -5
- data/{LICENSE.txt → LICENSE} +1 -1
- data/README.md +30 -21
- data/lib/loba.rb +67 -228
- data/lib/loba/internal.rb +9 -0
- data/lib/loba/internal/platform.rb +34 -0
- data/lib/loba/internal/time_keeper.rb +33 -0
- data/lib/loba/internal/value.rb +40 -0
- data/lib/loba/internal/value/value_helper.rb +126 -0
- data/lib/loba/version.rb +1 -1
- metadata +19 -54
- data/.codeclimate.yml +0 -21
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rubocop.yml +0 -1168
- data/.travis.yml +0 -9
- data/Gemfile +0 -12
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/loba.gemspec +0 -30
- data/readme/ts.md +0 -45
- data/readme/val.md +0 -117
- data/readme/zulu.png +0 -0
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "loba"
|
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
DELETED
data/loba.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'loba/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "loba"
|
8
|
-
spec.version = Loba::VERSION
|
9
|
-
spec.platform = Gem::Platform::RUBY
|
10
|
-
spec.authors = ["Richard Newman"]
|
11
|
-
spec.email = ["richard@newmanworks.com"]
|
12
|
-
|
13
|
-
spec.summary = %q{Loba: Easy tracing for debugging.}
|
14
|
-
spec.description = %q{Handy methods for adding trace lines to output or Rails logs.}
|
15
|
-
spec.homepage = "https://github.com/rdnewman/loba"
|
16
|
-
spec.license = "MIT"
|
17
|
-
|
18
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
-
spec.bindir = "exe"
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = ["lib"]
|
22
|
-
spec.required_ruby_version = '>= 2.1.0'
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler', '~> 1.11'
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
|
28
|
-
spec.add_dependency "binding_of_caller", "~> 0.7"
|
29
|
-
spec.add_dependency "colorize", "~> 0.7"
|
30
|
-
end
|
data/readme/ts.md
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
#### Timestamp notices: `Loba.ts`
|
2
|
-
Outputs a timestamped notice, useful for quick traces to see the code path and easier than, say, [Kernel#set_trace_func](http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-set_trace_func).
|
3
|
-
Also does a simple elapsed time check since the previous timestamp notice to help with quick, minimalist profiling.
|
4
|
-
|
5
|
-
For example,
|
6
|
-
|
7
|
-
```
|
8
|
-
[TIMESTAMP] #=0002, diff=93.478016, at=1451444972.970602 (in=/home/usracct/src/myapp/app/models/target.rb:55:in `some_calculation')
|
9
|
-
```
|
10
|
-
|
11
|
-
To invoke,
|
12
|
-
|
13
|
-
```
|
14
|
-
Loba.ts # no arguments
|
15
|
-
```
|
16
|
-
|
17
|
-
`Loba.timestamp` is an alias for `Loba.ts`.
|
18
|
-
|
19
|
-
The resulting notice output format is
|
20
|
-
|
21
|
-
```
|
22
|
-
[TIMESTAMP] #=nnnn, diff=ss.ssssss, at=tttttttttt.tttttt (in=/path/to/code/somecode.rb:LL:in 'some_method')
|
23
|
-
```
|
24
|
-
|
25
|
-
where
|
26
|
-
* `nnn` ("#=") is a sequential numbering (1, 2, 3, ...) of timestamp notices,
|
27
|
-
* `ss.ssssss` ("diff=") is number of seconds since the last timestamp notice was output (i.e., relative time),
|
28
|
-
* `tttttttttt.tttttt` ("at=") is Time.now (as seconds) (i.e., absolute time),
|
29
|
-
* `/path/to/code/somecode.rb` ("in=") is the source code file that invoked `Loba.ts`,
|
30
|
-
* `LL` ("in=...:") is the line number of the source code file that invoked `Loba.ts`, and
|
31
|
-
* `some_method`is the method in which `Loba.ts` was invoked.
|
32
|
-
|
33
|
-
|
34
|
-
##### Options
|
35
|
-
|
36
|
-
As the last argument, an options hash may be provided:
|
37
|
-
* `production`: true if this value notice is enabled when running in :production environment (see ["Environment Notes"](README.md#environment-notes)) \[_default: `false`_\]
|
38
|
-
|
39
|
-
###### Example 5: Using options hash
|
40
|
-
```ruby
|
41
|
-
Loba.ts production: true
|
42
|
-
```
|
43
|
-
```ruby
|
44
|
-
Loba.ts {production: true}
|
45
|
-
```
|
data/readme/val.md
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
#### Value notices: `Loba.val`
|
2
|
-
|
3
|
-
Inserts line to Rails.logger.debug (or to STDOUT if Rails.logger not available) showing value with method and class identification
|
4
|
-
|
5
|
-
```
|
6
|
-
Loba.val :var_sym # the :var_sym argument is the variable or method name given as a symbol (see below)
|
7
|
-
```
|
8
|
-
|
9
|
-
or
|
10
|
-
|
11
|
-
```
|
12
|
-
Loba.val some_identifier # directly give a variable or method name instead of a symbol (see below)
|
13
|
-
```
|
14
|
-
|
15
|
-
or
|
16
|
-
|
17
|
-
```
|
18
|
-
Loba.val some_identifier, "My label:" # same as direct variable, but allows a custom label
|
19
|
-
```
|
20
|
-
|
21
|
-
Will produce a notice similar to the following:
|
22
|
-
|
23
|
-
```
|
24
|
-
[Target.some_calculation] my_var: 54 (in /home/usracct/src/myapp/app/models/target.rb:55:in `some_calculation')
|
25
|
-
```
|
26
|
-
|
27
|
-
###### Example 1: Using simple Symbol as argument
|
28
|
-
```ruby
|
29
|
-
class HelloWorld
|
30
|
-
def hello(name)
|
31
|
-
Loba.val :name # best to put Loba statement to far left for easy removal when done
|
32
|
-
puts "Hello, #{name}!"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
HelloWorld.new.hello("Charlie")
|
36
|
-
#=> [HelloWorld#hello] name: Charlie (in /path/to/file/hello_world.rb:3:in `hello')
|
37
|
-
#=> Hello, Charlie!
|
38
|
-
```
|
39
|
-
|
40
|
-
###### Example 2: Using more complex Symbol as argument
|
41
|
-
```ruby
|
42
|
-
class HelloWorld
|
43
|
-
def hello(name)
|
44
|
-
myHash = {somename: name}
|
45
|
-
# Loba.val :myHash[name] won't work directly, but...
|
46
|
-
Loba.val "myHash[name]".to_sym # will work -- just express the name as a String and cast to a Symbol
|
47
|
-
puts "Hello, #{name}!"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
HelloWorld.new.hello("Charlie")
|
51
|
-
#=> [HelloWorld#hello] myHash[name]: Charlie (in /path/to/file/hello_world.rb:5:in `hello')
|
52
|
-
#=> Hello, Charlie!
|
53
|
-
```
|
54
|
-
|
55
|
-
###### Example 3: Using a non-Symbol as argument without a label
|
56
|
-
```ruby
|
57
|
-
class HelloWorld
|
58
|
-
def hello(name)
|
59
|
-
Loba.val name
|
60
|
-
puts "Hello, #{name}!"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
HelloWorld.new.hello("Charlie")
|
64
|
-
#=> [HelloWorld#hello] Charlie (in /path/to/file/hello_world.rb:3:in `hello')
|
65
|
-
#=> Hello, Charlie!
|
66
|
-
```
|
67
|
-
|
68
|
-
###### Example 4: Using a non-Symbol as argument with a label
|
69
|
-
```ruby
|
70
|
-
class HelloWorld
|
71
|
-
def hello(name)
|
72
|
-
Loba.val name, "Name:"
|
73
|
-
puts "Hello, #{name}!"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
HelloWorld.new.hello("Charlie")
|
77
|
-
#=> [HelloWorld#hello] Name: Charlie (in /path/to/file/hello_world.rb:3:in `hello')
|
78
|
-
#=> Hello, Charlie!
|
79
|
-
```
|
80
|
-
|
81
|
-
##### Notice format:
|
82
|
-
|
83
|
-
The resulting notice output format is
|
84
|
-
|
85
|
-
```
|
86
|
-
[ccccc.mmmmm] vvvvv: rrrrr (in /path/to/code/somecode.rb:LL:in 'some_method')
|
87
|
-
```
|
88
|
-
|
89
|
-
where
|
90
|
-
* `ccccc` is the name of the class from where `Loba.val` was invoked,
|
91
|
-
* `mmmmm` is the name of the method from where `Loba.val` was invoked,
|
92
|
-
* `vvvvv` is generally the name of the variable for which `Loba.val` is inspecting, or any custom label given,
|
93
|
-
* `rrrrr` is the result of inspecting what `Loba.val` was invoked against,
|
94
|
-
* `/path/to/code/somecode.rb` is the source code file that invoked `Loba.val`,
|
95
|
-
* `LL` is the line number of the source code file that invoked `Loba.val`, and
|
96
|
-
* `some_method`is the method in which `Loba.val` was invoked.
|
97
|
-
|
98
|
-
|
99
|
-
Notes:
|
100
|
-
* `ccccc`: Ruby supports anonymous classes (e.g., `= Class.new`). If an anonymous class, "<anonymous class>" will be output here.
|
101
|
-
* `mmmmm`: Ruby supports anonymous methods, procs, and lambdas. If an anonymous method, et al, "<anonymous method>" will be output here.
|
102
|
-
* `vvvvv`: This depends on the argument being provided: if a symbol, then this field will use that symbol to determine the name and present it here. If not, nothing will appear for this field.
|
103
|
-
* `rrrrr`: The value of the variable given to `Loba.val`. `inspect` may be used (see [options](#options) below).
|
104
|
-
|
105
|
-
##### Options
|
106
|
-
|
107
|
-
As the last argument, an options hash may be provided:
|
108
|
-
* `inspect`: true if this value notice is to use #inspect against the content being evaluated \[_default: `true`_\]
|
109
|
-
* `production`: true if this value notice is enabled when running in :production environment (see ["Environment Notes"](README.md#environment-notes)) \[_default: `false`_\]
|
110
|
-
|
111
|
-
###### Example 5: Using options hash
|
112
|
-
```ruby
|
113
|
-
Loba.val name, "Name:", inspect: false, production: true
|
114
|
-
```
|
115
|
-
```ruby
|
116
|
-
Loba.val :name, nil, {production: true}
|
117
|
-
```
|
data/readme/zulu.png
DELETED
Binary file
|