rspec_timer 0.0.2 → 0.0.3

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: 2cd7e2230eeb45822d0a390f9c72491fb23fdb61
4
- data.tar.gz: 6a0836aae47e4f725f65726cac9830cd6ed65e11
3
+ metadata.gz: 760b8f522ec25043cbe8085967e90db73cfba7b9
4
+ data.tar.gz: 3fe0f3b156634a4d84a1a0f697e6aeec0b963044
5
5
  SHA512:
6
- metadata.gz: 65887c9f52dfe0d65dea9639d186d6d11ee6c848914f0821f7b0161d73944a81d6b42a4b879404bbbce46f808aa5e28c4d73ca008f56727eb9d74ac1ef5a1e9d
7
- data.tar.gz: 8fb357c2fcef9270bdf710e1b311f29eacbbc113ba33ef9ed9d329381e9d07f955ab70ad627c7c782e3f4d97efd3dfbfd06b64a4245467b4ca3694a02d43376c
6
+ metadata.gz: cc43db6bac66e229357e7dff9390cd84ced6589c2b7b8139879160e65a631807a88c3a27a9157db261c21c6ee860ad1d3799b3aad69890fabe0daa7c978cc5e4
7
+ data.tar.gz: 764ed9ac2aaf80c0c77bb7f650ece2f1664b2a2bbb13871f47e2020862334dcee92b862f2d2efe0cbc2eef39f5763fb814e8594cb1c4be1156122d847ffefe58
data/README.md CHANGED
@@ -28,8 +28,11 @@ In your spec_helper.rb file, set up your "around" and "after" hooks like so:
28
28
  RSpec.configure do |config|
29
29
 
30
30
  config.before(:suite) do
31
+ # Set the log file's path (optional - if not set, defaults to a 'rspec-metrics.yml' file in your current folder)
32
+ RspecTimer.log_file_path = 'rspec_metrics.yml'
33
+
31
34
  # Completely wipes any metrics from the log (optional)
32
- RspecTimer.reset_metrics_log_file('rspec_metrics.yml')
35
+ RspecTimer.reset_metrics_log_file
33
36
  end
34
37
 
35
38
  config.around(:each) do |example|
@@ -40,7 +43,7 @@ RSpec.configure do |config|
40
43
  # Stores any metrics from this test run into the YAML log file
41
44
  # Adds/updates metrics according to unique signatures which are generated
42
45
  # using each individual test's line number and source code.
43
- RspecTimer.update_metrics_log_file('rspec_metrics.yml')
46
+ RspecTimer.update_metrics_log_file
44
47
  end
45
48
 
46
49
  end
@@ -1,3 +1,3 @@
1
1
  class RspecTimer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/rspec_timer.rb CHANGED
@@ -7,11 +7,11 @@ class RspecTimer
7
7
  include Singleton
8
8
  extend SingleForwardable
9
9
 
10
- def_delegators :instance, :reset_metrics, :log_file, :start_measurement, :end_measurement, :metrics,
10
+ def_delegators :instance, :reset_metrics, :log_file_path, :start_measurement, :end_measurement, :metrics,
11
11
  :run_and_measure, :reset_metrics_log_file, :update_metrics_log_file, :signature_for
12
12
 
13
13
  attr_reader :metrics
14
- attr_accessor :log_file
14
+ attr_writer :log_file_path
15
15
 
16
16
  def initialize
17
17
  reset_metrics
@@ -21,6 +21,10 @@ class RspecTimer
21
21
  @metrics = {}
22
22
  end
23
23
 
24
+ def log_file_path
25
+ @log_file_path ||= 'rspec_metrics.yml'
26
+ end
27
+
24
28
  def start_measurement(example)
25
29
  current_metrics = metrics_for(example)
26
30
  current_metrics[:path] = example_path(example)
@@ -41,18 +45,18 @@ class RspecTimer
41
45
  end_measurement(example)
42
46
  end
43
47
 
44
- def reset_metrics_log_file(file_name = default_metrics_file_name)
45
- File.write(file_name, YAML.dump({}))
48
+ def reset_metrics_log_file
49
+ File.write(log_file_path, YAML.dump({}))
46
50
  end
47
51
 
48
- def update_metrics_log_file(file_name = default_metrics_file_name)
52
+ def update_metrics_log_file
49
53
  updated_metrics = {}
50
54
  # Load any existing metrics
51
- updated_metrics = YAML.load_file(file_name) if File.exists? (file_name)
55
+ updated_metrics = YAML.load_file(log_file_path) if File.exists? (log_file_path)
52
56
  # Merge in the new metrics, updating any existing ones
53
57
  @metrics.keys.each { |key| updated_metrics[key] = @metrics[key] }
54
58
  # Save metrics to the YAML log file
55
- File.write(file_name, YAML.dump(updated_metrics))
59
+ File.write(log_file_path, YAML.dump(updated_metrics))
56
60
  end
57
61
 
58
62
  def signature_for(example)
@@ -61,10 +65,6 @@ class RspecTimer
61
65
 
62
66
  private
63
67
 
64
- def default_metrics_file_name
65
- 'rspec_metrics.yml'
66
- end
67
-
68
68
  def metrics_for(example)
69
69
  @metrics[signature_for(example)] ||= {
70
70
  path: nil,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Chapin