Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Just In Time Inventory with Spree

Ryan McGeary
February 16, 2012

Just In Time Inventory with Spree

In this talk, we will not only explore what it takes to extend Spree, but we will also experiment with the notion of using it build our products on demand. We will take Spree, slap a MakerBot on the backend, build some extensions, and build a store that automatically prints products only after an order is placed.

Ryan McGeary

February 16, 2012
Tweet

More Decks by Ryan McGeary

Other Decks in Technology

Transcript

  1. Hey Ryan, We're going to do a SpreeConf in NYC.

    We're asking some people to give talks. Thanks for volunteering ;-) Sure, I’d love to talk. Let me coordinate my schedule and get back to you. (Shit, I don’t know anything about Spree.) Can we confirm you to speak? Sure thing. Let’s make it official. (Crap, what am I going to talk about?)
  2. Hey Ryan, I was wondering if you’d given some thought

    about the topic of your talk. Oh, yeah, I’ve got some ideas. No problem. (I’m doomed.) Oh, by the way, we think we’re going to be able to get Bre Pettis to do the keynote. No way! That’s awesome! I think I have a new idea for my talk. (I have a man crush on Bre.)
  3. How Does It Print? •Reads STL Files •Cool 3D Preview

    •Includes Skeinforge •Generates GCode Files •Compiles to S3G •Triggers Print from SD Card
  4. DuplicatorG •Minimal CLI •Builds from SD Card •Uses JRuby •It

    worked! •Note: 32bit Only •RXTX (Serial comms) • JAVA_OPTS=-d32 https://github.com/rmm5t/duplicatorg
  5. require "java" Dir["build/jar/*.jar", "build/shared/lib/*.jar"].each do |lib| require lib end java_import

    "replicatorg.app.Base" # ... Usage handling omitted ... machine_name = Base.preferences.get("machine.name", nil) serial_port = Base.preferences.get("serial.last_selected", nil) machine_loader = Base.machine_loader machine_interface = machine_loader.get_machine_interface(machine_name); machine_loader.connect(serial_port) machine_interface.build_remote(ARGV[0]) }
  6. $ wc -l `find ReplicatorG/src` 51082 total So What? $

    wc -l duplicatorg/*.rb 24 duplicatorg/duplicatorg.rb
  7. Add Some Products Add a Shipping Method Add a Payment

    Method Custom Transition Hook Bam! Booya! Hellz Yeah!
  8. Spree::Order.class_eval do state_machine do after_transition to: "complete", do: :print_object end

    def print_object sku = self.line_items.first.product.sku command = "script/print_it #{sku}" (pid = fork) ? Process.detach(pid) : exec(command) rescue nil end end }
  9. $$$