clocker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37b5ce852633df86d89dd7ece1274e676e1f9371
4
+ data.tar.gz: e94d3bb2051086e8f1e81a5a6596ab26741518d4
5
+ SHA512:
6
+ metadata.gz: 4e1975d0e680432bae9516ec22758b69f96688aa0bed7d689e9d2fa267cf79920154dcaa0e463685b556e754f8f64d86e4237a821658d83e9ac293f58bb5b222
7
+ data.tar.gz: 0a0bc8ddbb6a522441b82f6fd538e947b7c862f8f6445ef65f8d0e55b9624911ce479dd9392af1361818322d15189bf279985e17f66f6dcda432fde8e9c1271d
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ clocker (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ x64-mingw32
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.9)
16
+ clocker!
17
+ rake (~> 10.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Michael Chadwick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Clocker
2
+
3
+ Find out how long that block of code takes to run.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'clocker'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install clocker
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ clocker = Clocker.new
25
+ clocker.clock do
26
+ # code here
27
+ end
28
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env ruby
data/bin/setup ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env ruby
data/clocker.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'clocker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'clocker'
8
+ spec.version = Clocker::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ['Michael Chadwick']
11
+ spec.email = ['mike@codana.me']
12
+ spec.homepage = 'http://rubygems.org/gems/clocker'
13
+ spec.summary = 'Calculate how long a block of code takes to run'
14
+ spec.description = 'Give Clocker some code to process, and it will run it and display how long it took to finish.'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+ spec.license = 'MIT'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,3 @@
1
+ module Clocker
2
+ VERSION = "0.1.0"
3
+ end
data/lib/clocker.rb ADDED
@@ -0,0 +1,34 @@
1
+ # Clocker
2
+
3
+ # Allows you to run a process for a time and get stats on how long it took
4
+ # If you give it ms bounds on init, it will just run a timer for a random
5
+ # time between the two params
6
+
7
+ class Clocker
8
+ def initialize(options = {})
9
+ @options = options
10
+ end
11
+
12
+ def clock
13
+ @start = Time.now
14
+ unless @options[:messages_on].nil?
15
+ puts "began: #{@start}"
16
+ end
17
+
18
+ begin
19
+ yield
20
+ rescue StandardError => e
21
+ puts e.message
22
+ end
23
+ stop
24
+ end
25
+
26
+ def stop
27
+ @stop = Time.now
28
+ unless @options[:messages_on].nil?
29
+ puts "\nstopped: #{@stop}"
30
+ end
31
+ duration = ((@stop - @start) * 1000).to_i
32
+ puts "\n#{duration} ms elapsed"
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clocker do
4
+ it 'has a version number' do
5
+ expect(Clocker::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'clocker'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clocker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Chadwick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Give Clocker some code to process, and it will run it and display how
42
+ long it took to finish.
43
+ email:
44
+ - mike@codana.me
45
+ executables:
46
+ - console
47
+ - setup
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - ".rspec"
53
+ - ".travis.yml"
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/console
60
+ - bin/setup
61
+ - clocker.gemspec
62
+ - lib/clocker.rb
63
+ - lib/clocker/version.rb
64
+ - spec/clocker_spec.rb
65
+ - spec/spec_helper.rb
66
+ homepage: http://rubygems.org/gems/clocker
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.6
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Calculate how long a block of code takes to run
90
+ test_files: []