Sha256: a315ffc6908446140f7fda3bf07405126637019a968f69dd48e258b6eab5e66a

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

module Returnly
  class << self
    mattr_accessor :return_item_amount_calculator,
      :return_item_builder,
      :return_item_restock_policy,
      :refunder,
      :refund_calculator,
      :refund_presenter,
      :gift_card,
      :git_card_estimate
  end

  def self.configure(&block)
    yield self if block
  end

  class Engine < Rails::Engine
    require 'spree/core'

    engine_name 'returnly'

    config.autoload_paths += %W(#{config.root}/lib)

    # use rspec for tests
    config.generators do |g|
      g.test_framework :rspec
    end

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end
    end

    config.to_prepare(&method(:activate).to_proc)

    rake_tasks do
      namespace :returnly do
        require 'securerandom'

        desc "Creates an returnly user and prints the generated API key"
        task install_user: :environment do

          returnly_email = 'api@returnly.com'

          password = SecureRandom.hex(24)

          if (user = Spree::User.find_by email: returnly_email)
            puts "The Returnly User is already generated"
            puts "The Api key is:    #{user.spree_api_key}"
          else
            user = Spree::User.new email: returnly_email, password: password,
                                   password_confirmation: password

            user.generate_spree_api_key!

            if user.save!
              puts "****************************************************"
              puts "Api key Generated #{user.spree_api_key}"
              puts "Returnly User Password #{password}"
              puts "Returnly User email #{returnly_email}"
              puts "****************************************************"
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
spree-returnly-0.13.1 lib/returnly/engine.rb
solidus-returnly-0.13.1 lib/returnly/engine.rb
spree-returnly-0.13.0 lib/returnly/engine.rb
solidus-returnly-0.13.0 lib/returnly/engine.rb