Permalink
Browse files

namespacing for Spree 1.0

  • Loading branch information...
1 parent 90a60d4 commit 8ffb3975a05bc8a064a8c1419ad114ac0de38e69 cmar committed Dec 21, 2011
View
5 Gemfile
@@ -3,8 +3,6 @@ source 'http://rubygems.org'
gem 'sqlite3'
group :test do
- gem 'rspec-rails', '= 2.7.0'
- gem 'factory_girl', '= 1.3.3'
gem 'factory_girl_rails', '= 1.0.1'
gem 'faker'
end
@@ -15,4 +13,7 @@ else
gem "ruby-debug19"
end
+gem 'rails', '3.1.3'
+gem 'spree', :git => 'https://github.com/spree/spree.git'
+
gemspec
View
151 Gemfile.lock
@@ -1,3 +1,44 @@
+GIT
+ remote: https://github.com/spree/spree.git
+ revision: 6525d8094f5ed23b6b17e452da3f3b5e6e9f9ee8
+ specs:
+ spree (1.0.0.beta)
+ spree_api (= 1.0.0.beta)
+ spree_auth (= 1.0.0.beta)
+ spree_core (= 1.0.0.beta)
+ spree_dash (= 1.0.0.beta)
+ spree_promo (= 1.0.0.beta)
+ spree_sample (= 1.0.0.beta)
+ spree_api (1.0.0.beta)
+ spree_auth (= 1.0.0.beta)
+ spree_core (= 1.0.0.beta)
+ spree_auth (1.0.0.beta)
+ cancan (= 1.6.7)
+ devise (= 1.4.8)
+ spree_core (= 1.0.0.beta)
+ spree_core (1.0.0.beta)
+ activemerchant (= 1.17.0)
+ acts_as_list (= 0.1.4)
+ deface (>= 0.7.2)
+ ffaker (~> 1.10.1)
+ highline (= 1.6.2)
+ jquery-rails (>= 1.0.18)
+ kaminari (>= 0.12.4)
+ meta_search (= 1.1.1)
+ nested_set (= 1.6.8)
+ paperclip (= 2.4.1)
+ rails (>= 3.1.1, <= 3.1.3)
+ rd_find_by_param (= 0.1.1)
+ state_machine (= 1.1.0)
+ stringex (~> 1.3.0)
+ spree_dash (1.0.0.beta)
+ spree_core (= 1.0.0.beta)
+ spree_promo (1.0.0.beta)
+ spree_auth (= 1.0.0.beta)
+ spree_core (= 1.0.0.beta)
+ spree_sample (1.0.0.beta)
+ spree_core (= 1.0.0.beta)
+
PATH
remote: .
specs:
@@ -7,64 +48,71 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.1)
- actionpack (= 3.1.1)
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
mail (~> 2.3.0)
- actionpack (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
- rack (~> 1.3.2)
+ rack (~> 1.3.5)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
- sprockets (~> 2.0.2)
+ sprockets (~> 2.0.3)
activemerchant (1.17.0)
activesupport (>= 2.3.11)
braintree (>= 2.0.0)
builder (>= 2.0.0)
json (>= 1.5.1)
- activemodel (3.1.1)
- activesupport (= 3.1.1)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
builder (~> 3.0.0)
i18n (~> 0.6)
- activerecord (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
- activeresource (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
- activesupport (3.1.1)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
multi_json (~> 1.0)
acts_as_list (0.1.4)
arel (2.2.1)
+ bcrypt-ruby (3.0.1)
braintree (2.13.1)
builder (>= 2.0.0)
builder (3.0.0)
- cocaine (0.2.0)
- columnize (0.3.4)
- deface (0.7.1)
+ cancan (1.6.7)
+ cocaine (0.2.1)
+ columnize (0.3.6)
+ deface (0.7.2)
nokogiri (~> 1.5.0)
rails (>= 3.0.9)
+ devise (1.4.8)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.0.3)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
railties (>= 3.0.0)
- faker (1.0.0)
+ faker (1.0.1)
i18n (~> 0.4)
- highline (1.5.1)
+ ffaker (1.10.1)
+ highline (1.6.2)
hike (1.2.1)
i18n (0.6.0)
- jquery-rails (1.0.17)
+ jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
- json (1.6.1)
+ json (1.6.3)
kaminari (0.12.4)
rails (>= 3.0.0)
linecache (0.46)
@@ -79,11 +127,12 @@ GEM
activesupport (~> 3.1.0)
polyamorous (~> 0.5.0)
mime-types (1.17.2)
- multi_json (1.0.3)
+ multi_json (1.0.4)
nested_set (1.6.8)
activerecord (>= 3.0.0)
railties (>= 3.0.0)
nokogiri (1.5.0)
+ orm_adapter (0.0.5)
paperclip (2.4.1)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
@@ -101,17 +150,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.1.1)
- actionmailer (= 3.1.1)
- actionpack (= 3.1.1)
- activerecord (= 3.1.1)
- activeresource (= 3.1.1)
- activesupport (= 3.1.1)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
bundler (~> 1.0)
- railties (= 3.1.1)
- railties (3.1.1)
- actionpack (= 3.1.1)
- activesupport (= 3.1.1)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -121,8 +170,7 @@ GEM
rd_find_by_param (0.1.1)
activerecord (~> 3.0)
activesupport (~> 3.0)
- rd_resource_controller (1.0.1)
- rdoc (3.11)
+ rdoc (3.12)
json (~> 1.4)
rspec (2.7.0)
rspec-core (~> 2.7.0)
@@ -142,44 +190,31 @@ GEM
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
- spree_core (0.70.1)
- activemerchant (= 1.17.0)
- acts_as_list (= 0.1.4)
- deface (>= 0.7.0)
- faker (= 1.0.0)
- highline (= 1.5.1)
- jquery-rails (>= 1.0.14)
- kaminari (>= 0.12.4)
- meta_search (= 1.1.1)
- nested_set (= 1.6.8)
- paperclip (= 2.4.1)
- rails (= 3.1.1)
- rd_find_by_param (= 0.1.1)
- rd_resource_controller
- state_machine (= 1.0.1)
- stringex (= 1.0.3)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.4)
- state_machine (1.0.1)
- stringex (1.0.3)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.5)
+ state_machine (1.1.0)
+ stringex (1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
+ warden (1.0.6)
+ rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
- factory_girl (= 1.3.3)
factory_girl_rails (= 1.0.1)
faker
- rspec-rails (= 2.7.0)
+ rails (= 3.1.3)
+ rspec-rails
ruby-debug
+ spree!
spree_skrill!
sqlite3
View
2 Rakefile
@@ -3,7 +3,7 @@ require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
-require 'spree_core/testing_support/common_rake'
+require 'spree/core/testing_support/common_rake'
RSpec::Core::RakeTask.new
View
30 app/controllers/checkout_controller_decorator.rb
@@ -1,30 +0,0 @@
-CheckoutController.class_eval do
- def skrill_cancel
- flash[:error] = t(:payment_has_been_cancelled)
- redirect_to edit_order_checkout_url(@order, :state => 'payment')
- end
-
- def skrill_success
- @order = Order.where(:number => params[:order_id]).first
-
- if @order.token == params[:token]
-
- if @order.payments.where(:source_type => 'SkrillAccount').present?
-
- #need to force checkout to complete state
- until @order.state == "complete"
- if @order.next!
- @order.update!
- state_callback(:after)
- end
- end
- end
-
- flash.notice = t(:order_processed_successfully)
- redirect_to completion_route
- else
- redirect_to root_url
- end
-
- end
-end
View
24 app/controllers/skrill_status_controller.rb
@@ -1,24 +0,0 @@
-class SkrillStatusController < ApplicationController
- def update
- payment_id = params[:transaction_id].split('-').last
-
- payment = Payment.find(payment_id)
-
- unless payment.completed?
-
- case params[:status]
- when "0"
- payment.pend #may already be pending
- when "2" #processed / captured
- payment.complete!
- when "-1", "-2"
- payment.failure!
- else
- raise "Unexpected payment status"
- end
-
- end
-
- render :text => ""
- end
-end
View
32 app/controllers/spree/checkout_controller_decorator.rb
@@ -0,0 +1,32 @@
+module Spree
+ CheckoutController.class_eval do
+ def skrill_cancel
+ flash[:error] = t(:payment_has_been_cancelled)
+ redirect_to edit_order_checkout_url(@order, :state => 'payment')
+ end
+
+ def skrill_success
+ @order = Order.where(:number => params[:order_id]).first
+
+ if @order.token == params[:token]
+
+ if @order.payments.where(:source_type => 'SkrillAccount').present?
+
+ #need to force checkout to complete state
+ until @order.state == "complete"
+ if @order.next!
+ @order.update!
+ state_callback(:after)
+ end
+ end
+ end
+
+ flash.notice = t(:order_processed_successfully)
+ redirect_to completion_route
+ else
+ redirect_to root_url
+ end
+
+ end
+ end
+end
View
26 app/controllers/spree/skrill_status_controller.rb
@@ -0,0 +1,26 @@
+module Spree
+ class SkrillStatusController < ApplicationController
+ def update
+ payment_id = params[:transaction_id].split('-').last
+
+ payment = Payment.find(payment_id)
+
+ unless payment.completed?
+
+ case params[:status]
+ when "0"
+ payment.pend #may already be pending
+ when "2" #processed / captured
+ payment.complete!
+ when "-1", "-2"
+ payment.failure!
+ else
+ raise "Unexpected payment status"
+ end
+
+ end
+
+ render :text => ""
+ end
+ end
+end
View
29 app/helpers/checkout_helper_decorator.rb
@@ -1,29 +0,0 @@
-CheckoutHelper.module_eval do
- def checkout_progress
- states = checkout_states
- items = states.map do |state|
- text = t("order_state.#{state}").titleize
-
- css_classes = []
- if @order.skrill?
- current_index = states.index('payment')
- else
- current_index = states.index(@order.state)
- end
- state_index = states.index(state)
-
- if state_index < current_index
- css_classes << 'completed'
- text = link_to text, checkout_state_path(state)
- end
-
- css_classes << 'next' if state_index == current_index + 1
- css_classes << 'current' if state == @order.state
- css_classes << 'first' if state_index == 0
- css_classes << 'last' if state_index == states.length - 1
- # It'd be nice to have separate classes but combining them with a dash helps out for IE6 which only sees the last class
- content_tag('li', content_tag('span', text), :class => css_classes.join('-'))
- end
- content_tag('ol', raw(items.join("\n")), :class => 'progress-steps', :id => "checkout-step-#{@order.state}")
- end
-end
View
31 app/helpers/spree/checkout_helper_decorator.rb
@@ -0,0 +1,31 @@
+module Spree
+ CheckoutHelper.module_eval do
+ def checkout_progress
+ states = checkout_states
+ items = states.map do |state|
+ text = t("order_state.#{state}").titleize
+
+ css_classes = []
+ if @order.skrill?
+ current_index = states.index('payment')
+ else
+ current_index = states.index(@order.state)
+ end
+ state_index = states.index(state)
+
+ if state_index < current_index
+ css_classes << 'completed'
+ text = link_to text, checkout_state_path(state)
+ end
+
+ css_classes << 'next' if state_index == current_index + 1
+ css_classes << 'current' if state == @order.state
+ css_classes << 'first' if state_index == 0
+ css_classes << 'last' if state_index == states.length - 1
+ # It'd be nice to have separate classes but combining them with a dash helps out for IE6 which only sees the last class
+ content_tag('li', content_tag('span', text), :class => css_classes.join('-'))
+ end
+ content_tag('ol', raw(items.join("\n")), :class => 'progress-steps', :id => "checkout-step-#{@order.state}")
+ end
+ end
+end
View
46 app/models/billing_integration/skrill/quick_checkout.rb
@@ -1,46 +0,0 @@
-class BillingIntegration::Skrill::QuickCheckout < BillingIntegration
- preference :merchant_id, :string
- preference :language, :string, :default => 'EN'
- preference :currency, :string, :default => 'EUR'
- preference :payment_options, :string, :default => 'ACC'
-
- def provider_class
- ActiveMerchant::Billing::Skrill
- end
-
- def redirect_url(order, opts = {})
- opts.merge! self.preferences
-
- set_global_options(opts)
-
- opts[:detail1_text] = order.number
- opts[:detail1_description] = 'Order Number:'
-
- opts[:pay_from_email] = order.email
- opts[:firstname] = order.bill_address.firstname
- opts[:lastname] = order.bill_address.lastname
- opts[:address] = order.bill_address.address1
- opts[:address2] = order.bill_address.address2
- opts[:phone_number] = order.bill_address.phone
- opts[:city] = order.bill_address.city
- opts[:postal_code] = order.bill_address.zipcode
- opts[:state] = order.bill_address.state.nil? ? order.bill_address.state_name.to_s : order.bill_address.state.abbr
- opts[:country] = order.bill_address.country.name
-
- opts[:hide_login] = 1
- opts[:merchant_fields] = 'platform'
- opts[:platform] = 'Spree'
-
- skrill = self.provider
- skrill.payment_url(opts)
- end
-
- private
- def set_global_options(opts)
- opts[:recipient_description] = Spree::Config[:site_name]
- opts[:payment_methods] = self.preferred_payment_options
- end
-
-end
-
-
View
7 app/models/skrill_account.rb
@@ -1,7 +0,0 @@
-class SkrillAccount < ActiveRecord::Base
- has_many :payments, :as => :source
-
- def actions
- []
- end
-end
View
46 app/models/spree/billing_integration/skrill/quick_checkout.rb
@@ -0,0 +1,46 @@
+module Spree
+ class BillingIntegration::Skrill::QuickCheckout < BillingIntegration
+ preference :merchant_id, :string
+ preference :language, :string, :default => 'EN'
+ preference :currency, :string, :default => 'EUR'
+ preference :payment_options, :string, :default => 'ACC'
+
+ def provider_class
+ ActiveMerchant::Billing::Skrill
+ end
+
+ def redirect_url(order, opts = {})
+ opts.merge! self.preferences
+
+ set_global_options(opts)
+
+ opts[:detail1_text] = order.number
+ opts[:detail1_description] = 'Order Number:'
+
+ opts[:pay_from_email] = order.email
+ opts[:firstname] = order.bill_address.firstname
+ opts[:lastname] = order.bill_address.lastname
+ opts[:address] = order.bill_address.address1
+ opts[:address2] = order.bill_address.address2
+ opts[:phone_number] = order.bill_address.phone
+ opts[:city] = order.bill_address.city
+ opts[:postal_code] = order.bill_address.zipcode
+ opts[:state] = order.bill_address.state.nil? ? order.bill_address.state_name.to_s : order.bill_address.state.abbr
+ opts[:country] = order.bill_address.country.name
+
+ opts[:hide_login] = 1
+ opts[:merchant_fields] = 'platform'
+ opts[:platform] = 'Spree'
+
+ skrill = self.provider
+ skrill.payment_url(opts)
+ end
+
+ private
+ def set_global_options(opts)
+ opts[:recipient_description] = Spree::Config[:site_name]
+ opts[:payment_methods] = self.preferred_payment_options
+ end
+
+ end
+end
View
9 app/models/spree/skrill_account.rb
@@ -0,0 +1,9 @@
+module Spree
+ class SkrillAccount < ActiveRecord::Base
+ has_many :payments, :as => :source
+
+ def actions
+ []
+ end
+ end
+end
View
0 app/views/checkout/_skrill.html.erb → app/views/spree/checkout/_skrill.html.erb
File renamed without changes.
View
0 .../checkout/payment/_quickcheckout.html.erb → .../checkout/payment/_quickcheckout.html.erb
File renamed without changes.
View
0 app/views/shared/_skrill_status.html.erb → ...iews/spree/shared/_skrill_status.html.erb
File renamed without changes.
View
13 lib/spree_skrill/engine.rb
@@ -10,19 +10,19 @@ class Engine < Rails::Engine
end
def self.activate
- Order.state_machine.states << skrill_state = StateMachine::State.new(Order.state_machine, 'skrill')
+ Spree::Order.state_machine.states << skrill_state = StateMachine::State.new(Spree::Order.state_machine, 'skrill')
- Order.state_machine.events << next_event = StateMachine::Event.new(Order.state_machine, :next)
+ Spree::Order.state_machine.events << next_event = StateMachine::Event.new(Spree::Order.state_machine, :next)
next_event.transition :from => 'cart', :to => 'address'
next_event.transition :from => 'address', :to => 'delivery'
next_event.transition :from => 'delivery', :to => 'payment', :if => :payment_required?
next_event.transition :from => 'payment', :to => 'skrill', :if => lambda {true}
next_event.transition :from => 'skrill', :to => 'complete'
- next_event.transition :from => 'payment', :to => 'confirm', :if => Proc.new { Gateway.current && Gateway.current.payment_profiles_supported? }
+ next_event.transition :from => 'payment', :to => 'confirm', :if => Proc.new { Spree::Gateway.current && Spree::Gateway.current.payment_profiles_supported? }
next_event.transition :from => 'payment', :to => 'complete'
- Order.state_machine.before_transition :to => 'skrill', :do => Proc.new{ |order|
- skrill_account = SkrillAccount.find_or_create_by_email(order.email)
+ Spree::Order.state_machine.before_transition :to => 'skrill', :do => Proc.new{ |order|
+ skrill_account = Spree::SkrillAccount.find_or_create_by_email(order.email)
payment = order.payment
payment.update_attribute(:source, skrill_account)
@@ -38,12 +38,11 @@ def self.activate
config.to_prepare &method(:activate).to_proc
- initializer "spree_skrill.register.payment_methods" do |app|
+ initializer "spree_skrill.register.payment_methods", :after => 'spree.register.payment_methods' do |app|
app.config.spree.payment_methods += [
Spree::BillingIntegration::Skrill::QuickCheckout
]
end
-
end
end

0 comments on commit 8ffb397

Please sign in to comment.