class Guard::Shopifytheme

Public Class Methods

new(options = {}) click to toggle source

VERSION = “0.0.1”

Calls superclass method
# File lib/guard/shopifytheme.rb, line 11
def initialize(options = {})
  super
end

Public Instance Methods

run_on_changes(paths) click to toggle source

Default behaviour on file(s) changes that the Guard plugin watches. @param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_change has failed @return [Object] the task result

# File lib/guard/shopifytheme.rb, line 70
def run_on_changes(paths)
  paths.each do |path|
    system "theme upload #{path}"
  end
end
run_on_removals(paths) click to toggle source

Called on file(s) removals that the Guard plugin watches.

@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_removals has failed @return [Object] the task result

# File lib/guard/shopifytheme.rb, line 100
def run_on_removals(paths)
  paths.each do |path|
    system "theme remove #{path}"
  end
end
start() click to toggle source

Called once when Guard starts. Please override initialize method to init stuff.

@raise [:task_has_failed] when start has failed @return [Object] the task result

# File lib/guard/shopifytheme.rb, line 20
    def start
     if File.exist? 'config.yml'
        Notifier.notify "Watching for changes to Shopify Theme"
      else
        data = <<-EOF
---
:api_key: YOUR_API_KEY
:password: YOUR_PASSWORD
:store: YOURSHOP.myshopify.com
:theme_id: 'YOUR_THEME_ID'
:ignore_files:
- README.md
- CHANGELOG.md
EOF
        File.open('./config.yml', "w") { |file| file.write data }
        Notifier.notify "Created config.yml. Remember to add your Shopify details to it."
      end
    end