log_elapsed_time 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ log_elapsed_time
2
+ ========
3
+
4
+ I found myself wanting a quick and easy way to log out how much time certain operations were taking (HTTP requests to external APIs, in my case). Since I found myself doing this in a bunch of places, I decided to extract the code into something reusable, which is what you see here.
5
+
6
+
7
+ Installation
8
+ ------------
9
+
10
+ gem install log_elapsed_time
11
+
12
+
13
+ Usage
14
+ -----
15
+
16
+ Requiring the gem in your project will add a global method named `log_elapsed_time`, which you can use like so:
17
+
18
+ log_elapsed_time("Request to external service took") do
19
+ HTTP.post(...)
20
+ end
21
+
22
+ This would write `Request to external service took 2048ms` to `Rails.logger.info` and return the result of the POST. If you needed to do something with the result, you could keep the return value:
23
+
24
+ response = log_elapsed_time do
25
+ HTTP.get(...)
26
+ end
27
+
28
+ There is one slight gotcha: variables set in the block aren't accessible outside of it, so the following would not work.
29
+
30
+ log_elapsed_time do
31
+ response = HTTP.get(...)
32
+ end
33
+
34
+ If you tried to use `response` later, it wouldn't be defined.
35
+
36
+
37
+ Todo
38
+ ----
39
+
40
+ * Don't depend directly on `Rails.logger`, or allow a way to customize the logger.
41
+ * Flesh out the pending specs.
42
+
43
+ Contributing
44
+ ------------
45
+
46
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
47
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
48
+ * Fork the project.
49
+ * Start a feature/bugfix branch.
50
+ * Commit and push until you are happy with your contribution.
51
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
52
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
53
+
54
+
55
+ Contact
56
+ -------
57
+
58
+ Problems, comments, and pull requests all welcome. [Find me on GitHub.](http://github.com/tfe/)
59
+
60
+
61
+ Copyright
62
+ ---------
63
+
64
+ Copyright © 2014 [Todd Eichel](http://toddeichel.com/). See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,10 +1,3 @@
1
- # Usage:
2
- # log_elapsed_time("Request to external service took") do
3
- # HTTP.post(...)
4
- # end
5
- # This would log "Request to external service took 2048ms" and return the
6
- # result of the POST.
7
-
8
1
  def log_elapsed_time(message_prefix = nil, &block)
9
2
  start_time = Time.now
10
3
  return_value = yield
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "log_elapsed_time"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Todd Eichel"]
12
+ s.date = "2014-03-19"
13
+ s.description = "Quick and easy way to log the time it takes code to run."
14
+ s.email = "todd@toddeichel.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/log_elapsed_time.rb",
29
+ "log_elapsed_time.gemspec",
30
+ "spec/log_elapsed_time_spec.rb",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = "https://github.com/tfe/log_elapsed_time"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.25"
37
+ s.summary = "Quick and easy way to log the time it takes code to run."
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
44
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
45
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
46
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
47
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
50
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
53
+ s.add_dependency(%q<simplecov>, [">= 0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
57
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
60
+ s.add_dependency(%q<simplecov>, [">= 0"])
61
+ end
62
+ end
63
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_elapsed_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -97,17 +97,18 @@ executables: []
97
97
  extensions: []
98
98
  extra_rdoc_files:
99
99
  - LICENSE.txt
100
- - README.rdoc
100
+ - README.md
101
101
  files:
102
102
  - .document
103
103
  - .rspec
104
104
  - Gemfile
105
105
  - Gemfile.lock
106
106
  - LICENSE.txt
107
- - README.rdoc
107
+ - README.md
108
108
  - Rakefile
109
109
  - VERSION
110
110
  - lib/log_elapsed_time.rb
111
+ - log_elapsed_time.gemspec
111
112
  - spec/log_elapsed_time_spec.rb
112
113
  - spec/spec_helper.rb
113
114
  homepage: https://github.com/tfe/log_elapsed_time
@@ -125,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
126
  version: '0'
126
127
  segments:
127
128
  - 0
128
- hash: -2110752389062959253
129
+ hash: -2890960856251512107
129
130
  required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  none: false
131
132
  requirements:
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = log_elapsed_time
2
-
3
- Description goes here.
4
-
5
- == Contributing to log_elapsed_time
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2014 Todd Eichel. See LICENSE.txt for
18
- further details.
19
-