jammit_lite 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/jammit_lite.gemspec +2 -2
- data/lib/jammit/lite/bundle.rb +13 -9
- data/lib/jammit_lite.rb +19 -9
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/jammit_lite.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jammit_lite}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jordan Glasner"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-29}
|
13
13
|
s.description = %q{Use Jammit on Heroku without slug bloat. Jammit::Lite loads Jammit in development, but replaces it in production saving over 9MB.}
|
14
14
|
s.email = %q{jordan@digitalignition.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/jammit/lite/bundle.rb
CHANGED
@@ -6,16 +6,20 @@ module Jammit
|
|
6
6
|
|
7
7
|
# takes array of files from yaml hash and expands any wilcards
|
8
8
|
def self.expand(files)
|
9
|
-
files.
|
10
|
-
|
11
|
-
|
12
|
-
return file
|
13
|
-
else
|
14
|
-
# expand wildcard into all matching filenames
|
15
|
-
return Dir[Rails.root + file].map { |path| path.gsub("#{Rails.root}/",'') }
|
16
|
-
end
|
9
|
+
files.inject([]) do |expanded,file|
|
10
|
+
wildcard?(file) ? expanded.concat(expand_wildcard_path(file)) : expanded.push(file)
|
11
|
+
expanded
|
17
12
|
end
|
18
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
# returns true if given path includes "*"
|
16
|
+
def self.wildcard?(path)
|
17
|
+
not path.match(/\*/).nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
# expands paths with wildcards into Array of matching filenames
|
21
|
+
def self.expand_wildcard_path(path)
|
22
|
+
Dir[Rails.root + path].map { |path| path.gsub("#{Rails.root}/",'') }
|
19
23
|
end
|
20
24
|
|
21
25
|
attr_accessor :path
|
data/lib/jammit_lite.rb
CHANGED
@@ -4,23 +4,33 @@ module Jammit
|
|
4
4
|
|
5
5
|
# returns hash of bundle file arrays keyed by bundle name
|
6
6
|
def self.assets(type)
|
7
|
-
hash = asset_hash
|
8
|
-
|
7
|
+
hash = asset_hash(type)
|
8
|
+
hash_to_assets(hash)
|
9
|
+
end
|
10
|
+
|
11
|
+
# typecasts paths in given Hash into Assets
|
12
|
+
def self.hash_to_assets(hash)
|
13
|
+
hash.inject({}) do |out,array|
|
9
14
|
key,paths = array
|
10
15
|
out[key] = paths.map { |path| Jammit::Lite::Asset.new(path) }
|
11
16
|
out
|
12
17
|
end
|
13
|
-
end
|
18
|
+
end
|
14
19
|
|
20
|
+
# returns hash from yaml with given type, e.g. :javascripts
|
21
|
+
# expands all wildcard paths
|
22
|
+
def self.asset_hash(type)
|
23
|
+
yaml[type].symbolize_keys.inject({}) do |out,pair|
|
24
|
+
bundle,files = pair
|
25
|
+
out[bundle] = Jammit::Lite::Bundle.expand(files)
|
26
|
+
out
|
27
|
+
end
|
28
|
+
end
|
15
29
|
|
16
30
|
# returns hash from config/assets.yml
|
17
|
-
|
18
|
-
def self.asset_hash
|
31
|
+
def self.yaml
|
19
32
|
yaml = File.open("#{Rails.root}/config/assets.yml")
|
20
|
-
|
21
|
-
hash.each do |key,bundles|
|
22
|
-
bundles.each { |name,files| bundles[name] = Jammit::Lite::Bundle.expand(files) }
|
23
|
-
end
|
33
|
+
YAML::load(yaml).symbolize_keys
|
24
34
|
end
|
25
35
|
|
26
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jammit_lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Glasner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-29 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|