Class: Versacommerce::CLI::Theme
- Inherits:
-
Thor
- Object
- Thor
- Versacommerce::CLI::Theme
- Defined in:
- lib/versacommerce/cli/theme.rb
Instance Method Summary collapse
Instance Method Details
#download ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/versacommerce/cli/theme.rb', line 21 def download save_config path = Pathname.new([:path]). logger.info('Downloading Theme to %s' % path) client.files(recursive: true).each do |file| logger.debug('Downloading %s' % file.path) file.reload_content file_path = path.join(file.path) FileUtils.mkdir_p(file_path.parent) File.open(file_path, 'wb') { |f| f.write(file.content) } end logger.success('Finished downloading Theme') end |
#upload ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/versacommerce/cli/theme.rb', line 70 def upload save_config theme_path = Pathname.new([:path]). validate_path!(theme_path) logger.info 'Uploading %s' % theme_path add_directory(theme_path, theme_path) logger.success('Uploaded %s' % theme_path) end |
#watch ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/versacommerce/cli/theme.rb', line 41 def watch save_config theme_path = Pathname.new([:path]). validate_path!(theme_path) logger.info 'Watching %s' % theme_path listener = Listen.to(theme_path) do |modified, added, removed| removed.each { |absolute_path| delete_file(theme_path, absolute_path) } modified.concat(added).each do |absolute_path| delete_file(theme_path, absolute_path) add_file(theme_path, absolute_path) end end begin listener.start sleep rescue SystemExit, Interrupt logger.info('Stopped watching') exit end end |