method_meter 0.2.5 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ef8552b2cba12b7917260d06e1c54268e145da95
4
- data.tar.gz: 8fa14b4958be0750d663aaa7535d5389bcf2f575
2
+ SHA256:
3
+ metadata.gz: 968a9343be92f7570f1a15dc5c341d39b64fd76b3922263605d008b5f6057e34
4
+ data.tar.gz: 86223aa04becb4ac8c8ef8c37f2d08489429d88f2438509250df02082386cc12
5
5
  SHA512:
6
- metadata.gz: 20e6127bc885f6b441a91d108bf02df76007daea015eeb6f07da8fc551c1cc02707d0ca83447547c0b816de011eeea007fde8ee526be031b5e15f760114420aa
7
- data.tar.gz: fc942005191d4c40f339b1e7d0b56c504ccd236b714a1b0651c84a9f88d7f7867a4ccb3d0f8706602ab096c90ea7e4ae59228cab6b06f256c8627e1fd7a40b97
6
+ metadata.gz: 45291068c777e3885de2a94767494b3e9c25dac036fe8dbe115a50c33b73e4ca148c54fa569c6afd094fa90900c45f7a901c9f8cf9341ca657cffa345a5c707a
7
+ data.tar.gz: 2d2344afed7ffc5b0acfa067859dd38297306d77781944f15b227b89a8b2176fb67a22a9ab4591c8bfa6938a66cd999beb91677801ebc5cedab1bbb0191775e1
@@ -0,0 +1,18 @@
1
+ version: v1.0
2
+ name: Initial Pipeline
3
+ agent:
4
+ machine:
5
+ type: e1-standard-2
6
+ os_image: ubuntu1804
7
+ blocks:
8
+ - name: Test
9
+ task:
10
+ jobs:
11
+ - name: rspec
12
+ commands:
13
+ - checkout
14
+ - sem-version ruby 2.6.5
15
+ - cache restore
16
+ - bundle install --path vendor/bundle
17
+ - cache store
18
+ - bundle exec rspec
Binary file
data/Gemfile CHANGED
@@ -1,10 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  # Specify your gem's dependencies in method_meter.gemspec
6
- gemspec
7
-
8
- gem 'activesupport'
9
- gem 'awesome_print'
10
- gem 'defined_methods'
4
+ gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # MethodMeter
1
+ # MethodMeter [![Build Status](https://wnuqui.semaphoreci.com/badges/method_meter/branches/master.svg?style=shields)](https://wnuqui.semaphoreci.com/projects/method_meter)
2
2
 
3
- `MethodMeter` is a library module that instruments methods defined in a given object. These methods are not from included or extended modules. These methods are not also from parent objects. By object, it means either a `class` or `module`.
3
+ `MethodMeter` is a library module that instruments **methods defined in a given object**. These methods are NOT from included or extended modules. These methods are also NOT from parent objects. By object, it means either a `class` or `module`.
4
4
 
5
5
  ## Installation
6
6
 
@@ -41,6 +41,10 @@ ap MethodMeter.measurement
41
41
 
42
42
  More examples found here: https://github.com/wnuqui/method_meter/tree/master/examples
43
43
 
44
+ ## In action
45
+
46
+ ![method_meter in action](1-basic-rb.gif)
47
+
44
48
  ## Development
45
49
 
46
50
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -49,7 +53,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
49
53
 
50
54
  ## Contributing
51
55
 
52
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/method_meter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wnuqui/method_meter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
53
57
 
54
58
  ## License
55
59
 
@@ -0,0 +1,21 @@
1
+ require_relative 'helper'
2
+
3
+ # values set will not be profiled/instrumented
4
+ MethodMeter.exceptions = [:perform_addition]
5
+
6
+ MethodMeter.observe Arithmeter
7
+
8
+ MethodMeter.measure!('key-1') do
9
+ arithmeter = Arithmeter.new
10
+ arithmeter.add 1, 3
11
+
12
+ Arithmeter.sum 1, 3
13
+
14
+ arithmeter = Arithmeter.new
15
+ arithmeter.add 4, 3
16
+
17
+ Arithmeter.sum 4, 3
18
+ end
19
+
20
+ ap MethodMeter.data
21
+ ap MethodMeter.measurement
@@ -5,15 +5,19 @@ require 'active_support/core_ext/string'
5
5
  require 'defined_methods'
6
6
 
7
7
  module MethodMeter
8
- mattr_accessor :events, :subscribers, :data
8
+ mattr_accessor :events, :subscribers, :data, :exceptions
9
9
 
10
10
  class << self
11
- def observe(object)
12
- self.events = [] if self.events.blank?
11
+ def observe(object, excepted_methods=[])
12
+ self.events = [] if self.events.nil?
13
+ self.exceptions = [] if self.exceptions.nil?
14
+ self.exceptions |= excepted_methods
13
15
 
14
16
  DefinedMethods.in(object).each do |group|
15
17
  group[:object].module_eval do
16
18
  group[:methods].each do |method|
19
+ next if MethodMeter.exceptions.include?(method)
20
+
17
21
  method_with_profiling = method.to_s + '_with_profiling'
18
22
  method_without_profiling = method.to_s + '_without_profiling'
19
23
  event_name = DefinedMethods.fqmn(group, method)
@@ -1,3 +1,3 @@
1
1
  module MethodMeter
2
- VERSION = '0.2.5'
2
+ VERSION = '0.3.5'
3
3
  end
@@ -19,9 +19,11 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.16'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'rspec', '~> 3.0'
22
+ spec.add_runtime_dependency 'activesupport'
23
+ spec.add_runtime_dependency 'awesome_print'
24
+ spec.add_runtime_dependency 'defined_methods'
25
25
 
26
- spec.add_development_dependency 'byebug', '~> 9.1.0' # can be put in Gemfile
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'rake', '>= 12.3.3'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
29
  end
metadata CHANGED
@@ -1,71 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: method_meter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilfrido T. Nuqui Jr.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-18 00:00:00.000000000 Z
11
+ date: 2021-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
19
+ version: '0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: awesome_print
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
+ type: :runtime
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: defined_methods
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - "~>"
66
+ - - ">="
39
67
  - !ruby/object:Gem::Version
40
- version: '10.0'
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
- name: rspec
70
+ name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '3.0'
75
+ version: 12.3.3
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '3.0'
82
+ version: 12.3.3
55
83
  - !ruby/object:Gem::Dependency
56
- name: byebug
84
+ name: rspec
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: 9.1.0
89
+ version: '3.0'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: 9.1.0
96
+ version: '3.0'
69
97
  description: MethodMeter is a library module that instruments methods defined in a
70
98
  given object.
71
99
  email:
@@ -76,6 +104,8 @@ extra_rdoc_files: []
76
104
  files:
77
105
  - ".gitignore"
78
106
  - ".rspec"
107
+ - ".semaphore/semaphore.yml"
108
+ - 1-basic-rb.gif
79
109
  - CODE_OF_CONDUCT.md
80
110
  - Gemfile
81
111
  - LICENSE.txt
@@ -87,6 +117,7 @@ files:
87
117
  - examples/2-serial-measurement-using-keys.rb
88
118
  - examples/3-observe-multiple-times.rb
89
119
  - examples/4-more-measurement.rb
120
+ - examples/5-excepted-methods.rb
90
121
  - examples/helper.rb
91
122
  - examples/src/arithmeter.rb
92
123
  - examples/src/raiser.rb
@@ -112,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
143
  - !ruby/object:Gem::Version
113
144
  version: '0'
114
145
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.6.13
146
+ rubygems_version: 3.0.3
117
147
  signing_key:
118
148
  specification_version: 4
119
149
  summary: MethodMeter is a library module that instruments methods defined in a given