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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efebcfd36e823c3ec86e0442561e0dae5b269992
4
- data.tar.gz: a5e89ce41f38db3a0b6b1bb0b93ac19f4778ad6c
3
+ metadata.gz: 6d5aba69bf87251e2474a2b0851ef99d5d85b7ef
4
+ data.tar.gz: c4583b708490467740c0846b67e7413a6af5b5a9
5
5
  SHA512:
6
- metadata.gz: 3f66c4238a91ea23234ff00fa0b3dadfaa6a304f6e5c144e10d3388cda68a45228edf3e280ed932a5f66804ae4760541d80fe4cc8c35986efca9ee1165a906f6
7
- data.tar.gz: 37d71071cd267674130898cd31856e47d788e26ebf765ddba3e34c888fdd040d6bfd0b5122bb9c8ba04f8e0ba6ef5a59cc3967755d221d02abc8c18f2d375481
6
+ metadata.gz: 3f1aa8c5167f12b45e444c0568b615a6e287809496054a0bc21f48c22ba243c17b5289292fe40ad2bb4e49478ae615a4199040a4dc97d0d965bb777f513ee144
7
+ data.tar.gz: f806f3cb5188661a16d3f889fab249e74a8cd0bfb2711a1e886bc41dec87b367daa0f54a3143d4d3624b2defba2daf77754c1ebaaef3a52ee439d373d72ff13a
@@ -0,0 +1,4 @@
1
+ Bunch: (Almost) configuration-free asset bundling.
2
+ ==================================================
3
+
4
+ <img src="http://i.imgur.com/QqufL.png">
@@ -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, ordering_file_contents)
98
+ def initialize(path, ordering)
89
99
  @path = path.join("/")
90
100
  @content = {}
91
- @ordering = ordering_file_contents.split("\n")
101
+ @ordering = ordering
92
102
  @extension = nil
93
103
  @empty = true
94
104
  end
@@ -22,9 +22,10 @@ module Bunch
22
22
  private
23
23
 
24
24
  def build_url_map(paths_and_options)
25
- paths, options = paths_and_options.partition { |k, _| String === k }
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(Hash[options].merge(root: directory))]
28
+ [url, Server.new(options.merge(root: directory))]
28
29
  end]
29
30
  Rack::URLMap.new(mapping)
30
31
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Bunch
4
- VERSION = "1.0.0pre1"
4
+ VERSION = "1.0.0pre2"
5
5
  end
@@ -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.0pre1
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