sundawg-sinatra-assetpack-fork 0.0.12.pre1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +27 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +72 -0
- data/HISTORY.md +60 -1
- data/README.md +54 -11
- data/examples/basic/app.rb +12 -1
- data/lib/sinatra/assetpack.rb +1 -1
- data/lib/sinatra/assetpack/class_methods.rb +8 -6
- data/lib/sinatra/assetpack/compressor.rb +1 -0
- data/lib/sinatra/assetpack/css.rb +1 -1
- data/lib/sinatra/assetpack/engines/less.rb +11 -0
- data/lib/sinatra/assetpack/helpers.rb +13 -3
- data/lib/sinatra/assetpack/html_helpers.rb +12 -0
- data/lib/sinatra/assetpack/image.rb +2 -2
- data/lib/sinatra/assetpack/options.rb +24 -9
- data/lib/sinatra/assetpack/package.rb +15 -8
- data/lib/sinatra/assetpack/version.rb +1 -1
- data/sinatra-assetpack.gemspec +5 -0
- data/test/app/app.rb +8 -1
- data/test/app/app/fonts/cantarell-regular-webfont.eot +0 -0
- data/test/app/app/fonts/cantarell-regular-webfont.svg +18 -0
- data/test/app/app/fonts/cantarell-regular-webfont.ttf +0 -0
- data/test/app/app/fonts/cantarell-regular-webfont.woff +0 -0
- data/test/app/app/js/jquery-1.8.0.min.js +1 -0
- data/test/app/app/packages/a_package/package.css +1 -0
- data/test/app/app/packages/a_package/package.js +1 -0
- data/test/app/app/packages/a_package/package.png +0 -0
- data/test/app/config.ru +2 -0
- data/test/arity_test.rb +8 -2
- data/test/cache_test.rb +17 -1
- data/test/glob_test.rb +3 -0
- data/test/ignore_test.rb +2 -2
- data/test/img_test.rb +2 -2
- data/test/local_file_test.rb +6 -0
- data/test/mime_type_test.rb +20 -0
- data/test/redundant_test.rb +1 -0
- data/test/sqwish_test.rb +4 -3
- data/test/test_helper.rb +6 -1
- data/test/tilt_test.rb +1 -0
- data/test/unit_test.rb +42 -5
- metadata +207 -189
- data/lib/sinatra/assetpack/hasharray.rb +0 -66
@@ -1,66 +0,0 @@
|
|
1
|
-
module Sinatra
|
2
|
-
module AssetPack
|
3
|
-
# Class: HashArray
|
4
|
-
# A stopgap solution to Ruby 1.8's lack of ordered hashes.
|
5
|
-
#
|
6
|
-
# A HashArray, for all intents and purposes, acts like an array. However, the
|
7
|
-
# common stuff are overloaded to work with hashes.
|
8
|
-
#
|
9
|
-
# ## Basic usage
|
10
|
-
#
|
11
|
-
# #### Creating
|
12
|
-
# You can create a HashArray by passing it an array.
|
13
|
-
#
|
14
|
-
# dict = HashArray.new([
|
15
|
-
# { :good_morning => "Bonjour" },
|
16
|
-
# { :goodbye => "Au revoir" },
|
17
|
-
# { :good_evening => "Bon nuit" }
|
18
|
-
# ])
|
19
|
-
#
|
20
|
-
# #### Converting
|
21
|
-
# You may also use it like so:
|
22
|
-
#
|
23
|
-
# letters = [ { :a => "Aye"}, { :b => "Bee" } ].to_hash_array
|
24
|
-
#
|
25
|
-
# #### Iterating
|
26
|
-
# Now you can use the typical enumerator functions:
|
27
|
-
#
|
28
|
-
# dict.each do |(key, value)|
|
29
|
-
# puts "#{key} is #{value}"
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
# #=> :good_morning is "Bonjour"
|
33
|
-
# # :goodbye is "Au revoir"
|
34
|
-
# # :good_evening is "Bon nuit"
|
35
|
-
#
|
36
|
-
class HashArray < Array
|
37
|
-
def self.[](*arr)
|
38
|
-
new arr.each_slice(2).map { |(k, v)| Hash[k, v] }
|
39
|
-
end
|
40
|
-
|
41
|
-
# Works like Hash#values.
|
42
|
-
def values
|
43
|
-
inject([]) { |a, (k, v)| a << v; a }
|
44
|
-
end
|
45
|
-
|
46
|
-
# Returns everything as a hash.
|
47
|
-
def to_hash
|
48
|
-
inject({}) { |hash, (k, v)| hash[k] = v; hash }
|
49
|
-
end
|
50
|
-
|
51
|
-
def keys
|
52
|
-
inject([]) { |a, (k, v)| a << k; a }
|
53
|
-
end
|
54
|
-
|
55
|
-
[:each, :map, :map!, :reject, :reject!, :select, :select!].each do |meth|
|
56
|
-
send(:define_method, meth) { |*a, &block|
|
57
|
-
if block.respond_to?(:call)
|
58
|
-
super(*a) { |hash| block.call *hash.to_a }
|
59
|
-
else
|
60
|
-
super(*a)
|
61
|
-
end
|
62
|
-
}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|