Class: Guard::Shopifytheme

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/shopifytheme.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Shopifytheme

VERSION = “0.0.1”



11
12
13
# File 'lib/guard/shopifytheme.rb', line 11

def initialize(options = {})
  super
end

Instance Method Details

#run_on_changes(paths) ⇒ Object

Default behaviour on file(s) changes that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_change has failed



70
71
72
73
74
# 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) ⇒ Object

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

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_removals has failed



100
101
102
103
104
# File 'lib/guard/shopifytheme.rb', line 100

def run_on_removals(paths)
  paths.each do |path|
    system "theme remove #{path}"
  end
end

#startObject

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

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when start has failed



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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