compressible 0.0.2.2 → 0.0.2.3
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/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
|
|
5
5
|
# http://docs.rubygems.org/read/chapter/20
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "compressible"
|
8
|
-
s.version = "0.0.2.
|
8
|
+
s.version = "0.0.2.3"
|
9
9
|
s.author = "Lance Pollard"
|
10
10
|
s.summary = "Compressible: Quick asset compression for Ruby - Perfect for Heroku"
|
11
11
|
s.homepage = "http://github.com/viatropos/compressible"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Compressible
|
2
|
+
module Assetable
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def javascripts(hash)
|
11
|
+
hash.each do |to, paths|
|
12
|
+
paths << {:to => to}
|
13
|
+
javascript(*paths)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
alias_method :add_javascripts, :javascripts
|
17
|
+
|
18
|
+
def stylesheets(hash)
|
19
|
+
hash.each do |to, paths|
|
20
|
+
paths << {:to => to}
|
21
|
+
stylesheet(*paths)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
alias_method :add_stylesheets, :stylesheets
|
25
|
+
|
26
|
+
def javascript(*args)
|
27
|
+
paths = args.dup
|
28
|
+
options = paths.extract_options!
|
29
|
+
to = asset_name(options[:to])
|
30
|
+
raise "Please define a name for the cached javascript using ':to => :my_name'" unless to
|
31
|
+
|
32
|
+
add_to_config(:js, to, paths)
|
33
|
+
|
34
|
+
write_javascript(*args) unless config[:read_only] == true
|
35
|
+
end
|
36
|
+
alias_method :add_javascript, :javascript
|
37
|
+
alias_method :js, :javascript
|
38
|
+
|
39
|
+
def stylesheet(*args)
|
40
|
+
paths = args.dup
|
41
|
+
options = paths.extract_options!
|
42
|
+
to = asset_name(options[:to])
|
43
|
+
add_to_config(:css, to, paths)
|
44
|
+
write_stylesheet(*args) unless config[:read_only] == true
|
45
|
+
end
|
46
|
+
alias_method :add_stylesheet, :stylesheet
|
47
|
+
alias_method :css, :stylesheet
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -28,7 +28,8 @@ module Compressible
|
|
28
28
|
:js => [],
|
29
29
|
:css => [],
|
30
30
|
:stylesheet_path => defined?(Rails) ? "#{Rails.root}/public/stylesheets" : nil,
|
31
|
-
:javascript_path => defined?(Rails) ? "#{Rails.root}/public/javascripts" : nil
|
31
|
+
:javascript_path => defined?(Rails) ? "#{Rails.root}/public/javascripts" : nil,
|
32
|
+
:read_only => false
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Compressible
|
2
|
-
module
|
2
|
+
module Readable
|
3
3
|
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
@@ -48,10 +48,6 @@ module Compressible
|
|
48
48
|
IO.read(path_for(type, from))
|
49
49
|
end
|
50
50
|
|
51
|
-
def write(type, to, result)
|
52
|
-
File.open(path_for(type, to), "w") {|f| f.puts result}
|
53
|
-
end
|
54
|
-
|
55
51
|
def asset_name(path)
|
56
52
|
result = path.to_s.split(".")
|
57
53
|
if result.last =~ /(js|css)/
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Compressible
|
2
|
-
module
|
2
|
+
module Writable
|
3
3
|
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
@@ -17,58 +17,43 @@ module Compressible
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def compress_from_hash(k, v)
|
22
22
|
args = v.dup.delete(:paths) + [v]
|
23
23
|
self.send(k, *args)
|
24
24
|
end
|
25
|
-
|
26
|
-
def javascripts(hash)
|
27
|
-
hash.each do |to, paths|
|
28
|
-
paths << {:to => to}
|
29
|
-
javascript(*paths)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
alias_method :add_javascripts, :javascripts
|
33
|
-
|
34
|
-
def stylesheets(hash)
|
35
|
-
hash.each do |to, paths|
|
36
|
-
paths << {:to => to}
|
37
|
-
stylesheet(*paths)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
alias_method :add_stylesheets, :stylesheets
|
41
25
|
|
42
|
-
|
26
|
+
# figure out how to do alias_method_chain or something
|
27
|
+
# otherwise the modules are tightly coupled
|
28
|
+
def write_javascript(*args)
|
29
|
+
paths = args.dup
|
43
30
|
options = paths.extract_options!
|
44
31
|
to = asset_name(options[:to])
|
45
|
-
|
32
|
+
require 'yui/compressor' unless defined?(YUI)
|
33
|
+
|
46
34
|
munge = options.has_key?(:munge) ? options[:munge] : true
|
47
35
|
|
48
|
-
add_to_config(:js, to, paths)
|
49
|
-
|
50
|
-
require 'yui/compressor' unless defined?(YUI)
|
51
|
-
|
52
36
|
compressor = YUI::JavaScriptCompressor.new(:munge => munge)
|
53
37
|
|
54
38
|
result = paths.collect do |path|
|
55
39
|
puts "Compressing #{path}..."
|
56
40
|
compressor.compress(read(:javascript, path))
|
57
41
|
end.join("\n\n")
|
58
|
-
|
42
|
+
|
59
43
|
write(:javascript, to, result) if to
|
60
44
|
|
61
45
|
result
|
62
46
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def stylesheet(*paths)
|
47
|
+
|
48
|
+
def write_stylesheet(*args)
|
49
|
+
paths = args.dup
|
67
50
|
options = paths.extract_options!
|
68
51
|
to = asset_name(options[:to])
|
69
52
|
|
70
53
|
add_to_config(:css, to, paths)
|
71
54
|
|
55
|
+
return if options[:read_only] == true
|
56
|
+
|
72
57
|
require 'yui/compressor' unless defined?(YUI)
|
73
58
|
|
74
59
|
compressor = YUI::CssCompressor.new
|
@@ -82,9 +67,10 @@ module Compressible
|
|
82
67
|
|
83
68
|
result
|
84
69
|
end
|
85
|
-
|
86
|
-
|
70
|
+
|
71
|
+
def write(type, to, result)
|
72
|
+
File.open(path_for(type, to), "w") {|f| f.puts result}
|
73
|
+
end
|
87
74
|
end
|
88
|
-
|
89
|
-
end
|
75
|
+
end
|
90
76
|
end
|
data/lib/compressible.rb
CHANGED
@@ -23,5 +23,6 @@ end
|
|
23
23
|
Dir["#{this}/compressible/*"].each { |c| require c }
|
24
24
|
|
25
25
|
Compressible.send(:include, Compressible::Configurable)
|
26
|
-
Compressible.send(:include, Compressible::
|
27
|
-
Compressible.send(:include, Compressible::
|
26
|
+
Compressible.send(:include, Compressible::Assetable)
|
27
|
+
Compressible.send(:include, Compressible::Readable)
|
28
|
+
Compressible.send(:include, Compressible::Writable)
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lance Pollard
|
@@ -57,10 +57,11 @@ files:
|
|
57
57
|
- Rakefile
|
58
58
|
- init.rb
|
59
59
|
- MIT-LICENSE
|
60
|
-
- lib/compressible/
|
61
|
-
- lib/compressible/condensible.rb
|
60
|
+
- lib/compressible/assetable.rb
|
62
61
|
- lib/compressible/configurable.rb
|
62
|
+
- lib/compressible/readable.rb
|
63
63
|
- lib/compressible/view_helpers.rb
|
64
|
+
- lib/compressible/writable.rb
|
64
65
|
- lib/compressible.rake
|
65
66
|
- lib/compressible.rb
|
66
67
|
- lib/ext.rb
|