Class: ThemeCheck::ShopifyLiquid::SourceManager
- Inherits:
-
Object
- Object
- ThemeCheck::ShopifyLiquid::SourceManager
- Defined in:
- lib/theme_check/shopify_liquid/source_manager.rb
Constant Summary collapse
- REQUIRED_FILE_NAMES =
[:filters, :objects, :tags, :latest].freeze
Class Method Summary collapse
- .download(destination = default_destination) ⇒ Object
- .download_or_refresh_files(destination = default_destination) ⇒ Object
- .has_required_files?(destination = default_destination) ⇒ Boolean
- .local_path(file_name, destination = default_destination) ⇒ Object
- .refresh(destination = default_destination) ⇒ Object
- .wait_downloads ⇒ Object
Class Method Details
.download(destination = default_destination) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 21 def download(destination = default_destination) Dir.mkdir(destination) unless destination.exist? REQUIRED_FILE_NAMES.each do |file_name| download_file(local_path(file_name, destination), remote_path(file_name)) end end |
.download_or_refresh_files(destination = default_destination) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 13 def download_or_refresh_files(destination = default_destination) if has_required_files?(destination) refresh(destination) else download(destination) end end |
.has_required_files?(destination = default_destination) ⇒ Boolean
37 38 39 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 37 def has_required_files?(destination = default_destination) REQUIRED_FILE_NAMES.all? { |file_name| local_path(file_name, destination).exist? } end |
.local_path(file_name, destination = default_destination) ⇒ Object
33 34 35 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 33 def local_path(file_name, destination = default_destination) destination + "#{file_name}.json" end |
.refresh(destination = default_destination) ⇒ Object
29 30 31 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 29 def refresh(destination = default_destination) refresh_threads << Thread.new { refresh_thread(destination) } end |
.wait_downloads ⇒ Object
41 42 43 |
# File 'lib/theme_check/shopify_liquid/source_manager.rb', line 41 def wait_downloads refresh_threads.each(&:join) end |