shopifydev 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTQxYmJjYTU1Zjg1N2UzM2I4NGQ4YmM5ODk0ODY5Nzk0MmY2YTk4NA==
5
- data.tar.gz: !binary |-
6
- MjcxMTgxOWE2ZDNlOTcxOWRhMjYxN2I1YmMwYWYyY2I1MzA4YWFiMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MDY3MjhhOTJlYjA2MzI5YzM3YzQyZDhjZjc4YTQzNGZkODFkZWRkYWZjNzhi
10
- ZWY5MDdkNzgzOWIwNjhlZGI2NjY5ZTIzOTFhNWZkOGExNGYxOGMzYTAxNjc5
11
- M2QzOWJhZTExY2FkMTk0YWM0MGUyNTY3YTlkODNlY2M5YzViNmM=
12
- data.tar.gz: !binary |-
13
- NWJkMTc1NWIxMjc0NDFjYWUwNTA0ZTg3MTAwMzE5YjMzMDAyZmI2YjQxZGEx
14
- NjkzNTg5NDE0MzMwN2VmODgwMjA0MzY4OGZiOTQ3NTZlNGFmZGMwNjZhYzdi
15
- NWNlZDM4YjBhMDQ2ODgxNDMzNGRlOWExNGRjYmNlMTA0NTJhZTg=
2
+ SHA1:
3
+ metadata.gz: d3a379f60e7afc95834823f896746678afd4f905
4
+ data.tar.gz: 7d7108f548752db32fc5cbcceb2e954431004723
5
+ SHA512:
6
+ metadata.gz: 719025171d807948b814a8b9a40e922d6c9a09584cd7a0a887761b29eaf094442feb82055b87bd73fc0e8a1c62fe35c8efd7ec4b57b4b3447dcb052f8281dac6
7
+ data.tar.gz: 2ec654364cbb14d18ca5a074c8bd5b1d81d8acd9288e37762f5c1c8123e09de42f19540e839c8748de67bb0a50b236dbc7c598ab16939d586a3b970204d52fd6
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3
1
+ ruby-2.1.0
@@ -6,7 +6,7 @@ module Shopifydev
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
 
8
8
  def generate_product_cache
9
- generate 'model ProductCache shop:references shopify_product_id:integer shopify_title:string shopify_handle:string shopify_product_type:string shopify_vendor:string shopify_updated_at:datetime'
9
+ generate 'migration ProductCache shop:references shopify_product_id:integer shopify_title:string shopify_handle:string shopify_product_type:string shopify_vendor:string shopify_updated_at:datetime'
10
10
  end
11
11
 
12
12
  def generate_worker
@@ -0,0 +1,33 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Shopifydev
4
+ class ProductUiGenerator < Rails::Generators::Base
5
+ desc "Creates a UI for editing product list (via ProductCache). Provides partials for adding custom fields."
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def generate_views
9
+ template "views/product_caches/_app_fields_header.html.slim", "app/views/product_caches/_app_fields_header.html.slim"
10
+ template "views/product_caches/_app_fields.html.slim", "app/views/product_caches/_app_fields.html.slim"
11
+ template "views/product_caches/index.html.slim", "app/views/product_caches/index.html.slim"
12
+ end
13
+
14
+ def generate_controller
15
+ template "controllers/product_caches_controller.rb", "app/controllers/product_caches_controller.rb"
16
+ end
17
+
18
+ def add_inline_error_helper
19
+ template "helpers/inline_error_helper.rb", "app/helpers/inline_error_helper.rb"
20
+ end
21
+
22
+ def routes
23
+ route %Q{
24
+ resources :product_caches, only: [:index] do
25
+ collection do
26
+ get 'page/:page', action: :index
27
+ put 'update_multiple'
28
+ end
29
+ end
30
+ }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ class ProductCachesController < ApplicationController
2
+ around_filter :shopify_session
3
+
4
+ # GET /product_caches
5
+ # GET /product_caches.json
6
+ def index
7
+ @jid = ProductCacheUpdater.perform_async(current_shop.id)
8
+ params[:page] = 1 if params[:page] == ""
9
+ current_shop.product_caches.page params[:page]
10
+ end
11
+
12
+ # PATCH/PUT /product_caches/update_multiple
13
+ def update_multiple
14
+
15
+ @product_caches = current_shop.product_caches.update(
16
+ params[:product_caches].keys,
17
+ permitted_params(params[:product_caches].values)
18
+ ).reject { |p| p.errors.empty? }
19
+ if @product_caches.empty?
20
+ flash[:success] = "Products updated"
21
+ redirect_to product_caches_page_path(page: params[:page])
22
+ else
23
+ flash.now[:error] = "The following entries had errors:"
24
+ @product_caches = []
25
+ render :index
26
+ end
27
+ end
28
+
29
+ # GET
30
+ def status
31
+ data = Sidekiq::Status::get_all(params[:jid])
32
+ data[:created_ids] = data[:created_ids].split(',')
33
+ data[:updated_ids] = data[:updated_ids].split(',')
34
+ data[:status] = case data[:status]
35
+ when 'queued', 'working'
36
+ 'updating cache...'
37
+ else
38
+ 'product cache updated'
39
+ end
40
+ render json: data.to_json
41
+ end
42
+
43
+ private
44
+
45
+ # Never trust parameters from the scary internet, only allow the white list through.
46
+ def product_caches_params(arr)
47
+ arr.map{|h| h.permit(:custom, :fields)}
48
+ end
49
+ end
@@ -0,0 +1,6 @@
1
+ module InlineErrorHelper
2
+ def inline_error(obj, attr)
3
+ return "" if obj.nil? || obj.errors[attr].empty
4
+ content_tag(:small, obj.errors[attr].join(', '), class: 'error')
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ / shopify_handle is used as example so empty ui doesn't cause error
2
+ td
3
+ = f.text_field(:shopify_handle, class: "radius")
4
+ = inline_error(product_cache, :shopify_handle) if show_errors
@@ -0,0 +1,64 @@
1
+ - title "Products"
2
+ - show_errors = @product_caches.empty?
3
+ = paginate(@product_caches) unless show_errors
4
+ #product-status.alert.secondary.round Updating...
5
+ = form_tag update_multiple_product_caches_path, method: :put
6
+ = hidden_field_tag 'page', params[:page]
7
+ table.product-caches-list
8
+ thead
9
+ tr
10
+ th Shopify ID
11
+ th Product
12
+ == render 'app_fields_header'
13
+ tbody
14
+ - @product_caches.each do |product_cache|
15
+ = fields_for "product_caches[]", product_cache do |f|
16
+ tr class="#{product_cache.errors.empty? ? 'valid' : 'error'}"
17
+ td.text-cell = product_cache.shopify_product_id
18
+ td.text-cell = product_cache.shopify_title
19
+ == render 'app_fields'
20
+ tr
21
+ td colspan='3'
22
+ ul.button-group.radius.right
23
+ - if @product_caches.empty?
24
+ = link_to "Cancel", product_caches_path(page: params[:page]), class: "button secondary"
25
+ = submit_tag "Save All", class: 'button'
26
+
27
+ = paginate(@product_caches) unless show_errors
28
+ javascript:
29
+ $('#product-status').on('click', function(){
30
+ var elm = $(this);
31
+ $.ajax({
32
+ type: 'GET',
33
+ url: '/product_caches/update_status',
34
+ data: {jid: elm.data('jid')},
35
+ statusCode: {
36
+ 206: function(){
37
+ setTimeout(function(){
38
+ elm.trigger('click'), 2000
39
+ })
40
+ }
41
+ }
42
+ })
43
+ .done(function(data){
44
+ var h = data.status;
45
+ var warn = false;
46
+ if( data.created_ids.length > 0 ) {
47
+ h += " "+data.created_ids.length+" new"
48
+ warn = true;
49
+ }
50
+ if( data.updated_ids.length > 0 ) {
51
+ h += " "+data.updated_ids.length+" changed"
52
+ warn = true;
53
+ }
54
+ if( warn ) {
55
+ elm.removeClass('secondary');
56
+ elm.addClass('warning')
57
+ }
58
+ elm.html(h);
59
+ })
60
+ })
61
+
62
+ $(function () {
63
+ $('#product-status').trigger('click');
64
+ });
@@ -119,7 +119,7 @@ EOF
119
119
  obj.r(msg)
120
120
  elsif (obj.params != opts)
121
121
  msg = "reloading #{entity.collection_name} with new params..."
122
- obj.params = opts
122
+ obj.params = opts.merge({limit: false})
123
123
  obj.r(msg)
124
124
  end
125
125
  obj
@@ -1,3 +1,3 @@
1
1
  module Shopifydev
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,223 +1,223 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopifydev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Johnston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-19 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activeresource
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shopify_api
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 3.0.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.0.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ruby-filemagic
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.4.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.4.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: gli
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.5.2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.5.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: oj
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: dalli
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: shydra
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: shopify_unlimited
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: pry
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ! '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ! '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: term-ansicolor
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ! '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ! '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ! '>='
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: ffaker
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ! '>='
213
+ - - ">="
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ! '>='
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  description: Abstracts out and port to ruby the functionality of the shopify textmate
@@ -232,11 +232,11 @@ executables:
232
232
  extensions: []
233
233
  extra_rdoc_files: []
234
234
  files:
235
- - .gitignore
236
- - .pryrc
237
- - .root.shopifydev.yaml.sample
238
- - .ruby-version
239
- - .shopifydev.yaml.sample
235
+ - ".gitignore"
236
+ - ".pryrc"
237
+ - ".root.shopifydev.yaml.sample"
238
+ - ".ruby-version"
239
+ - ".shopifydev.yaml.sample"
240
240
  - Gemfile
241
241
  - LICENSE.txt
242
242
  - NEXTSTEPS.md
@@ -245,11 +245,18 @@ files:
245
245
  - bin/shopify_console
246
246
  - bin/shopifydev
247
247
  - lib/rails/generators/shopifydev/product_cache_generator.rb
248
+ - lib/rails/generators/shopifydev/product_ui_generator.rb
248
249
  - lib/rails/generators/shopifydev/shops_generator.rb
249
250
  - lib/rails/generators/shopifydev/templates/cache_job_migration.rb
251
+ - lib/rails/generators/shopifydev/templates/config/initializers/inflections.rb
252
+ - lib/rails/generators/shopifydev/templates/config/initializers/sidekiq_status.rb
253
+ - lib/rails/generators/shopifydev/templates/controllers/product_caches_controller.rb
254
+ - lib/rails/generators/shopifydev/templates/helpers/inline_error_helper.rb
250
255
  - lib/rails/generators/shopifydev/templates/product_cache_updater.rb
251
256
  - lib/rails/generators/shopifydev/templates/shops.rake
252
- - lib/rails/generators/shopifydev/templates/sidekiq_status_initializer.rb
257
+ - lib/rails/generators/shopifydev/templates/views/product_caches/_app_fields.html.slim
258
+ - lib/rails/generators/shopifydev/templates/views/product_caches/_app_fields_header.html.slim
259
+ - lib/rails/generators/shopifydev/templates/views/product_caches/index.html.slim
253
260
  - lib/rails/tasks/shops.rake
254
261
  - lib/shopifydev.rb
255
262
  - lib/shopifydev/asset.rb
@@ -289,17 +296,17 @@ require_paths:
289
296
  - lib
290
297
  required_ruby_version: !ruby/object:Gem::Requirement
291
298
  requirements:
292
- - - ! '>='
299
+ - - ">="
293
300
  - !ruby/object:Gem::Version
294
301
  version: '0'
295
302
  required_rubygems_version: !ruby/object:Gem::Requirement
296
303
  requirements:
297
- - - ! '>='
304
+ - - ">="
298
305
  - !ruby/object:Gem::Version
299
306
  version: '0'
300
307
  requirements: []
301
308
  rubyforge_project:
302
- rubygems_version: 2.0.6
309
+ rubygems_version: 2.2.2
303
310
  signing_key:
304
311
  specification_version: 4
305
312
  summary: Tools for using SCM with shopify. Not Rails 4.0 ready.