Top Level Namespace
Defined Under Namespace
Modules: ApiTokenable, App47Logger, ArchiveAble, AwsConfiguration, CdnUrl, CipherAble, CoreAccount, CoreApplicationHelper, CoreAvatarHelper, CoreBreadcrumbHelper, CoreCardNavItemsHelper, CoreController, CoreCronServersController, CoreCronTabsController, CoreDelayedJobMetricsController, CoreDelayedJobWorkersController, CoreDelayedJobsController, CoreDropdownHelper, CoreFlashToastHelper, CoreFloatingActionButtonHelper, CoreFormCheckboxHelper, CoreFormHelper, CoreFormInputHelper, CoreFormSelectHelper, CoreFormTextareaHelper, CoreHelper, CoreHtml5FormHelper, CoreJobStateHelper, CoreLinkHelper, CoreMenuHelper, CoreNavBarHelper, CoreSelectTwoHelper, CoreSmtpConfiguration, CoreSsoServersHelper, CoreSystemConfiguration, CoreSystemConfigurationsController, CoreTableActionHelper, CoreTableHelper, CoreUser, Cron, Delayed, DelayedJobConfiguration, DeviseAble, EmailAble, EncryptedPassword, GoogleSsoConfiguration, ModelModalHelper, RestfulController, RoleAble, SearchAble, SecureFields, ServerProcessAble, SlackConfiguration, StandardModel, SvgIconHelper, SwitchboardAble, SwitchboardConfiguration, TagAble, TimeZoneAble, TwilioConfiguration, Web47core, ZendeskConfiguration
Classes: ApiToken, ApplicationJob, AuditLog, CommandJob, CommandJobLog, EmailFormatValidator, EmailNotification, EmailTemplate, ExceptionsController, Notification, NotificationTemplate, NotificationsController, Object, RedisConfiguration, SlackNotification, SmsNotification, SmtpConfiguration, StatusController, Tag, Template, UserActionAuditLog, UserAuditLog, UserModelAuditLog
Constant Summary
collapse
- SOURCE_DIR =
(ARGV[0] || 'tabler/icons').to_s
- DEST_ROOT =
(ARGV[1] || 'app/views/icons').to_s
Instance Method Summary
collapse
Instance Method Details
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/update_icons.rb', line 10
def (svg_path)
xml = File.read(svg_path)
require 'nokogiri'
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
doc.remove_namespaces!
doc.xpath('//path').map(&:to_xml)
rescue LoadError => error
puts error.inspect
end
|
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
|
# File 'lib/update_icons.rb', line 21
def process
unless Dir.exist?(SOURCE_DIR)
warn "Source directory not found: #{SOURCE_DIR}"
exit 1
end
FileUtils.mkdir_p(DEST_ROOT)
Dir.children(SOURCE_DIR).each do |sub|
src_subdir = File.join(SOURCE_DIR, sub)
next unless File.directory?(src_subdir)
dest_subdir = File.join(DEST_ROOT, sub)
FileUtils.mkdir_p(dest_subdir)
Dir.glob(File.join(src_subdir, '*.svg')).each do |svg_file|
paths = (svg_file)
basename = File.basename(svg_file, '.svg')
dest_file = File.join(dest_subdir, "_#{basename}.html.erb")
File.write(dest_file, paths.join("\n"))
puts "Wrote #{dest_file} (#{paths.size} path element#{paths.size == 1 ? '' : 's'})"
end
end
end
|