marked 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/marked.rb +13 -1
- data/marked.gemspec +3 -3
- data/test/marked_test.rb +10 -6
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/marked.rb
CHANGED
@@ -3,7 +3,15 @@ module Marked
|
|
3
3
|
|
4
4
|
Marked.log "\nMARKED #{caller.first.split(':in ').first}"
|
5
5
|
|
6
|
-
returnable = block_given?
|
6
|
+
returnable = if block_given?
|
7
|
+
require 'benchmark'
|
8
|
+
result = nil
|
9
|
+
bench = Benchmark.measure { result = yield }
|
10
|
+
Marked.print_benchmark bench
|
11
|
+
result
|
12
|
+
else
|
13
|
+
objects.last
|
14
|
+
end
|
7
15
|
|
8
16
|
if block_given?
|
9
17
|
Marked.log Marked.pad returnable
|
@@ -34,6 +42,10 @@ module Marked
|
|
34
42
|
def self.pad object
|
35
43
|
" " + (object.is_a?(String) ? object : object.inspect)
|
36
44
|
end
|
45
|
+
|
46
|
+
def self.print_benchmark measurement
|
47
|
+
log " * Executed in #{'%0.3f' % measurement.real} seconds (#{'%0.3f' % measurement.cutime} cpu)\n"
|
48
|
+
end
|
37
49
|
end
|
38
50
|
|
39
51
|
class Object
|
data/marked.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{marked}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jack Danger Canty"]
|
12
|
-
s.date = %q{2011-09-
|
12
|
+
s.date = %q{2011-09-14}
|
13
13
|
s.description = %q{Quick Ruby debugger. Easily print any object or string to the console and to your logs while you're working.}
|
14
14
|
s.email = %q{rubygems@6brand.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
]
|
30
30
|
s.homepage = %q{http://github.com/JackDanger/marked}
|
31
31
|
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.
|
32
|
+
s.rubygems_version = %q{1.4.2}
|
33
33
|
s.summary = %q{Fast debugging for Ruby. Output any objects or blocks to both Rails log and console output simultaneously}
|
34
34
|
|
35
35
|
if s.respond_to? :specification_version then
|
data/test/marked_test.rb
CHANGED
@@ -14,8 +14,8 @@ class MarkedTest < Test::Unit::TestCase
|
|
14
14
|
|
15
15
|
context "logging" do
|
16
16
|
setup {
|
17
|
-
Rails.logger.expects(:debug).with "\nMARKED
|
18
|
-
Marked.expects(:print).with "\nMARKED
|
17
|
+
Rails.logger.expects(:debug).with "\nMARKED #{__FILE__}:24"
|
18
|
+
Marked.expects(:print).with "\nMARKED #{__FILE__}:24"
|
19
19
|
Rails.logger.expects(:debug).with " this should be printed"
|
20
20
|
Marked.expects(:print).with " this should be printed"
|
21
21
|
Rails.logger.expects(:debug).with " / FINISHED MARKING"
|
@@ -26,7 +26,7 @@ class MarkedTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
context "printing and logging a single argument" do
|
28
28
|
setup {
|
29
|
-
expect_unpadded_log "\nMARKED
|
29
|
+
expect_unpadded_log "\nMARKED #{__FILE__}:33"
|
30
30
|
expect_log "this should be printed"
|
31
31
|
}
|
32
32
|
should "return its argument" do
|
@@ -35,7 +35,7 @@ class MarkedTest < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
context "printing and logging multiple arguments" do
|
37
37
|
setup {
|
38
|
-
expect_unpadded_log "\nMARKED
|
38
|
+
expect_unpadded_log "\nMARKED #{__FILE__}:43"
|
39
39
|
expect_log "this should be printed"
|
40
40
|
expect_log "this too"
|
41
41
|
}
|
@@ -45,7 +45,7 @@ class MarkedTest < Test::Unit::TestCase
|
|
45
45
|
end
|
46
46
|
context "printing and logging non-strings" do
|
47
47
|
setup {
|
48
|
-
expect_unpadded_log "\nMARKED
|
48
|
+
expect_unpadded_log "\nMARKED #{__FILE__}:53"
|
49
49
|
expect_log({:a =>'a'})
|
50
50
|
expect_log [1, 2, 3]
|
51
51
|
}
|
@@ -57,7 +57,7 @@ class MarkedTest < Test::Unit::TestCase
|
|
57
57
|
setup {
|
58
58
|
@obj = {}
|
59
59
|
@obj.expects(:called!).returns('returned!').once
|
60
|
-
expect_unpadded_log "\nMARKED
|
60
|
+
expect_unpadded_log "\nMARKED #{__FILE__}:65"
|
61
61
|
expect_log "first arg"
|
62
62
|
expect_log "returned!"
|
63
63
|
}
|
@@ -71,4 +71,8 @@ class MarkedTest < Test::Unit::TestCase
|
|
71
71
|
Marked.pad('padme')
|
72
72
|
end
|
73
73
|
end
|
74
|
+
def setup
|
75
|
+
Marked.stubs(:print_benchmark)
|
76
|
+
end
|
77
|
+
|
74
78
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jack Danger Canty
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-14 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements: []
|
69
69
|
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.4.2
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
74
|
summary: Fast debugging for Ruby. Output any objects or blocks to both Rails log and console output simultaneously
|