githubbish_assets 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/githubbish_assets.gemspec +3 -2
- data/lib/githubbish_assets.rb +1 -0
- data/lib/githubbish_assets/helper.rb +12 -12
- data/lib/githubbish_assets/lister.rb +13 -0
- data/lib/githubbish_assets/packer.rb +10 -30
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/githubbish_assets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{githubbish_assets}
|
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 = ["Oleg Dashevskii"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-07}
|
13
13
|
s.description = %q{Github style assets bundling in a Rails 3 engine}
|
14
14
|
s.email = %q{olegdashevski@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"githubbish_assets.gemspec",
|
28
28
|
"lib/githubbish_assets.rb",
|
29
29
|
"lib/githubbish_assets/helper.rb",
|
30
|
+
"lib/githubbish_assets/lister.rb",
|
30
31
|
"lib/githubbish_assets/packer.rb",
|
31
32
|
"lib/vendor/js_minimizer.rb",
|
32
33
|
"test/helper.rb",
|
data/lib/githubbish_assets.rb
CHANGED
@@ -28,15 +28,7 @@ module GithubbishAssets
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def javascript_include_files(bundles)
|
31
|
-
|
32
|
-
bundles.each do |bundle|
|
33
|
-
files = GithubbishAssets::Packer.recursive_file_list("public/javascripts/#{bundle}", ".js")
|
34
|
-
files.each do |file|
|
35
|
-
file = file.gsub('public/javascripts/', '')
|
36
|
-
output << javascript_src_tag(file, {}) + "\n"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
output.html_safe
|
31
|
+
_gh_include_files("public/javascripts", ".js", bundles) { |file| javascript_src_tag(file) }
|
40
32
|
end
|
41
33
|
|
42
34
|
def javascript_dev(*sources)
|
@@ -60,14 +52,22 @@ module GithubbishAssets
|
|
60
52
|
end
|
61
53
|
|
62
54
|
def stylesheet_include_files(bundles)
|
55
|
+
_gh_include_files("public/stylesheets", ".css", bundles) { |file| stylesheet_link_tag(file) }
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def _gh_include_files(asset_root, ext, bundles)
|
61
|
+
p_asset_root = Rails.root + asset_root
|
63
62
|
output = ""
|
63
|
+
|
64
64
|
bundles.each do |bundle|
|
65
|
-
files =
|
65
|
+
files = RecursiveLister[p_asset_root + bundle.to_s, ext]
|
66
66
|
files.each do |file|
|
67
|
-
|
68
|
-
output << stylesheet_link_tag(file) + "\n"
|
67
|
+
output << yield(file.relative_path_from(p_asset_root).to_s) << "\n"
|
69
68
|
end
|
70
69
|
end
|
70
|
+
|
71
71
|
output.html_safe
|
72
72
|
end
|
73
73
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'yui/compressor'
|
2
|
-
require 'find'
|
3
2
|
|
4
3
|
module GithubbishAssets
|
5
4
|
class Packer
|
@@ -11,7 +10,7 @@ module GithubbishAssets
|
|
11
10
|
require 'closure-compiler'
|
12
11
|
end
|
13
12
|
|
14
|
-
pack('public/javascripts', '.js') do |target, files|
|
13
|
+
pack(Rails.root + 'public/javascripts', '.js') do |target, files|
|
15
14
|
case GithubbishAssets.js_compressor
|
16
15
|
when :closure
|
17
16
|
opts = [ [:js_output_file, target] ]
|
@@ -36,38 +35,23 @@ module GithubbishAssets
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def self.css
|
39
|
-
pack('public/stylesheets', '.css') do |target, files|
|
38
|
+
pack(Rails.root + 'public/stylesheets', '.css') do |target, files|
|
40
39
|
compress_with_yui(YUI::CssCompressor.new(:line_break => 0), files, target)
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
|
-
def self.recursive_file_list(basedir, ext)
|
45
|
-
files = []
|
46
|
-
Find.find(basedir) do |path|
|
47
|
-
if FileTest.directory?(path)
|
48
|
-
if File.basename(path)[0] == ?. # Skip dot directories
|
49
|
-
Find.prune
|
50
|
-
else
|
51
|
-
next
|
52
|
-
end
|
53
|
-
end
|
54
|
-
files << path if File.extname(path) == ext
|
55
|
-
end
|
56
|
-
files.sort
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
43
|
private
|
61
44
|
|
62
|
-
def self.pack(
|
45
|
+
def self.pack(path, ext)
|
63
46
|
targets = []
|
64
|
-
get_top_level_directories(
|
47
|
+
get_top_level_directories(path).each do |bundle_directory|
|
65
48
|
bundle_name = bundle_directory.basename
|
49
|
+
next if bundle_name.to_s == 'dev'
|
66
50
|
|
67
|
-
files =
|
68
|
-
next if files.empty?
|
51
|
+
files = RecursiveLister[bundle_directory, ext]
|
52
|
+
next if files.empty?
|
69
53
|
|
70
|
-
target =
|
54
|
+
target = path + "bundle_#{bundle_name}#{ext}"
|
71
55
|
|
72
56
|
yield target, files
|
73
57
|
|
@@ -77,12 +61,8 @@ module GithubbishAssets
|
|
77
61
|
targets
|
78
62
|
end
|
79
63
|
|
80
|
-
def self.get_top_level_directories(
|
81
|
-
|
82
|
-
if path[0] != ?. && (Rails.root + base_path + path).directory?
|
83
|
-
path
|
84
|
-
end
|
85
|
-
end.compact
|
64
|
+
def self.get_top_level_directories(root_path)
|
65
|
+
root_path.children.select { |path| path.directory? }
|
86
66
|
end
|
87
67
|
|
88
68
|
def self.compress_with_yui(compressor, files, target)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: githubbish_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Oleg Dashevskii
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-07 00:00:00 +06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- githubbish_assets.gemspec
|
129
129
|
- lib/githubbish_assets.rb
|
130
130
|
- lib/githubbish_assets/helper.rb
|
131
|
+
- lib/githubbish_assets/lister.rb
|
131
132
|
- lib/githubbish_assets/packer.rb
|
132
133
|
- lib/vendor/js_minimizer.rb
|
133
134
|
- test/helper.rb
|