web_resource_bundler 0.0.15 → 0.0.16
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/Readme.md
CHANGED
@@ -24,47 +24,13 @@ Installation
|
|
24
24
|
Usage
|
25
25
|
-------------------
|
26
26
|
|
27
|
-
|
28
|
-
You can set separate settings for each environment
|
27
|
+
Declare web_resource_bundler in your Gemfile like this:
|
29
28
|
|
30
|
-
|
29
|
+
gem web_resource_bundler
|
31
30
|
|
32
|
-
|
33
|
-
:base64_filter:
|
34
|
-
:use: true
|
35
|
-
:max_image_size: 23
|
36
|
-
:protocol: http
|
37
|
-
:domain: localhost:3000
|
38
|
-
:bundle_filter:
|
39
|
-
:use: true
|
40
|
-
:cdn_filter:
|
41
|
-
:use: true
|
42
|
-
:http_hosts: ['http://localhost:3000']
|
43
|
-
:https_hosts: ['https://localhost:3000']
|
31
|
+
Add this two lines in your application.rb file on rails config dir:
|
44
32
|
|
45
|
-
|
46
|
-
/path/to/your/rails_app/config/initializers/ directory
|
47
|
-
Let's say it will be web_resource_bundler_init.rb
|
48
|
-
Then you should put content like this in it.
|
49
|
-
|
50
|
-
config/initializers/web_resource_bundler_init.rb
|
51
|
-
|
52
|
-
require 'web_resource_bundler'
|
53
|
-
require 'yaml'
|
54
|
-
root_dir = Rails.root #or RAILS_ROOT if you are using older rails version than 3
|
55
|
-
environment = Rails.env #or RAILS_ENV in case rails <= 2.3
|
56
|
-
settings = { }
|
57
|
-
settings_file_path = File.join(root_dir, 'config', 'web_resource_bundler.yml')
|
58
|
-
if File.exist?(settings_file_path)
|
59
|
-
settings_file = File.open(settings_file_path)
|
60
|
-
all_settings = YAML::load(settings_file)
|
61
|
-
if all_settings[environment]
|
62
|
-
settings = all_settings[environment]
|
63
|
-
settings[:resource_dir] = File.join(root_dir, 'public')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
WebResourceBundler::Bundler.instance.set_settings(settings)
|
33
|
+
WebResourceBundler::Bundler.instance.setup(Rails.root, Rails.env)
|
68
34
|
ActionView::Base.send(:include, WebResourceBundler::RailsAppHelpers)
|
69
35
|
|
70
36
|
Now in your view files you can call **`web_resource_bundler_process`** helper like this:
|
@@ -109,10 +75,24 @@ And as result you'll have
|
|
109
75
|
!!!
|
110
76
|
Don't forget to clean your cache directory after deploy to clean old bundles
|
111
77
|
|
112
|
-
|
113
78
|
To disable bundling and see raw results add no_bundler param
|
114
79
|
mysite.com/?no_bundler=1
|
115
80
|
|
81
|
+
To configure bundler by your self you can create your custom config file - web_resource_bundler.yml
|
82
|
+
|
83
|
+
/your_rails_app/config/web_resource_bundler.yml
|
84
|
+
|
85
|
+
development:
|
86
|
+
:base64_filter:
|
87
|
+
:use: true
|
88
|
+
:max_image_size: 23
|
89
|
+
:bundle_filter:
|
90
|
+
:use: true
|
91
|
+
:cdn_filter:
|
92
|
+
:use: false
|
93
|
+
:http_hosts: ['http://localhost:3000']
|
94
|
+
:https_hosts: ['https://localhost:3000']
|
95
|
+
|
116
96
|
Recommendations
|
117
97
|
--------------------
|
118
98
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
data/lib/web_resource_bundler.rb
CHANGED
@@ -138,7 +138,7 @@ module WebResourceBundler
|
|
138
138
|
#because block_data isn't populated with files content yet
|
139
139
|
block_data_copy.apply_filters(filters_array)
|
140
140
|
#cheking if resulted files exist on disk in cache folder
|
141
|
-
block_data_copy.
|
141
|
+
block_data_copy.all_files.each do |file|
|
142
142
|
return false unless File.exist?(File.join(@settings[:resource_dir], file.path))
|
143
143
|
end
|
144
144
|
true
|
@@ -33,6 +33,14 @@ module WebResourceBundler
|
|
33
33
|
clon
|
34
34
|
end
|
35
35
|
|
36
|
+
def all_files
|
37
|
+
result = self.files
|
38
|
+
self.child_blocks.each do |child|
|
39
|
+
result += child.all_files
|
40
|
+
end
|
41
|
+
result
|
42
|
+
end
|
43
|
+
|
36
44
|
def self.all_childs(block_data)
|
37
45
|
result = []
|
38
46
|
result << block_data
|
@@ -5,6 +5,7 @@ module WebResourceBundler
|
|
5
5
|
TAGS = ['background-image', 'background']
|
6
6
|
SEPARATOR = 'A_SEPARATOR'
|
7
7
|
PATTERN = /((#{TAGS.join('|')})\s*:[^\(]*)url\(\s*['|"]([^\)]*)['|"]\s*\)/
|
8
|
+
MAX_IMAGE_SIZE = 20
|
8
9
|
|
9
10
|
def initialize(settings, file_manager)
|
10
11
|
@settings = settings
|
@@ -13,7 +14,7 @@ module WebResourceBundler
|
|
13
14
|
|
14
15
|
def set_settings(settings)
|
15
16
|
@settings = settings
|
16
|
-
@settings[:max_image_size] =
|
17
|
+
@settings[:max_image_size] = MAX_IMAGE_SIZE unless @settings[:max_image_size]
|
17
18
|
end
|
18
19
|
|
19
20
|
#construct mhtml head of css file with definition of image data in base64
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{web_resource_bundler}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["gregolsen"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-02}
|
13
13
|
s.description = %q{this lib could bundle you css/js files in single file, encode images in base64, rewrite images urls to your cdn hosts}
|
14
14
|
s.email = %q{anotheroneman@yahoo.com}
|
15
15
|
s.files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 16
|
9
|
+
version: 0.0.16
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- gregolsen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-02-02 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|