vignette 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,27 @@ module ObjectExtensions
5
5
 
6
6
  # Test will select a random object from the Array
7
7
  def vignette(name=nil)
8
- key = "vignette_#{name || hash}"
9
- test_name = if name.blank?
8
+ key = "vignette_#{name || hash.abs.to_s(16)}"
9
+ test_name = nil
10
+
11
+ if name.blank?
10
12
  if caller[0].include?('filter.rb')
11
- caller[1].split(':in')[0].gsub(Rails.root.to_s,'') # Take the view name
13
+ # E.g /Users/hayesgm/animals/shadow/app/views/landing/family.html.haml:11:in `_app_views_landing_family_html_haml__3008026497873467685_70232967999960'
14
+ # -> app/views/landing/family.html.haml:313c7f3a472883ba
15
+ filename = caller[1].split(':')[0].gsub(Rails.root.to_s+'/','') # Take the view name
16
+ test_name = "#{filename}:#{hash.abs.to_s(16)}"
12
17
  else
13
- caller[0].gsub(Rails.root.to_s,'') # Take everything but the Rails root portion
18
+ # E.g /Users/hayesgm/animals/shadow/app/controllers/home_controller.rb:27:in `home'
19
+ # -> app/controllers/home_controller:home:313c7f3a472883ba
20
+ line = caller[0].gsub(Rails.root.to_s+'/','') # Take everything but the Rails root portion
21
+
22
+ m = /(?<filename>[\w.\/]+):(?<line>\d+):in `(?<function>\w+)'/.match(line)
23
+
24
+ if m && !m[:filename].blank? && !m[:function].blank?
25
+ test_name = "#{m[:filename]}:#{m[:function]}:#{hash.abs.to_s(16)}"
26
+ else # Fallback
27
+ test_name = key
28
+ end
14
29
  end
15
30
  else
16
31
  name
@@ -1,3 +1,3 @@
1
1
  module Vignette
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vignette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: