quickdraw 0.0.4 → 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 +104 -20
  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 +54 -126
  39. data/.gitignore +0 -17
  40. data/Rakefile +0 -1
  41. data/bin/quickdraw +0 -25
  42. data/lib/quickdraw/cli.rb +0 -240
  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,157 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickdraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
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: 2013-12-27 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: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
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'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: listen
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
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'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
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'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
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'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
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
120
- - .ruby-version
21
+ - ".rubocop.yml"
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: ''
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
140
70
  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.1.11
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,240 +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 'listen'
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('theme')
34
- end
35
-
36
- desc "upload FILES", "upload all theme assets to shop"
37
- def upload(filter=nil)
38
-
39
- if filter
40
- assets = (FilePath.getwd / 'theme').files(true).select{ |i|
41
- i.relative_to(Quickdraw.theme_dir).to_s[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/]
42
- }
43
- else
44
- assets = (FilePath.getwd / 'theme').files(true)
45
- end
46
-
47
- futures = []
48
- assets.each do |asset|
49
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
50
- end
51
- futures.each do |future|
52
- asset, response = future.value
53
- if response.success?
54
- say("Uploaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
55
- else
56
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not upload #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
57
- end
58
- end
59
-
60
- say("Done.", :green)
61
- end
62
-
63
- desc "download FILES", "download the shops current theme assets"
64
- def download(filter=nil)
65
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
66
-
67
- if filter
68
- assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| FilePath.getwd / 'theme' / a }
69
- else
70
- assets = asset_list.map{|a| FilePath.getwd / 'theme' / a }
71
- end
72
-
73
- futures = []
74
- assets.each do |asset|
75
- futures << Celluloid::Actor[:shopify_connector].future.download_asset(asset)
76
- end
77
- futures.each do |future|
78
- asset, response = future.value
79
- if response.success?
80
- say("Downloaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
81
- else
82
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not download #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
83
- end
84
- end
85
- say("Done.", :green)
86
- end
87
-
88
- desc "replace FILES", "completely replace shop theme assets with local theme assets"
89
- def replace(filter=nil)
90
- say("Are you sure you want to completely replace your shop theme assets? This is not undoable.", :yellow)
91
- if ask("Continue? (y/n): ") == "y"
92
- # only delete files on remote that are not present locally
93
- # files present on remote and present locally get overridden anyway
94
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
95
-
96
- if filter
97
- remote_assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| (FilePath.getwd / 'theme' / a) }
98
- else
99
- remote_assets = asset_list.map{|a| (FilePath.getwd / 'theme' / a) }
100
- end
101
-
102
- if filter
103
- local_assets = (FilePath.getwd / 'theme').files(true).select{ |i| i.relative_to(Quickdraw.theme_dir).to_s[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }
104
- else
105
- local_assets = (FilePath.getwd / 'theme').files(true)
106
- end
107
-
108
- remote_only_assets = remote_assets.to_a.map{|p| p.to_s} - local_assets.to_a.map{|p| p.to_s}
109
-
110
- futures = []
111
- remote_only_assets.each do |asset|
112
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset.as_path)
113
- end
114
- local_assets.each do |asset|
115
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
116
- end
117
- futures.each do |future|
118
- asset, response = future.value
119
- if response.success?
120
- if response.request.http_method.to_s == "Net::HTTP::Put"
121
- say("Uploaded: #{asset.relative_to(Quickdraw.getwd)}", :green)
122
- else
123
- say("Removed: #{asset.relative_to(Quickdraw.getwd)}", :green)
124
- end
125
- else
126
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not download #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
127
- end
128
- end
129
- say("Done.", :green) unless options['quiet']
130
- end
131
- end
132
-
133
- desc "remove FILES", "remove theme asset"
134
- def remove(filter=nil)
135
- asset_list = Celluloid::Actor[:shopify_connector].get_asset_list
136
-
137
- if filter
138
- assets = asset_list.select{ |i| i[/^#{filter.gsub(/[^a-z0-9A-Z\/]/, '')}/] }.map{|a| FilePath.getwd / 'theme' / a }
139
- else
140
- assets = asset_list.map{|a| FilePath.getwd / 'theme' / a }
141
- end
142
-
143
- futures = []
144
- assets.each do |asset|
145
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset)
146
- end
147
- futures.each do |future|
148
- asset, response = future.value
149
- if response.success?
150
- say("Deleted: #{asset.relative_to(Quickdraw.getwd)}", :green)
151
- else
152
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: Could not remove #{asset.relative_to(Quickdraw.getwd)}. #{errors_from_response(response)}\n", :red)
153
- end
154
- end
155
- say("Done.", :green) unless options['quiet']
156
- end
157
-
158
- desc "watch", "compile then upload or delete individual theme assets as they change."
159
- def watch
160
- puts "Watching current folder: #{Dir.pwd}"
161
-
162
- futures = []
163
-
164
- listener = Listen.to((Quickdraw.getwd/'theme').to_s, (Quickdraw.getwd/'src').to_s, :force_polling => true, :latency => 0.2 ) do |modified, added, removed|
165
- modified.each do |asset|
166
- asset = asset.as_path
167
- say("MODIFIED: #{asset.relative_to(Quickdraw.getwd)}", :green)
168
- if theme_file?(asset)
169
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
170
- elsif src_file?(asset)
171
- futures << Celluloid::Actor[:shopify_connector].future.compile_asset(asset)
172
- end
173
- end
174
- added.each do |asset|
175
- asset = asset.as_path
176
- say("ADDED: #{asset}", :green)
177
- if theme_file?(asset)
178
- futures << Celluloid::Actor[:shopify_connector].future.upload_asset(asset)
179
- else
180
- end
181
- end
182
- removed.each do |asset|
183
- asset = asset.as_path
184
- say("REMOVED: #{asset}", :green)
185
- if theme_file?(asset)
186
- futures << Celluloid::Actor[:shopify_connector].future.remove_asset(asset)
187
- else
188
- end
189
- end
190
- end
191
- listener.start
192
-
193
- loop do
194
-
195
- futures.each do |future|
196
- asset, response = future.value
197
- if response
198
- unless response.success?
199
- say("[" + Time.now.strftime(TIMEFORMAT) + "] Error: #{asset.relative_to(Quickdraw.getwd)} Failed", :red)
200
- end
201
- else
202
- say("Compiled: #{asset.relative_to(Quickdraw.getwd)}")
203
- end
204
- futures.delete(future)
205
- end
206
-
207
- sleep 0.2
208
- end
209
-
210
- rescue
211
- puts "exiting...."
212
- end
213
-
214
- private
215
-
216
- def errors_from_response(response)
217
- return unless response.parsed_response
218
-
219
- errors = response.parsed_response["errors"]
220
-
221
- case errors
222
- when NilClass
223
- ''
224
- when String
225
- errors
226
- else
227
- errors.values.join(", ")
228
- end
229
- end
230
-
231
- def theme_file?(asset)
232
- asset.as_path.relative_to(Quickdraw.getwd).to_s[/^theme\//]
233
- end
234
-
235
- def src_file?(asset)
236
- asset.as_path.relative_to(Quickdraw.getwd).to_s[/^src\//]
237
- end
238
-
239
- end
240
- 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 = ""
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"
23
-
24
- spec.add_runtime_dependency "thor"
25
- spec.add_runtime_dependency "listen"
26
- spec.add_runtime_dependency "celluloid"
27
- spec.add_runtime_dependency "httparty"
28
- spec.add_runtime_dependency "filepath"
29
- end