bunch 1.0.0pre1 → 1.0.0pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/bunch/combiner.rb +15 -5
- data/lib/bunch/middleware.rb +3 -2
- data/lib/bunch/version.rb +1 -1
- data/spec/bunch/combiner_spec.rb +20 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d5aba69bf87251e2474a2b0851ef99d5d85b7ef
|
4
|
+
data.tar.gz: c4583b708490467740c0846b67e7413a6af5b5a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f1aa8c5167f12b45e444c0568b615a6e287809496054a0bc21f48c22ba243c17b5289292fe40ad2bb4e49478ae615a4199040a4dc97d0d965bb777f513ee144
|
7
|
+
data.tar.gz: f806f3cb5188661a16d3f889fab249e74a8cd0bfb2711a1e886bc41dec87b367daa0f54a3143d4d3624b2defba2daf77754c1ebaaef3a52ee439d373d72ff13a
|
data/README.md
ADDED
data/lib/bunch/combiner.rb
CHANGED
@@ -18,10 +18,10 @@ module Bunch
|
|
18
18
|
if tree.name
|
19
19
|
@path << tree.name
|
20
20
|
|
21
|
-
combine_file = tree.get("_combine")
|
21
|
+
combine_file = tree.get("_combine") || tree.get("_.yml")
|
22
22
|
|
23
23
|
if combine_file || combining?
|
24
|
-
ordering = combine_file ? combine_file.content : ""
|
24
|
+
ordering = combine_file ? extract_ordering(combine_file.content) : ""
|
25
25
|
push_context Context.new(@path, ordering)
|
26
26
|
end
|
27
27
|
end
|
@@ -46,7 +46,7 @@ module Bunch
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def visit_file(file)
|
49
|
-
return if file.path == "_combine"
|
49
|
+
return if file.path == "_combine" || file.path == "_.yml"
|
50
50
|
|
51
51
|
if combining?
|
52
52
|
context.add file.path, file.content, file.extension
|
@@ -82,13 +82,23 @@ module Bunch
|
|
82
82
|
@contexts.any?
|
83
83
|
end
|
84
84
|
|
85
|
+
def extract_ordering(file_content)
|
86
|
+
as_yaml = YAML.load(file_content)
|
87
|
+
|
88
|
+
if as_yaml.is_a?(Array)
|
89
|
+
as_yaml
|
90
|
+
else
|
91
|
+
file_content.split("\n").map(&:strip)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
85
95
|
class Context
|
86
96
|
attr_accessor :ordering, :extension
|
87
97
|
|
88
|
-
def initialize(path,
|
98
|
+
def initialize(path, ordering)
|
89
99
|
@path = path.join("/")
|
90
100
|
@content = {}
|
91
|
-
@ordering =
|
101
|
+
@ordering = ordering
|
92
102
|
@extension = nil
|
93
103
|
@empty = true
|
94
104
|
end
|
data/lib/bunch/middleware.rb
CHANGED
@@ -22,9 +22,10 @@ module Bunch
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def build_url_map(paths_and_options)
|
25
|
-
paths,
|
25
|
+
paths, options_arr = paths_and_options.partition { |k, _| String === k }
|
26
|
+
options = { environment: "development" }.merge(Hash[options_arr])
|
26
27
|
mapping = Hash[paths.map do |url, directory|
|
27
|
-
[url, Server.new(
|
28
|
+
[url, Server.new(options.merge(root: directory))]
|
28
29
|
end]
|
29
30
|
Rack::URLMap.new(mapping)
|
30
31
|
end
|
data/lib/bunch/version.rb
CHANGED
data/spec/bunch/combiner_spec.rb
CHANGED
@@ -96,6 +96,26 @@ module Bunch
|
|
96
96
|
}},
|
97
97
|
{"a" => {"e.js" => "stuff"}}
|
98
98
|
|
99
|
+
scenario "ordering specified as YAML",
|
100
|
+
{"a" => {
|
101
|
+
"d" => "pants",
|
102
|
+
"a" => "spigot",
|
103
|
+
"_combine" => "- d\n- a\n",
|
104
|
+
"c" => "deuce",
|
105
|
+
"b" => "rands"
|
106
|
+
}},
|
107
|
+
{"a" => "pants\nspigot\nrands\ndeuce"}
|
108
|
+
|
109
|
+
scenario "ordering in _.yml instead of _combine (compatibility)",
|
110
|
+
{"a" => {
|
111
|
+
"d" => "pants",
|
112
|
+
"a" => "spigot",
|
113
|
+
"_.yml" => "- d\n- a\n",
|
114
|
+
"c" => "deuce",
|
115
|
+
"b" => "rands"
|
116
|
+
}},
|
117
|
+
{"a" => "pants\nspigot\nrands\ndeuce"}
|
118
|
+
|
99
119
|
it "raises when one combine has incompatible files" do
|
100
120
|
proc do
|
101
121
|
result_for_hash(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Fitzgerald
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- Gemfile
|
247
247
|
- Guardfile
|
248
248
|
- LICENSE.txt
|
249
|
+
- README.md
|
249
250
|
- Rakefile
|
250
251
|
- bin/bunch
|
251
252
|
- bunch.gemspec
|