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, TimeZoneAble, TwilioConfiguration, Web47core, ZendeskConfiguration Classes: ApplicationJob, AuditLog, CardNavBuilder, CommandJob, CommandJobLog, EmailFormatValidator, EmailNotification, EmailTemplate, ErrorsController, ExceptionsController, Notification, NotificationTemplate, NotificationsController, Object, RedisConfiguration, SlackNotification, SmsNotification, SmtpConfiguration, StatusController, Template, UserActionAuditLog, UserAuditLog, UserModelAuditLog
Constant Summary collapse
- SOURCE_DIR =
SOURCE_DIR = (ARGV || 'tabler/icons').to_s
(ARGV[0] || '../tabler-icons/icons').to_s
- DEST_ROOT =
(ARGV[1] || 'app/views/icons').to_s
Instance Method Summary collapse
Instance Method Details
#extract_paths(svg_path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/update_icons.rb', line 11 def extract_paths(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 |
#process ⇒ Object
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 |
# File 'lib/update_icons.rb', line 22 def process unless Dir.exist?(SOURCE_DIR) warn "Source directory not found: #{SOURCE_DIR}" exit 1 end FileUtils.mkdir_p(DEST_ROOT) # Only iterate first-level subdirectories under SOURCE_DIR 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 = extract_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 |