shopify_theme 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,6 +30,12 @@ Remove a theme file
30
30
  theme remove assets/layout.liquid
31
31
  ````
32
32
 
33
+ Completely replace shop theme assets with the local assets
34
+
35
+ ````
36
+ theme replace
37
+ ````
38
+
33
39
  Watch the theme directory and upload any files as they change
34
40
 
35
41
  ````
@@ -30,36 +30,50 @@ module ShopifyTheme
30
30
 
31
31
  assets.each do |asset|
32
32
  download_asset(asset)
33
- puts "Downloaded: #{asset}" unless options['quiet']
33
+ say("Downloaded: #{asset}", :green) unless options['quiet']
34
34
  end
35
- puts "\nDone." unless options['quiet']
35
+ say("Done.", :green) unless options['quiet']
36
36
  end
37
37
 
38
38
  desc "upload FILE", "upload all theme assets to shop"
39
39
  method_option :quiet, :type => :boolean, :default => false
40
40
  def upload(*keys)
41
41
  assets = keys.empty? ? local_assets_list : keys
42
- assets.each do |a|
43
- send_asset(a, options['quiet'])
42
+ assets.each do |asset|
43
+ send_asset(asset, options['quiet'])
44
44
  end
45
- puts "Done." unless options['quiet']
45
+ say("Done.", :green) unless options['quiet']
46
+ end
47
+
48
+ desc "replace FILE", "completely replace shop theme assets with local theme assets"
49
+ method_option :quiet, :type => :boolean, :default => false
50
+ def replace(*keys)
51
+ say("Are you sure you want to completely replace your shop theme assets? This is not undoable.", :yellow)
52
+ if ask("Continue? (Y/N): ") == "Y"
53
+ remote_assets = keys.empty? ? ShopifyParty.asset_list : keys
54
+ remote_assets.each do |asset|
55
+ delete_asset(asset, options['quiet'])
56
+ end
57
+ local_assets = keys.empty? ? local_assets_list : keys
58
+ local_assets.each do |asset|
59
+ send_asset(asset, options['quiet'])
60
+ end
61
+ say("Done.", :green) unless options['quiet']
62
+ end
46
63
  end
47
64
 
48
65
  desc "remove FILE", "remove theme asset"
49
66
  method_option :quiet, :type => :boolean, :default => false
50
67
  def remove(*keys)
51
68
  keys.each do |key|
52
- if ShopifyParty.delete_asset(key).success?
53
- puts "Removed: #{key}" unless options['quiet']
54
- else
55
- puts "Error: Could not remove #{key} from #{@config['store']}"
56
- end
69
+ delete_asset(key, options['quiet'])
57
70
  end
58
- puts "Done." unless options['quiet']
71
+ say("Done.", :green) unless options['quiet']
59
72
  end
60
73
 
61
- desc "watch", "upload individual theme assets as they change"
74
+ desc "watch", "upload and delete individual theme assets as they change, use the --keep_files flag to disable remote file deletion"
62
75
  method_option :quiet, :type => :boolean, :default => false
76
+ method_option :keep_files, :type => :boolean, :default => false
63
77
  def watch
64
78
  FSSM.monitor '.' do |m|
65
79
  m.update do |base, relative|
@@ -68,6 +82,11 @@ module ShopifyTheme
68
82
  m.create do |base, relative|
69
83
  send_asset(relative, options['quiet']) if local_assets_list.include?(relative)
70
84
  end
85
+ if !options['keep_files']
86
+ m.delete do |base, relative|
87
+ delete_asset(relative, options['quiet'])
88
+ end
89
+ end
71
90
  end
72
91
  end
73
92
 
@@ -99,10 +118,18 @@ module ShopifyTheme
99
118
  end
100
119
 
101
120
  if ShopifyParty.send_asset(data).success?
102
- puts "Uploaded: #{asset}" unless quiet
121
+ say("Uploaded: #{asset}", :green) unless quiet
103
122
  else
104
- puts "Error: Could not upload #{asset} to #{@config['store']}"
123
+ say("Error: Could not upload #{asset}", :red)
105
124
  end
106
125
  end
126
+
127
+ def delete_asset(key, quiet=false)
128
+ if ShopifyParty.delete_asset(key).success?
129
+ say("Removed: #{key}", :green) unless quiet
130
+ else
131
+ say("Error: Could not remove #{key}", :red)
132
+ end
133
+ end
107
134
  end
108
135
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyTheme
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "shopify_theme"
16
16
  s.add_dependency("thor", [">= 0.14.4"])
17
- s.add_dependency("httparty")
17
+ s.add_dependency("httparty", ["= 0.7.8"])
18
18
  s.add_dependency("json")
19
19
  s.add_dependency("fssm")
20
20
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_theme
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Duff
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-02 00:00:00 -04:00
18
+ date: 2011-10-19 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,14 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - "="
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 19
46
46
  segments:
47
47
  - 0
48
- version: "0"
48
+ - 7
49
+ - 8
50
+ version: 0.7.8
49
51
  type: :runtime
50
52
  version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency