fixturize 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/fixturize.rb +18 -6
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2Q5YTIyMzVlNTNiNGMzMzlhMGU4YmE4MTM4MDhkOWVhNmMyNTJkYQ==
4
+ MjdhY2FmMDZjYTE2MDg0ODE4YjUxMDA2ZWZjZDlkOGYzM2M1MzViZg==
5
5
  data.tar.gz: !binary |-
6
- ZGI2NDFlYzgzZmVjMGIwMjZlOWYyNzQwMDZmNTc5OTk0ZTJjMzE5Yw==
6
+ Yjc3ZWQ2YjIzZmRjZjI0MGY4YTgyNjgyMzE1NmYxZTJlMmQyZjY3MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjBiNmM5NDIyYTkwZTliMTczZDJhMDdhZDUwODVlZGZkYjVlYjgyNDU4MDM1
10
- YjhjMTBjZjVjOGUwZTU4ZTEyMjA3YmI4MjNiY2VhODZiZTQ3MGIyYTQ3YTFl
11
- MDRkMGYzNjVjYzQ2MmZiYTBmNzU3NGI1MGFjYjE2NmYwODllMDA=
9
+ NzdjZmU0MTZjYzgxNmU0MTEyMWM2NzIzNGJiMWYwMDI2MjQ1MzQ1M2ViNzgx
10
+ NjllYTNjOGE3ZjE2MmY2OTc2YTVmN2U1YTE5M2ViZjI4YWVhMjQzYWE0OWMw
11
+ Y2E1YmZmZGYzMmQ1YjE1MGRiZjA3YmQxMzliNzk2ODhlYzE2NDY=
12
12
  data.tar.gz: !binary |-
13
- MDNjNTA2YmQ2OTA3N2IwM2VmMWI4NjFhYmQ1OThkOTBkYjZhODkzZWJmY2Qw
14
- MTVhMDI0ZDRhYjlhNzgyNDE1OTZiNmQyMTg4MTIzMjAwYWZkNTY2NWM2MTg3
15
- NWJlMDk1OGVhY2Q4ZTJmNzNkOGRiOTA2NTIxMzA0MzFlMzU0Zjg=
13
+ MGM4NTljNTRjODk3ZmFhZTdkOTBlNjExM2NhM2MxZGYzZmE3NmU0NWNhNGI5
14
+ OTcyOGZmM2RkZTFjNTM0NTkxY2RlMTFjOGNiYmJlYTA1ODI3MjYxOGZiMmU1
15
+ YzE0OTMzMTQ0YmU0ZDk3ZmE5OGEyN2U1ZDBmZGQzMjQwM2Q0MDQ=
data/lib/fixturize.rb CHANGED
@@ -22,6 +22,7 @@ class Fixturize
22
22
  attr_accessor :current_instrumentation
23
23
  attr_accessor :enabled
24
24
  attr_writer :database_version
25
+ attr_accessor :relative_path_root
25
26
 
26
27
  def enabled?
27
28
  enabled ? true : false
@@ -71,20 +72,31 @@ class Fixturize
71
72
  end
72
73
  end
73
74
 
74
- def fixturize(name = nil, &block)
75
- raise LocalJumpError.new("fixturize requires a block") unless block_given?
76
- return yield if !enabled?
77
-
75
+ def fixture_name(name = nil, &block)
78
76
  if !name && block.respond_to?(:source_location)
79
77
  # is this portable?
80
- name = block.source_location.join(":")
78
+ file_name, line_number = block.source_location
79
+
80
+ if relative_path_root && file_name.start_with?(relative_path_root)
81
+ file_name = file_name[relative_path_root.length + 1 .. -1]
82
+ end
83
+
84
+ name = [file_name, line_number].join(":")
81
85
  end
82
86
 
83
87
  if !name
84
88
  raise "A name must be given to fixturize"
85
89
  end
86
90
 
87
- name = name.to_s
91
+ name.to_s
92
+ end
93
+
94
+ def fixturize(name = nil, &block)
95
+ raise LocalJumpError.new("fixturize requires a block") unless block_given?
96
+ return yield if !enabled?
97
+
98
+ name = fixture_name(name, &block)
99
+
88
100
  self.current_instrumentation = name
89
101
  db_instrumentations = collection.find({ :name => name, :type => INSTRUMENT_DATABASE }).to_a
90
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixturize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Taylor
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-24 00:00:00.000000000 Z
12
+ date: 2015-05-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: fixturize your mongo(mapper) tests inline by caching blocks of created
15
15
  objects
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  version: '0'
42
42
  requirements: []
43
43
  rubyforge_project:
44
- rubygems_version: 2.4.5
44
+ rubygems_version: 2.2.2
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: fixturize your mongo tests inline