shopifydev 0.0.19 → 0.0.20

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDg5ZDEzNWNiYWMyZmExY2Y0N2U3OWFkOTE1NzlmMzFjMjc3MTQ5Ng==
4
+ Mzk3YTFjNzhmNjJhZTU4MTI4MGEwYmZmZmExN2Q3ZGYwN2FkZjk4MA==
5
5
  data.tar.gz: !binary |-
6
- NzExYzg2OGIwM2M5MDg1NWFjNTdmMzMwOTcxNGQ2NWUwOTliMGU5Mw==
6
+ ZDQxZThmZGJiYWRlNWEyZjc2NzA0MTkxMmZjNzYzNjhhNDMwMjM4ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2ZhM2M2Y2RiNTc3OTE5N2JiZTY0ODM0YTlkNGIwMGI3MmNiYmM0NTc0ZGFi
10
- NTNhOWE5NzY1OWUxNWVlNzBhZTRiMDU0ZWEyMjcwZjI4NzcyNjU2Y2I5ZmYy
11
- MmE5MzAxNDkyZjRlOTVlYWZkMWUyMDY5MTRiNjc3OTZiNDBhNzE=
9
+ Yzg3N2YxMmYzODY2ZGYxY2QyYWU2ZWQ2OWI2OWQ3MDgwMWY4ODg4MTNhMmRh
10
+ OTdkYWI2ZGJjYWU0NzIyNGNlYTIzNjA2MGQ5ODVkOWNlMGQ2YTYwNjNlMGJi
11
+ NDRlN2RkNjUwY2Q0N2NhZGFhMmJkODY3Nzk4NzBlMDI5MmFhODI=
12
12
  data.tar.gz: !binary |-
13
- NDRkOGMzMjdkODJmZGVjZmEzODljYjE2ZmMyMDAzMGRiNWNmZTFjMjIyNTMy
14
- OTYwYzRmZDI0ODFiOTY5ZGE0MWJiYzE1ZGZhZTg5YTE4YzIxNDZiZGUwNmQ3
15
- ZGJjYzk4ZWNjNWRlZjg1MDRkMGY3N2IwYThkYmQ0ZGU2MjRmMjc=
13
+ NzQzOWRmYWJmMzY3ZDMyZmNhMWVlZmVlYWIyNmQxNTQ5MzM4NzYxNjFmODkz
14
+ OTk1MjJmMzA2N2RjZmFhNzc3MWQ5YzEwNzJjMWY4N2VhZGY1Y2M1MmNhNzJj
15
+ ZWNkYjUzYWVmYTUxYmI2MzZiMmI4NmQyMTc0NzcyZWQwNzg2NzI=
data/README.md CHANGED
@@ -4,7 +4,7 @@ Abstract out and port to ruby the functionality of the shopify textmate bundle f
4
4
 
5
5
  ## Compatibility
6
6
 
7
- shopifydev currently specifically targets **Rails 3.2.13**. This was due to a dependency problem with ```shopify_api``` that arose when Rails 4.0 was released. ASAP, shopifydev will be updated to rails 4.0
7
+ There is a branch of shopifydev that specifically targets **Rails 3.2.13**. This is due to a dependency problem with ```shopify_api``` that arose when Rails 4.0 was released. If you have problems using shopifydev with Rails 3, try using the rails3 branch.
8
8
 
9
9
  ## Installation
10
10
 
@@ -73,8 +73,37 @@ you won't upload a file twice unless it gets changed twice in the same commit)
73
73
 
74
74
  One final tip: `alias upify='shopifydev upload'`
75
75
 
76
- # Caches
76
+ # Rails Console / Pry
77
+ To use shopifydev in the console of a rails app, add the following to your .pryrc:
77
78
 
79
+ require 'shopifydev'
80
+ require 'shopifydev/console'
81
+
82
+
83
+ ## Switch
84
+ The switch command lets you switch between shops in the console. In a rails app, it knows how to look up shops the local rails app knows about (that have been installed) or you can configure it in ```~/.shopifydev.yaml``` thusly:
85
+
86
+ test_shops:
87
+ arbitrary-label:
88
+ api_key: xxx
89
+ password: xxx
90
+ myshopify_domain: weird-autogenerated-name.myshopify.com
91
+ weird2:
92
+ api_key: xxx
93
+ password: xxx
94
+ myshopify_domain: weird-autogenerated-name2.myshopify.com
95
+ apps:
96
+ development:
97
+ app_name1: /path/to/a/rails/app
98
+ app_name1: /path/to/a/rails/app
99
+
100
+ heroku:
101
+ name: heroku-app-name
102
+
103
+ The heroku support may or may not be working currently.
104
+
105
+ ## Caches
106
+ When using pry or rails console in a rails app, shopifydev keeps caches of the current shop's resources.
78
107
  Caches are defined on ```ShopifyAPI```.
79
108
  Assuming you ```cd ShopifyAPI```:
80
109
 
@@ -1,4 +1,13 @@
1
- class Color
1
+ require 'shopifydev/pry/commands'
2
+ require 'shopifydev/pry/save_json'
3
+ require 'shopifydev/shopify_api/caches'
4
+
5
+ require 'term/ansicolor'
6
+
7
+ require 'shydra'
8
+ require 'shydra/hydra'
9
+
10
+ class TColor
2
11
  if Pry.config.color
3
12
  extend Term::ANSIColor
4
13
  else
@@ -10,15 +19,6 @@ class Color
10
19
  end
11
20
  end
12
21
 
13
- require 'shopifydev/pry/commands'
14
- require 'shopifydev/pry/save_json'
15
- require 'shopifydev/shopify_api/caches'
16
-
17
- require 'term/ansicolor'
18
-
19
- require 'shydra'
20
- require 'shydra/hydra'
21
-
22
22
 
23
23
 
24
24
  Pry.config.hooks.add_hook(:before_session, :set_context) { |_, _, pry| pry.input = StringIO.new("cd ShopifyAPI") }
@@ -9,7 +9,7 @@ class Switch
9
9
 
10
10
  def current_shop
11
11
  @current_shop = ShopifyAPI::Base.site || 'none'
12
- Color.green{ "current shop:"} + " #{@current_shop}"
12
+ TColor.green{ "current shop:"} + " #{@current_shop}"
13
13
  end
14
14
 
15
15
  def reset!
@@ -36,7 +36,7 @@ class Switch
36
36
  @breadcrumbs, @cfg = pick_config(ix)
37
37
 
38
38
  if @breadcrumbs == :no_such_config
39
- result << Color.red{ "I don't know about #{ix}\n" }
39
+ result << TColor.red{ "I don't know about #{ix}\n" }
40
40
  result << self.menu.print
41
41
  else
42
42
  # update the menu based on the choice
@@ -90,7 +90,7 @@ class Switch
90
90
  if menu_method
91
91
  result << "you picked #{@breadcrumbs.join('.')}\n"
92
92
  result << @cfg.inspect + "\n"
93
- result << Color.yellow { menu_method.call.print }
93
+ result << TColor.yellow { menu_method.call.print }
94
94
  end
95
95
  result
96
96
  end
@@ -104,7 +104,7 @@ class Switch
104
104
  session.valid? # returns true
105
105
  ShopifyAPI::Base.activate_session(session)
106
106
  when :heroku
107
- puts Color.red{ "can't handle heroku yet"}
107
+ puts TColor.red{ "can't handle heroku yet"}
108
108
  end
109
109
  else
110
110
  ShopifyAPI::Base.clear_session
@@ -279,7 +279,7 @@ class ConfigMenu
279
279
  header("Local Apps")
280
280
  json[:apps][:development].each do |k, path|
281
281
  if Pathname(path).expand_path == Pathname.getwd
282
- path = Color.green{ path }
282
+ path = TColor.green{ path }
283
283
  end
284
284
  choice([:apps, :development, k], path)
285
285
  end
@@ -311,17 +311,17 @@ class ConfigMenu
311
311
  # TODO I think these three related methods could be moved into a module called "Writer" or something
312
312
  def header(label)
313
313
  @lines << ''
314
- @lines << Color.blue { label }
314
+ @lines << TColor.blue { label }
315
315
  end
316
316
 
317
317
  def warn(label)
318
318
  @lines << ''
319
- @lines << Color.red { label }
319
+ @lines << TColor.red { label }
320
320
  end
321
321
 
322
322
  def choice(path, value)
323
323
  ix = @choices.length
324
- @lines << Color.yellow{ ix.to_s } + '. ' + value.to_s
324
+ @lines << TColor.yellow{ ix.to_s } + '. ' + value.to_s
325
325
  @choices[ix] = path
326
326
  end
327
327
  end
@@ -343,9 +343,9 @@ shopifydev_command_set = Pry::CommandSet.new do
343
343
  result = ''
344
344
  until _pry_.switch.finished?
345
345
  output.puts _pry_.switch.menu.print
346
- print "❔ " + Color.yellow
346
+ print "❔ " + TColor.yellow
347
347
  choice = $stdin.gets
348
- print Color.clear
348
+ print TColor.clear
349
349
  if choice.blank?
350
350
  _pry_.switch.reset!
351
351
  else
@@ -366,10 +366,10 @@ shopifydev_command_set = Pry::CommandSet.new do
366
366
  def process
367
367
  case args.first
368
368
  when 'off'
369
- puts Color.black{"ActiveResource logging "} + Color.red{'off'}
369
+ puts TColor.black{"ActiveResource logging "} + TColor.red{'off'}
370
370
  ActiveResource::Base.logger = nil
371
371
  else
372
- puts Color.black{"ActiveResource logging "} + Color.yellow{'on'}
372
+ puts TColor.black{"ActiveResource logging "} + TColor.yellow{'on'}
373
373
  ActiveResource::Base.logger = Logger.new STDOUT
374
374
  end
375
375
  end
@@ -384,9 +384,9 @@ shopifydev_command_set = Pry::CommandSet.new do
384
384
  report = Shopifydev::ShopifyAPI::ConsumeAPI.consume(num) do |report_line|
385
385
  case report_line.level
386
386
  when :info
387
- puts Color.yellow{ report_line.msg }
387
+ puts TColor.yellow{ report_line.msg }
388
388
  when :status
389
- puts Color.blue{ report_line.msg}
389
+ puts TColor.blue{ report_line.msg}
390
390
  else
391
391
  puts report_line.msg
392
392
  end
@@ -6,7 +6,7 @@ module Kernel
6
6
  path = UnixTree.get_path(path, require: :file, new: true)
7
7
  if path
8
8
  path = path.sub_ext('json') unless path.nil?
9
- puts Color.green{"writing json to #{path.to_s}..."}
9
+ puts TColor.green{"writing json to #{path.to_s}..."}
10
10
  File.open(path, 'w'){|f| f.write(json)}
11
11
  true
12
12
  else
@@ -17,7 +17,7 @@ module Kernel
17
17
  def load_json(path=nil)
18
18
  path = UnixTree.get_path(path, require: :file)
19
19
  if path
20
- puts Color.green{"loading json from #{path.to_s}..."}
20
+ puts TColor.green{"loading json from #{path.to_s}..."}
21
21
  Oj.load(path)
22
22
  else
23
23
  nil
@@ -35,12 +35,12 @@ module UnixTree
35
35
  path.expand_path.descend{|p| unless p.exist?; missing = p; break; end} if path
36
36
  if missing
37
37
  what = (missing == path) ? opts[:require].to_s : 'directory'
38
- puts Color.red{ "couldn't find #{what} #{missing.to_s}" }
38
+ puts TColor.red{ "couldn't find #{what} #{missing.to_s}" }
39
39
  missing = missing.dirname
40
40
  print_tree missing
41
41
 
42
42
  end
43
- print Color.yellow{ "enter path: "}
43
+ print TColor.yellow{ "enter path: "}
44
44
  in_path = $stdin.gets.chomp
45
45
  return nil if in_path == 'q'
46
46
  unless in_path.blank?
@@ -74,8 +74,8 @@ module UnixTree
74
74
  path ||= Pathname.getwd
75
75
  path = Pathname.new(path) unless path.is_a?(Pathname)
76
76
  path = path.dirname if path.file?
77
- puts Color.blue{ "listing #{path}..."}
78
- puts `cd #{path.expand_path.to_s}; tree`.gsub(%r{(^[^\w]+)}, Color.black{'\1'})
77
+ puts TColor.blue{ "listing #{path}..."}
78
+ puts `cd #{path.expand_path.to_s}; tree`.gsub(%r{(^[^\w]+)}, TColor.black{'\1'})
79
79
  end
80
80
  end
81
81
  end
@@ -23,18 +23,18 @@ module ShopifyAPI
23
23
  dirty?
24
24
  subset = ''
25
25
  opts = ''
26
- length = Color.black{'unloaded'}
26
+ length = TColor.black{'unloaded'}
27
27
  since = ''
28
28
  unless cache.nil?
29
29
  if !show_opts && (cache.params.keys.to_set != Set[:limit])
30
- subset = Color.red('!')
30
+ subset = TColor.red('!')
31
31
  end
32
32
  if show_opts
33
- opts = cache.params.map{|k, v| Color.magenta{k.to_s} + Color.black{':'} + Color.green{v.to_s}}.join(Color.black{', '})
33
+ opts = cache.params.map{|k, v| TColor.magenta{k.to_s} + TColor.black{':'} + TColor.green{v.to_s}}.join(TColor.black{', '})
34
34
  opts = "\n #{opts}"
35
35
  end
36
- length = (cache.length > 0) ? "#{cache.length.to_s}#{subset} #{Color.black{cache.label}}" : 'empty'
37
- since = "#{Color.black{'on:'}}#{cache.since.strftime("%a %H:%M:%S")}"
36
+ length = (cache.length > 0) ? "#{cache.length.to_s}#{subset} #{TColor.black{cache.label}}" : 'empty'
37
+ since = "#{TColor.black{'on:'}}#{cache.since.strftime("%a %H:%M:%S")}"
38
38
  end
39
39
  "#{length.ljust(18)} #{since}#{opts}"
40
40
  end
@@ -43,13 +43,13 @@ module ShopifyAPI
43
43
  return if warn_site
44
44
  dirty?
45
45
  puts <<-EOF
46
- #{Color.blue{'products'}}: #{cache_status(@@products, show_opts)}
47
- #{Color.blue{'variants'}}: #{cache_status(@@variants, show_opts)}
48
- #{Color.blue{'metafields'}}: #{cache_status(@@metafields, show_opts)}
49
- #{Color.blue{'orders'}}: #{cache_status(@@orders, show_opts)}
50
- #{Color.blue{'customers'}}: #{cache_status(@@customers, show_opts)}
51
- #{Color.blue{'custom_collections'}}: #{cache_status(@@custom_collections, show_opts)}
52
- #{Color.blue{'smart_collections'}}: #{cache_status(@@smart_collections, show_opts)}
46
+ #{TColor.blue{'products'}}: #{cache_status(@@products, show_opts)}
47
+ #{TColor.blue{'variants'}}: #{cache_status(@@variants, show_opts)}
48
+ #{TColor.blue{'metafields'}}: #{cache_status(@@metafields, show_opts)}
49
+ #{TColor.blue{'orders'}}: #{cache_status(@@orders, show_opts)}
50
+ #{TColor.blue{'customers'}}: #{cache_status(@@customers, show_opts)}
51
+ #{TColor.blue{'custom_collections'}}: #{cache_status(@@custom_collections, show_opts)}
52
+ #{TColor.blue{'smart_collections'}}: #{cache_status(@@smart_collections, show_opts)}
53
53
  EOF
54
54
  end
55
55
 
@@ -1,3 +1,3 @@
1
1
  module Shopifydev
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
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.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Johnston