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
|
# File 'lib/generators/voltron/svg/install_generator.rb', line 8
def inject_initializer
voltron_initialzer_path = Rails.root.join("config", "initializers", "voltron.rb")
unless File.exist? voltron_initialzer_path
unless system("cd #{Rails.root.to_s} && rails generate voltron:install")
puts "Voltron initializer does not exist. Please ensure you have the 'voltron' gem installed and run `rails g voltron:install` to create it"
return false
end
end
current_initiailzer = File.read voltron_initialzer_path
unless current_initiailzer.match(Regexp.new(/# === Voltron SVG Configuration ===/))
inject_into_file(voltron_initialzer_path, after: "Voltron.setup do |config|\n") do
"\n # === Voltron SVG Configuration ===\n\n # The directory that contains SVG icons from which to create PNG's\n # config.svg.source_directory = Rails.root.join(\"app\", \"assets\", \"svg\")\n\n # The directory where generated fallback images for SVG's should reside\n # config.svg.image_directory = Rails.root.join(\"app\", \"assets\", \"images\")\n\n # The environment(s) that svg -> png generation can occur in. Defaults to \"development\"\n # Can specify either a single environment or an array of environments. NOT recommended for production\n # config.svg.build_environment << :development\n\n # The quality (0-100) of generated PNG's, can be overridden in SASS using:\n # svg-icon(icon, $quality: 100) or in the view helper:\n # svg_tag(:icon, quality: 100)\n # config.svg.quality = 90\n"
end
end
end
|