lineprof 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 280724b58ea63ece019e85ea8e5544434d1eb5a6
4
- data.tar.gz: 4a0f98d65aeea9056a909c7445068c5141129d81
3
+ metadata.gz: 068d92a8e134b51fdb78e66e6c7364a8351fa7b7
4
+ data.tar.gz: a5745996dce9e47c7b232c627054726e7ba0f89b
5
5
  SHA512:
6
- metadata.gz: a8137cee40302053d758bf007b16c19a1721ee60deb506abc583db773e846d05819eda15364cc3ec37547eb4779ed8e5dcc185e3dabac618934feac99a340315
7
- data.tar.gz: 54a4aae326851d869cd4324be0cab2a05d98ef092f4ebf30eb87d4b1765658cb79fcd4b8aed48b663e88d33db69b29be5f17162aebdf9b7283d3c55cb4595953
6
+ metadata.gz: 7bc9864ac9470bab131b4f83b271f4068885b5b4649cad093af208c89b5a14dc4aacabd308378a68ff8a0821dc63dd70049a82c968b3ef178d1a72a3c34747b8
7
+ data.tar.gz: 345eb06123850fbb9f7091029e159250881000dc51034466e58c04a57db9714235d29d2d38753455b7cfa9bf7dd75c9838026aa3c8fe483aaceafd9b9fc00d33
@@ -2,12 +2,13 @@ require 'rblineprof'
2
2
  require 'rack/lineprof/source_extension'
3
3
 
4
4
  class Lineprof
5
- IGNORE_PATTERN = /lib\/lineprof\.rb$/
5
+ IGNORE_PATTERN = /lib\/lineprof\.rb$/
6
+ DEFAULT_PATTERN = /./
6
7
 
7
8
  class << self
8
- def profile(&block)
9
- value = nil
10
- result = lineprof(/./) { value = block.call }
9
+ def profile(filename = caller_filename(caller), &block)
10
+ value = nil
11
+ result = lineprof(filename) { value = block.call }
11
12
 
12
13
  puts Term::ANSIColor.blue("\n[Lineprof] #{'=' * 70}")
13
14
  puts "\n#{format(result)}\n"
@@ -16,6 +17,10 @@ class Lineprof
16
17
 
17
18
  private
18
19
 
20
+ def caller_filename(caller_lines)
21
+ caller_lines.first.split(':').first || DEFAULT_PATTERN
22
+ end
23
+
19
24
  def format(result)
20
25
  sources = result.map do |filename, samples|
21
26
  next if filename =~ IGNORE_PATTERN
@@ -1,3 +1,3 @@
1
1
  class Lineprof
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lineprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2015-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rblineprof
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.4.5
120
+ rubygems_version: 2.4.5.1
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Easy-to-use line profiler for Ruby.