File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class AssetManifest
66 def self . load ( manifest_path )
77 JsonManifest . try ( manifest_path , ".sprockets-manifest*.json" ) ||
88 JsonManifest . try ( manifest_path , "manifest*.json" ) ||
9+ JsonManifest . try ( manifest_path ) ||
910 YamlManifest . try ( manifest_path ) ||
1011 NullManifest . new
1112 end
@@ -75,9 +76,13 @@ def write
7576 end
7677
7778 class JsonManifest < AssetManifest
78- def self . try ( manifest_path , pattern )
79- paths = Dir [ File . join ( manifest_path , pattern ) ]
80- new ( paths . first ) if paths . any?
79+ def self . try ( manifest_path , pattern = nil )
80+ if pattern
81+ paths = Dir [ File . join ( manifest_path , pattern ) ]
82+ new ( paths . first ) if paths . any?
83+ elsif File . file? ( manifest_path )
84+ new ( manifest_path )
85+ end
8186 end
8287
8388 def initialize ( file )
Original file line number Diff line number Diff line change 1+ {}
Original file line number Diff line number Diff line change @@ -8,19 +8,25 @@ def fixture(path)
88 end
99
1010 describe ".load" do
11- it "returns a YamlManifest if a YAML manifest file exists" do
11+ it "returns a YamlManifest if a YAML manifest file exists within the given path " do
1212 manifest = AssetManifest . load ( fixture ( "yaml_manifest" ) )
1313 expect ( manifest ) . to be_an_instance_of ( YamlManifest )
1414 expect ( manifest . file ) . to eq fixture ( "yaml_manifest/manifest.yml" )
1515 end
1616
17- it "returns a JsonManifest if a JSON manifest file exists" do
17+ it "returns a JsonManifest if a JSON manifest file exists within the given path " do
1818 manifest = AssetManifest . load ( fixture ( "json_manifest" ) )
1919 expect ( manifest ) . to be_an_instance_of ( JsonManifest )
2020 expect ( manifest . file ) . to eq fixture ( "json_manifest/.sprockets-manifest-18802ea98f713a419dac90694dd5b6c4.json" )
2121 end
2222
23- it "returns a JsonManifest if a legacy JSON manifest file exists" do
23+ it "returns a JsonManifest if a specific JSON manifest file is provided" do
24+ manifest = AssetManifest . load ( fixture ( "json_manifest.json" ) )
25+ expect ( manifest ) . to be_an_instance_of ( JsonManifest )
26+ expect ( manifest . file ) . to eq fixture ( "json_manifest.json" )
27+ end
28+
29+ it "returns a JsonManifest if a legacy JSON manifest file exists within the given path" do
2430 manifest = AssetManifest . load ( fixture ( "legacy_manifest" ) )
2531 expect ( manifest ) . to be_an_instance_of ( JsonManifest )
2632 expect ( manifest . file ) . to eq fixture ( "legacy_manifest/manifest-18802ea98f713a419dac90694dd5b6c4.json" )
You can’t perform that action at this time.
0 commit comments