Module: Spree::Sample

Defined in:
lib/spree/sample.rb

Class Method Summary collapse

Class Method Details

.load_sample(file, shell: Thor::Base.shell.new) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spree/sample.rb', line 9

def load_sample(file, shell: Thor::Base.shell.new)
  # If file is exists within application it takes precendence.
  if File.exist?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
    path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
  else
    # Otherwise we will use this gems default file.
    path = File.expand_path(samples_path + "#{file}.rb")
  end
  # Check to see if the specified file has been loaded before
  unless $LOADED_FEATURES.include?(path)
    shell.say_status :sample, file.titleize
    require path
  end
end