clocker 0.1.6 → 1.0.0

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
2
  SHA1:
3
- metadata.gz: e356e7d0d50521af9d67ef4698607fa341f746c3
4
- data.tar.gz: 48f595a7020894dc8f649a3085d098ed96be1475
3
+ metadata.gz: d1a6a6c26851388c2fb79d9791fde1235a7549f7
4
+ data.tar.gz: 5b3310c6c7ebeb323a9487da6e8a70dedaff9a2f
5
5
  SHA512:
6
- metadata.gz: 2408d28b66ba3c6261f7ecdc7e4f900dc9457b153aad468282474a2ca230863f3987d5d4390aee3fec8f7a4473a6e28c7b4efd96ee83038b8b055245deee9080
7
- data.tar.gz: af3169ae0ab1ff937dcac51d4f3468b413a269896b19b6cac2e1dcc829c7090e6fda147560ac6cbd668bd45b92532eee38a8eb29c9a80821dd6ed476e8bf206a
6
+ metadata.gz: 2659f02b0c59f2a5f83a63b48d17d67a312ebcda368d1dd50c0a5718d728eb7dc63994ff362902a960429e3cf95098ad2c77df3d2383cb16c5c127cdf16a77a2
7
+ data.tar.gz: e6e32f90fc1cadf19314cb3f6d909428d737852d52347e274e7ae383d3130f8075788163ff69d54b71a041ba2c7f28cd7b722415885a7f742489ed43b2c0a38c
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Clocker
2
- Quick way to find out how long that command or block of code takes to run.
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/clocker.svg)](http://badge.fury.io/rb/clocker)
4
+
5
+ A simple RubyGem that gauges how long that Ruby command or block of code takes to run.
3
6
 
4
7
  ## Usage
5
8
  ### Command Line
6
- Simply run `clocker` followed by a command or block in double quotes. Add an `-m` before the command or block to print out start and end times.
9
+ Simply run `clocker` followed by a command or block of code. Add an `-m` before the command or block to print out start and end times.
7
10
 
8
11
  Ex. 1
9
12
  ```
@@ -31,7 +34,7 @@ ended: 2015-08-18 16:16:49 -0700
31
34
  Clocked at 0 mins, 2 secs, and 12 ms
32
35
  ```
33
36
 
34
- ### As Gem Library
37
+ ### Gem Library
35
38
  Add this line to your application's Gemfile:
36
39
 
37
40
  ```ruby
@@ -73,7 +76,7 @@ c1c1c1
73
76
  ```ruby
74
77
  >> c2 = Clocker.new(show_messages: true)
75
78
  >> duration = c2.clock do
76
- >> 3.times { purint 'c2'; sleep(1) }
79
+ >> 3.times { print 'c2'; sleep(1) }
77
80
  >> end
78
81
  >> puts duration
79
82
 
@@ -82,3 +85,11 @@ c2c2c2
82
85
  ended: 2015-08-18 16:07:20 -0700
83
86
  {:mins=>0, :secs=>3, :ms=>14}
84
87
  ```
88
+
89
+ ## Contributing
90
+
91
+ Bug reports and pull requests are welcome on GitHub at https://github.com/michaelchadwick/clocker.
92
+
93
+ ## License
94
+
95
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
-
5
4
  require_relative '../lib/clocker'
6
5
  require_relative '../lib/clocker/version'
7
6
 
@@ -13,18 +12,19 @@ def parse_options
13
12
  }
14
13
 
15
14
  optparse = OptionParser.new do |opts|
16
- opts.banner = "usage: #{BINARY_NAME} [command|block]"
15
+ opts.banner = "Calculate how long a command or block of code takes to run\n"
16
+ opts.banner += "usage: #{BINARY_NAME} COMMAND|BLOCK\n"
17
17
 
18
18
  opts.on('-m', '--message', 'Show start and ended messages') do |m|
19
19
  options[:show_messages] = m
20
20
  end
21
21
 
22
22
  opts.on('-v', '--version', 'Display version number and exit') do
23
- puts "#{BINARY_NAME} #{Clocker::VERSION}"
23
+ puts "#{Clocker::VERSION}"
24
24
  exit
25
25
  end
26
26
 
27
- opts.on('-h', '--help', 'Display this screen and exit') do
27
+ opts.on('-h', '-?', '--help', 'Display this screen and exit') do
28
28
  puts opts
29
29
  exit
30
30
  end
@@ -38,10 +38,9 @@ end
38
38
  def print_error(error)
39
39
  case error
40
40
  when OptionParser::InvalidOption
41
- puts "#{BINARY_NAME}: illegal option #{error.args.join(' ')}"
41
+ puts "#{BINARY_NAME} ERROR: illegal option #{error.args.join(' ')}"
42
42
  else
43
- puts "An unexpected error occurred while running #{BINARY_NAME}:"
44
- puts " #{error}\n"
43
+ puts "#{BINARY_NAME} ERROR: #{error}"
45
44
  end
46
45
  end
47
46
 
@@ -49,12 +48,13 @@ begin
49
48
  options = parse_options
50
49
 
51
50
  if (ARGV.count > 0)
51
+ command = ARGV.join(" ")
52
52
  c = Clocker.new(options)
53
- t = c.clock { eval(ARGV[0]) }
53
+ t = c.clock { eval(command) }
54
54
  puts
55
55
  puts "Clocked at #{t[:mins]} mins, #{t[:secs]} secs, and #{t[:ms]} ms"
56
56
  else
57
- puts "#{BINARY_NAME} error: missing command or block"
57
+ puts "#{BINARY_NAME} ERROR: missing command or block"
58
58
  end
59
59
  rescue => error
60
60
  print_error(error)
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Michael Chadwick']
11
11
  spec.email = ['mike@codana.me']
12
12
  spec.homepage = 'http://rubygems.org/gems/clocker'
13
- spec.summary = 'Calculate how long a block of code takes to run'
13
+ spec.summary = 'Calculate how long a command or block of code takes to run'
14
14
  spec.description = 'Give Clocker some code to process, and it will run it and display how long it took to finish.'
15
15
 
16
16
  spec.files = `git ls-files`.split("\n")
@@ -1,9 +1,6 @@
1
+ # lib/clocker.rb
1
2
  # Clocker
2
3
 
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
4
  class Clocker
8
5
  attr_accessor :options
9
6
 
@@ -21,7 +18,7 @@ class Clocker
21
18
  begin
22
19
  block.call
23
20
  rescue StandardError => e
24
- puts e.message
21
+ puts "ERROR: invalid command or block"
25
22
  end
26
23
 
27
24
  return stop
@@ -2,5 +2,5 @@
2
2
  # Version of Clocker
3
3
 
4
4
  class Clocker
5
- VERSION = '0.1.6'
5
+ VERSION = '1.0.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clocker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,8 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.4.8
84
+ rubygems_version: 2.5.0
85
85
  signing_key:
86
86
  specification_version: 4
87
- summary: Calculate how long a block of code takes to run
87
+ summary: Calculate how long a command or block of code takes to run
88
88
  test_files: []