Class: LocalShopifyApp
Instance Attribute Summary
#path
Instance Method Summary
collapse
#initialize
Instance Method Details
#data ⇒ Object
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/shopifydev/pry/commands.rb', line 209
def data
@data ||= begin
data = {}
if Pathname(path).expand_path == Pathname.getwd
url_column = 'myshopify_domain'
url_column = 'domain' unless ::Shop.column_names.include?(url_column)
url_column = 'url' unless ::Shop.column_names.include?(url_column)
data = {
'shops' => ::Shop.select("id,#{url_column},token").all.map(&:attributes),
'url_column' => url_column
}
else
json = `/bin/bash -l -c "unset BUNDLE_GEMFILE; cd #{path} 2> /dev/null; bundle exec rake shops 2>/dev/null"`
json = json.split("----snip----\n").last
json = json.split("\n").last
data = Oj.load(json)
end
unless data['url_column'] == 'url'
data['shops'].each{|shop| shop['url'] = shop[data['url_column']]}
end
data
end
end
|
#refresh! ⇒ Object
197
198
199
|
# File 'lib/shopifydev/pry/commands.rb', line 197
def refresh!
@data = nil
end
|
#shops ⇒ Object
205
206
207
|
# File 'lib/shopifydev/pry/commands.rb', line 205
def shops
data['shops']
end
|
#url_column ⇒ Object
201
202
203
|
# File 'lib/shopifydev/pry/commands.rb', line 201
def url_column
data['url_column']
end
|