dassets 0.14.1 → 0.14.2

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: 89a17e9e4689219cffdda2b968a4c481f9813591
4
- data.tar.gz: 2a74fdbbc78e44ec82d23f1aabbc284d70f03397
3
+ data.tar.gz: 27368bfd4202c312aa66d309d27517a6704f9bca
4
+ metadata.gz: 78fc0e7996a2a58dac2402129e53bc692d6ee24a
5
5
  SHA512:
6
- metadata.gz: d19a0f7587afb5d0d19a9878a0667973474ef55a3d684d363a66cb750394249a97cf957cac9e99df6662fd72d32be6e9eb46794c7d121c7d7b45558f85dd0dd7
7
- data.tar.gz: bf6bfb399f0ab12d21f50d58db6b6e39b22da71768660236ae21f287ebf3470477598dc95a397a39395c960980fd428bf6cf1968145975a65ab7db67da28041b
6
+ data.tar.gz: d86da74bebfd5c5799768c1c449348d9da0015ec948af9bd0aa706206a61b93e89e941804368683b275bcba6345fe008f7a7f86a7bd2908df8646fcb49c36c6b
7
+ metadata.gz: 0c6e6fde12b20fbb9614e7510a8b09a6f6fb78a3084e037cb6b94f9340e1a9caf63e9364d1c48066c6e9ff8e04cd3a56ad561775bf214da646f5f08c82c19be7
@@ -15,6 +15,11 @@ module Dassets
15
15
  @source_files = SourceFiles.new(self.config.sources)
16
16
  end
17
17
 
18
+ def self.reset
19
+ @asset_files = {}
20
+ self.config.reset
21
+ end
22
+
18
23
  def self.[](digest_path)
19
24
  @asset_files[digest_path] ||= AssetFile.new(digest_path)
20
25
  end
@@ -11,13 +11,17 @@ module Dassets
11
11
 
12
12
  def initialize
13
13
  super
14
- @sources = []
15
- @combinations = Hash.new{ |h, k| [k] } # digest pass-thru if none defined
14
+ self.reset
16
15
  @content_cache = Dassets::Cache::NoCache.new
17
16
  @fingerprint_cache = Dassets::Cache::NoCache.new
18
17
  @file_store = FileStore::NullStore.new
19
18
  end
20
19
 
20
+ def reset
21
+ @sources = []
22
+ @combinations = Hash.new{ |h, k| [k] } # digest pass-thru if none defined
23
+ end
24
+
21
25
  def base_url(value = nil)
22
26
  set_base_url(value) if !value.nil?
23
27
  @base_url
@@ -1,3 +1,3 @@
1
1
  module Dassets
2
- VERSION = "0.14.1"
2
+ VERSION = "0.14.2"
3
3
  end
@@ -14,10 +14,26 @@ class Dassets::Config
14
14
  subject{ @config }
15
15
 
16
16
  should have_readers :combinations
17
+ should have_imeths :reset
17
18
  should have_imeths :base_url, :set_base_url
18
19
  should have_imeths :file_store, :content_cache, :fingerprint_cache
19
20
  should have_imeths :source, :combination, :combination?
20
21
 
22
+ should "reset its sources and combination on `reset`" do
23
+ assert_empty subject.sources
24
+ assert_empty subject.combinations
25
+
26
+ path = Factory.path
27
+ subject.source(path)
28
+ subject.combination path, [Factory.path]
29
+ assert_equal 1, subject.sources.size
30
+ assert_equal 1, subject.combinations.size
31
+
32
+ subject.reset
33
+ assert_empty subject.sources
34
+ assert_empty subject.combinations
35
+ end
36
+
21
37
  should "have no base url by default" do
22
38
  assert_nil subject.base_url
23
39
  end
@@ -84,7 +100,7 @@ class Dassets::Config
84
100
  end
85
101
 
86
102
  should "register new sources with the `source` method" do
87
- path = '/path/to/app/assets'
103
+ path = Factory.path
88
104
  filter = proc{ |paths| [] }
89
105
  subject.source(path){ |s| s.filter(&filter) }
90
106
 
@@ -10,17 +10,30 @@ module Dassets
10
10
  desc "Dassets"
11
11
  subject{ Dassets }
12
12
 
13
- should have_imeths :config, :configure, :init, :[]
14
- should have_imeths :source_files
13
+ should have_imeths :config, :configure, :init, :reset
14
+ should have_imeths :[], :source_files
15
15
 
16
16
  should "return a `Config` instance with the `config` method" do
17
17
  assert_kind_of Config, subject.config
18
18
  end
19
19
 
20
+ should "know how to reset itself" do
21
+ config_reset_called = false
22
+ Assert.stub(subject.config, :reset){ config_reset_called = true }
23
+
24
+ file1 = subject['nested/file3.txt']
25
+
26
+ subject.reset
27
+
28
+ file2 = subject['nested/file3.txt']
29
+ assert_not_same file2, file1
30
+ assert_true config_reset_called
31
+ end
32
+
20
33
  should "return asset files given a their digest path using the index operator" do
21
34
  file = subject['nested/file3.txt']
22
35
 
23
- assert_kind_of Dassets::AssetFile, file
36
+ assert_kind_of subject::AssetFile, file
24
37
  assert_equal 'nested/file3.txt', file.digest_path
25
38
  assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.fingerprint
26
39
  end
@@ -38,7 +51,7 @@ module Dassets
38
51
  end
39
52
 
40
53
  should "know its list of configured source files" do
41
- exp = Dassets::SourceFiles.new(Dassets.config.sources)
54
+ exp = Dassets::SourceFiles.new(subject.config.sources)
42
55
  assert_equal exp, subject.source_files
43
56
  end
44
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dassets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding