shopifydev 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/NEXTSTEPS.md CHANGED
@@ -1,4 +1,4 @@
1
- # switch command
1
+ # switch command
2
2
 
3
3
  Z(2013.06.06):
4
4
  M, I think you should work on memoizing the shop array and the 'refresh'
@@ -123,3 +123,8 @@ https://github.com/cldwalker/bond
123
123
  # Using pry features
124
124
  https://github.com/ConradIrwin/pry-rescue -- we **really** want to be using this in test/development environments in rails apps.
125
125
  https://github.com/envygeeks/pry-vterm_aliases
126
+
127
+
128
+
129
+ # Switch should reload last client. If it has been less than 30 minutes, automatically. If it has been more than 30 minutes, ask [y/n/s]
130
+
@@ -1,7 +1,35 @@
1
1
  require 'active_support/core_ext/hash'
2
+ require 'singleton'
2
3
 
3
4
  module Shopifydev
4
5
  module Config
6
+ class Data
7
+ include Singleton
8
+
9
+ def datafilepath
10
+ File.expand_path('~/.shopifydev.data')
11
+ end
12
+
13
+ def write
14
+ File.open(datafilepath, 'w'){ |f| YAML.dump(data, f) }
15
+ end
16
+
17
+ def data
18
+ data ||= YAML::load(File.open(
19
+ datafilepath
20
+ )).with_indifferent_access
21
+ end
22
+
23
+ def []=(key,value)
24
+ data[key] = value
25
+ write
26
+ end
27
+
28
+ def [](key)
29
+ data[key]
30
+ end
31
+ end
32
+
5
33
  def self.config
6
34
  YAML::load(File.open(File.expand_path('~/.shopifydev.yaml'))).with_indifferent_access
7
35
  end
@@ -5,20 +5,25 @@ module Shopifydev
5
5
  extend ::Faker::ModuleUtils
6
6
  extend self
7
7
 
8
+ NL = "\n"
9
+
8
10
 
9
11
  def metafield(owner=nil, opts={})
10
12
  owner_resource = owner && owner.class.element_name
11
13
  owner_id = owner && owner.id
12
14
  metafield = ::ShopifyAPI::Metafield.new(
13
15
  {
14
- owner_resource: owner_resource,
15
- owner_id: owner_id,
16
16
  namespace: opts[:namespace] || namespace,
17
17
  key: opts[:key] || key,
18
18
  value_type: 'string',
19
19
  value: opts[:value] || value
20
20
  }
21
21
  )
22
+ unless owner.is_a?(::ShopifyAPI::Shop)
23
+ metafield.owner_resource = owner_resource
24
+ metafield.owner_id = owner_id
25
+ end
26
+
22
27
  metafield.save! if owner_id
23
28
  metafield
24
29
  end
@@ -38,12 +43,51 @@ module Shopifydev
38
43
  end
39
44
 
40
45
  def key
41
- ::Faker::Lorem.word.downcase
46
+ k = ""
47
+ while((k = ::Faker::Lorem.word).length < 3);end
48
+ k.downcase
42
49
  end
43
50
 
44
51
  def value
45
- ::Faker::Lorem.sentence(rand(10))
52
+ ::Faker::Lorem.sentence(rand(10) + 1)
46
53
  end
47
54
 
55
+ def csv_value
56
+ value.gsub('"','').gsub(',', '')[0..-2]
57
+ end
58
+
59
+ def metafield_import_csv(resources, opts={})
60
+ opts[:import_type] ||= :product_variant_sku
61
+ opts[:num] ||= 1
62
+ opts[:namespace] ||= namespace
63
+
64
+ out = ""
65
+
66
+ case opts[:import_type]
67
+ when :owner_resource
68
+ when :product_handle
69
+ when :product_variant_sku
70
+ when :product_variant_multikey
71
+ out = %w{sku namespace}
72
+ out += opts[:keys]
73
+ out = out.join(',')
74
+ out << NL
75
+
76
+ resources.each do |resource|
77
+ line = [resource.sku, opts[:namespace]]
78
+ values = opts[:values]
79
+ values ||= [csv_value]
80
+ values = [values].flatten
81
+ while(values.length < opts[:num]); values << csv_value; end
82
+ line += values
83
+ out << line.join(',')
84
+ out << NL
85
+ end
86
+ else
87
+ raise "don't know how to create import csv for #{opts[:type].to_s}"
88
+ end
89
+
90
+ out
91
+ end
48
92
  end
49
93
  end
@@ -355,6 +355,7 @@ shopifydev_command_set = Pry::CommandSet.new do
355
355
  puts result
356
356
  _pry_.switch.reset!
357
357
  when (args.length == 1)
358
+ _pry_.switch.reset! # reset to the first menu page
358
359
  ix = args.first.to_i
359
360
  output.puts _pry_.switch.pick(ix)
360
361
  end
@@ -1,12 +1,8 @@
1
1
  module Shopifydev
2
2
  module ShopifyAPI
3
3
  module DirtyCache
4
- def dirty!
5
- ShopifyAPI.dirty!
6
- end
7
-
8
4
  def site=(uri)
9
- ShopifyAPI.dirty!
5
+ ::ShopifyAPI.dirty!
10
6
  super uri
11
7
  end
12
8
  end
@@ -15,7 +11,8 @@ end
15
11
 
16
12
  module ShopifyAPI
17
13
  class Base
18
- include Shopifydev::ShopifyAPI::DirtyCache
14
+ puts "include Shopifydev::ShopifyAPI::DirtyCache"
15
+ extend Shopifydev::ShopifyAPI::DirtyCache
19
16
  end
20
17
  end
21
18
 
@@ -1,3 +1,3 @@
1
1
  module Shopifydev
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/shopifydev.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |gem|
36
36
  gem.add_dependency 'oj'
37
37
  gem.add_dependency 'dalli'
38
38
  gem.add_dependency 'shydra'
39
+ gem.add_dependency 'shopify_unlimited'
39
40
  gem.add_dependency 'pry'
40
41
  gem.add_dependency 'term-ansicolor'
41
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopifydev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -171,6 +171,22 @@ dependencies:
171
171
  - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: shopify_unlimited
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :runtime
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
174
190
  - !ruby/object:Gem::Dependency
175
191
  name: pry
176
192
  requirement: !ruby/object:Gem::Requirement
@@ -304,7 +320,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
304
320
  version: '0'
305
321
  segments:
306
322
  - 0
307
- hash: -600776122306853732
323
+ hash: 3004059551718716320
308
324
  required_rubygems_version: !ruby/object:Gem::Requirement
309
325
  none: false
310
326
  requirements:
@@ -313,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
329
  version: '0'
314
330
  segments:
315
331
  - 0
316
- hash: -600776122306853732
332
+ hash: 3004059551718716320
317
333
  requirements: []
318
334
  rubyforge_project:
319
335
  rubygems_version: 1.8.25