nimbleshop_core 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/app/assets/javascripts/admin.js +6 -4
  2. data/app/assets/javascripts/admin/payment_method.js.coffee +26 -0
  3. data/app/assets/javascripts/{product-group-condition.js.coffee → admin/product-group-condition.js.coffee} +0 -0
  4. data/app/assets/javascripts/admin/products/edit.js.coffee +26 -13
  5. data/app/assets/javascripts/admin/shipit.js.coffee +10 -0
  6. data/app/assets/javascripts/{fadeout_success.js.coffee → admin/utils/fadeout_success.js.coffee} +0 -0
  7. data/app/assets/stylesheets/admin_custom.css +4 -4
  8. data/app/controllers/admin_controller.rb +1 -5
  9. data/app/models/order.rb +11 -6
  10. data/app/{observers/order_observer.rb → models/order/payment_transitions.rb} +7 -4
  11. data/app/views/admin/shipping_zones/_form.html.erb +1 -1
  12. data/app/views/mailer/shipment_notification_to_buyer.text.erb +1 -1
  13. data/config/routes.rb +4 -1
  14. data/db/migrate/{20111107035350_create_creditcard_transactions.rb → 20111107035350_create_payment_transactions.rb} +1 -1
  15. data/lib/generators/nimbleshop/app/install_generator.rb +1 -0
  16. data/lib/generators/nimbleshop/app/templates/config/initializers/001_load_nimbleshop_config.rb +10 -0
  17. data/lib/generators/nimbleshop/app/templates/config/initializers/setup_email.rb +2 -2
  18. data/lib/generators/nimbleshop/app/templates/config/nimbleshop.yml +2 -1
  19. data/lib/nimbleshop/engine.rb +5 -4
  20. data/lib/nimbleshop/nimbleshop/util.rb +63 -0
  21. data/lib/nimbleshop/processor/base.rb +9 -2
  22. data/lib/nimbleshop/sampledata/data.rb +14 -12
  23. data/lib/nimbleshop/version.rb +2 -2
  24. data/lib/nimbleshop_core.rb +3 -0
  25. data/test/factories/address_factory.rb +10 -10
  26. data/test/fixtures/payment_methods.yml +5 -5
  27. data/{config/initializers/001_settings_application.rb → test/myshop/config/initializers/001_load_nimbleshop_config.rb} +1 -1
  28. data/test/myshop/config/initializers/carrierwave.rb +2 -3
  29. data/test/myshop/config/initializers/secret_token.rb +1 -1
  30. data/test/myshop/config/initializers/setup_email.rb +4 -13
  31. data/test/myshop/config/nimbleshop.yml +14 -17
  32. data/test/myshop/db/development.sqlite3 +0 -0
  33. data/test/myshop/db/migrate/{20120707041905_create_product_groups.nimbleshop_core.rb → 20120717095234_create_product_groups.nimbleshop_core.rb} +0 -0
  34. data/test/myshop/db/migrate/{20120707041906_create_products.nimbleshop_core.rb → 20120717095235_create_products.nimbleshop_core.rb} +0 -0
  35. data/test/myshop/db/migrate/{20120707041907_create_orders.nimbleshop_core.rb → 20120717095236_create_orders.nimbleshop_core.rb} +0 -0
  36. data/test/myshop/db/migrate/{20120707041908_create_line_items.nimbleshop_core.rb → 20120717095237_create_line_items.nimbleshop_core.rb} +0 -0
  37. data/test/myshop/db/migrate/{20120707041909_create_shops.nimbleshop_core.rb → 20120717095238_create_shops.nimbleshop_core.rb} +0 -0
  38. data/test/myshop/db/migrate/{20120707041910_create_link_groups.nimbleshop_core.rb → 20120717095239_create_link_groups.nimbleshop_core.rb} +0 -0
  39. data/test/myshop/db/migrate/{20120707041911_create_navigations.nimbleshop_core.rb → 20120717095240_create_navigations.nimbleshop_core.rb} +0 -0
  40. data/test/myshop/db/migrate/{20120707041912_create_links.nimbleshop_core.rb → 20120717095241_create_links.nimbleshop_core.rb} +0 -0
  41. data/test/myshop/db/migrate/{20120707041913_create_custom_fields.nimbleshop_core.rb → 20120717095242_create_custom_fields.nimbleshop_core.rb} +0 -0
  42. data/test/myshop/db/migrate/{20120707041914_create_custom_field_answers.nimbleshop_core.rb → 20120717095243_create_custom_field_answers.nimbleshop_core.rb} +0 -0
  43. data/test/myshop/db/migrate/{20120707041915_create_product_group_conditions.nimbleshop_core.rb → 20120717095244_create_product_group_conditions.nimbleshop_core.rb} +0 -0
  44. data/test/myshop/db/migrate/{20120707041916_create_creditcard_transactions.nimbleshop_core.rb → 20120717095245_create_creditcard_transactions.nimbleshop_core.rb} +0 -0
  45. data/test/myshop/db/migrate/{20120707041917_create_addresses.nimbleshop_core.rb → 20120717095246_create_addresses.nimbleshop_core.rb} +0 -0
  46. data/test/myshop/db/migrate/{20120707041918_create_pictures.nimbleshop_core.rb → 20120717095247_create_pictures.nimbleshop_core.rb} +0 -0
  47. data/test/myshop/db/migrate/{20120707041919_create_shipping_methods.nimbleshop_core.rb → 20120717095248_create_shipping_methods.nimbleshop_core.rb} +0 -0
  48. data/test/myshop/db/migrate/{20120707041920_create_shipping_zones.nimbleshop_core.rb → 20120717095249_create_shipping_zones.nimbleshop_core.rb} +0 -0
  49. data/test/myshop/db/migrate/{20120707041921_create_payment_methods.nimbleshop_core.rb → 20120717095250_create_payment_methods.nimbleshop_core.rb} +0 -0
  50. data/test/myshop/db/migrate/{20120707041922_create_preferences.nimbleshop_core.rb → 20120717095251_create_preferences.nimbleshop_core.rb} +0 -0
  51. data/test/myshop/db/migrate/{20120707041923_create_shipments.nimbleshop_core.rb → 20120717095252_create_shipments.nimbleshop_core.rb} +0 -0
  52. data/test/myshop/db/migrate/{20120707041924_create_shipment_carriers.nimbleshop_core.rb → 20120717095253_create_shipment_carriers.nimbleshop_core.rb} +0 -0
  53. data/test/myshop/db/migrate/{20120707041925_create_delayed_jobs.nimbleshop_core.rb → 20120717095254_create_delayed_jobs.nimbleshop_core.rb} +0 -0
  54. data/test/myshop/db/schema.rb +1 -1
  55. data/test/myshop/db/test.sqlite3 +0 -0
  56. data/test/myshop/log/development.log +3 -0
  57. data/test/support/shipping_method_test_helper.rb +1 -1
  58. data/test/test_helper.rb +1 -1
  59. metadata +85 -136
  60. data/app/assets/javascripts/payment_method.js.coffee +0 -19
  61. data/app/assets/javascripts/remove_deletion_of_product_pictures.js.coffee +0 -5
  62. data/app/assets/javascripts/shipit.js.coffee +0 -10
  63. data/app/mailers/mailer.rb +0 -31
  64. data/config/initializers/strip_and_nullify.rb +0 -13
  65. data/lib/nimbleshop/util.rb +0 -60
  66. data/test/integration/checkout/cart_acceptance_test.rb +0 -113
  67. data/test/integration/checkout/payment_confirmation_acceptance_test.rb +0 -24
  68. data/test/integration/checkout/paypal_acceptance_test.rb +0 -34
  69. data/test/integration/checkout/shipping_address_acceptance_test.rb +0 -91
  70. data/test/integration/checkout/shipping_method_acceptance_test.rb +0 -51
  71. data/test/integration/homepage_acceptance_test.rb +0 -24
  72. data/test/integration/products_acceptance_test.rb +0 -12
  73. data/test/integration/static_pages_acceptance_test.rb +0 -13
  74. data/test/mailers/mailer_test.rb +0 -25
  75. data/test/unit/payment_method/authorizedotnet_test.rb +0 -21
  76. data/test/unit/payment_method/paypalwp_test.rb +0 -17
  77. data/test/unit/payment_method/splitable_test.rb +0 -18
  78. data/test/unit/processor/authorize_net_test.rb +0 -236
  79. data/test/unit/processor/paypal_test.rb +0 -40
  80. data/test/unit/processor/splitable_test.rb +0 -123
  81. data/test/vcr_cassettes/authorize_net/authorize-failure.yml +0 -38
  82. data/test/vcr_cassettes/authorize_net/authorize-success.yml +0 -38
  83. data/test/vcr_cassettes/authorize_net/capture-failure.yml +0 -38
  84. data/test/vcr_cassettes/authorize_net/capture-success.yml +0 -38
  85. data/test/vcr_cassettes/authorize_net/purchase-failure.yml +0 -38
  86. data/test/vcr_cassettes/authorize_net/purchase-success.yml +0 -38
  87. data/test/vcr_cassettes/authorize_net/refund-failure.yml +0 -38
  88. data/test/vcr_cassettes/authorize_net/refund-success.yml +0 -38
  89. data/test/vcr_cassettes/authorize_net/void-authorize.yml +0 -38
  90. data/test/vcr_cassettes/authorize_net/void-failure.yml +0 -38
  91. data/test/vcr_cassettes/authorize_net/void-success.yml +0 -38
  92. data/test/vcr_cassettes/splitable/split-create-failure.yml +0 -48
  93. data/test/vcr_cassettes/splitable/split-create-success.yml +0 -50
  94. data/test/vcr_cassettes/splitable/split-draft-create-failure.yml +0 -50
  95. data/test/vcr_cassettes/splitable/split-draft-create-success.yml +0 -50
@@ -15,11 +15,13 @@
15
15
  //= require utils/formatPrice
16
16
  //= require loading_state_for_buttons
17
17
 
18
- //= require payment_method
19
- //= require product-group-condition
20
- //= require shipit
18
+ //= require admin/payment_method
19
+ //= require admin/product-group-condition
20
+ //= require admin/shipit
21
21
  //= require admin/shipping_methods/edit
22
22
  //= require admin/products/edit
23
- //= require fadeout_success
23
+ //= require admin/utils/fadeout_success
24
24
  //= require autoresize
25
+
26
+ //comes from twitter-bootstrap
25
27
  //= require show_help_on_hover
@@ -0,0 +1,26 @@
1
+ window.Nimbleshop = {} if typeof(Nimbleshop) == 'undefined'
2
+
3
+ Nimbleshop.managePaymentMethods = class ManagePaymentMethods
4
+ constructor: ->
5
+ @cancelPaymentForm()
6
+ @editPaymentForm()
7
+
8
+ cancelPaymentForm: ->
9
+ $(".nimbleshop-payment-method-form .cancel").click ->
10
+ $this = $(this)
11
+ div = $this.closest(".nimbleshop-payment-method-form-well")
12
+ div.hide() if div.length
13
+ false
14
+
15
+ editPaymentForm: ->
16
+ $(".nimbleshop-payment-method-edit").click ->
17
+ $this = $(this)
18
+ well = $this.parent("div").find(".nimbleshop-payment-method-form-well")
19
+ if well.length
20
+ visible = well.is(":visible")
21
+ well.toggle(!visible)
22
+ false
23
+
24
+
25
+ $ ->
26
+ new Nimbleshop.managePaymentMethods
@@ -1,19 +1,32 @@
1
- $ ->
1
+ window.Nimbleshop = {} if typeof(Nimbleshop) == 'undefined'
2
2
 
3
+ $ ->
3
4
  # work around the nested form ugliness
4
5
  $("form input:file").parents('.fields').hide()
5
6
 
6
- # deleting a picture
7
- $(".product_pictures .actions .delete").on "click", ->
8
- $("#delete_picture_" + $(this).attr("data-action-id")).trigger "click"
9
- $(this).parent().parent().hide "fast"
10
- false
11
7
 
12
- # making picutures sortable
13
- $(".product_pictures").sortable(update: (e, ui) ->
14
- orders = {}
15
- $(".product_pictures li").each (index, el) ->
16
- orders[index] = $(el).attr("data-id")
17
8
 
18
- $("#product_pictures_order").attr "value", $.toJSON(orders)
19
- ).disableSelection()
9
+
10
+ Nimbleshop.managePicture = class ManagePicture
11
+ constructor: ->
12
+ @deletePicture()
13
+ @makePictureSortable()
14
+
15
+ deletePicture: ->
16
+ $(".product_pictures .actions .delete").on "click", ->
17
+ $("#delete_picture_" + $(this).attr("data-action-id")).trigger "click"
18
+ $(this).parent().parent().hide "fast"
19
+ false
20
+
21
+ makePictureSortable: ->
22
+ $(".product_pictures").sortable(update: ->
23
+ order = {}
24
+ $(".product_pictures li").each (index, elem) ->
25
+ order[index] = $(elem).attr("data-id")
26
+
27
+ $("#product_pictures_order").attr "value", $.toJSON(order)
28
+ ).disableSelection()
29
+
30
+
31
+ $ ->
32
+ new Nimbleshop.managePicture
@@ -0,0 +1,10 @@
1
+ $ ->
2
+ $("a.ship-items-link").on 'click', ->
3
+ $(this).hide()
4
+ $("#ship_items_action_box").show()
5
+ false
6
+
7
+ $("#ship_items_cancel").on "click", ->
8
+ $("a.ship-items-link").show()
9
+ $("#ship_items_action_box").hide()
10
+ false
@@ -11,8 +11,8 @@
11
11
  }
12
12
 
13
13
  .payment-method-engine-well {
14
- border: 1px solid #999;
15
- background-color: #eee;
14
+ border: 1px solid #dfdfdf;
15
+ background-color: #fbfbfb;
16
16
  padding: 10px;
17
17
  }
18
18
 
@@ -36,13 +36,13 @@
36
36
  }
37
37
 
38
38
  .nimbleshop-payment-method-edit {
39
- float:left;
39
+ float:left;
40
40
  margin-left:10px;
41
41
  margin-right:10px;
42
42
  }
43
43
 
44
44
  .nimbleshop-payment-method-delete {
45
- float:left;
45
+ float:left;
46
46
  margin-left:6px;
47
47
  margin-right:10px;
48
48
  }
@@ -16,15 +16,11 @@ class AdminController < ::ApplicationController
16
16
  def restricted_access
17
17
  return unless Nimbleshop.config.ask_admin_to_login
18
18
 
19
- authenticate_or_request_with_http_basic('staging') { |username, password|
19
+ authenticate_or_request_with_http_basic('nimbleshop') { |username, password|
20
20
  username == Nimbleshop.config.admin_email && password == Nimbleshop.config.admin_password
21
21
  }
22
22
  end
23
23
 
24
- def delayed_job_admin_authentication
25
- return true if Rails.env.development? || Rails.env.test?
26
- end
27
-
28
24
  def no_page_title
29
25
  @do_not_use_page_title = true
30
26
  end
@@ -1,5 +1,7 @@
1
1
  class Order < ActiveRecord::Base
2
2
 
3
+ include PaymentTransitions
4
+
3
5
  # to allow extensions to store any type of information
4
6
  store :metadata
5
7
 
@@ -103,17 +105,13 @@ class Order < ActiveRecord::Base
103
105
  end
104
106
 
105
107
  def total_amount_in_cents
106
- Util.in_cents(total_amount)
108
+ Nimbleshop::Util.in_cents(total_amount)
107
109
  end
108
110
 
109
111
  def to_param
110
112
  number
111
113
  end
112
114
 
113
- def final_billing_address
114
- (shipping_address && !shipping_address.use_for_billing) ? billing_address : shipping_address
115
- end
116
-
117
115
  def initialize_addresses
118
116
  shipping_address || build_shipping_address(country_code: "US", use_for_billing: true)
119
117
  billing_address || build_billing_address(country_code: "US", use_for_billing: false)
@@ -123,6 +121,13 @@ class Order < ActiveRecord::Base
123
121
  billing_address_same_as_shipping
124
122
  end
125
123
 
124
+ # If billing_address is same as shipping_address then order.billing_address returns nil .
125
+ # order.real_billing_address will always returns a valid address
126
+ def real_billing_address
127
+ (shipping_address && !shipping_address.use_for_billing) ? billing_address : shipping_address
128
+ end
129
+ alias_method :final_billing_address, :real_billing_address
130
+
126
131
  def line_item_for(product_id)
127
132
  line_items.find_by_product_id(product_id)
128
133
  end
@@ -151,7 +156,7 @@ class Order < ActiveRecord::Base
151
156
  end
152
157
 
153
158
  def after_shipped
154
- Mailer.delay.shipment_notification_to_buyer(number)
159
+ Nimbleshop.config.mailer.constantize.delay.shipment_notification_to_buyer(number)
155
160
  touch(:shipped_at)
156
161
  end
157
162
 
@@ -1,4 +1,4 @@
1
- class OrderObserver < ActiveRecord::Observer
1
+ module Order::PaymentTransitions
2
2
 
3
3
  # All the methods listed below get transition object as the second
4
4
  # parameter. It is an instance of +StateMachine::Transition+.
@@ -16,7 +16,8 @@ class OrderObserver < ActiveRecord::Observer
16
16
  #
17
17
 
18
18
  def after_purchase(order, transition)
19
- Mailer.delay.order_notification_to_buyer(order.number)
19
+ mailer = Nimbleshop.config.mailer.constantize
20
+ mailer.delay.order_notification_to_buyer(order.number)
20
21
  AdminMailer.delay.new_order_notification(order.number)
21
22
 
22
23
  order.mark_as_purchased!
@@ -25,7 +26,8 @@ class OrderObserver < ActiveRecord::Observer
25
26
  end
26
27
 
27
28
  def after_authorize(order, transition)
28
- Mailer.delay.order_notification_to_buyer(order.number)
29
+ mailer = Nimbleshop.config.mailer.constantize
30
+ mailer.delay.order_notification_to_buyer(order.number)
29
31
  AdminMailer.delay.new_order_notification(order.number)
30
32
 
31
33
  order.mark_as_purchased!
@@ -37,7 +39,8 @@ class OrderObserver < ActiveRecord::Observer
37
39
 
38
40
  def after_pending(order, transition)
39
41
  if order.payment_method.is_a? NimbleshopCod::Cod
40
- Mailer.delay.order_notification_to_buyer(order.number)
42
+ mailer = Nimbleshop.config.mailer.constantize
43
+ mailer.order_notification_to_buyer(order.number).deliver
41
44
  AdminMailer.delay.new_order_notification(order.number)
42
45
  end
43
46
 
@@ -16,7 +16,7 @@
16
16
  <div class="control-group">
17
17
  <%= f.label :country_code, "Country name", class: 'control-label' %>
18
18
  <div class="controls">
19
- <%= f.select :country_code, Util.unconfigured_shipping_zone_countries, class: 'xlarge focus', size: 30 %>
19
+ <%= f.select :country_code, Nimbleshop::Util.unconfigured_shipping_zone_countries, class: 'xlarge focus', size: 30 %>
20
20
  </div>
21
21
  </div>
22
22
  </fieldset>
@@ -30,5 +30,5 @@ Item total price: <%= number_to_currency(line_item.price) %>
30
30
  <% end %>
31
31
 
32
32
  <% if @order.payment_method.permalink == 'authorize-net' %>
33
- Your credit card has been charged <%= number_to_currency(@order.total_amount) %> .This charge will appear on your credit card statement as "<%= @order.payment_method.company_name_on_creditcard_statement%>".
33
+ Your credit card has been charged <%= number_to_currency(@order.total_amount) %> .This charge will appear on your credit card statement as "<%= @order.payment_method.business_name %>".
34
34
  <% end %>
@@ -4,6 +4,9 @@ Rails.application.routes.draw do
4
4
 
5
5
  get '/admin', to: 'admin/main#index'
6
6
 
7
+ # Ideally it should only be included in development mode
8
+ get "/reset", to: "carts#reset"
9
+
7
10
  namespace :admin do
8
11
 
9
12
  resource :shop, only: [:update, :edit]
@@ -42,7 +45,7 @@ Rails.application.routes.draw do
42
45
  end
43
46
 
44
47
  resources :link_groups do
45
- resources :navigations, only: [:create, :new, :destroy]
48
+ resources :navigations, only: [:create, :new, :destroy]
46
49
  end
47
50
 
48
51
  end
@@ -1,4 +1,4 @@
1
- class CreateCreditcardTransactions < ActiveRecord::Migration
1
+ class CreatePaymentTransactions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :payment_transactions do |t|
4
4
  t.belongs_to :order, null: false
@@ -64,6 +64,7 @@ module Nimbleshop
64
64
  handle_localtunnel_callback_file
65
65
  handle_nimbleshop_yml_file
66
66
 
67
+ template "config/initializers/001_load_nimbleshop_config.rb", "#{destination_path}/config/initializers/001_load_nimbleshop_config.rb"
67
68
  template "config/initializers/cache_images.rb", "#{destination_path}/config/initializers/cache_images.rb"
68
69
  template "config/initializers/carrierwave.rb", "#{destination_path}/config/initializers/carrierwave.rb"
69
70
  template "config/initializers/delayed_job.rb", "#{destination_path}/config/initializers/delayed_job.rb"
@@ -0,0 +1,10 @@
1
+ # TODO why rescue
2
+ Settings = Nimbleshop::Util.config2hash(Rails.root.join('config', 'nimbleshop.yml')) rescue nil
3
+
4
+ module Nimbleshop
5
+ extend self
6
+
7
+ def config
8
+ Settings
9
+ end
10
+ end
@@ -6,8 +6,8 @@ else
6
6
 
7
7
  ActionMailer::Base.delivery_method = :smtp
8
8
  ActionMailer::Base.smtp_settings = {
9
- user_name: Nimbleshop.config.mailtrapio.username || "nimbleshop",
10
- password: Nimbleshop.config.mailtrapio.password || "7663e1f272637a4b",
9
+ user_name: Nimbleshop.config.mailtrapio.username,
10
+ password: Nimbleshop.config.mailtrapio.password,
11
11
  address: "mailtrap.io",
12
12
  port: 2525,
13
13
  authentication: :plain }
@@ -5,6 +5,7 @@
5
5
  common:
6
6
  google_analytics_tracking_id: <%= ENV['GOOGLE_ANALYTICS_TRACKING_ID'] %>
7
7
  deliver_email: false
8
+ mailer: NimbleshopSimply::Mailer
8
9
 
9
10
  # this is used for IPN notification and other places where external serivce cannot ping localhost
10
11
  use_localhost2public_url: true
@@ -21,7 +22,7 @@ common:
21
22
 
22
23
  mailtrapio:
23
24
  username: <%= ENV['MAILTRAPIO_USERNAME'] || 'nimbleshop' %>
24
- password: <%= ENV['MAILTRAPIO_PASSWORD'] || '7663e1f272637a4b' %>
25
+ password: <%= ENV['MAILTRAPIO_PASSWORD'] || 'f42c2934fbc2e229' %>
25
26
 
26
27
  development:
27
28
  use_s3: false
@@ -5,11 +5,12 @@ module Nimbleshop
5
5
 
6
6
  config.autoload_paths += %W(#{config.root}/lib)
7
7
  config.autoload_paths += %W(#{config.root}/lib/nimbleshop)
8
- config.active_record.observers = :order_observer
9
8
 
10
- config.to_prepare do
11
- Address
12
- ShippingZone
9
+ initializer 'nimbleshop_core.config_to_prepare' do |app|
10
+ app.config.to_prepare do
11
+ Address
12
+ ShippingZone
13
+ end
13
14
  end
14
15
 
15
16
  initializer 'nimbleshop_core.action_controller' do |app|
@@ -0,0 +1,63 @@
1
+
2
+ module Nimbleshop
3
+ class Util
4
+
5
+ # loads a yaml based configuration file and returns hash
6
+ def self.config2hash(file)
7
+ hash = YAML.load(ERB.new(File.read(file)).result)
8
+
9
+ common_hash = hash['common'] || {}
10
+ env_hash = hash[Rails.env.to_s] || {}
11
+
12
+ final_hash = common_hash.deep_merge(env_hash)
13
+ Hashr.new(final_hash)
14
+ end
15
+
16
+ # Converts the amount in cents and returns an integer.
17
+ def self.in_cents(amount)
18
+ (BigDecimal(amount.to_s) * 100).round(0).to_i
19
+ end
20
+
21
+ # returns public url for a given localhost url
22
+ #
23
+ # Usage: localhost2public_url ( '/nimbleshop_paypal/notify', 'http' )
24
+ #
25
+ def self.localhost2public_url(url, protocol)
26
+ return url unless Nimbleshop.config.use_localhost2public_url
27
+
28
+ tunnel = Rails.root.join('config', '.tunnel')
29
+ return Nimbleshop.config.default_localhost2public_url unless File.exists?(tunnel)
30
+
31
+ path = []
32
+
33
+ host = File.open(tunnel, "r").gets.sub("\n", "")
34
+ path << "#{protocol}://#{host}"
35
+
36
+ path << url
37
+ path.join('')
38
+ end
39
+
40
+ # The output is something like
41
+ # ["Timor-Leste", "TL"], ["Turkmenistan", "TM"], ["Tunisia", "TN"], ["Tonga", "TO"], .......
42
+ def self.countries_list_with_name_and_code
43
+ Carmen::Country.all.map { |t| [t.name, t.alpha_2_code] }
44
+ end
45
+
46
+ def self.countries_without_shipping_zone
47
+ Nimbleshop::Util.countries_list_with_name_and_code.reject { |_, t| CountryShippingZone.all_country_codes.include?(t) }
48
+ end
49
+
50
+ def self.disabled_shipping_zone_countries
51
+ countries_with_shipping_zone.reduce([]) { |result, element| result << [element[0], element[1], {disabled: :disabled}]}
52
+ end
53
+
54
+ def self.unconfigured_shipping_zone_countries
55
+ (Nimbleshop::Util.disabled_shipping_zone_countries + Nimbleshop::Util.countries_without_shipping_zone).sort
56
+ end
57
+
58
+ def self.countries_with_shipping_zone
59
+ Nimbleshop::Util.countries_list_with_name_and_code.select { |_, t| CountryShippingZone.all_country_codes.include?(t)}
60
+ end
61
+
62
+ end
63
+ end
@@ -1,4 +1,11 @@
1
- module Processor
1
+ module Processor #:nodoc:
2
+ # = Processor
3
+ #
4
+ # Processor class is responsible for payment processing transactions using gateway. This is an abstract
5
+ # class in the sense that implementations of processors should sublass Processor class.
6
+ #
7
+ # It defines five methods: authorize, kapture, purchase, void and refund .
8
+ # These methods in turn invoke methods do_authorize, do_kapture, do_purchase, do_void, do_refund.
2
9
  class Base
3
10
 
4
11
  extend ActiveModel::Callbacks
@@ -41,7 +48,7 @@ module Processor
41
48
  end
42
49
  end
43
50
 
44
- # this method can be overriden by individual payment method
51
+ # this method can be overriden by individual payment processor
45
52
  def set_active_merchant_mode
46
53
  mode = Rails.env.production? ? :production : :test
47
54
  ActiveMerchant::Billing::Base.mode = mode
@@ -124,11 +124,14 @@ module Sampledata
124
124
  desc = %q{
125
125
  Chronograph sport watch from Guess
126
126
 
127
- Chronograph: Stopwatch function, 24 Hour/Intl. time
128
- 43/43/13
127
+ Stopwatch function, 24 Hour/International time
128
+
129
129
  Brushed + Polished Ionic Black case
130
+
130
131
  Red + Black dial
131
- Brushed + Polished Ionic Black Steel bracelet
132
+
133
+ Brushed + Polished Ionic Black Steel bracelet
134
+
132
135
  100 M/330 FT Water resistant
133
136
  }
134
137
  product = Product.create!( title: "chronograph sport watch from Guess", price: 219, description: desc)
@@ -139,13 +142,11 @@ module Sampledata
139
142
  def load_turquoise_bracelet
140
143
  print '.'
141
144
  desc = %q{
142
- Simple, modern, stylish, easy to wear bracelet !
143
-
144
- For a scale reference please see the photos with the bracelet worn.
145
+ Simple, modern, stylish, easy to wear bracelet !
145
146
 
146
147
  For a custom color bracelet send me a message and I will see what colors are available for your bracelet.
147
148
 
148
- The strap of the bracelet can also be customized in any color you would like.
149
+ The strap of the bracelet can also be customized in any color you would like.
149
150
 
150
151
  All items come to you beautifully packaged and ready for gift giving.
151
152
 
@@ -200,9 +201,9 @@ module Sampledata
200
201
  def load_shoes
201
202
  print '.'
202
203
  desc = %q{
203
- People of India love color. Everything they use from top to bottom is colorful.
204
+ The shoes that you see in picture are called 'jutti' in India.
204
205
 
205
- Lets talk about shoes. Making good looking shoes is an art they have perfected over centuries. Making a shoe takes the whole village. And the whole village participates in the business of making and selling quality colorful shoes.
206
+ They are usually made of fine leather and are delicately embroidered with threads or beads. Juttis are slip-on in style and are characterized by rising high in the back and covering the toes with a round heavily-embroidered upper shoe and leaving the top of the foot nearly bare.
206
207
  }
207
208
  product = Product.create!( title: "Colorful shoes", price: 191, description: desc)
208
209
  handle_pictures_for_product(product, "product7")
@@ -232,10 +233,11 @@ module Sampledata
232
233
  def load_iphone_cover
233
234
  print '.'
234
235
  desc = %q{
235
- This is a hard case is for your iPhone 4. Fits both AT&T & Verizon models of the iPhone 4. The case has a wood like appearance.
236
- It is not actual wood. It will protect it from scractches while also bringing it to life with some color!
236
+ This is a hard case is for your iPhone 4. Fits both AT&T & Verizon models of the iPhone 4.
237
+
238
+ The case has a wood like appearance. It is not actual wood. It will protect it from scractches while also bringing it to life with some color!
237
239
 
238
- It does not interfere with any buttons. It is available in many different colors. If you have a specific color in my then contact me.
240
+ It does not interfere with any buttons. It is available in many different colors. If you have a specific color in mind then contact me.
239
241
  }
240
242
  product = Product.create!( title: "Hard wood case for iphone", price: 7.95, description: desc)
241
243
  handle_pictures_for_product(product, "product9")