Skip to content
This repository
Browse code

Readme upgrade

  • Loading branch information...
commit 5138225c72f075bd757597d4464bf86e24802549 1 parent fafc108
Innokenty Mikhailov authored

Showing 1 changed file with 21 additions and 39 deletions. Show diff stats Hide diff stats

  1. 60  Readme.md
60  Readme.md
Source Rendered
@@ -24,47 +24,13 @@ Installation
24 24
 Usage
25 25
 -------------------
26 26
 
27  
-Firstly you should create your settings file in config dir.
28  
-You can set separate settings for each environment
  27
+Declare web_resource_bundler in your Gemfile like this:
29 28
 
30  
-config/web_resource_bundler.yml
  29
+    gem web_resource_bundler
31 30
 
32  
-    development:
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  
-Then you should create initializer file in
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,26 @@ 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 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
+        :protocol: http
  90
+        :domain: localhost:3000
  91
+      :bundle_filter:
  92
+        :use: true
  93
+      :cdn_filter:
  94
+        :use: true
  95
+        :http_hosts: ['http://localhost:3000']
  96
+        :https_hosts: ['https://localhost:3000']
  97
+
116 98
 Recommendations
117 99
 --------------------
118 100
 

0 notes on commit 5138225

Please sign in to comment.
Something went wrong with that request. Please try again.