Class: EasyHtmlGenerator::Generator::Service::Analytics
Overview
this generator adds web tracking snippets to files in the dist folder
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
#do_file, #generate!, #input_to_output_file, #walk_files
Methods inherited from Base
#enabled?, #file_changed?, #generate, #generate!, #initialize, #log, #log_running, #repetitive?, #store_file_hash, #tasks
Instance Method Details
#begin_marker(config) ⇒ Object
17
18
19
|
# File 'lib/easy_html_generator/generator/service/analytics.rb', line 17
def begin_marker(config)
"<!-- #{config.name} Analytics -->"
end
|
#build_content(config) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/easy_html_generator/generator/service/analytics.rb', line 25
def build_content(config)
content = config.code
config.params.each do |key, value|
content.sub!("{#{key}}", value)
end
"#{begin_marker(config)} #{content} #{end_marker(config)}"
end
|
9
10
11
12
13
14
15
|
# File 'lib/easy_html_generator/generator/service/analytics.rb', line 9
def do_input!(input, _input_file, _output_file, config)
return if input.include? begin_marker(config)
analytics_code = build_content(config)
input.sub('</head>', "#{analytics_code}</head>")
end
|
#end_marker(config) ⇒ Object
21
22
23
|
# File 'lib/easy_html_generator/generator/service/analytics.rb', line 21
def end_marker(config)
"<!-- End #{config.name} Analytics -->"
end
|
#watch_files(config) ⇒ Object
35
36
37
|
# File 'lib/easy_html_generator/generator/service/analytics.rb', line 35
def watch_files(config)
Dir[File.join(config.source, config.selector)]
end
|