magento_remote 0.2.0 → 0.2.1

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
- ZWMyMzg2MGJhMzVlZGExZmVkMjljOGJkYjdlMmVlOWI1MzY3NWQ0Yw==
4
+ NDdiMDk3MTBjMjA1Y2MwZmEwMGI5OWY1ZTE5YmMwMDg2OTU3MWJjMw==
5
5
  data.tar.gz: !binary |-
6
- NWRiZTM2MDUxMzJlOTIwNzY5M2FmNmNmMTdhNWJkNWZkNmI4YTQ2OQ==
6
+ NTg5NTg2ZDNiZGE1OGE3OGUzNDgwYjFlMDdlNjMyZjYxOTg5NmY0Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2JiM2YyYzZjMjJiNTA3NDk4MGUxMjM1ZjllMTQ4ZmQzYTNlMTI1ZjM2NmMx
10
- NzM4NzNiNmMwZjgwYWVlZTYzNzJlMzI3MTVmMzVlZTEwZDcxODc4MTE4NmU1
11
- OGNkYWE0YjY1NjViMDkxMWQxMjVlODEwMmZkYWQ4OTAzMjNjZjM=
9
+ ZDNmZTkwODcyZWY3NDFiODcyMzA1YmZmOGI5NzhkZGM0NDAwYjdhZWY0MzJi
10
+ NWY3NTlhNGUxMmI0ODk2Yzk3N2Y4OTgyMGQ0ZDc0NzU3NTAzNzQ4N2Y5ZDg1
11
+ MjNiOWIwZGFiNWM0YmQzMWFkYzFhMzcyZTg4ZTNhMTlkYjA2ZWM=
12
12
  data.tar.gz: !binary |-
13
- Y2Q0YTUyNmEwYjI5YTNmYjk0NjRhZDI5YmY0MDM1NjgxNWFhZjQ0NzY3Yzk5
14
- OWE0MTFhOWJjYWZiMmMxMGMyYTk4MjUwYjk0M2U5MTVmZjRmNDU4OWIyOTcy
15
- ZDRlOTZhMjMzYjYwYmEyMGYxNWE3NDkxZDk0OTFkYTgzNGU1NmQ=
13
+ OWY3NGI4OWU0NDM4YWVkNWY5MWZkOWU3MzM2OTdlMjI2ZmFkNTZlYjg5MjA3
14
+ OGE0MTY1MDFhN2E1M2FiMTBjMDA4MTY2NzRiMGEzNmJjMjA4MmM3NGNhMGM5
15
+ Y2YzNmJmNWYzZmQ5NzVjMjc2ZWMyMDc5NjcyMjFhNWYwOTU5ODk=
@@ -12,6 +12,13 @@ program_name = File.basename __FILE__
12
12
  optparse = OptionParser.new do |opts|
13
13
  opts.banner = "Usage: #{program_name} [OPTIONS]\n Show last order."
14
14
 
15
+ opts.separator ""
16
+ opts.separator "Order options"
17
+
18
+ opts.on("-o", '--order-id ORDERID', 'order id in shop.') do |o|
19
+ options[:order_id] = o
20
+ end
21
+
15
22
  opts.separator ""
16
23
  opts.separator "Magento shop options"
17
24
 
@@ -67,7 +74,12 @@ return_code = 0
67
74
 
68
75
  mech.login
69
76
 
70
- products = mech.last_order_products
77
+ if options[:order_id]
78
+ products = mech.products_from_order options[:order_id]
79
+ else
80
+ products = mech.last_order_products
81
+ end
82
+
71
83
  if products.empty?
72
84
  puts "Nothing found"
73
85
  else
@@ -203,6 +203,17 @@ class MagentoMech
203
203
  end
204
204
  end
205
205
 
206
+ def products_from_order order_id
207
+ order_url = relative_url("/sales/order/view/order_id/#{order_id}/")
208
+ @mech.get order_url
209
+ @mech.page.search('tr.border').map do |tr|
210
+ product_name = tr.children[1].children[0].content
211
+ product_sku = tr.children[3].children[0].content
212
+ product_qty = tr.children[7].children[1].content[/\d+/]
213
+ [product_name, product_sku, product_qty]
214
+ end
215
+ end
216
+
206
217
  private
207
218
 
208
219
  # Construct path relative to base uri.
@@ -1,3 +1,3 @@
1
1
  module MagentoRemote
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magento_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller