-
Notifications
You must be signed in to change notification settings - Fork 40
/
assets_generator.rb
49 lines (38 loc) · 1.4 KB
/
assets_generator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copy BlacklightRangeLimit assets to public folder in current app.
# If you want to do this on application startup, you can
# add this next line to your one of your environment files --
# generally you'd only want to do this in 'development', and can
# add it to environments/development.rb:
# require File.join(BlacklightRangeLimit.root, "lib", "generators", "blacklight", "assets_generator.rb")
# BlacklightRangeLimit::AssetsGenerator.start(["--force", "--quiet"])
# Need the requires here so we can call the generator from environment.rb
# as suggested above.
require 'rails/generators'
require 'rails/generators/base'
module BlacklightRangeLimit
class AssetsGenerator < Rails::Generators::Base
source_root File.join(BlacklightRangeLimit::Engine.root, 'app', 'assets')
def assets
application_css = Dir["app/assets/stylesheets/application{.css,.scss,.css.scss}"].first
if application_css
insert_into_file application_css, :before => "*/" do
%q{
*
* Used by blacklight_range_limit
*= require 'blacklight_range_limit'
*
}
end
else
say_status "warning", "Can not find application.css, did not insert our require", :red
end
append_to_file "app/assets/javascripts/application.js" do
%q{
// For blacklight_range_limit built-in JS, if you don't want it you don't need
// this:
//= require 'blacklight_range_limit'
}
end
end
end
end