quickdraw 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +18 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +6 -1
  7. data/Gemfile.lock +49 -0
  8. data/LICENSE.txt +17 -18
  9. data/README.md +100 -29
  10. data/config/quickdraw.rb +16 -0
  11. data/exe/qt +12 -0
  12. data/lib/quickdraw/cluster.rb +27 -0
  13. data/lib/quickdraw/configuration.rb +13 -0
  14. data/lib/quickdraw/context.rb +138 -0
  15. data/lib/quickdraw/expectation.rb +62 -0
  16. data/lib/quickdraw/map.rb +30 -0
  17. data/lib/quickdraw/matchers/boolean.rb +11 -0
  18. data/lib/quickdraw/matchers/case_equality.rb +9 -0
  19. data/lib/quickdraw/matchers/change.rb +33 -0
  20. data/lib/quickdraw/matchers/equality.rb +39 -0
  21. data/lib/quickdraw/matchers/include.rb +15 -0
  22. data/lib/quickdraw/matchers/predicate.rb +14 -0
  23. data/lib/quickdraw/matchers/respond_to.rb +15 -0
  24. data/lib/quickdraw/matchers/to_be_a.rb +18 -0
  25. data/lib/quickdraw/matchers/to_have_attributes.rb +13 -0
  26. data/lib/quickdraw/matchers/to_raise.rb +26 -0
  27. data/lib/quickdraw/matchers/to_receive.rb +30 -0
  28. data/lib/quickdraw/matchers.rb +13 -0
  29. data/lib/quickdraw/pipe.rb +27 -0
  30. data/lib/quickdraw/queue.rb +32 -0
  31. data/lib/quickdraw/registry.rb +57 -0
  32. data/lib/quickdraw/run.rb +53 -0
  33. data/lib/quickdraw/runner.rb +48 -0
  34. data/lib/quickdraw/timer.rb +30 -0
  35. data/lib/quickdraw/version.rb +3 -1
  36. data/lib/quickdraw/worker.rb +28 -0
  37. data/lib/quickdraw.rb +29 -22
  38. metadata +51 -123
  39. data/.gitignore +0 -17
  40. data/Rakefile +0 -1
  41. data/bin/quickdraw +0 -25
  42. data/lib/quickdraw/cli.rb +0 -251
  43. data/lib/quickdraw/shopify_connector.rb +0 -105
  44. data/lib/quickdraw/shopify_connector_pool.rb +0 -54
  45. data/quickdraw.gemspec +0 -29
metadata CHANGED
@@ -1,139 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickdraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Bryan Morris
8
- autorequire:
9
- bindir: bin
7
+ - Joel Drapper
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10'
41
- - !ruby/object:Gem::Dependency
42
- name: thor
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.18'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.18'
55
- - !ruby/object:Gem::Dependency
56
- name: filewatcher
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.3'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.3'
69
- - !ruby/object:Gem::Dependency
70
- name: celluloid
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.15'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.15'
83
- - !ruby/object:Gem::Dependency
84
- name: httparty
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.12'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.12'
97
- - !ruby/object:Gem::Dependency
98
- name: filepath
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.6'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.6'
111
- description: Quickly develop Shopify themes
11
+ date: 2024-02-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Experimental test framework
112
14
  email:
113
- - bryan@internalfx.com
15
+ - joel@drapper.me
114
16
  executables:
115
- - quickdraw
17
+ - qt
116
18
  extensions: []
117
19
  extra_rdoc_files: []
118
20
  files:
119
- - ".gitignore"
21
+ - ".rubocop.yml"
120
22
  - ".ruby-version"
23
+ - CHANGELOG.md
24
+ - CODE_OF_CONDUCT.md
121
25
  - Gemfile
26
+ - Gemfile.lock
122
27
  - LICENSE.txt
123
28
  - README.md
124
- - Rakefile
125
- - bin/quickdraw
29
+ - config/quickdraw.rb
30
+ - exe/qt
126
31
  - lib/quickdraw.rb
127
- - lib/quickdraw/cli.rb
128
- - lib/quickdraw/shopify_connector.rb
129
- - lib/quickdraw/shopify_connector_pool.rb
32
+ - lib/quickdraw/cluster.rb
33
+ - lib/quickdraw/configuration.rb
34
+ - lib/quickdraw/context.rb
35
+ - lib/quickdraw/expectation.rb
36
+ - lib/quickdraw/map.rb
37
+ - lib/quickdraw/matchers.rb
38
+ - lib/quickdraw/matchers/boolean.rb
39
+ - lib/quickdraw/matchers/case_equality.rb
40
+ - lib/quickdraw/matchers/change.rb
41
+ - lib/quickdraw/matchers/equality.rb
42
+ - lib/quickdraw/matchers/include.rb
43
+ - lib/quickdraw/matchers/predicate.rb
44
+ - lib/quickdraw/matchers/respond_to.rb
45
+ - lib/quickdraw/matchers/to_be_a.rb
46
+ - lib/quickdraw/matchers/to_have_attributes.rb
47
+ - lib/quickdraw/matchers/to_raise.rb
48
+ - lib/quickdraw/matchers/to_receive.rb
49
+ - lib/quickdraw/pipe.rb
50
+ - lib/quickdraw/queue.rb
51
+ - lib/quickdraw/registry.rb
52
+ - lib/quickdraw/run.rb
53
+ - lib/quickdraw/runner.rb
54
+ - lib/quickdraw/timer.rb
130
55
  - lib/quickdraw/version.rb
131
- - quickdraw.gemspec
132
- homepage: https://github.com/internalfx/quickdraw
56
+ - lib/quickdraw/worker.rb
57
+ homepage: https://github.com/joeldrapper/quickdraw
133
58
  licenses:
134
59
  - MIT
135
- metadata: {}
136
- post_install_message:
60
+ metadata:
61
+ homepage_uri: https://github.com/joeldrapper/quickdraw
62
+ source_code_uri: https://github.com/joeldrapper/quickdraw
63
+ changelog_uri: https://github.com/joeldrapper/quickdraw
64
+ funding_uri: https://github.com/sponsors/joeldrapper
65
+ rubygems_mfa_required: 'true'
66
+ post_install_message:
137
67
  rdoc_options: []
138
68
  require_paths:
139
69
  - lib
@@ -141,17 +71,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
71
  requirements:
142
72
  - - ">="
143
73
  - !ruby/object:Gem::Version
144
- version: '0'
74
+ version: '3.3'
145
75
  required_rubygems_version: !ruby/object:Gem::Requirement
146
76
  requirements:
147
77
  - - ">="
148
78
  - !ruby/object:Gem::Version
149
79
  version: '0'
150
80
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 2.2.0
153
- signing_key:
81
+ rubygems_version: 3.5.3
82
+ signing_key:
154
83
  specification_version: 4
155
- summary: Allows the use of ERB templates to develop and "compile" a theme and then
156
- automatically deploy to Shopify
84
+ summary: Experimental test framework
157
85
  test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
data/bin/quickdraw DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- def fallback_load_path(path)
4
- retried = false
5
- begin
6
- yield
7
- rescue LoadError
8
- unless retried
9
- $: << path
10
- retried = true
11
- retry
12
- end
13
- raise
14
- end
15
- end
16
-
17
- fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do
18
- require 'quickdraw'
19
- require 'quickdraw/shopify_connector'
20
- require 'quickdraw/shopify_connector_pool'
21
- require 'quickdraw/cli'
22
- require 'celluloid'
23
- end
24
-
25
- Quickdraw::Cli.start(ARGV)
data/lib/quickdraw/cli.rb DELETED
@@ -1,251 +0,0 @@
1
- require 'thor'
2
- require 'yaml'
3
- #YAML::ENGINE.yamler = 'syck' if defined? Syck
4
- #require 'abbrev'
5
- #require 'base64'
6
- #require 'fileutils'
7
- #require 'json'
8
- require 'filewatcher'
9
- #require 'launchy'
10
- require 'benchmark'
11
- require 'pathname'
12
- require 'filepath'
13
-
14
- module Quickdraw
15
- class Cli < Thor
16
- include Thor::Actions
17
-
18
- BINARY_EXTENSIONS = %w(png gif jpg jpeg eot svg ttf woff otf swf ico)
19
- IGNORE = %w(config.yml)
20
- DEFAULT_WHITELIST = %w(layout/ assets/ config/ snippets/ templates/)
21
- TIMEFORMAT = "%H:%M:%S"
22
-
23
- desc "configure", "generate a config file for the store to connect to"
24
- def configure
25
- config = {
26
- :api_key => ask("API Key?"),
27
- :password => ask("Password?"),
28
- :store => ask("Store domain (ex. 'example.myshopify.com')?"),
29
- :theme_id => ask("Theme ID")
30
- }
31
- create_file('config.yml', config.to_yaml)
32
- empty_directory('src')
33
- empty_directory('src/assets')
34
- empty_directory('src/config')
35
- empty_directory('src/layout')
36
- empty_directory('src/snippets')
37
- empty_directory('src/templates')
38
- empty_directory('theme')
39
- empty_directory('theme/assets')
40
- empty_directory('theme/config')
41
- empty_directory('theme/layout')
42
- empty_directory('theme/snippets')
43
- empty_directory('theme/templates')
44
- end
45
-
46
- desc "upload FILES", "upload all theme assets to shop"
47
- def upload(filter=nil)
48
-
49
- if filter
50
- assets = (FilePath.getwd / 'theme').files(true).select{ |i|
51
- i.relative_to(Quickdraw.theme_dir).to_s[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/]
52
- }
53
- else
54
- assets = (FilePath.getwd / 'theme').files(true)
55
- end
56
-
57
- futures = []
58
- assets.each do |asset|
59
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
60
- end
61
- futures.each do |future|
62
- asset, response = future.value
63
- if response.success?
64
- say("Uploaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
65
- else
66
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not upload #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
67
- end
68
- end
69
-
70
- say("Done.", :green)
71
- end
72
-
73
- desc "download FILES", "download the shops current theme assets"
74
- def download(filter=nil)
75
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
76
-
77
- if filter
78
- assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| FilePath.getwd / 'theme' / a }
79
- else
80
- assets = asset_list.map{|a| FilePath.getwd / 'theme' / a }
81
- end
82
-
83
- futures = []
84
- assets.each do |asset|
85
- futures << Celluloid::Actor[:shopify_connector].future.download_asset(asset)
86
- end
87
- futures.each do |future|
88
- asset, response = future.value
89
- if response.success?
90
- say("Downloaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
91
- else
92
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not download #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
93
- end
94
- end
95
- say("Done.", :green)
96
- end
97
-
98
- desc "replace FILES", "completely replace shop theme assets with local theme assets"
99
- def replace(filter=nil)
100
- say("Are you sure you want to completely replace your shop theme assets? This is not undoable.", :yellow)
101
- if ask("Continue? (y/n): ") == "y"
102
- # only delete files on remote that are not present locally
103
- # files present on remote and present locally get overridden anyway
104
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
105
-
106
- if filter
107
- remote_assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| (FilePath.getwd / 'theme' / a) }
108
- else
109
- remote_assets = asset_list.map{|a| (FilePath.getwd / 'theme' / a) }
110
- end
111
-
112
- if filter
113
- local_assets = (FilePath.getwd / 'theme').files(true).select{ |i| i.relative_to(Quickdraw.theme_dir).to_s[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }
114
- else
115
- local_assets = (FilePath.getwd / 'theme').files(true)
116
- end
117
-
118
- remote_only_assets = remote_assets.to_a.map{|p| p.to_s} - local_assets.to_a.map{|p| p.to_s}
119
-
120
- futures = []
121
- remote_only_assets.each do |asset|
122
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset.as_path)
123
- end
124
- local_assets.each do |asset|
125
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
126
- end
127
- futures.each do |future|
128
- asset, response = future.value
129
- if response.success?
130
- if response.request.http_method.to_s == "Net::HTTP::Put"
131
- say("Uploaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
132
- else
133
- say("Removed: #{asset.relative_to(Quickdraw.getwd)}", :green)
134
- end
135
- else
136
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not download #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
137
- end
138
- end
139
- say("Done.", :green) unless options['quiet']
140
- end
141
- end
142
-
143
- desc "remove FILES", "remove theme asset"
144
- def remove(filter=nil)
145
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
146
-
147
- if filter
148
- assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| FilePath.getwd / 'theme' / a }
149
- else
150
- assets = asset_list.map{|a| FilePath.getwd / 'theme' / a }
151
- end
152
-
153
- futures = []
154
- assets.each do |asset|
155
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset)
156
- end
157
- futures.each do |future|
158
- asset, response = future.value
159
- if response.success?
160
- say("Deleted: #{asset.relative_to(Quickdraw.getwd)}", :green)
161
- else
162
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not remove #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
163
- end
164
- end
165
- say("Done.", :green) unless options['quiet']
166
- end
167
-
168
- desc "watch", "compile then upload or delete individual theme assets as they change."
169
- def watch
170
- puts "Watching current folder: #{Dir.pwd}"
171
-
172
- futures = []
173
-
174
- FileWatcher.new([(Quickdraw.getwd/'theme').to_s, (Quickdraw.getwd/'src').to_s]).watch(0.5) do |asset, event|
175
- asset = asset.as_path
176
- if(event == :changed)
177
- if theme_file?(asset)
178
- say("UPLOADING: #{asset.relative_to(Quickdraw.getwd)}", :green)
179
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
180
- elsif src_file?(asset)
181
- say("COMPILING: #{asset.relative_to(Quickdraw.getwd)}", :green)
182
- futures << Celluloid::Actor[:shopify_connector].future.compile_asset(asset)
183
- end
184
- end
185
- if(event == :delete)
186
- if theme_file?(asset)
187
- say("REMOVING: #{asset}", :green)
188
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset)
189
- else
190
- end
191
- end
192
- if(event == :new)
193
- if theme_file?(asset)
194
- say("ADDING: #{asset}", :green)
195
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
196
- else
197
- end
198
- end
199
- end
200
-
201
- loop do
202
-
203
- futures.each do |future|
204
- asset, response = future.value
205
- if response
206
- unless response.success?
207
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: #{asset.relative_to(Quickdraw.getwd)} Failed", :red)
208
- end
209
- else
210
- say("Compiled: #{asset.relative_to(Quickdraw.getwd)}")
211
- end
212
- futures.delete(future)
213
- end
214
-
215
- sleep 0.2
216
- end
217
-
218
- rescue => e
219
- puts e.message
220
- puts e.backtrace
221
- retry
222
- puts "exiting...."
223
- end
224
-
225
- private
226
-
227
- def errors_from_response(response)
228
- return unless response.parsed_response
229
-
230
- errors = response.parsed_response["errors"]
231
-
232
- case errors
233
- when NilClass
234
- ''
235
- when String
236
- errors
237
- else
238
- errors.values.join(", ")
239
- end
240
- end
241
-
242
- def theme_file?(asset)
243
- asset.as_path.relative_to(Quickdraw.getwd).to_s[/^theme\//]
244
- end
245
-
246
- def src_file?(asset)
247
- asset.as_path.relative_to(Quickdraw.getwd).to_s[/^src\//]
248
- end
249
-
250
- end
251
- end
@@ -1,105 +0,0 @@
1
-
2
- require 'httparty'
3
- require 'celluloid'
4
- require 'pathname'
5
- require 'filepath'
6
-
7
- module Quickdraw
8
- class ShopifyConnector
9
- include Celluloid
10
-
11
- NOOPParser = Proc.new {|data, format| {} }
12
- BINARY_EXTENSIONS = %w(png gif jpg jpeg eot svg ttf woff otf swf ico)
13
- IGNORE = %w(config.yml)
14
- DEFAULT_WHITELIST = %w(layout/ assets/ config/ snippets/ templates/)
15
- TIMEFORMAT = "%H:%M:%S"
16
-
17
- def initialize
18
- @config = Quickdraw.config
19
- @auth = {:username => @config[:api_key], :password => @config[:password]}
20
- end
21
-
22
- def get_asset_list(options={})
23
- options.merge!({:parser => NOOPParser})
24
- response = Celluloid::Actor[:shopify_connector_pool].request(:get, "https://#{@config[:store]}/admin/themes/#{@config[:theme_id]}/assets.json", options)
25
-
26
- if JSON.parse(response.body)["assets"]
27
- return JSON.parse(response.body)["assets"].collect {|a| a['key'] }
28
- end
29
-
30
- return nil
31
- end
32
-
33
- def upload_asset(asset)
34
- time = Time.now
35
- data = {:key => asset.relative_to(Quickdraw.theme_dir).to_s}
36
-
37
- content = File.read(asset)
38
- if BINARY_EXTENSIONS.include?(File.extname(asset).gsub('.','')) || is_binary_data?(content)
39
- content = File.open(asset, "rb") { |io| io.read }
40
- data.merge!(:attachment => Base64.encode64(content))
41
- else
42
- data.merge!(:value => content)
43
- end
44
-
45
- data = {:body => {:asset => data}}
46
-
47
- response = Celluloid::Actor[:shopify_connector_pool].request(:put, "https://#{@config[:store]}/admin/themes/#{@config[:theme_id]}/assets.json", data)
48
-
49
- return [asset, response]
50
- end
51
-
52
- def download_asset(asset, options={})
53
- options.merge!({:query => {:asset => {:key => asset.relative_to(Quickdraw.theme_dir).to_s}}, :parser => NOOPParser})
54
-
55
- response = Celluloid::Actor[:shopify_connector_pool].request(:get, "https://#{@config[:store]}/admin/themes/#{@config[:theme_id]}/assets.json", options)
56
-
57
- # HTTParty json parsing is broken?
58
- data = response.code == 200 ? JSON.parse(response.body)["asset"] : {}
59
- data['response'] = response
60
-
61
- if data['value']
62
- # For CRLF line endings
63
- content = data['value'].gsub("\r", "")
64
- format = "w"
65
- elsif data['attachment']
66
- content = Base64.decode64(data['attachment'])
67
- format = "w+b"
68
- end
69
-
70
- FileUtils.mkdir_p(File.dirname(asset))
71
- File.open(asset, format) {|f| f.write content} if content
72
-
73
- return [asset, response]
74
- end
75
-
76
- def remove_asset(asset, options={})
77
- options.merge!({:body => {:asset => {:key => asset.relative_to(Quickdraw.theme_dir).to_s}}})
78
-
79
- response = Celluloid::Actor[:shopify_connector_pool].request(:delete, "https://#{@config[:store]}/admin/themes/#{@config[:theme_id]}/assets.json", options)
80
-
81
- return [asset, response]
82
- end
83
-
84
- def is_binary_data?(string)
85
- if string.respond_to?(:encoding)
86
- string.encoding == "US-ASCII"
87
- else
88
- ( string.count( "^ -~", "^\r\n" ).fdiv(string.size) > 0.3 || string.index( "\x00" ) ) unless string.empty?
89
- end
90
- end
91
-
92
- def compile_asset(asset)
93
- if File.exists?(asset.to_s)
94
- target_asset = "theme/#{asset.relative_to(Quickdraw.src_dir).to_s.gsub('.erb', '')}"
95
- template = ERB.new(File.read(asset))
96
- File.write("#{target_asset}", template.result)
97
- end
98
-
99
- return [asset, nil]
100
- end
101
-
102
- end
103
-
104
- ShopifyConnector.supervise_as(:shopify_connector)
105
- end
@@ -1,54 +0,0 @@
1
-
2
- require 'httparty'
3
- require 'celluloid'
4
- require 'filepath'
5
-
6
- module Quickdraw
7
- class ShopifyConnectorPool
8
- include HTTParty
9
- include Celluloid
10
-
11
- def initialize
12
- @config = Quickdraw.config
13
- @auth = {:username => @config[:api_key], :password => @config[:password]}
14
- end
15
-
16
- def request(call_type, path, options)
17
- options.merge!({:basic_auth => @auth})
18
-
19
- begin
20
- tries ||= 3
21
-
22
- response = HTTParty.send(call_type, path, options)
23
-
24
- if response.code == 429
25
- tries += 1
26
- puts "Too fast for Shopify! Retrying..."
27
- raise "Slow down!"
28
- end
29
-
30
- if response.code == 403
31
- tries == 0
32
- raise "Forbidden"
33
- end
34
-
35
- if response.code != 200
36
- puts response.inspect
37
- raise "Request Failed"
38
- end
39
-
40
- rescue => e
41
- tries -= 1
42
- if tries > 0
43
- sleep 1
44
- retry
45
- end
46
- end
47
-
48
- return response
49
- end
50
-
51
- end
52
-
53
- Celluloid::Actor[:shopify_connector_pool] = ShopifyConnectorPool.pool(:size => 24)
54
- end
data/quickdraw.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'quickdraw/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "quickdraw"
8
- spec.version = Quickdraw::VERSION
9
- spec.authors = ["Bryan Morris"]
10
- spec.email = ["bryan@internalfx.com"]
11
- spec.description = %q{Quickly develop Shopify themes}
12
- spec.summary = %q{Allows the use of ERB templates to develop and "compile" a theme and then automatically deploy to Shopify}
13
- spec.homepage = "https://github.com/internalfx/quickdraw"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake", "~> 10"
23
-
24
- spec.add_runtime_dependency "thor", "~> 0.18"
25
- spec.add_runtime_dependency "filewatcher", "~> 0.3"
26
- spec.add_runtime_dependency "celluloid", "~> 0.15"
27
- spec.add_runtime_dependency "httparty", "~> 0.12"
28
- spec.add_runtime_dependency "filepath", "~> 0.6"
29
- end