Class: LocalShopifyApp

Inherits:
ShopifyAppShopList show all
Defined in:
lib/shopifydev/pry/commands.rb

Instance Attribute Summary

Attributes inherited from ShopifyAppShopList

#path

Instance Method Summary collapse

Methods inherited from ShopifyAppShopList

#initialize

Constructor Details

This class inherits a constructor from ShopifyAppShopList

Instance Method Details

#dataObject



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)
      # TODO: this should go away when we refactor into objects, since the app object will know what it's url_column is and be responsible for shop data
    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

#shopsObject



205
206
207
# File 'lib/shopifydev/pry/commands.rb', line 205

def shops
  data['shops']
end

#url_columnObject



201
202
203
# File 'lib/shopifydev/pry/commands.rb', line 201

def url_column
  data['url_column']
end